Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Windows
pEp for Outlook
Commits
b721e3b0
Commit
b721e3b0
authored
Sep 27, 2021
by
Thomas
Browse files
Remove obsolete code
parent
78ac1768
Changes
5
Hide whitespace changes
Inline
Side-by-side
UI/Models/PatchDialog.cs
View file @
b721e3b0
using
pEp.DPE
;
using
pEp.DPE
;
using
System
;
using
System
;
using
System.Linq
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
pEp.UI.Models
namespace
pEp.UI.Models
{
{
...
@@ -71,8 +72,7 @@ namespace pEp.UI.Models
...
@@ -71,8 +72,7 @@ namespace pEp.UI.Models
/// <param name="patchAction">The action to perform with the patch.</param>
/// <param name="patchAction">The action to perform with the patch.</param>
/// <param name="patch">The patch to manage.</param>
/// <param name="patch">The patch to manage.</param>
/// <param name="isEditable">Whether the patch can be edited.</param>
/// <param name="isEditable">Whether the patch can be edited.</param>
/// <returns>The dialog result.</returns>
public
static
async
Task
ShowDialog
(
PatchDialog
.
PatchAction
patchAction
,
Patch
patch
,
bool
isEditable
=
false
)
public
static
System
.
Windows
.
Forms
.
DialogResult
ShowDialog
(
PatchDialog
.
PatchAction
patchAction
,
Patch
patch
,
bool
isEditable
=
false
)
{
{
// If needed, make sure we have a valid own identity
// If needed, make sure we have a valid own identity
PEPIdentity
me
=
null
;
PEPIdentity
me
=
null
;
...
@@ -82,43 +82,40 @@ namespace pEp.UI.Models
...
@@ -82,43 +82,40 @@ namespace pEp.UI.Models
true
)
!=
Globals
.
ReturnStatus
.
Success
))
true
)
!=
Globals
.
ReturnStatus
.
Success
))
{
{
Log
.
Error
(
"ShowDialog: Error getting own identity."
);
Log
.
Error
(
"ShowDialog: Error getting own identity."
);
return
System
.
Windows
.
Forms
.
DialogResult
.
Cancel
;
return
;
}
}
// Open dialog and retrieve result
// Open dialog and retrieve result
PatchDialog
patchDialog
=
new
PatchDialog
(
patchAction
,
patch
,
isEditable
);
PatchDialog
patchDialog
=
new
PatchDialog
(
patchAction
,
patch
,
isEditable
);
System
.
Windows
.
Forms
.
DialogResult
dialogResult
=
new
DialogHost
(
patchDialog
).
ShowDialog
();
if
(
new
DialogHost
(
patchDialog
).
ShowDialog
()
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
// Perform the action the user selected
switch
(
patchAction
)
{
{
case
PatchDialog
.
PatchAction
.
NewPatch
:
// Perform the action the user selected
case
PatchDialog
.
PatchAction
.
EditPatch
:
if
(
patchAction
==
PatchDialog
.
PatchAction
.
NewPatch
)
{
try
{
{
if
(
dialogResult
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
await
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Suggest
(
patchDialog
.
Patch
,
me
);
{
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Suggest
(
patchDialog
.
Patch
,
me
);
}
}
}
break
;
catch
(
Exception
ex
)
case
PatchDialog
.
PatchAction
.
SupportOrRejectPatch
:
{
{
if
(
dialogResult
==
System
.
Windows
.
Forms
.
DialogResult
.
OK
)
Log
.
Error
(
"ShowDialog: Error occured. "
+
ex
);
{
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Support
(
patchDialog
.
Patch
,
me
);
while
(
ex
.
InnerException
!=
null
)
}
else
if
(
dialogResult
==
System
.
Windows
.
Forms
.
DialogResult
.
No
)
{
{
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Reject
(
patchDialog
.
Patch
,
me
)
;
ex
=
ex
.
InnerException
;
}
}
CustomMessageBox
.
ShowDialog
(
ex
.
Message
,
"Error suggesting patch"
,
"OK"
);
return
;
}
}
break
;
case
PatchDialog
.
PatchAction
.
ShowPatch
:
default
:
break
;
}
return
dialogResult
;
AdapterExtensions
.
ShowNotification
(
"Patch successfully suggested"
,
patch
.
CommitMessage
);
}
else
{
Log
.
ErrorAndFailInDebugMode
(
"ShowDialog: Unsupported patch action "
+
Enum
.
GetName
(
typeof
(
PatchDialog
.
PatchAction
),
patchAction
));
}
}
}
}
}
}
}
}
UI/ViewModels/OptionsViewModel.cs
View file @
b721e3b0
...
@@ -624,11 +624,6 @@ namespace pEp.UI.ViewModels
...
@@ -624,11 +624,6 @@ namespace pEp.UI.ViewModels
}
}
}
}
/// <summary>
/// Gets the collection of existing patches.
/// </summary>
public
ObservableCollection
<
PatchViewModel
>
Patches
{
get
;
}
=
new
ObservableCollection
<
PatchViewModel
>();
/// <summary>
/// <summary>
/// Gets or sets the pEp copyright used in the about information.
/// Gets or sets the pEp copyright used in the about information.
/// </summary>
/// </summary>
...
...
UI/ViewModels/PatchViewModel.cs
deleted
100644 → 0
View file @
78ac1768
using
pEp.DPE
;
using
pEp.UI.Models
;
using
System
;
using
System.Linq
;
using
System.Windows.Media
;
namespace
pEp.UI.ViewModels
{
internal
class
PatchViewModel
{
private
Patch
patch
;
private
PEPIdentity
_Me
=
null
;
/// <summary>
/// Gets the background color for this patch.
/// </summary>
public
Brush
Background
=>
this
.
IsEditable
?
Brushes
.
White
:
Brushes
.
WhiteSmoke
;
/// <summary>
/// Gets the foreground color for this patch.
/// </summary>
public
Brush
Foreground
=>
this
.
IsEditable
?
Brushes
.
Black
:
Brushes
.
Gray
;
/// <summary>
/// Gets the commit message of this patch.
/// </summary>
public
string
CommitMessage
=>
this
.
patch
?.
CommitMessage
;
/// <summary>
/// Gets whether the patch is editable.
/// </summary>
public
bool
IsEditable
{
get
;
}
/// <summary>
/// Gets a string stating the patch's last update.
/// </summary>
public
string
LastUpdate
=>
this
.
GetLastUpdateString
();
/// <summary>
/// Gets the own identity to use to support/reject patches.
/// </summary>
public
PEPIdentity
Me
{
get
{
if
((
this
.
_Me
==
null
)
&&
(
PEPIdentity
.
GetOwnIdentity
(
Globals
.
ThisAddIn
.
Settings
.
AccountSettingsList
.
First
(),
out
PEPIdentity
me
,
true
)
==
Globals
.
ReturnStatus
.
Success
))
{
this
.
_Me
=
me
;
}
return
this
.
_Me
;
}
}
/// <summary>
/// Primar constructor.
/// </summary>
/// <param name="patch">The patch that this view model is based on.</param>
public
PatchViewModel
(
Patch
patch
,
bool
isEditable
)
{
this
.
patch
=
patch
;
this
.
IsEditable
=
isEditable
;
}
/// <summary>
/// Gets a string referencing the patch's last update.
/// </summary>
/// <returns>A string describing the last update.</returns>
private
string
GetLastUpdateString
()
{
TimeSpan
elapsedTime
=
DateTime
.
UtcNow
-
(
this
.
patch
?.
CreationDate
??
DateTime
.
UtcNow
);
if
(
elapsedTime
.
Days
>
0
)
{
return
(
elapsedTime
.
Days
==
1
)
?
"1 day ago"
:
$"
{
elapsedTime
.
Days
}
days ago"
;
}
else
if
(
elapsedTime
.
Hours
>
0
)
{
return
(
elapsedTime
.
Hours
==
1
)
?
"1 hour ago"
:
$"
{
elapsedTime
.
Hours
}
hours ago"
;
}
else
if
(
elapsedTime
.
Minutes
>
0
)
{
return
(
elapsedTime
.
Minutes
==
1
)
?
"1 minute ago"
:
$"
{
elapsedTime
.
Minutes
}
minutes ago"
;
}
else
{
return
"just now"
;
}
}
/// <summary>
/// Opens the patch dialog.
/// </summary>
/// <returns>The dialog result.</returns>
public
System
.
Windows
.
Forms
.
DialogResult
OpenPatchDialog
(
PatchDialog
.
PatchAction
patchAction
)
{
return
PatchDialog
.
ShowDialog
(
patchAction
,
this
.
patch
,
this
.
IsEditable
);
}
/// <summary>
/// Supports the patch.
/// </summary>
public
void
SupportPatch
()
{
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Support
(
this
.
patch
,
this
.
Me
);
}
/// <summary>
/// Rejects the patch.
/// </summary>
public
void
RejectPatch
()
{
Globals
.
ThisAddIn
.
DistributedPolicyEngine
.
Reject
(
this
.
patch
,
this
.
Me
);
}
}
}
UI/Views/OptionsView.xaml.cs
View file @
b721e3b0
...
@@ -29,17 +29,5 @@ namespace pEp.UI.Views
...
@@ -29,17 +29,5 @@ namespace pEp.UI.Views
Process
.
Start
(
e
.
Uri
.
AbsoluteUri
);
Process
.
Start
(
e
.
Uri
.
AbsoluteUri
);
e
.
Handled
=
true
;
e
.
Handled
=
true
;
}
}
/// <summary>
/// Event handler for when a patch is double-clicked.
/// </summary>
private
void
ContentControl_MouseDoubleClick
(
object
sender
,
MouseButtonEventArgs
e
)
{
if
((
sender
as
ContentControl
)?.
DataContext
is
PatchViewModel
patchViewModel
)
{
PatchDialog
.
PatchAction
action
=
patchViewModel
.
IsEditable
?
PatchDialog
.
PatchAction
.
EditPatch
:
PatchDialog
.
PatchAction
.
SupportOrRejectPatch
;
patchViewModel
.
OpenPatchDialog
(
action
);
}
}
}
}
}
}
pEpForOutlook.csproj
View file @
b721e3b0
...
@@ -448,7 +448,6 @@
...
@@ -448,7 +448,6 @@
<Compile
Include=
"UI\ViewModels\InputMessageBoxViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\InputMessageBoxViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\MessageBoxBaseViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\MessageBoxBaseViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\PatchDialogViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\PatchDialogViewModel.cs"
/>
<Compile
Include=
"UI\ViewModels\PatchViewModel.cs"
/>
<Compile
Include=
"UI\Views\CustomMessageBoxView.xaml.cs"
>
<Compile
Include=
"UI\Views\CustomMessageBoxView.xaml.cs"
>
<DependentUpon>
CustomMessageBoxView.xaml
</DependentUpon>
<DependentUpon>
CustomMessageBoxView.xaml
</DependentUpon>
</Compile>
</Compile>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment