Ejemplo n.º 1
0
        private bool InternalShowSaveFileDialog(SaveFileOptions options)
        {
            var dlg = new Microsoft.Win32.SaveFileDialog
            {
                Filter      = GetFilterString(options),
                FilterIndex = options.FilterIndex
            };

            //dlg.Multiselect = options.Multiselect;
            if (options.Title != null)
            {
                dlg.Title = options.Title;
            }
            if (options.InitialDirectory != null && System.IO.Directory.Exists(options.InitialDirectory))
            {
                dlg.InitialDirectory = options.InitialDirectory;
            }
            dlg.RestoreDirectory = options.RestoreDirectory;
            dlg.OverwritePrompt  = options.OverwritePrompt;
            dlg.AddExtension     = options.AddExtension;

            if (true == dlg.ShowDialog(TopmostModalWindow))
            {
                options.FileName  = dlg.FileName;
                options.FileNames = dlg.FileNames;
                return(true);
            }
            else
            {
                options.FileName  = null;
                options.FileNames = null;
                return(false);
            }
        }
Ejemplo n.º 2
0
        public override bool ShowSaveFileDialog(SaveFileOptions options)
        {
            var dlg = new SaveFileDialog();

            dlg.Filter      = GetFilterString(options);
            dlg.FilterIndex = options.FilterIndex;
            //dlg.Multiselect = options.Multiselect;
            if (options.Title != null)
            {
                dlg.Title = options.Title;
            }
            if (options.InitialDirectory != null)
            {
                dlg.InitialDirectory = options.InitialDirectory;
            }
            dlg.RestoreDirectory = options.RestoreDirectory;

            DialogResult r = dlg.ShowDialog(MainWindow);

            if (r == DialogResult.OK)
            {
                options.FileName  = dlg.FileName;
                options.FileNames = dlg.FileNames;
            }
            else
            {
                options.FileName  = null;
                options.FileNames = null;
            }

            return(r == DialogResult.OK);
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        public static void ShowFileExportDialog(GraphDocument doc, Altaxo.Graph.Gdi.GraphExportOptions graphExportOptions)
        {
            var saveOptions = new Altaxo.Gui.SaveFileOptions();
            var list        = GetFileFilterString(graphExportOptions.ImageFormat);

            foreach (var entry in list)
            {
                saveOptions.AddFilter(entry.Key, entry.Value);
            }
            saveOptions.FilterIndex      = 0;
            saveOptions.RestoreDirectory = true;

            if (Current.Gui.ShowSaveFileDialog(saveOptions))
            {
                using (Stream myStream = new FileStream(saveOptions.FileName, FileMode.Create, FileAccess.Write, FileShare.Read))
                {
                    new Gui.Graph.Graph3D.Common.D3D10BitmapExporter().ExportAsImageToStream(doc, graphExportOptions, myStream);
                    myStream.Close();
                } // end openfile ok
            }     // end dlgresult ok
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Asks the user for a file name for the current project, and then saves the project under the given name.
        /// </summary>
        public static void SaveProjectAs(Altaxo.AltaxoDocument projectToSave)
        {
            var dlg = new Altaxo.Gui.SaveFileOptions();

            string description = StringParser.Parse("${res:Altaxo.FileFilter.ProjectFiles})");

            dlg.AddFilter("*.axoprj", description);
            dlg.OverwritePrompt = true;
            dlg.AddExtension    = true;

            if (!Current.Gui.ShowSaveFileDialog(dlg))
            {
                return;
            }

            try
            {
                SaveProject(projectToSave, dlg.FileName);
            }
            catch (Exception ex)
            {
                Current.Gui.ErrorMessageBox(ex.Message, "Error during saving of the mini project");
            }
        }
Ejemplo n.º 6
0
 public override bool ShowSaveFileDialog(SaveFileOptions options)
 {
     return(Current.Dispatcher.InvokeIfRequired(InternalShowSaveFileDialog, options));
 }