예제 #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 Utility.IsCurrentVersion();
         TitleBarTooltip();
     });
 }
예제 #2
0
 public MainWindow(
     ISpellCheckProvider spellCheckProvider,
     ISnippetManager snippetManager)
 {
     DataContext = this;
     InitializeComponent();
     SpellCheckProvider      = spellCheckProvider;
     SnippetManager          = snippetManager;
     Closing                += OnClosing;
     Activated              += OnFirstActivation;
     IsVisibleChanged       += OnIsVisibleChanged;
     Editor.PropertyChanged += EditorOnPropertyChanged;
     Editor.TextChanged     += (s, e) => Preview.UpdatePreview(((Editor)s));
     Editor.ScrollChanged   += (s, e) => Preview.SetScrollOffset(e);
 }
예제 #3
0
 public MainWindow(
     IMarkdownConverter markdownConverter,
     ISpellCheckProvider spellCheckProvider,
     ISnippetManager snippetManager)
 {
     InitializeComponent();
     MarkdownConverter       = markdownConverter;
     SpellCheckProvider      = spellCheckProvider;
     SnippetManager          = snippetManager;
     Loaded                 += OnLoaded;
     Closing                += OnClosing;
     SizeChanged            += (s, e) => CalculateEditorMargins();
     Editor.PropertyChanged += EditorOnPropertyChanged;
     Editor.TextChanged     += (s, e) => Preview.UpdatePreview(Editor.Text);
     Editor.ScrollChanged   += (s, e) => Preview.SetScrollOffset(e);
 }
예제 #4
0
        public MainWindow(
            ISpellCheckProvider spellCheckProvider,
            ISnippetManager snippetManager)
        {
            InitializeComponent();

            _vm                    = (MainWindowViewModel)DataContext;
            _vm.MainWindow         = this;
            _vm.SpellCheckProvider = spellCheckProvider;
            _vm.SnippetManager     = snippetManager;

            Closing                += _vm.OnClosing;
            Activated              += _vm.OnFirstActivation;
            IsVisibleChanged       += _vm.OnIsVisibleChanged;
            Editor.PropertyChanged += _vm.EditorOnPropertyChanged;
            Editor.TextChanged     += (s, e) => Preview.UpdatePreview((Editor)s);
            Editor.ScrollChanged   += (s, e) => Preview.SetScrollOffset(s, e);
        }
예제 #5
0
 public MainWindow(
     IMarkdownConverter commonMarkConverter,
     IMarkdownConverter githubMarkdownConverter,
     ISpellCheckProvider spellCheckProvider,
     ISnippetManager snippetManager)
 {
     DataContext = this;
     InitializeComponent();
     CommonMarkConverter     = commonMarkConverter;
     GitHubMarkdownConverter = githubMarkdownConverter;
     UpdateMarkdownConverter();
     SpellCheckProvider      = spellCheckProvider;
     SnippetManager          = snippetManager;
     Closing                += OnClosing;
     Activated              += OnActivated;
     IsVisibleChanged       += OnIsVisibleChanged;
     Editor.PropertyChanged += EditorOnPropertyChanged;
     Editor.TextChanged     += (s, e) => Preview.UpdatePreview(((Editor)s));
     Editor.ScrollChanged   += (s, e) => Preview.SetScrollOffset(e);
 }
예제 #6
0
 private void OnActivated(object sender, EventArgs eventArgs)
 {
     Activated -= OnActivated;
     Dispatcher.InvokeAsync(() =>
     {
         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))
             {
                 UpdateMarkdownConverter();
                 Preview.UpdatePreview(Editor);
             }
         };
         SizeChanged += (s, e) => updateMargins();
         updateMargins();
         LoadCommandLineOrLastFile();
     });
 }
예제 #7
0
 private void ExecutePrintHtml(object sender, ExecutedRoutedEventArgs e) => Preview.Print();
예제 #8
0
 private void ExecuteUpdatePreview(object sender, ExecutedRoutedEventArgs e) => Preview.UpdatePreview(Editor);