/// <summary> /// This shows a dialog where the user can add a referenced assembly temporarily. /// </summary> public static void ShowAddTemporaryAssemblyDialog() { OpenFileOptions options = new OpenFileOptions(); options.Title = "Add a temporary assembly to be referenced"; options.AddFilter("*.dll", "Libary files (*.dll)"); options.AddFilter("*.*", "All files (*.*)"); options.FilterIndex = 0; options.Multiselect = true; options.InitialDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); if (Current.Gui.ShowOpenFileDialog(options)) { StringBuilder stb = new StringBuilder(); // try to create an assembly out of the filename(s) foreach (string filename in options.FileNames) { Assembly asm = null; try { asm = Assembly.LoadFrom(filename); } catch (Exception ex) { stb.AppendFormat("File {0} could not be loaded: {1}", filename, ex.Message); continue; } ReferencedAssemblies.AddTemporaryUserAssembly(asm); } if (stb.Length != 0) Current.Gui.ErrorMessageBox(stb.ToString()); } }
public override void Execute(object parameter) { var dlg = new OpenFileOptions(); dlg.AddFilter("*.axowks;*.axogrp", "Worksheet or graph files(*.axowks; *.axogrp"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.RestoreDirectory = true; dlg.FilterIndex = 0; dlg.Multiselect = true; if (Current.Gui.ShowOpenFileDialog(dlg)) { var failedToOpen = new List <string>(); foreach (var fileName in dlg.FileNames) { if (!Current.IProjectService.TryOpenProjectDocumentFile(fileName, forceTrialRegardlessOfExtension: true)) { failedToOpen.Add(fileName); } } if (failedToOpen.Count > 0) { var stb = new System.Text.StringBuilder(); stb.AppendFormat("The following {0} of {1} file(s) could not be opened:\r\n", failedToOpen.Count, dlg.FileNames.Length); foreach (var fileName in failedToOpen) { stb.AppendFormat("{0}\r\n", fileName); } Current.Gui.ErrorMessageBox(stb.ToString(), "Error opening file(s)"); } } }
public static void ImportShowDialog() { var options = new MarkdownImportOptions(); var dlg = new OpenFileOptions(); dlg.AddFilter("*.md", "Markdown files (*.md)"); dlg.AddFilter("*.txt", "Text files (*.txt)"); dlg.AddFilter("*.*", "All files (*.*)"); if (true == Current.Gui.ShowOpenFileDialog(dlg)) { try { var errors = options.Import(dlg.FileName); if (!string.IsNullOrEmpty(errors)) { Current.Gui.ErrorMessageBox(errors, "Error(s) during import"); } } catch (Exception ex) { Current.Gui.ErrorMessageBox(string.Format("{0}\r\nDetails:\r\n{1}", ex.Message, ex), "Error during import"); } } }
/// <summary> /// Gets the template file by showing a open file dialog. /// </summary> /// <returns></returns> public static (bool dialogResult, string templateFileName) ShowGetTemplateFileDialog(string oldFileName = null) { var dlg = new OpenFileOptions(); dlg.AddFilter("*.docx", "Docx files (*.docx)"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.Title = "Select a .docx file used as style template"; if (null != oldFileName) { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(oldFileName); dlg.FileName = oldFileName; } var dialogResult = Current.Gui.ShowOpenFileDialog(dlg); return(dialogResult, dlg.FileName); }
/// <summary> /// This shows a dialog where the user can add a referenced assembly temporarily. /// </summary> public static void ShowAddTemporaryAssemblyDialog() { var options = new OpenFileOptions { Title = "Add a temporary assembly to be referenced" }; options.AddFilter("*.dll", "Libary files (*.dll)"); options.AddFilter("*.*", "All files (*.*)"); options.FilterIndex = 0; options.Multiselect = true; options.InitialDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); if (Current.Gui.ShowOpenFileDialog(options)) { var stb = new StringBuilder(); // try to create an assembly out of the filename(s) foreach (string filename in options.FileNames) { Assembly asm = null; try { asm = Assembly.LoadFrom(filename); } catch (Exception ex) { stb.AppendFormat("File {0} could not be loaded: {1}", filename, ex.Message); continue; } ReferencedAssemblies.AddTemporaryUserAssembly(asm); } if (stb.Length != 0) { Current.Gui.ErrorMessageBox(stb.ToString()); } } }
private void EhLoadFromFile(object sender, EventArgs e) { var options = new OpenFileOptions(); options.AddFilter("*.*", "All files (*.*"); options.FilterIndex = 0; if (Current.Gui.ShowOpenFileDialog(options)) { var img = ImageProxy.FromFile(options.FileName); if (img.IsValid) { TextureManager.UserTextures.Add(img); AddImage(img); TextureImage = img; } } }
void EhLoadFromFile(object sender, EventArgs e) { OpenFileOptions options = new OpenFileOptions(); options.AddFilter("*.*", "All files (*.*"); options.FilterIndex = 0; if (Current.Gui.ShowOpenFileDialog(options)) { ImageProxy img = ImageProxy.FromFile(options.FileName); if (img.IsValid) { TextureManager.UserTextures.Add(img); SetDataSource(img); OnSelectedItemChanged(EventArgs.Empty); OnSelectedValueChanged(EventArgs.Empty); OnSelectionChangeCommitted(EventArgs.Empty); } } }
void EhLoadFromFile(object sender, EventArgs e) { OpenFileOptions options = new OpenFileOptions(); options.AddFilter("*.*", "All files (*.*"); options.FilterIndex = 0; if (Current.Gui.ShowOpenFileDialog(options)) { ImageProxy img = ImageProxy.FromFile(options.FileName); if (img.IsValid) { TextureManager.UserTextures.Add(img); SetDataSource(img); OnSelectedItemChanged(EventArgs.Empty); OnSelectedValueChanged(EventArgs.Empty); OnSelectionChangeCommitted(EventArgs.Empty); } } }
public bool EhScriptExecution(IScriptText script, IProgressReporter reporter) { if (script is FileImportScript fileImportScript) { var dlg = new OpenFileOptions(); foreach (var tuple in fileImportScript.FileFilters) { dlg.AddFilter(tuple.Filter, tuple.Description); } dlg.Multiselect = fileImportScript.CanAcceptMultipleFiles; if (Current.Gui.ShowOpenFileDialog(dlg)) { _table.DataSource = new FileImportScriptDataSource(dlg.FileNames, fileImportScript); return(fileImportScript.ExecuteWithSuspendedNotifications(_table, dlg.FileNames, reporter)); } } return(false); }
private void EhLoadFromFile(object sender, EventArgs e) { OpenFileOptions options = new OpenFileOptions(); options.AddFilter("*.*", "All files (*.*"); options.FilterIndex = 0; if (Current.Gui.ShowOpenFileDialog(options)) { ImageProxy img = ImageProxy.FromFile(options.FileName); if (img.IsValid) { TextureManager.UserTextures.Add(img); AddImage(img); TextureImage = img; } } }