コード例 #1
0
 private void OnFirstActivation(object sender, EventArgs eventArgs)
 {
     Activated -= OnFirstActivation;
     Dispatcher.InvokeAsync(async() =>
     {
         var updateMargins = Utility.Debounce(() => Dispatcher.Invoke(() => EditorMargins = CalculateEditorMargins()), 50);
         App.UserSettings.PropertyChanged += (o, args) =>
         {
             if (args.PropertyName == nameof(App.UserSettings.SinglePaneMargin))
             {
                 updateMargins();
             }
             if (args.PropertyName == nameof(App.UserSettings.GitHubMarkdown))
             {
                 Preview.UpdatePreview(Editor);
             }
         };
         SizeChanged += (s, e) => updateMargins();
         updateMargins();
         LoadCommandLineOrLastFile();
         Application.Current.Activated += OnActivated;
         NewVersion = !await Version.IsCurrentVersion();
         TitleBarTooltip();
     });
 }
コード例 #2
0
ファイル: MainWindow.vm.cs プロジェクト: vtlns/Markdown-Edit
        public void OnFirstActivation(object sender, EventArgs eventArgs)
        {
            MainWindow.Activated -= OnFirstActivation;
            MainWindow.Dispatcher.InvokeAsync(async() =>
            {
                var updateMargins = Utility.Debounce(() =>
                                                     MainWindow.Dispatcher.Invoke(() => EditorMargins = CalculateEditorMargins()), 50);

                Func <Visibility> isVisible = () => MainWindow.WindowState == WindowState.Maximized
                    ? Visibility.Visible
                    : Visibility.Collapsed;

                App.UserSettings.PropertyChanged += (o, args) =>
                {
                    if (args.PropertyName == nameof(App.UserSettings.SinglePaneMargin))
                    {
                        updateMargins();
                    }
                    if (args.PropertyName == nameof(App.UserSettings.GitHubMarkdown))
                    {
                        MainWindow.Preview.UpdatePreview(MainWindow.Editor);
                    }
                };

                StartClock();
                ClockIsVisible          = isVisible();
                MainWindow.SizeChanged += (s, e) => ClockIsVisible = isVisible();

                updateMargins();
                MainWindow.SizeChanged += (s, e) => updateMargins();

                LoadCommandLineOrLastFile();
                Application.Current.Activated += OnActivated;
                NewVersion = !await Version.IsCurrentVersion();
            });
        }