示例#1
0
        internal DocumentView NewDocument()
        {
            DocumentView doc = new DocumentView();

            InitScintillaDocument(doc);
            doc.Title = String.Format(CultureInfo.CurrentCulture, "{0}{1}", ScintillaConstants.NEW_DOCUMENT_TEXT, ++_newDocumentCount);
            documentsRoot.Children.Add(doc);
            doc.DockAsDocument();
            doc.IsActive  = true;
            doc.ContentId = Guid.NewGuid().ToString();
            doc.Closing  += Doc_Closing;
            doc.Title    += " *";
            return(doc);
        }
示例#2
0
        public DocumentView OpenFile(string filePath)
        {
            DocumentView doc = new DocumentView();

            InitScintillaDocument(doc);
            doc.scintilla.Text = File.ReadAllText(filePath);
            doc.scintilla.EmptyUndoBuffer();
            doc.Title    = System.IO.Path.GetFileName(filePath);
            doc.FilePath = filePath;
            documentsRoot.Children.Add(doc);
            doc.DockAsDocument();
            doc.IsActive  = true;
            doc.ContentId = Guid.NewGuid().ToString();
            doc.Closing  += Doc_Closing;
            RefreshSoltionExplorer();

            return(doc);
        }
示例#3
0
        private void InitScintillaDocument(DocumentView doc)
        {
            ScintillaMethods.InitBase(doc);

            if (lineNumbersMenuItem.IsChecked)
            {
                doc.scintilla.Margins[ScintillaConstants.NUMBER_MARGIN].Width = ScintillaConstants.LINE_NUMBERS_MARGIN_WIDTH;
            }
            else
            {
                doc.scintilla.Margins[ScintillaConstants.NUMBER_MARGIN].Width = 0;
            }

            // Turn on white space?
            if (whitespaceMenuItem.IsChecked)
            {
                doc.scintilla.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }
            else
            {
                doc.scintilla.ViewWhitespace = WhitespaceMode.Invisible;
            }

            // Turn on word wrap?
            if (wordWrapMenuItem.IsChecked)
            {
                doc.scintilla.WrapMode = WrapMode.Word;
            }
            else
            {
                doc.scintilla.WrapMode = WrapMode.None;
            }

            // Show EOL?
            doc.scintilla.ViewEol = endOfLineMenuItem.IsChecked;

            // Set the zoom
            doc.scintilla.Zoom = _zoomLevel;
        }