コード例 #1
0
ファイル: LempDemoPanel.cs プロジェクト: sizzles/ecsharp
 public bool SaveOutput()
 {
     if (string.IsNullOrEmpty(_outFileName))
     {
         MessageBox.Show("Output does not yet have a file name.");
         return(false);
     }
     else
     {
         if (_lempStarted)
         {
             Thread.Sleep(250);                     // wait and hope it'll finish
         }
         try {
             _outEditor.SaveFile(_outFileName);
         } catch (Exception ex) {
             MessageBox.Show(ex.Message, ex.GetType().Name);
             return(false);
         }
         if (_lempStarted)
         {
             MessageBox.Show("LeMP is still running. Old version of output was saved.");
         }
         return(true);
     }
 }
コード例 #2
0
 private bool DoSave(TextEditorControl 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(ex.Message, ex.GetType().Name);
             return(false);
         }
     }
 }
コード例 #3
0
        private bool DoSaveAs(LempDemoPanel panel)
        {
            TextEditorControl editor = panel.Editor;

            saveFileDialog.FileName = editor.FileName;
            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                try {
                    editor.SaveFile(saveFileDialog.FileName);
                    panel.ChooseHighlighter();                     // fix syntax highlighting
                    panel.Parent.Text = Path.GetFileName(editor.FileName);
                    panel.SetModifiedFlag(false);
                    return(true);
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message, ex.GetType().Name);
                }
            }
            return(false);
        }
コード例 #4
0
        private bool DoSaveAs(TextEditorControl 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(ex.Message, ex.GetType().Name);
                }
            }
            return(false);
        }