예제 #1
0
        private void ux_tab_cms_NavigatorProperties_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            ContextMenuStrip cms = (ContextMenuStrip)tsmi.GetCurrentParent();
            TabControl tc = (TabControl)cms.SourceControl;

            NavigatorTabProperties newTabDialog = new NavigatorTabProperties(_pathSeparator, "_", _sharedUtils);
            newTabDialog.StartPosition = FormStartPosition.CenterParent;
            if (newTabDialog.ShowDialog(this) == DialogResult.OK)
            {
                string currentTabText = tc.SelectedTab.Text;
                if (tc != null &&
                    tc.Tag != null &&
                    tc.Tag.GetType() == typeof(Dictionary<string, TabPage>) &&
                    ((Dictionary<string, TabPage>)tc.Tag).ContainsKey(currentTabText))
                {
                    // Remove the current tab from the Show Tabs list (to make the list of unique names accurate
                    // when calling EnsureUniqueTabText method is called)...
                    ((Dictionary<string, TabPage>)tc.Tag).Remove(currentTabText);
                    // Enusre the tab's text/name is unique...
                    string uniqueTabText = EnsureUniqueTabText(tc, newTabDialog.TabText);
                    // Rename the tab's text, name, and treeview control's name...
                    tc.SelectedTab.Text = uniqueTabText;
                    tc.SelectedTab.Name = uniqueTabText;
                    tc.SelectedTab.Controls[currentTabText + "TreeView"].Name = uniqueTabText + "TreeView";
                    // Re-Add the new tab name to the list of tabs (in the Show Tab menu)...
                    ((Dictionary<string, TabPage>)tc.Tag).Add(uniqueTabText, tc.SelectedTab);
                    // Re-Add the new tab name to the collection of tabs associated with this Navigator Control...
                    ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems[currentTabText].Text = uniqueTabText;
                    ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems[currentTabText].Name = uniqueTabText;
                }
            }
        }
예제 #2
0
        private void ux_TabControl_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabControl tc = (TabControl)sender;
            ContextMenuStrip cms = tc.ContextMenuStrip;

            if (tc.SelectedIndex > -1)
            {
                if (tc.SelectedTab.Name == "ux_tabpageGroupListNavigatorNewTab")
                //if (tc.SelectedIndex == (tc.TabPages.Count - 1))
                {
                    int indexOfNewTab = tc.SelectedIndex;
                    NavigatorTabProperties newTabDialog = new NavigatorTabProperties(_pathSeparator, "_", _sharedUtils);
                    newTabDialog.StartPosition = FormStartPosition.CenterParent;
                    if (newTabDialog.ShowDialog(this) == DialogResult.OK)
                    {
                        string uniqueTabText = EnsureUniqueTabText(tc, newTabDialog.TabText);
                        TabPage tp = BuildTabPageAndTreeView(uniqueTabText, null);

                        if (tp != null)
                        {
                            tc.TabPages.Insert(indexOfNewTab, tp);
                            tc.SelectedIndex = indexOfNewTab;

                            // Create the new tool strip menu item and bind it to the click event handler...
                            ToolStripMenuItem tsmi = new ToolStripMenuItem(tp.Text, null, ux_tab_tsmi_NavigatorShowTabsItem_Click, tp.Text);
                            tsmi.Checked = true;
                            ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Add(tsmi);

                            // Add this new tabpage to the tabcontrol's dictionary list (for hide/show functionality)...
                            if (tc != null &&
                                tc.Tag != null &&
                                tc.Tag.GetType() == typeof(Dictionary<string, TabPage>) &&
                                !((Dictionary<string, TabPage>)tc.Tag).ContainsKey(tp.Name))
                            {
                                ((Dictionary<string, TabPage>)tc.Tag).Add(tp.Name, tp);
                            }

                            if (((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Count > 1)
                            {
                                // We have more than one tab in the ShowTabs list so enable some menu choices...
                                ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorHideTab"]).Enabled = true;
                                ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorDeleteTab"]).Enabled = true;
                                ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).Enabled = true;
                            }
                        }
                        else
                        {
                            tc.DeselectTab(indexOfNewTab);
                        }
                    }
                    else
                    {
                        tc.DeselectTab(indexOfNewTab);
                    }
                }
                else
                {
                    // Set focus on the treeview node for this treeview if it is not set...
                    foreach (Control ctrl in tc.SelectedTab.Controls)
                    {
                        if (ctrl.GetType() == typeof(TreeView))
                        {
                            TreeView tv = (TreeView)ctrl;
                            if (tv.SelectedNode == null)
                            {
                                RestoreActiveNode(tv);
                            }
                        }
                    }

                    // Now refresh the data views...
            //lastFullPath = "";
            //lastTabName = "";
                    SetAllUserSettings();
                    // Refresh the data view...
                    RefreshMainDGVData();
                    RefreshMainDGVFormatting();
                }
            }
        }
예제 #3
0
        private void ux_tab_cms_NavigatorNewTab_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem tsmi = (ToolStripMenuItem)sender;
            ContextMenuStrip cms = (ContextMenuStrip)tsmi.GetCurrentParent();
            TabControl tc = (TabControl)cms.SourceControl;

            NavigatorTabProperties newTabDialog = new NavigatorTabProperties(_pathSeparator, "_", _sharedUtils);
            newTabDialog.StartPosition = FormStartPosition.CenterParent;
            if (newTabDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Build the empty tabpage (includes an empty treeview)...
                string uniqueTabText = EnsureUniqueTabText(tc, newTabDialog.TabText);
                TabPage tpNew = BuildTabPageAndTreeView(uniqueTabText, null);

                if (tpNew != null)
                {
                    if (tc.SelectedIndex > -1)
                    {
                        tc.TabPages.Insert(tc.SelectedIndex, tpNew);
                    }
                    else
                    {
                        tc.TabPages.Insert(tc.TabPages.IndexOfKey("ux_tabpageGroupListNavigatorNewTab"), tpNew);
                    }
                    // Create the new tool strip menu item and bind it to the click event handler...
                    ToolStripMenuItem tsmiNew = new ToolStripMenuItem(tpNew.Text, null, ux_tab_tsmi_NavigatorShowTabsItem_Click, tpNew.Text);
                    tsmiNew.Checked = true;
                    ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Add(tsmiNew);

                    // Add this new tabpage to the tabcontrol's dictionary list (for hide/show functionality)...
                    if (tc != null &&
                        tc.Tag != null &&
                        tc.Tag.GetType() == typeof(Dictionary<string, TabPage>) &&
                        !((Dictionary<string, TabPage>)tc.Tag).ContainsKey(tpNew.Name))
                    {
                        ((Dictionary<string, TabPage>)tc.Tag).Add(tpNew.Name, tpNew);
                    }

                    // Update the Show/Hide tabs menu items...
                    if (((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).DropDownItems.Count > 1)
                    {
                        // We have more than one tab in the ShowTabs list so enable some menu choices...
                        ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorHideTab"]).Enabled = true;
                        ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorDeleteTab"]).Enabled = true;
                        ((ToolStripMenuItem)cms.Items["ux_tab_cms_NavigatorShowTab"]).Enabled = true;
                    }
                }
            }
        }
예제 #4
0
 private void ux_tab_cms_NavigatorProperties_Click(object sender, EventArgs e)
 {
     NavigatorTabProperties newTabDialog = new NavigatorTabProperties(_pathSeparator, "_", _sharedUtils);
             newTabDialog.StartPosition = FormStartPosition.CenterParent;
             if (newTabDialog.ShowDialog(this) == DialogResult.OK)
             {
                 _ux_NavigatorTabControl.SelectedTab.Text = newTabDialog.TabText;
             }
 }