OUT-386: Add context menu to reset single own account sync
authorThomas
Thu, 01 Aug 2019 07:58:36 +0200
branchsync
changeset 2690bbb6238d7b32
parent 2689 7cd444e4eaa0
child 2691 98aaf91e2bc4
OUT-386: Add context menu to reset single own account
UI/FormControlOptions.xaml
UI/FormControlOptions.xaml.cs
     1.1 --- a/UI/FormControlOptions.xaml	Wed Jul 31 15:13:24 2019 +0200
     1.2 +++ b/UI/FormControlOptions.xaml	Thu Aug 01 07:58:36 2019 +0200
     1.3 @@ -218,7 +218,8 @@
     1.4                          <TextBlock  Grid.Row="0"
     1.5                                      Visibility="Collapsed" />
     1.6                          <!-- Can be used for a title -->
     1.7 -                        <ListBox  Grid.Row="1"
     1.8 +                        <ListBox  Name="accountSettingsListBox"
     1.9 +                                  Grid.Row="1"
    1.10                                    HorizontalContentAlignment="Stretch"
    1.11                                    ScrollViewer.HorizontalScrollBarVisibility="Disabled"
    1.12                                    ItemsSource="{Binding Path=AccountSettingsList}"
    1.13 @@ -229,6 +230,16 @@
    1.14                                             Right="0"
    1.15                                             Top="{StaticResource PageSubSectionSpacing}" />
    1.16                              </ListBox.Margin>
    1.17 +                            <ListBox.ContextMenu>
    1.18 +                                <ContextMenu>
    1.19 +                                    <MenuItem Header="{x:Static p:Resources.PrivacyStatus_ResetTrust}"                                               
    1.20 +                                              Click="AccountMenuItem_Click">
    1.21 +                                        <MenuItem.Icon>
    1.22 +                                            <Image Source="pack://application:,,,/pEp;component/Resources/ImageLogoSmall.png"/>
    1.23 +                                        </MenuItem.Icon>
    1.24 +                                    </MenuItem>
    1.25 +                                </ContextMenu>
    1.26 +                            </ListBox.ContextMenu>
    1.27                              <ListBox.ItemTemplate>
    1.28                                  <DataTemplate>
    1.29                                      <Grid HorizontalAlignment="Stretch"
     2.1 --- a/UI/FormControlOptions.xaml.cs	Wed Jul 31 15:13:24 2019 +0200
     2.2 +++ b/UI/FormControlOptions.xaml.cs	Thu Aug 01 07:58:36 2019 +0200
     2.3 @@ -1,4 +1,5 @@
     2.4 -´╗┐using System;
     2.5 +´╗┐using pEpCOMServerAdapterLib;
     2.6 +using System;
     2.7  using System.Collections.Generic;
     2.8  using System.Collections.ObjectModel;
     2.9  using System.Collections.Specialized;
    2.10 @@ -110,6 +111,37 @@
    2.11           *************************************************************/
    2.12  
    2.13          /// <summary>
    2.14 +        /// Event handler for when an account menu entry context menu item is clicked.
    2.15 +        /// </summary>
    2.16 +        private void AccountMenuItem_Click(object sender, RoutedEventArgs e)
    2.17 +        {
    2.18 +            if (accountSettingsListBox.SelectedIndex == -1)
    2.19 +            {
    2.20 +                Log.Error("AccountMenuItem_Click: Nothing selected. Returning.");
    2.21 +                return;
    2.22 +            }
    2.23 +
    2.24 +            // Get the identity and reset its keys
    2.25 +            if (accountSettingsListBox.SelectedItem is FormControlOptions.AccountState accountState)
    2.26 +            {
    2.27 +                PEPIdentity identity = new PEPIdentity(accountState.SmtpAddress)
    2.28 +                {
    2.29 +                    UserId = PEPSettings.PEP_OWN_USER_ID
    2.30 +                };               
    2.31 +
    2.32 +                try
    2.33 +                {
    2.34 +                    pEpIdentity _identity = identity.ToCOMType();
    2.35 +                    ThisAddIn.PEPEngine.KeyResetIdentity(_identity, null);
    2.36 +                }
    2.37 +                catch (Exception ex)
    2.38 +                {
    2.39 +                    Log.Error("AccountMenuItem_Click: Error resetting identity. " + ex.ToString());
    2.40 +                }
    2.41 +            }
    2.42 +        }
    2.43 +
    2.44 +        /// <summary>
    2.45          /// Event handler for when a property is changed within the display state.
    2.46          /// </summary>
    2.47          private void DisplayState_PropertyChanged(object sender, PropertyChangedEventArgs e)