private void menuFileSave_Click(object sender, EventArgs e) { SciTextEditorControl editor = ActiveEditor; if (editor != null) { DoSave(editor); } }
private static void SetModifiedFlag(SciTextEditorControl editor, bool flag) { if (IsModified(editor) != flag) { var p = editor.Parent; if (IsModified(editor)) { p.Text = p.Text.Substring(0, p.Text.Length - 1); } else { p.Text += "*"; } } }
private bool DoSave(SciTextEditorControl editor) { if (string.IsNullOrEmpty(editor.FileName)) { return(DoSaveAs(editor)); } else { try { editor.SaveFile(editor.FileName); SetModifiedFlag(editor, false); return(true); } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); return(false); } } }
private bool DoSaveAs(SciTextEditorControl editor) { saveFileDialog.FileName = editor.FileName; if (saveFileDialog.ShowDialog() == DialogResult.OK) { try { editor.SaveFile(saveFileDialog.FileName); editor.Parent.Text = Path.GetFileName(editor.FileName); SetModifiedFlag(editor, false); // The syntax highlighting strategy doesn't change // automatically, so do it manually. //editor.Document.HighlightingStrategy = // HighlightingStrategyFactory.CreateHighlightingStrategyForFile(editor.FileName); return(true); } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); } } return(false); }
/// <summary>Gets whether the file in the specified editor is modified.</summary> /// <remarks>TextEditorControl doesn't maintain its own internal modified /// flag, so we use the '*' shown after the file name to represent the /// modified state.</remarks> private static bool IsModified(SciTextEditorControl editor) { // TextEditorControl doesn't seem to contain its own 'modified' flag, so // instead we'll treat the "*" on the filename as the modified flag. return(editor.Parent.Text.EndsWith("*")); }
private static void SetModifiedFlag(SciTextEditorControl editor, bool flag) { if (IsModified(editor) != flag) { var p = editor.Parent; if (IsModified(editor)) p.Text = p.Text.Substring(0, p.Text.Length - 1); else p.Text += "*"; } }
/// <summary>Gets whether the file in the specified editor is modified.</summary> /// <remarks>TextEditorControl doesn't maintain its own internal modified /// flag, so we use the '*' shown after the file name to represent the /// modified state.</remarks> private static bool IsModified(SciTextEditorControl editor) { // TextEditorControl doesn't seem to contain its own 'modified' flag, so // instead we'll treat the "*" on the filename as the modified flag. return editor.Parent.Text.EndsWith("*"); }
private bool DoSaveAs(SciTextEditorControl editor) { saveFileDialog.FileName = editor.FileName; if (saveFileDialog.ShowDialog() == DialogResult.OK) { try { editor.SaveFile(saveFileDialog.FileName); editor.Parent.Text = Path.GetFileName(editor.FileName); SetModifiedFlag(editor, false); // The syntax highlighting strategy doesn't change // automatically, so do it manually. //editor.Document.HighlightingStrategy = // HighlightingStrategyFactory.CreateHighlightingStrategyForFile(editor.FileName); return true; } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); } } return false; }
private bool DoSave(SciTextEditorControl editor) { if (string.IsNullOrEmpty(editor.FileName)) return DoSaveAs(editor); else { try { editor.SaveFile(editor.FileName); SetModifiedFlag(editor, false); return true; } catch (Exception ex) { MessageBox.Show(this, ex.Message, ex.GetType().Name); return false; } } }