WorkingWindow.xaml の相互作用ロジック
Inheritance: System.Windows.Window
示例#1
0
        public static void OptimizeDatabaseIfRequired()
        {
            if (!_isDatabaseOptimizationRequired) return;

            // change application shutdown mode for preventing 
            // auto-exit when optimization is completed.
            Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
            try
            {
                // run database optimization
                var optDlg = new WorkingWindow(
                    "optimizing database...",
                    OptimizeDatabase);
                optDlg.ShowDialog();
            }
            finally
            {
                // restore shutdown mode
                Application.Current.ShutdownMode = ShutdownMode.OnLastWindowClose;
            }
        }
示例#2
0
 private async void ChangeDisplayOfTimeline(TweetDisplayMode newValue)
 {
     if (Setting.TweetDisplayMode.Value == newValue)
     {
         RaisePropertyChanged();
         return;
     }
     var showDonationInfo = false;
     if (Setting.TweetDisplayMode.Value == Settings.TweetDisplayMode.Expanded &&
         (newValue == Settings.TweetDisplayMode.SingleLine || newValue == Settings.TweetDisplayMode.Mixed))
     {
         var resp = this.Messenger.GetResponse(new TaskDialogMessage(new TaskDialogOptions
         {
             Title = "一行表示モードの警告",
             MainIcon = VistaTaskDialogIcon.Warning,
             MainInstruction = "一行表示モードを有効にしようとしています。",
             Content = "一行表示モードは複数行表示モードに比べ、リソースを大量に消費します。" + Environment.NewLine +
                       "また、Krile StarryEyesは一行表示モードをベースとして設計されてはいないため、意図しない動作をする可能性があります。" +
                       Environment.NewLine +
                       "一行表示モードを本当に有効にしますか?",
             CommonButtons = TaskDialogCommonButtons.YesNo
         }));
         if (resp.Response.Result == TaskDialogSimpleResult.No)
         {
             this.TweetDisplayMode = (int)Settings.TweetDisplayMode.Expanded;
             return;
         }
         showDonationInfo = true;
     }
     await DispatcherHolder.BeginInvoke(async () =>
     {
         var ww = new WorkingWindow(
             "changing timeline mode...", async () =>
             {
                 await Task.Run(() => Setting.TweetDisplayMode.Value = newValue);
                 RaisePropertyChanged(() => IsDonationVisible);
                 await DispatcherHolder.BeginInvoke(async () =>
                 {
                     await Dispatcher.Yield(DispatcherPriority.Background);
                 });
             });
         if (showDonationInfo && !ContributionService.IsContributor())
         {
             ww.Closed += async (o, e) =>
             {
                 await this.Messenger.RaiseAsync(new TaskDialogMessage(new TaskDialogOptions
                 {
                     Title = "Krileの開発にご協力ください。",
                     MainIcon = VistaTaskDialogIcon.Information,
                     MainInstruction = "Krileの開発にご協力ください。",
                     Content = "多くのユーザーの補助によってKrileが開発されています。" + Environment.NewLine +
                               "Krileの開発を継続するため、寄付にご協力ください。",
                     CustomButtons = new[] { "開発者に寄付" }
                 }));
                 BrowserHelper.Open(App.DonationUrl);
             };
         }
         ww.ShowDialog();
     });
 }
 private static void ShowWorkingDialog(string description, Func<Action<string>, Task> executeTask)
 {
     // change application shutdown mode for preventing 
     // auto-exit when optimization is completed.
     Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
     try
     {
         // run database optimization
         var optDlg = new WorkingWindow(
             description, executeTask);
         optDlg.ShowDialog();
     }
     finally
     {
         // restore shutdown mode
         Application.Current.ShutdownMode = ShutdownMode.OnLastWindowClose;
     }
 }
示例#4
0
 private async void ChangeDisplayOfTimeline(TweetDisplayMode newValue)
 {
     if (Setting.TweetDisplayMode.Value == newValue)
     {
         RaisePropertyChanged();
         return;
     }
     if (Setting.TweetDisplayMode.Value == Settings.TweetDisplayMode.Expanded &&
         (newValue == Settings.TweetDisplayMode.SingleLine || newValue == Settings.TweetDisplayMode.Mixed))
     {
         var resp = this.Messenger.GetResponseSafe(() => new TaskDialogMessage(new TaskDialogOptions
         {
             Title = SettingFlipResources.TimelineSinglelineWarnTitle,
             MainIcon = VistaTaskDialogIcon.Warning,
             MainInstruction = SettingFlipResources.TimelineSingleLineWarnInst,
             Content = SettingFlipResources.TimelineSingleLineWarnContent,
             CommonButtons = TaskDialogCommonButtons.YesNo
         }));
         if (resp.Response.Result == TaskDialogSimpleResult.No)
         {
             this.TweetDisplayMode = (int)Settings.TweetDisplayMode.Expanded;
             return;
         }
     }
     await DispatcherHolder.BeginInvoke(() =>
     {
         var ww = new WorkingWindow(
             "changing timeline mode...", async () =>
             {
                 await Task.Run(() => Setting.TweetDisplayMode.Value = newValue);
                 RaisePropertyChanged(() => IsDonationVisible);
                 await DispatcherHolder.BeginInvoke(async () =>
                 {
                     await Dispatcher.Yield(DispatcherPriority.Background);
                 });
             });
         ww.ShowDialog();
     });
 }