Example #1
0
 private static void CheckAndCloseView(DocumentView view)
 {
     if (view != null)
     {
         view.Cleanup();
     }
 }
        public void ConnectToDocumentView(DocumentView view)
        {
            if (providers.Any(p => p.View == view)) throw new ArgumentException("View already has a spell check provider connected", "view");

            var provider = new SpellCheckProvider(spellingService, view);
            providers.Add(provider);
        }
        public void DisconnectFromDocumentView(DocumentView view)
        {
            var provider = providers.FirstOrDefault(p => p.View == view);
            if (provider == null) return;

            provider.Disconnect();
            providers.Remove(provider);
        }
        public SpellCheckProvider(ISpellingService spellingService, DocumentView view)
        {
            _spellingService = spellingService;
            _spellCheckRenderer = new SpellCheckBackgroundRenderer();
            this.View = view;

            this.View.Editor.TextArea.TextView.BackgroundRenderers.Add(_spellCheckRenderer);
            this.View.Editor.TextArea.TextView.VisualLinesChanged += TextView_VisualLinesChanged;
        }
        public override void CanClose(Action <bool> callback)
        {
            DocumentView view = (DocumentView)this.GetView();

            if (!HasChanges)
            {
                view.wb.Close();
                callback(true);
                return;
            }

            var saveResult = dialogService.ShowConfirmationWithCancel("MarkPad", "Save modifications.", "Do you want to save your changes to '" + title + "'?",
                                                                      new ButtonExtras(ButtonType.Yes, "Save",
                                                                                       string.IsNullOrEmpty(filename) ? "The file has not been saved yet" : "The file will be saved to " + Path.GetFullPath(filename)),
                                                                      new ButtonExtras(ButtonType.No, "Don't Save", "Close the document without saving the modifications"),
                                                                      new ButtonExtras(ButtonType.Cancel, "Cancel", "Don't close the document")
                                                                      );
            var result = false;

            // true = Yes
            switch (saveResult)
            {
            case true:
                result = Save();
                break;

            case false:
                result = true;
                break;
            }

            // Close browser if tab is being closed
            if (result == true)
            {
                view.wb.Close();
            }

            callback(result);
        }
Example #6
0
 private static void CheckAndCloseView(DocumentView view)
 {
     if (view != null)
     {
         view.Cleanup();
     }
 }
 private static void CheckAndCloseView(DocumentView view)
 {
     if (view != null
         && view.wb != null)
     {
         view.wb.Close();
     }
 }