Ejemplo n.º 1
0
        private void menuFileSave_Click(object sender, EventArgs e)
        {
            SciTextEditorControl editor = ActiveEditor;

            if (editor != null)
            {
                DoSave(editor);
            }
        }
Ejemplo n.º 2
0
 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 += "*";
         }
     }
 }
Ejemplo n.º 3
0
 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);
         }
     }
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
 /// <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("*"));
 }
Ejemplo n.º 6
0
 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 += "*";
     }
 }
Ejemplo n.º 7
0
 /// <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("*");
 }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
 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;
         }
     }
 }