void TextFileToolStripMenuItem_Click(object sender, EventArgs e) { DefaultExtensions.TXTEditor e2 = new NotepadX.DefaultExtensions.TXTEditor().Create("") as DefaultExtensions.TXTEditor; AddForm(e2, DockState.Document); }
public void ProcessParameters(object sender, string[] args) { if (args.Length > 1) { ITextEditor e = null; try { e = IExtendFramework.Text.FileExtensionManager.OpenDocument(args[1]); } catch (IExtendFramework.Text.InvalidFileTypeException) { if (MessageBox.Show("No editor registered for file extension '" + System.IO.Path.GetExtension(args[1]) + "'. Open as a text file?", "Notepad X", MessageBoxButtons.YesNo, MessageBoxIcon.None) == DialogResult.Yes) { DefaultExtensions.TXTEditor ed = new NotepadX.DefaultExtensions.TXTEditor(); ed.Open(args[1]); AddForm(ed as DockContent, DockState.Document); } } catch (Exception ex) { MessageBox.Show("Cannot open file '" + args[1] + "'!\n" + ex.ToString()); } if (e != null) AddForm(e as DockContent, DockState.Document); } this.BringToFront(); }
void OpenToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = FileFilterSettings.ToFilter(); if (ofd.ShowDialog() == DialogResult.OK) { ITextEditor e2 = null; try { e2 = IExtendFramework.Text.FileExtensionManager.OpenDocument(ofd.FileName); } catch (IExtendFramework.Text.InvalidFileTypeException) { if (MessageBox.Show("No editor registered for file extension '" + System.IO.Path.GetExtension(ofd.FileName) + "'. Open as a text file?", "Notepad X", MessageBoxButtons.YesNo, MessageBoxIcon.None) == DialogResult.Yes) { DefaultExtensions.TXTEditor ed = new NotepadX.DefaultExtensions.TXTEditor(); ed.Open(ofd.FileName); AddForm(ed as DockContent, DockState.Document); } } catch (Exception ex) { MessageBox.Show("Cannot open file '" + ofd.FileName + "!\n" + ex.ToString()); } if (e2 != null) { FileFilterSettings.AddAHit(e2.Extension); AddForm(e2 as WeifenLuo.WinFormsUI.Docking.DockContent, DockState.Document); } } }