Handling some warnings and proper disposals of shells etc.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -447,7 +447,7 @@
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Text="{x:Bind Email}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
Visibility="{x:Bind HasDistinctDisplayName, Mode=OneWay}" />
|
||||
Visibility="{x:Bind HasDistinctDisplayName}" />
|
||||
</StackPanel>
|
||||
|
||||
<Button
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:reader="using:Wino.Core.Domain.Models.Reader"
|
||||
xmlns:toolkitExt="using:CommunityToolkit.WinUI"
|
||||
xmlns:x509="using:System.Security.Cryptography.X509Certificates"
|
||||
x:Name="root"
|
||||
mc:Ignorable="d">
|
||||
|
||||
@@ -65,18 +66,23 @@
|
||||
Grid.Column="2"
|
||||
Click="SetAliasPrimary_Click"
|
||||
CommandParameter="{x:Bind}"
|
||||
IsChecked="{x:Bind IsPrimary, Mode=OneWay}" />
|
||||
IsChecked="{x:Bind IsPrimary}" />
|
||||
|
||||
|
||||
<ComboBox
|
||||
Grid.Column="3"
|
||||
HorizontalAlignment="Center"
|
||||
DisplayMemberPath="Subject"
|
||||
DropDownClosed="SigningCertificateDropDownClosed"
|
||||
IsEnabled="{x:Bind IsSmimeEncryptionEnabled}"
|
||||
ItemsSource="{x:Bind Certificates, Mode=OneWay}"
|
||||
ItemsSource="{x:Bind Certificates}"
|
||||
PlaceholderText="{x:Bind domain:Translator.SettingsSignatureAndEncryption_SigningCertificatePlaceholder}"
|
||||
SelectedItem="{Binding SelectedSigningCertificate, Mode=TwoWay}" />
|
||||
SelectedItem="{x:Bind SelectedSigningCertificate, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="x509:X509Certificate2">
|
||||
<TextBlock Text="{x:Bind Subject}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<CheckBox
|
||||
Grid.Column="4"
|
||||
|
||||
@@ -65,17 +65,17 @@
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1" Text="{x:Bind Subject, Mode=OneWay}" />
|
||||
<TextBlock Grid.Column="1" Text="{x:Bind Subject}" />
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
FontSize="10"
|
||||
Foreground="Gray"
|
||||
Text="{x:Bind NotAfter, Mode=OneWay}" />
|
||||
Text="{x:Bind NotAfter}" />
|
||||
<TextBlock
|
||||
Grid.Column="3"
|
||||
FontSize="10"
|
||||
Foreground="Gray"
|
||||
Text="{x:Bind Thumbprint, Mode=OneWay}" />
|
||||
Text="{x:Bind Thumbprint}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
@@ -146,17 +146,17 @@
|
||||
<ColumnDefinition Width="120" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Grid.Column="1" Text="{x:Bind Subject, Mode=OneWay}" />
|
||||
<TextBlock Grid.Column="1" Text="{x:Bind Subject}" />
|
||||
<TextBlock
|
||||
Grid.Column="2"
|
||||
FontSize="10"
|
||||
Foreground="Gray"
|
||||
Text="{x:Bind NotAfter, Mode=OneWay}" />
|
||||
Text="{x:Bind NotAfter}" />
|
||||
<TextBlock
|
||||
Grid.Column="3"
|
||||
FontSize="10"
|
||||
Foreground="Gray"
|
||||
Text="{x:Bind Thumbprint, Mode=OneWay}" />
|
||||
Text="{x:Bind Thumbprint}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
|
||||
@@ -21,23 +21,23 @@
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
<controls:SettingsCard.Header>
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey), Mode=OneWay}" />
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey)}" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(DescriptionKey), Mode=OneWay}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(DescriptionKey)}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(KeywordsKey), Mode=OneWay}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(KeywordsKey)}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<StackPanel
|
||||
Margin="0,4,0,0"
|
||||
Orientation="Horizontal"
|
||||
Spacing="12">
|
||||
<Button
|
||||
Command="{x:Bind PurchaseCommand, Mode=OneWay}"
|
||||
Command="{x:Bind PurchaseCommand}"
|
||||
CommandParameter="{x:Bind}"
|
||||
Content="{x:Bind domain:Translator.Buttons_Purchase}"
|
||||
Style="{StaticResource AccentButtonStyle}" />
|
||||
@@ -59,7 +59,7 @@
|
||||
</controls:SettingsExpander.HeaderIcon>
|
||||
<controls:SettingsExpander.Header>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey), Mode=OneWay}" />
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey)}" />
|
||||
<Border
|
||||
Padding="8,2"
|
||||
Background="{ThemeResource SystemAccentColor}"
|
||||
@@ -88,7 +88,7 @@
|
||||
Text="{x:Bind RenewalText, Mode=OneWay}" />
|
||||
</StackPanel>
|
||||
</controls:SettingsExpander.Description>
|
||||
<HyperlinkButton Command="{x:Bind ManageCommand, Mode=OneWay}" Content="{x:Bind domain:Translator.Buttons_Manage}" />
|
||||
<HyperlinkButton Command="{x:Bind ManageCommand}" Content="{x:Bind domain:Translator.Buttons_Manage}" />
|
||||
<controls:SettingsExpander.Items>
|
||||
<controls:SettingsCard HorizontalContentAlignment="Stretch">
|
||||
<controls:SettingsCard.Header>
|
||||
@@ -137,16 +137,16 @@
|
||||
</controls:SettingsCard.HeaderIcon>
|
||||
<controls:SettingsCard.Header>
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey), Mode=OneWay}" />
|
||||
<TextBlock FontWeight="SemiBold" Text="{x:Bind domain:Translator.GetTranslatedString(NameKey)}" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource BodyTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(DescriptionKey), Mode=OneWay}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(DescriptionKey)}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<TextBlock
|
||||
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
|
||||
Style="{StaticResource CaptionTextBlockStyle}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(KeywordsKey), Mode=OneWay}"
|
||||
Text="{x:Bind domain:Translator.GetTranslatedString(KeywordsKey)}"
|
||||
TextWrapping="WrapWholeWords" />
|
||||
<Border
|
||||
Padding="12,4"
|
||||
|
||||
@@ -23,7 +23,10 @@ using Wino.Core.Domain.Models.Calendar;
|
||||
using Wino.Core.Domain.Models.Folders;
|
||||
using Wino.Core.Domain.Models.MailItem;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Calendar.ViewModels;
|
||||
using Wino.Mail.ViewModels;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
using Wino.Mail.WinUI.ViewModels;
|
||||
using Wino.Mail.WinUI.Controls;
|
||||
using Wino.MenuFlyouts;
|
||||
using Wino.MenuFlyouts.Context;
|
||||
@@ -49,6 +52,7 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
private WinoApplicationMode? _activeMode;
|
||||
private bool _isSyncingNavigationViewSelection;
|
||||
private bool _isSynchronizingVisibleDateRangeCalendar;
|
||||
private bool _isPreparedForWindowClose;
|
||||
|
||||
public WinoAppShell()
|
||||
{
|
||||
@@ -98,10 +102,33 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedFrom(e);
|
||||
DeactivateCurrentMode();
|
||||
|
||||
if (!_isPreparedForWindowClose)
|
||||
{
|
||||
DeactivateCurrentMode();
|
||||
DetachLifetimeSubscriptions();
|
||||
}
|
||||
|
||||
Bindings.StopTracking();
|
||||
}
|
||||
|
||||
public void PrepareForWindowClose()
|
||||
{
|
||||
if (_isPreparedForWindowClose)
|
||||
return;
|
||||
|
||||
_isPreparedForWindowClose = true;
|
||||
|
||||
DeactivateAllShellClients();
|
||||
WeakReferenceMessenger.Default.Unregister<LanguageChanged>(this);
|
||||
UnregisterRecipients();
|
||||
DetachLifetimeSubscriptions();
|
||||
Bindings.StopTracking();
|
||||
|
||||
navigationView.MenuItemsSource = null;
|
||||
CalendarHostListView.ItemsSource = null;
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UpdateNavigationPaneLayout(navigationView.DisplayMode);
|
||||
@@ -155,6 +182,44 @@ public sealed partial class WinoAppShell : Views.Abstract.WinoAppShellAbstract,
|
||||
}
|
||||
}
|
||||
|
||||
private void DeactivateAllShellClients()
|
||||
{
|
||||
ViewModel.StatePersistenceService.IsReadingMail = false;
|
||||
ViewModel.StatePersistenceService.IsEventDetailsVisible = false;
|
||||
|
||||
ViewModel.MailClient.Deactivate();
|
||||
ViewModel.CalendarClient.Deactivate();
|
||||
|
||||
if (ViewModel.GetClient(WinoApplicationMode.Contacts) is ContactsShellClient contactsClient)
|
||||
{
|
||||
contactsClient.PrepareForShellShutdown();
|
||||
}
|
||||
|
||||
if (ViewModel.GetClient(WinoApplicationMode.Settings) is SettingsShellClient settingsClient)
|
||||
{
|
||||
settingsClient.PrepareForShellShutdown();
|
||||
}
|
||||
|
||||
if (ViewModel.MailClient is MailAppShellViewModel mailClient)
|
||||
{
|
||||
mailClient.PrepareForShellShutdown();
|
||||
}
|
||||
|
||||
if (ViewModel.CalendarClient is CalendarAppShellViewModel calendarClient)
|
||||
{
|
||||
calendarClient.PrepareForShellShutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void DetachLifetimeSubscriptions()
|
||||
{
|
||||
ViewModel.MailClient.PropertyChanged -= MailClientPropertyChanged;
|
||||
ViewModel.CalendarClient.PropertyChanged -= CalendarClientPropertyChanged;
|
||||
ViewModel.PropertyChanged -= ViewModelPropertyChanged;
|
||||
ViewModel.PreferencesService.PreferenceChanged -= PreferencesServiceChanged;
|
||||
ViewModel.StatePersistenceService.StatePropertyChanged -= StatePersistenceServiceChanged;
|
||||
}
|
||||
|
||||
private void ResetShellModeNavigationState()
|
||||
{
|
||||
InnerShellFrame.BackStack.Clear();
|
||||
|
||||
Reference in New Issue
Block a user