/****************************** * Section that allows for Tab renaming ******************************/ private void renameTabToolStripMenuItem_Click(object sender, EventArgs e) { RenameForm rename = new RenameForm(); rename.ShowDialog(this); Classes.LogTabPage SelectedFolder = GetSelectedFolder(); Classes.LogTabPage SelectedTabPage = GetSelectedTabPage(); if (SelectedFolder != null) { if (TabControlParent.GetTabRect(TabControlParent.SelectedIndex).Contains(lastClickedPoint)) { SelectedTabPage = SelectedFolder; } } if (rename.DialogResult == DialogResult.OK) { if (SelectedTabPage.Tag.ToString() == "Folder" && !CheckForExistingTabName(rename.RenameTextBox.Text)) { SelectedTabPage.Name = rename.RenameTextBox.Text; } else if (SelectedTabPage.Tag.ToString() == "Folder" && CheckForExistingTabName(rename.RenameTextBox.Text)) { MessageBox.Show("Folder Name Already Exists."); rename.Hide(); return; } SelectedTabPage.Text = rename.RenameTextBox.Text; SelectedTabPage.Update(); } else { rename.Hide(); } }
/************************* * Handles the Tab menu item selections ***************************/ private void TabContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { Classes.LogTabPage SelectedFolder = GetSelectedFolder(); Classes.LogTabPage SelectedTabPage = GetSelectedTabPage(); if (SelectedFolder != null) { if (TabControlParent.GetTabRect(TabControlParent.SelectedIndex).Contains(lastClickedPoint)) { SelectedTabPage = SelectedFolder; } } ToolStripItem clickedItem = e.ClickedItem; if (e.ClickedItem.Name == "TabToolStripMenuItem") { RenameForm rename = new RenameForm(); rename.ShowDialog(this); if (rename.DialogResult == DialogResult.OK) { SelectedTabPage.Text = rename.RenameTextBox.Text; SelectedTabPage.Update(); } else { rename.Hide(); } } else if (e.ClickedItem.Name == "moveToFolderToolStripMenuItem") { MoveToFolderForm MoveToForm = new MoveToFolderForm(); string parentFolderName = SelectedTabPage.Parent.Name; for (int ix = 0; ix < TabControlParent.TabCount; ++ix) { if (TabControlParent.TabPages[ix].Tag.ToString() == "Folder") { MoveToForm.FolderListBox.Items.Add(Text = TabControlParent.TabPages[ix].Text); } } MoveToForm.ShowDialog(this); if (MoveToForm.DialogResult == DialogResult.OK) { try { string selection = MoveToForm.FolderListBox.SelectedItem.ToString(); if (selection.ToString() == "No Folder") { TabControlParent.TabPages.Add(SelectedTabPage); } TabPage folder = GetFolderByName(selection); TabControl subTabPageControl = folder.Controls.Find("SubTabControl", true).FirstOrDefault() as TabControl; subTabPageControl.TabPages.Add(SelectedTabPage); } catch (NullReferenceException) { } //No folder selected do nothing } } else if (e.ClickedItem.Name == "deleteToolStripMenuItem") { /*if (SelectedTabPage.IsFolder) * { * * TabControl subTabPageControl = SelectedTabPage.Controls.Find("SubTabControl", true).FirstOrDefault() as TabControl; * * }*/ Console.WriteLine(SelectedTabPage.Name); TabControl tabControl = SelectedTabPage.Parent as TabControl; tabControl.TabPages.Remove(SelectedTabPage); } }