예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This will build a tooltip for a info. bar button that's made up of the title of
        /// the button's corresponding sidebar tab (i.e. task tab) and -- if the tab is the
        /// active sidebar tab -- the tab's current button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void infoButton_MouseHover(object sender, EventArgs e)
        {
            InformationBarButton button = sender as InformationBarButton;

            if (button == null || button.Tag == null)
            {
                return;
            }

            SideBarTab tab = button.Tag as SideBarTab;

            if (tab == null)
            {
                return;
            }

            if (tab == sideBarFw.ActiveTab)
            {
                button.TooltipText = String.Format(FrameworkStrings.ksInfoBarBtnToolTipFmt,
                                                   tab.Title, tab.Buttons[tab.IntSelection[0]].Text);
            }
            else
            {
                button.TooltipText = tab.Title;
            }
        }
예제 #2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Build information bar buttons based on the sideBar tabs.
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public void BuildInfoBarButtons()
        {
            if (m_mnuView == null || informationBar == null ||
                sideBarFw == null || sideBarFw.Tabs.Count == 0)
            {
                return;
            }

            // First, clear all the buttons from the info bar..
            informationBar.Buttons.Clear();

            foreach (SideBarTab tab in sideBarFw.Tabs)
            {
                // Add event handlers for adding and removing tab buttons
                tab.Buttons.AfterInsert +=
                    new SideBarButtonCollection.CollectionChange(tabButton_AddOrRemove);
                tab.Buttons.BeforeRemove +=
                    new SideBarButtonCollection.CollectionChange(tabButton_AddOrRemove);

                // Add a 'Button Click' event to each tab
                tab.ButtonClickEvent += new EventHandler(tabButton_Click);

                // Create an information button based on the tab and add it to the info bar
                InformationBarButton infoButton = new InformationBarButton();
                infoButton.Text      = tab.Title;
                infoButton.Tag       = tab;
                infoButton.ImageList = sideBarFw.ImageListSmall;
                informationBar.Buttons.Add(infoButton);
                infoButton.Click      += new EventHandler(infoButton_Click);
                infoButton.MouseHover += new EventHandler(infoButton_MouseHover);
            }
        }
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This will trap clicks on the info. bar buttons and build a context menu containing
        /// one item for each side bar button in the corresponding sidebar tab. It will also
        /// add a title item with the corresponding tab's title.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ------------------------------------------------------------------------------------
        private void infoButton_Click(object sender, EventArgs e)
        {
            InformationBarButton button = sender as InformationBarButton;

            if (button == null || button.Tag == null)
            {
                return;
            }

            SideBarTab tab = button.Tag as SideBarTab;

            if (tab == null)
            {
                return;
            }

            if (m_cmnuInfoBarButton == null)
            {
                m_cmnuInfoBarButton = new ContextMenu();
            }
            else
            {
                // Clear the menus items so that we start fresh the next time the
                // user clicks on the information bar button.
                foreach (MenuItem menuItem in m_cmnuInfoBarButton.MenuItems)
                {
                    MenuExtender.ClearMenuItem(menuItem);
                }

                m_cmnuInfoBarButton.MenuItems.Clear();
            }

            // Load the context menu
            m_cmnuInfoBarButton.MenuItems.Add(new LabelMenuItem(tab.Title));
            m_cmnuInfoBarButton.MenuItems.AddRange(BuildMenusForSideBarTab(tab));

            MenuExtender.AddContextMenu(m_cmnuInfoBarButton);

            // Popup the loaded ContextMenu just below the button.
            m_cmnuInfoBarButton.Show(button, new Point(0, button.Bottom));
        }