예제 #1
0
        public override void Execute(object parameter)
        {
            Altaxo.Scripting.IScriptText script = null; // or load it from somewhere

            if (script == null)
            {
                script = new Altaxo.Scripting.ProgramInstanceScript();
            }
            var options = new Altaxo.Gui.OpenFileOptions
            {
                Title = "Open a script or press Cancel to create a new script"
            };

            options.AddFilter("*.cs", "C# files (*.cs)");
            options.AddFilter("*.*", "All files (*.*)");
            options.FilterIndex = 0;
            if (Current.Gui.ShowOpenFileDialog(options))
            {
                string err = OpenScriptText(options.FileName, out var scripttext);
                if (null != err)
                {
                    Current.Gui.ErrorMessageBox(err);
                }
                else
                {
                    script.ScriptText = scripttext;
                }
            }

            object[] args = new object[] { script, new Altaxo.Gui.Scripting.ScriptExecutionHandler(EhScriptExecution) };
            if (Current.Gui.ShowDialog(args, "New instance script"))
            {
                string errors = null;
                do
                {
                    errors = null;
                    // store the script somewhere m_Table.TableScript = (TableScript)args[0];
                    var saveOptions = new Altaxo.Gui.SaveFileOptions
                    {
                        Title = "Save your script"
                    };
                    saveOptions.AddFilter("*.cs", "C# files (*.cs)");
                    saveOptions.AddFilter("*.*", "All files (*.*)");
                    saveOptions.FilterIndex = 0;
                    if (Current.Gui.ShowSaveFileDialog(saveOptions))
                    {
                        errors = SaveScriptText(saveOptions.FileName, script.ScriptText);
                        if (null != errors)
                        {
                            Current.Gui.ErrorMessageBox(errors);
                        }
                    }
                } while (null != errors);
            }
        }
 /// <summary>
 /// Creates a  script as a copy from another script with the option for modifying the txt.
 /// </summary>
 /// <param name="b">The script to copy from.</param>
 /// <param name="forModification">If true, the new script text can be modified.</param>
 public ProgramInstanceScript(ProgramInstanceScript b, bool forModification)
   : base(b, forModification)
 {
 }
 /// <summary>
 /// Creates a script as a copy from another script.
 /// </summary>
 /// <param name="b">The script to copy from.</param>
 public ProgramInstanceScript(ProgramInstanceScript b)
   : this(b, true)
 {
 }
예제 #4
0
 /// <summary>
 /// Creates a  script as a copy from another script with the option for modifying the txt.
 /// </summary>
 /// <param name="b">The script to copy from.</param>
 /// <param name="forModification">If true, the new script text can be modified.</param>
 public ProgramInstanceScript(ProgramInstanceScript b, bool forModification)
     : base(b, forModification)
 {
 }
예제 #5
0
 /// <summary>
 /// Creates a script as a copy from another script.
 /// </summary>
 /// <param name="b">The script to copy from.</param>
 public ProgramInstanceScript(ProgramInstanceScript b)
     : this(b, true)
 {
 }