コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
 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);
             }
         }
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 private void mnuNew_Click(object sender, EventArgs e)
 {
     if (ProceedWithNewDocument())
     {
         Document = new MagiWolDocument.Document();
         UpdateData(null);
     }
 }
コード例 #5
0
        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);
            }
        }