private void TabsEditors_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Middle) { EditorTab tab = tabsEditors.TabPages.Cast <EditorTab>().Where((t, i) => tabsEditors.GetTabRect(i).Contains(e.Location)).FirstOrDefault(); if (tab != null) { if (tab.Modified || tab.FileName == null) { DialogResult result = MessageBox.Show("This tab has unsaved changes. Would you like to save them before closing?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { saveToolStripMenuItem.PerformClick(); tabsEditors.TabPages.Remove(tab); } else if (result == DialogResult.No) { tabsEditors.TabPages.Remove(tab); } } else { tabsEditors.TabPages.Remove(tab); } } } }
private void newToolStripMenuItem_Click(object sender, EventArgs e) { EditorTab tab = new EditorTab(); tab.CodeBox.Text = Properties.Resources.DefaultScript; tab.Modified = false; tab.Text = "New Script"; tabsEditors.TabPages.Add(tab); tabsEditors.SelectedTab = tab; }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = "RBot Scripts (*.cs)|*.cs"; ofd.InitialDirectory = "Scripts"; if (ofd.ShowDialog() == DialogResult.OK) { string full = Path.GetFullPath(ofd.FileName); EditorTab tab = tabsEditors.TabPages.Cast <EditorTab>().Where(x => x.FileName == full).FirstOrDefault(); if (tab == null) { tab = new EditorTab(); tab.Load(full); tabsEditors.TabPages.Add(tab); } tabsEditors.SelectedTab = tab; } } }