private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { string file = openFileDialog1.FileName; InternalOpenFile(file); MRUListConfigurationSection mruList = cfg.GetMRUList(); if (!mruList.Contains(file)) { if (mruList.Instances.Count >= 15) { mruList.RemoveAt(14); } mruList.InsertAt(0, file); ToolStripMenuItem tsi = new ToolStripMenuItem(file, null, new EventHandler(RecentFiles_Click)); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } else { mruList.Remove(file); mruList.InsertAt(0, file); ToolStripMenuItem tsi = GetRecentMenuItem(file); recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } } }
private void AppendToMRU(string filename) { MRUListConfigurationSection mruList = cfg.GetMRUList(); if (!mruList.Contains(filename)) { if (mruList.Instances.Count >= 15) { mruList.RemoveAt(14); } mruList.InsertAt(0, filename); ToolStripMenuItem tsi = new ToolStripMenuItem(filename, null, new EventHandler(RecentFiles_Click)); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } else { mruList.Remove(filename); mruList.InsertAt(0, filename); ToolStripMenuItem tsi = GetRecentMenuItem(filename); recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } }
internal void InternalOpenFile(string fileToLoad) { if (string.IsNullOrWhiteSpace(fileToLoad)) { return; } if (this.WindowState != FormWindowState.Normal) { this.WindowState = FormWindowState.Normal; } this.BringToFront(); var tab = FindTabByPath(fileToLoad); if (tab != null) { tabControl1.SelectedTab = tab; SetupActiveTab(); return; } EditorTabPage etb = new EditorTabPage(); etb.LoadFile(fileToLoad); etb.Editor.DragEnter += new DragEventHandler(tabControl1_DragEnter); etb.Editor.DragDrop += new DragEventHandler(tabControl1_DragDrop); etb.OnEditorTextChanged += new EventHandler(etb_TextChanged); etb.OnEditorTabFilenameChanged += new EventHandler(TabControl_TabCaptionUpdate); etb.OnEditorTabStateChanged += new EventHandler(TabControl_TabCaptionUpdate); tabControl1.TabPages.Add(etb); etb.Show(); tabControl1.SelectedTab = etb; etb.Update(); MRUListConfigurationSection mruList = cfg.GetMRUList(); if (!mruList.Contains(fileToLoad)) { if (mruList.Instances.Count >= 15) { mruList.RemoveAt(14); } mruList.InsertAt(0, fileToLoad); ToolStripMenuItem tsi = new ToolStripMenuItem(fileToLoad, null, new EventHandler(RecentFiles_Click)); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } else { mruList.Remove(fileToLoad); mruList.InsertAt(0, fileToLoad); ToolStripMenuItem tsi = GetRecentMenuItem(fileToLoad); recentFilesToolStripMenuItem.DropDown.Items.Remove(tsi); recentFilesToolStripMenuItem.DropDown.Items.Insert(0, tsi); } }