private void OpenFromCommandLineArgs() //goes through all files until it can open one and redirects all other files to new instances with /OpenOrExit argument. That argument ensures that each new instance will close in case of error. { var filesToOpen = Medo.Application.Args.Current.GetValues(null); FileInfo iFile; for (int i = 0; i < filesToOpen.Length; ++i) { iFile = new FileInfo(filesToOpen[i]); try { Document = MagiWolDocument.Document.Open(iFile.FullName); Recent.Push(iFile.FullName); //send all other files to second instances for (int j = i + 1; j < filesToOpen.Length; ++j) { var jFile = new FileInfo(filesToOpen[j]); Process.Start(GetProcessStartInfo(@"""" + jFile.FullName + @""" /OpenOrExit")); Thread.Sleep(100 / Environment.ProcessorCount); } break; //i } catch (Exception ex) { Medo.MessageBox.ShowError(this, string.Format("Cannot open \"{0}\".\n\n{1}", iFile.Name, ex.Message)); if (Medo.Application.Args.Current.ContainsKey("OpenOrExit")) { System.Environment.Exit(1); } } } }
private void mnuOpen_Click(object sender, EventArgs e) { if (ProceedWithNewDocument()) { using (var dialog = new OpenFileDialog()) { dialog.AddExtension = true; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.DefaultExt = "magiwol"; dialog.Filter = "MagiWOL files (*.magiwol)|*.magiwol|All files (*.*)|*.*"; dialog.Multiselect = false; dialog.ShowReadOnly = false; if (dialog.ShowDialog(this) == DialogResult.OK) { try { Document = MagiWolDocument.Document.Open(dialog.FileName); Recent.Push(dialog.FileName); } catch (Exception ex) { var exFile = new FileInfo(dialog.FileName); Medo.MessageBox.ShowError(this, string.Format("Cannot open \"{0}\".\n\n{1}", exFile.Name, ex.Message)); } UpdateData(null); } } } }
public MainForm() { InitializeComponent(); this.Font = SystemFonts.MessageBoxFont; mnu.Renderer = new Helper.ToolStripBorderlessProfessionalRenderer(); Helper.ScaleToolstrip(mnu, mnuOpenRoot.DropDown, mnuSaveRoot.DropDown, mnxList); Medo.Windows.Forms.TaskbarProgress.DefaultOwner = this; Medo.Windows.Forms.TaskbarProgress.DoNotThrowNotImplementedException = true; if (Settings.IsInstalled == false) { mnuImport0.Visible = false; } this.Document = new MagiWolDocument.Document(); this.Recent = new Medo.Configuration.RecentFiles(); list.ListViewItemSorter = _listColumnSorter; this._listColumnSorter.SortColumn = 0; this._listColumnSorter.Order = SortOrder.Ascending; list.Sort(); Medo.Windows.Forms.State.SetupOnLoadAndClose(this, list); }
private void mnuNew_Click(object sender, EventArgs e) { if (ProceedWithNewDocument()) { Document = new MagiWolDocument.Document(); UpdateData(null); } }
void recentItem_Click(object sender, EventArgs e) { var item = (ToolStripMenuItem)sender; var recentItem = (Medo.Configuration.RecentFile)item.Tag; if (ProceedWithNewDocument()) { try { Document = MagiWolDocument.Document.Open(recentItem.FileName); Recent.Push(recentItem.FileName); } catch (Exception ex) { var exFile = new FileInfo(recentItem.FileName); Medo.MessageBox.ShowError(this, string.Format("Cannot open \"{0}\".\n\n{1}", exFile.Name, ex.Message)); } UpdateData(null); } }