//private bool openFile(string OpenFilePath) //{ // String FileName; // if (OpenFilePath == null) // { // openFileDlg.CheckFileExists = true; // if (openFileDlg.ShowDialog(this) != System.Windows.Forms.DialogResult.OK) // { // return false; // } // else // { // OpenFilePath = openFileDlg.FileName; // } // } // FileName = System.IO.Path.GetFileName(OpenFilePath); // DockableDocument dockDoc = new DockableDocument(OpenFilePath, dockPanel); // dockDoc.DockContent.Activated += new EventHandler(DockContent_Activated); // bool success = dockDoc.DockContent != null; // lex.SetStyles(dockDoc.Editor); // if (success) // { // ActiveDocument = dockDoc; // setRecentFile(OpenFilePath); // } // return success; // //System.IO.StreamReader sr = new System.IO.StreamReader(FilePath); // //string str = sr.ReadToEnd(); // //sr.Close(); // //SciEditor.Text = str; // //SciEditor.Modified = false; // //WorkingWithFile = true; // //Text = FileName; // //SciEditor.UndoRedo.EmptyUndoBuffer(); // //return true; //} void DockContent_Activated(object sender, EventArgs e) { DockContent docDock = sender as DockContent; ActiveDocument = docDock.Tag as DockableDocument; Text = ActiveDocument.DocTitle + titleSuffix; }
private void mainFrame_FormClosing(object sender, FormClosingEventArgs e) { List <string> tabs = new List <string>(); foreach (DockContent dc in dockPanel.Documents) { DockableDocument dd = dc.Tag as DockableDocument; if (string.IsNullOrEmpty(dd.FilePath) == false) { tabs.Add(dd.FilePath); } } Properties.Settings.Default.LastTabs = string.Join("|", tabs.ToArray()); if (recentFiles != null) { Properties.Settings.Default.RecentFiles = string.Join("|", recentFiles.ToArray()); } if (selectedFont != null) { Properties.Settings.Default.DefaultFontName = selectedFont.Name; Properties.Settings.Default.DefaultFontSize = selectedFont.Size; } Properties.Settings.Default.GlyphFilterText = glyphTable.Filter; Properties.Settings.Default.LineNumber = lineNumbersToolStripMenuItem.Checked; Properties.Settings.Default.HexNotation = hexadecimalToolStripMenuItem.Checked; //lex.SaveStyles(); Properties.Settings.Default.Save(); }
void DockContent_FormClosing(object sender, FormClosingEventArgs e) { DockContent dc = sender as DockContent; DockableDocument dd = dc.Tag as DockableDocument; if (dd.Editor.Modified) { switch (MessageBox.Show(this, string.Format("Do you want to save '{0}'?", dc.TabText), "Saving?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)) { case DialogResult.Cancel: e.Cancel = true; break; case DialogResult.Yes: if (dd.Save() == DialogResult.Cancel) { e.Cancel = true; } break; case DialogResult.No: break; } } }
private void RecentFileMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem recentItem = (ToolStripMenuItem)sender; if (SwitchIfOpened(recentItem.Text)) { return; } ActiveDocument = CreateNewDocument(recentItem.Text); }
private bool SwitchIfOpened(string OpenFilePath) { foreach (DockContent dc in dockPanel.Documents) { DockableDocument dd = dc.Tag as DockableDocument; if (string.IsNullOrEmpty(dd.FilePath) == false && dd.FilePath.Equals(OpenFilePath)) { dc.Show(); return(true); } } return(false); }
void DockContent_FormClosing(object sender, FormClosingEventArgs e) { DockContent dc = sender as DockContent; DockableDocument dd = dc.Tag as DockableDocument; if (dd.Editor.Modified) { switch (MessageBox.Show(this, string.Format("Do you want to save '{0}'?", dc.TabText), "Saving?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)) { case DialogResult.Cancel: e.Cancel = true; break; case DialogResult.Yes: if (dd.Save() == DialogResult.Cancel) { e.Cancel = true; } break; case DialogResult.No: break; } //MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("ask for saving"); //msgBox.Caption = "Saving?"; //msgBox.Text = string.Format("Do you want to save '{0}'?", dd.FileName); //msgBox.Icon = MessageBoxExIcon.Exclamation; //msgBox.AddButton("Yes", "Y"); //msgBox.AddButton("No", "N"); //msgBox.AddButton("Cancel", "C"); //switch (msgBox.Show(this)) //{ // case "C": // e.Cancel = true; // break; // case "Y": // if (dd.Save() == DialogResult.Cancel) // { // e.Cancel = true; // } // break; // case "N": // break; //} } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { ActiveDocument = CreateNewDocument(""); //if (askToSaveModifiedDocument() != System.Windows.Forms.DialogResult.Cancel) //{ // SciEditor.Text = newDocumentTemplate; // SciEditor.UndoRedo.EmptyUndoBuffer(); // SciEditor.Selection.Start = newDocumentTemplate.Length; // SciEditor.Selection.End = newDocumentTemplate.Length; // FileName = "Untitled" + titleSuffix; // FilePath = ""; // Text = FileName; // SciEditor.Modified = false; // WorkingWithFile = false; //} }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { openFileDlg.CheckFileExists = true; if (openFileDlg.ShowDialog(this) != System.Windows.Forms.DialogResult.OK) { return; } else { string OpenFilePath = openFileDlg.FileName; if (SwitchIfOpened(OpenFilePath)) { return; } ActiveDocument = CreateNewDocument(OpenFilePath); setRecentFile(OpenFilePath); } }
private DockableDocument CreateNewDocument(string filePath) { DockableDocument doc = new DockableDocument(filePath, dockPanel); lex.SetStyles(doc.Editor); doc.DockContent.Activated += new EventHandler(DockContent_Activated); doc.DockContent.FormClosing += new FormClosingEventHandler(DockContent_FormClosing); doc.Editor.CharAdded += new EventHandler <ScintillaNet.CharAddedEventArgs>(Editor_CharAdded); doc.Editor.TextChanged += new EventHandler <EventArgs>(Editor_TextChanged); doc.Editor.SelectionChanged += new EventHandler(Editor_SelectionChanged); if (string.IsNullOrEmpty(doc.DocTitle)) { doc.DockContent.Close(); return(null); } activeDocument = doc; Text = doc.DocTitle + titleSuffix; return(doc); }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { ActiveDocument = CreateNewDocument(""); }