/// <summary> /// Asks for a file name and exports the table data into that file as Ascii. /// </summary> /// <param name="dataTable">DataTable to export.</param> public static void ShowExportAsciiDialog(this DataTable dataTable) { var options = new Altaxo.Gui.SaveFileOptions(); options.AddFilter("*.csv;*.dat;*.txt", "Text files (*.csv;*.dat;*.txt)"); options.AddFilter("*.*", "All files (*.*)"); options.FilterIndex = 0; options.RestoreDirectory = true; if (Current.Gui.ShowSaveFileDialog(options)) { using (Stream myStream = new FileStream(options.FileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { try { Altaxo.Serialization.Ascii.AsciiExporter.ExportAscii(myStream, dataTable, '\t'); } catch (Exception ex) { Current.Gui.ErrorMessageBox("There was an error during ascii export, details follow:\n" + ex.ToString()); } finally { myStream.Close(); } } } }
/// <summary> /// Shows the SaveAs dialog and then saves the worksheet (data table and the corresponding layout, including scripts) into a xml file. /// </summary> /// <param name="worksheet">The worksheet to save.</param> /// <param name="saveAsTemplate">If true, the data are not saved, but only the layout of the worksheet (columns, property columns, scripts). If false, everything including the data is saved.</param> public static void ShowSaveAsDialog(this WorksheetLayout worksheet, bool saveAsTemplate) { var options = new Altaxo.Gui.SaveFileOptions(); options.AddFilter("*.axowks", "Altaxo worksheet files (*.axowks)"); options.AddFilter("*.*", "All files (*.*)"); options.FilterIndex = 0; options.RestoreDirectory = true; if (Current.Gui.ShowSaveFileDialog(options)) { using (Stream myStream = new System.IO.FileStream(options.FileName, FileMode.Create, FileAccess.Write, FileShare.Read)) { Save(worksheet, myStream, saveAsTemplate); myStream.Close(); } } }
public static void ShowFileExportDialog(this GraphDocumentBase doc, 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.ReadWrite, FileShare.Read)) // we need FileAccess.ReadWrite when exporting to EMF/WMF format { var exporter = Current.ProjectService.GetProjectItemImageExporter(doc); exporter?.ExportAsImageToStream(doc, graphExportOptions, myStream); myStream.Close(); } // end openfile ok } // end dlgresult ok }
public override void Run() { Altaxo.Scripting.IScriptText script = null; // or load it from somewhere if (script == null) script = new Altaxo.Scripting.ProgramInstanceScript(); var options = new Altaxo.Gui.OpenFileOptions(); options.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 scripttext; string err = OpenScriptText(options.FileName, out scripttext); if (null != err) Current.Gui.ErrorMessageBox(err); else script.ScriptText = scripttext; } object[] args = new object[] { script, new Altaxo.Gui.Scripting.ScriptExecutionHandler(this.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(); saveOptions.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> /// 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"); } }
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 }