private bool OnClose(DocumentForm doc) { CancelEventArgs e = new CancelEventArgs(); if (doc.Scintilla.Modified) { // Prompt if not saved string message = String.Format(CultureInfo.CurrentCulture, "The Text in the {0} file has changed.{1}{2}Do you want to save the changes?", ((MainWindow)System.Windows.Application.Current.MainWindow).Title.TrimEnd(' ', '*'), Environment.NewLine, Environment.NewLine); MessageBoxResult dr = MessageBox.Show(message, Program.Title, MessageBoxButton.YesNoCancel, MessageBoxImage.Exclamation); if (dr == MessageBoxResult.No) { // Stop closing //e.Cancel = true; ((MainWindow)System.Windows.Application.Current.MainWindow).documentsRoot.Children.Remove(doc); return(true); } else if (dr == MessageBoxResult.Yes) { // Try to save before closing e.Cancel = !doc.Save(); return(true); } else if (dr == MessageBoxResult.Cancel) { return(false); } } ((MainWindow)System.Windows.Application.Current.MainWindow).documentsRoot.Children.Remove(doc); return(true); }
private void SetScintillaToCurrentOptions(DocumentForm doc) { ScintillaWPF ScintillaNet = doc.Scintilla; ScintillaNet.KeyDown += ScintillaNet_KeyDown; // INITIAL VIEW CONFIG ScintillaNet.WrapMode = WrapMode.None; ScintillaNet.IndentationGuides = IndentView.LookBoth; // STYLING InitColors(ScintillaNet); InitSyntaxColoring(ScintillaNet); // NUMBER MARGIN InitNumberMargin(ScintillaNet); // BOOKMARK MARGIN InitBookmarkMargin(ScintillaNet); // CODE FOLDING MARGIN InitCodeFolding(ScintillaNet); // DRAG DROP // TODO - Enable InitDragDropFile //InitDragDropFile(); // INIT HOTKEYS // TODO - Enable InitHotkeys //InitHotkeys(ScintillaNet); #region Uncomment Later //// Turn on line numbers? //if (lineNumbersMenuItem.IsChecked) // doc.Scintilla.Margins[NUMBER_MARGIN].Width = LINE_NUMBERS_MARGIN_WIDTH; //else // doc.Scintilla.Margins[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; #endregion }
public DocumentForm NewDocument() { DocumentForm doc = new DocumentForm(); SetScintillaToCurrentOptions(doc); doc.Title = String.Format(CultureInfo.CurrentCulture, "{0}{1}", NEW_DOCUMENT_TEXT, ++_newDocumentCount); ((MainWindow)System.Windows.Application.Current.MainWindow).documentsRoot.Children.Add(doc); doc.DockAsDocument(); doc.IsActive = true; return(doc); }
public DocumentForm OpenFile(string filePath) { DocumentForm doc = new DocumentForm(); doc.Scintilla.Text = File.ReadAllText(filePath); SetScintillaToCurrentOptions(doc); //doc.Scintilla.UndoRedo.EmptyUndoBuffer(); //doc.Scintilla.Modified = false; doc.Title = Path.GetFileName(filePath); doc.FilePath = filePath; ((MainWindow)System.Windows.Application.Current.MainWindow).documentsRoot.Children.Add(doc); doc.DockAsDocument(); doc.IsActive = true; //incrementalSearcher.Scintilla = doc.Scintilla; return(doc); }