Exemple #1
0
 public DocumentBase CreateDocument(DocumentBase.DocumentDescribor describor)
 {
     if (describor == SqfDocumentDescribor)
     {
         return(new SqfDocument());
     }
     else if (describor == ConfigDocumentDescribor)
     {
         return(new ConfigDocument());
     }
     else if (describor == ImageViewerDescribor)
     {
         return(new ImageViewerDocument());
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Exemple #2
0
 /// <summary>
 /// User will be prompted to select a <see cref="DocumentBase.DocumentDescribor"/>.
 /// In case he aborts, exception will be thrown.
 /// </summary>
 /// <returns>The <see cref="DocumentBase.DocumentDescribor"/> the user selected.</returns>
 /// <exception cref="KeyNotFoundException">Thrown when user aborted the selection dialog.</exception>
 public DocumentBase.DocumentDescribor GetDocumentDescriborByPrompt()
 {
     DocumentBase.DocumentDescribor descr = null;
     Application.Current.Dispatcher.Invoke(() =>
     {
         var dlgdc     = new Dialogs.DocumentSelectorDialogDataContext();
         var dlg       = new Dialogs.DocumentSelectorDialog(dlgdc);
         var dlgResult = dlg.ShowDialog();
         if (dlgResult.HasValue && dlgResult.Value)
         {
             descr = dlgdc.SelectedItem as DocumentBase.DocumentDescribor;
         }
     });
     if (descr != null)
     {
         return(descr);
     }
     throw new KeyNotFoundException();
 }
Exemple #3
0
        /// <summary>
        /// Creates a new document with provided describor.
        /// If describor is not found in any document providers, exception will be thrown.
        /// </summary>
        /// <param name="describor">Describor of some <see cref="DocumentBase"/>.</param>
        /// <returns>new <see cref="DocumentBase"/> instance.</returns>
        /// <exception cref="KeyNotFoundException">Thrown when <see cref="DocumentBase.DocumentDescribor"/> is not found in any DocumentProvider</exception>
        private DocumentBase CreateNewDocument(DocumentBase.DocumentDescribor describor)
        {
            foreach (var p in App.GetPlugins <IDocumentProviderPlugin>())
            {
                if (!p.Documents.Contains(describor))
                {
                    continue;
                }
                var doc = p.CreateDocument(describor);
                doc.KeyManager         = this.KeyManager;
                doc.OnDocumentClosing += this.Document_OnDocumentClosing;
                if (doc is CodeEditorBaseDataContext)
                {
                    (doc as CodeEditorBaseDataContext).OnLintingInfoUpdated += this.Workspace_OnLintingInfoUpdated;
                }
                if (doc is TextEditorBaseDataContext)
                {
                    (doc as TextEditorBaseDataContext).GetEditorInstanceAsync().ContinueWith((t) => Application.Current.Dispatcher.Invoke(() => t.Result.TextArea.TextView.BackgroundRenderers.Add(new UI.LineHighlighterBackgroundRenderer(t.Result))));
                }
                return(doc);
            }

            throw new KeyNotFoundException();
        }
Exemple #4
0
 public static DocumentBase CreateDocument(this IEnumerable <IDocumentProviderPlugin> col, DocumentBase.DocumentDescribor describor)
 {
     return(col.First((pr) => pr.Documents.Contains(describor)).CreateDocument(describor));
 }