Example #1
0
        private async void Logout_Click(object sender, RoutedEventArgs e)
        {
            ContentDialog dialog = new ContentDialog
            {
                Title             = "警告",
                PrimaryButtonText = "继续",
                CloseButtonText   = "取消",
                Content           = "此操作将注销当前账户\r\r可能需要重新输入相关信息,是否继续?",
                Background        = Application.Current.Resources["DialogAcrylicBrush"] as Brush
            };

            if ((await dialog.ShowAsync()) != ContentDialogResult.Primary)
            {
                return;
            }

            LoadingText.Text         = "正在注销...";
            LoadingControl.IsLoading = true;

            ConnectionCancellation?.Cancel();

            await Task.Delay(1000);

            ConnectionCancellation?.Dispose();
            ConnectionCancellation = null;

            DisplayMode.SelectionChanged -= DisplayMode_SelectionChanged;
            LastSelectedItem              = null;

            if (EmailProtocolServiceProvider.CheckWhetherInstanceExist())
            {
                EmailProtocolServiceProvider.GetInstance().Dispose();
            }

            EmailService = null;

            ApplicationData.Current.LocalSettings.Values["EmailStartup"]              = null;
            ApplicationData.Current.RoamingSettings.Values["EmailCredentialName"]     = null;
            ApplicationData.Current.RoamingSettings.Values["EmailCredentialPassword"] = null;
            ApplicationData.Current.RoamingSettings.Values["EmailIMAPAddress"]        = null;
            ApplicationData.Current.RoamingSettings.Values["EmailIMAPPort"]           = null;
            ApplicationData.Current.RoamingSettings.Values["EmailSMTPAddress"]        = null;
            ApplicationData.Current.RoamingSettings.Values["EmailSMTPPort"]           = null;
            ApplicationData.Current.RoamingSettings.Values["EmailEnableSSL"]          = null;
            ApplicationData.Current.RoamingSettings.Values["EmailCallName"]           = null;

            LoadingControl.IsLoading = false;
            await Task.Delay(700);

            EmailAllItemCollection.Clear();
            EmailNotSeenItemCollection.Clear();
            EmailDisplayCollection?.Clear();

            EmailPage.ThisPage.Nav.Navigate(typeof(EmailStartupOne), EmailPage.ThisPage.Nav, new DrillInNavigationTransitionInfo());

            NothingDisplayControl.Visibility = Visibility.Visible;
        }
Example #2
0
 /// <summary>
 /// 在将要挂起应用程序执行时调用。  在不知道应用程序
 /// 无需知道应用程序会被终止还是会恢复,
 /// 并让内存内容保持不变。
 /// </summary>
 /// <param name="sender">挂起的请求的源。</param>
 /// <param name="e">有关挂起请求的详细信息。</param>
 private void OnSuspending(object sender, SuspendingEventArgs e)
 {
     //TODO: 保存应用程序状态并停止任何后台活动
     SQLite.GetInstance().Dispose();
     if (EmailProtocolServiceProvider.CheckWhetherInstanceExist())
     {
         EmailProtocolServiceProvider.GetInstance().Dispose();
     }
 }