Ejemplo n.º 1
0
 public IEditor NewEditor()
 {
     DocumentContent document = new DocumentContent();
     Editor editor = new Editor(document);
     document.Show(manager);
     document.Activate();
     return editor;
 }
Ejemplo n.º 2
0
 public static void ShowDocument(DocumentContent doc, bool floating)
 {
     doc.Show(DockingManager, floating);
     doc.Activate();
 }
Ejemplo n.º 3
0
        private void ExportLayoutToDocument(object sender, RoutedEventArgs e)
        {
            DocumentContent doc = new DocumentContent()
            {
                Title = string.Format("Layout_{0}", DateTime.Now.ToString()),
                Content = new TextBox()
                {
                    AcceptsReturn = true,
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
                    HorizontalScrollBarVisibility = ScrollBarVisibility.Auto,
                    Text = DockManager.LayoutToString()
                }
            };

            doc.Show(DockManager);
            doc.Activate();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new tab for the editor
        /// </summary>
        /// <param name="file">File path (possibly empty)</param>
        private void CreateEditorTab(string file = "")
        {
            // create new syntax highlight box
              var info = new DocumentInfo();
              var shbox = new SyntaxHighlightBox.SyntaxHighlightBox();
              shbox.CurrentHighlighter = SyntaxHighlightBox.HighlighterManager.Instance.Highlighters["Mirelle"];

              // create a new tab
              var newdoc = new DocumentContent();
              newdoc.Content = shbox;

              if (file == "")
              {
            // mark tab as 'untitled'
            newdoc.Title = Editor.Resources.Untitled + " " + UntitledCount.ToString();
            UntitledCount++;
              }
              else
              {
            // load file into tab
            try
            {
              var fi = new FileInfo(file);
              info.FullPath = file;
              newdoc.Title = info.Name = fi.Name;
              var sr = fi.OpenText();
              shbox.Text = sr.ReadToEnd().Replace("\t", "  ");
              shbox.Redraw();
              sr.Close();
            }
            catch
            {
              Error(String.Format(Editor.Resources.FileNotFound, file));
              return;
            }
              }

              newdoc.Closing += (s, e) =>
              {
            // check for interface being disabled
            if (DisableInterface)
            {
              e.Cancel = true;
              return;
            }

            // check if there's need to saves
            var docinfo = Documents[s as DocumentContent];
            if (info.Modified)
            {
              var result = MessageBox.Show(Editor.Resources.SourceModified, Editor.Resources.Caption, MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
              if (result == MessageBoxResult.Cancel)
            e.Cancel = true;
            }

            if (!e.Cancel)
              Documents.Remove((DocumentContent)s);
              };

              shbox.TextChanged += (s, e) =>
              {
            var dc = docContent.SelectedItem as DocumentContent;
            if (!Documents[dc].Modified)
            {
              Documents[dc].Modified = true;
              dc.Title += " *";
            }
              };

              docContent.Items.Add(newdoc);
              Documents.Add(newdoc, info);

              newdoc.Activate();
        }