/// ------------------------------------------------------------------------------------ /// <summary> /// Handle calling the configure menu's update handler. /// </summary> /// <param name="cfgMenuItem"></param> /// ------------------------------------------------------------------------------------ internal void HandleConfigureMenuPopup(ButtonItem cfgMenuItem) { if (cfgMenuItem == null) { return; } // Call the configure menu's update handler. If there isn't one and it // doesn't have a receiver, then disable it. if (!(cfgMenuItem.Tag is TagHelper)) { return; } string configMessage = ((TagHelper)cfgMenuItem.Tag).Message; if (configMessage == null) { return; } SBTabProperties tabProps = Properties; if (!m_mediator.SendMessage("Update" + configMessage, tabProps)) { cfgMenuItem.Enabled = m_mediator.HasReceiver(configMessage); } else { cfgMenuItem.Enabled = tabProps.ConfigureMenuEnabled; cfgMenuItem.Visible = tabProps.ConfigureMenuVisible; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Tells the side bar adapter to setup it's menus so they show up on the application's /// view menu. This method should be called after all the tabs and tab items have been /// created. /// </summary> /// <param name="menuAdapter">Menu adapter used by the application.</param> /// <param name="insertBeforeItem">Name of the menu item before which the sidebar /// menus will be added.</param> /// ------------------------------------------------------------------------------------ public void SetupViewMenuForSideBarTabs(ITMAdapter adapter, string insertBeforeItem) { Debug.Assert(adapter != null); adapter.MessageMediator.AddColleague(this); foreach (SideBarTab tab in m_navPane.Items) { // Add the menu for the view tab. TMItemProperties props = tab.MenuItemProperties; props.Message = "SideBarViewTabMenuHandler"; adapter.AddMenuItem(props, null, insertBeforeItem); // Add menus for the view tab items. foreach (TMItemProperties itemProps in tab.SubMenuItemProperties) { itemProps.Text = itemProps.Text.Replace(Environment.NewLine, " "); itemProps.Message = "SideBarViewTabItemMenuHandler"; adapter.AddMenuItem(itemProps, tab.MenuItemProperties.Name, null); } // Add the menu item for the view tab's configure menu. SBTabProperties tabProps = tab.Properties; props = new TMItemProperties(); props.Name = tab.Name + "Config"; props.Text = tabProps.ConfigureMenuText; props.Message = tabProps.ConfigureMessage; props.BeginGroup = true; props.Tag = tabProps; adapter.AddMenuItem(props, tab.MenuItemProperties.Name, null); } }
public void AddTab_basic() { // Add a tab SBTabProperties tabProps = new SBTabProperties(); tabProps.Name = "tabname"; tabProps.Text = "tabtext"; tabProps.Message = "SideBarTabClicked"; tabProps.ConfigureMessage = "SideBarConfigure"; tabProps.ConfigureMenuText = "cfgText"; tabProps.InfoBarButtonToolTipFormat = "fmttooltip"; m_sibAdapter.AddTab(tabProps); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void InitMenuAndInfoBarButton(SBTabProperties tabProps) { m_infoBarButton = new PanelEx(); m_infoBarButton.Name = Name; m_infoBarButton.Style.BackColor1.Alpha = 255; m_infoBarButton.Style.BackColor2.Alpha = 255; m_infoBarButton.Style.BackgroundImageAlpha = 255; m_infoBarButton.Style.BackgroundImagePosition = eBackgroundImagePosition.Center; m_infoBarButton.StyleMouseOver.BackgroundImageAlpha = 255; m_infoBarButton.StyleMouseOver.BorderColor.Color = SystemColors.ControlDarkDark; m_infoBarButton.StyleMouseOver.BorderWidth = 1; m_infoBarButton.StyleMouseOver.Border = eBorderType.Raised; m_infoBarButton.StyleMouseDown.BackgroundImageAlpha = 255; m_infoBarButton.StyleMouseDown.BorderColor.Color = SystemColors.ControlDarkDark; m_infoBarButton.StyleMouseDown.BorderWidth = 1; m_infoBarButton.StyleMouseDown.Border = eBorderType.Sunken; m_infoBarButton.Anchor = AnchorStyles.Right; m_infoBarButton.Enabled = Enabled; m_infoBarButton.Click += new EventHandler(m_infoBarButton_Click); m_infoBarButton.Tag = this; UpdateInfoBarButtonImage(); m_menu = new ButtonItem(Name, Text); m_menu.Enabled = Enabled; m_menu.PopupType = ePopupType.Menu; m_menu.PopupOpen += new DotNetBarManager.PopupOpenEventHandler(Menu_PopupOpen); m_menu.PopupClose += new EventHandler(Menu_PopupClose); // When m_menu pops-up as a result of clicking on an info. bar button, then this // header button is visible. However, when m_menu pops-up from the View menu, // this header button is hidden. m_hdrMenuItem = new HeaderButton(Name, Text); m_hdrMenuItem.ImageIndex = -1; m_hdrMenuItem.Visible = false; m_menu.SubItems.Add(m_hdrMenuItem); // Create the configure menu item. This will be made visible when shown from the // View menu but not when menu is popped-up from the info. bar button. m_cfgMenuItem = new ButtonItem(Name + "Config", tabProps.ConfigureMenuText); m_cfgMenuItem.Tag = new TagHelper(false, tabProps.ConfigureMessage); m_cfgMenuItem.Visible = true; m_cfgMenuItem.BeginGroup = true; m_cfgMenuItem.Click += new EventHandler(HandleMenuItemClick); m_menu.SubItems.Add(m_cfgMenuItem); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add category tab to sidebar /// </summary> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) { return; } m_tabProps.Add(tabProps); ToolStrip toolStrip = new ToolStrip(); toolStrip.Name = tabProps.Name + "_toolstrip"; toolStrip.Dock = DockStyle.Fill; toolStrip.GripStyle = ToolStripGripStyle.Hidden; toolStrip.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow; toolStrip.Location = new System.Drawing.Point(0, 0); toolStrip.Padding = new Padding(0); toolStrip.Margin = new Padding(0, 0, 0, 0); toolStrip.GripMargin = new Padding(0); toolStrip.Paint += ItemAreaPaintDelegate; m_sidebarItemAreas.Add(toolStrip); m_sideBar.Panel1.Controls.Add(toolStrip); // Add a button to the category toolstrip ToolStripButton button = new ToolStripButton(); button.Name = tabProps.Name + "_category_button"; button.Overflow = ToolStripItemOverflow.AsNeeded; button.Text = tabProps.Text; button.TextImageRelation = TextImageRelation.ImageBeforeText; button.Click += HandleTabClick; button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; button.Padding = new Padding(5); button.Margin = new Padding(-3); button.ImageScaling = ToolStripItemImageScaling.SizeToFit; button.Image = m_tabImageList.Images[tabProps.ImageIndex]; button.ImageAlign = ContentAlignment.MiddleLeft; m_categoryStrip.Items.Add(button); PositionInfoBarButtons(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add category tab to sidebar /// </summary> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) { return; } m_tabProps.Add(tabProps); Tab tab = new Tab(tabProps.Name); tab.Text = tabProps.Text; if (m_tabImageList != null) { tab.Icon = m_tabImageList.Images[tabProps.ImageIndex]; } tab.Enabled = tabProps.Enabled; m_sidePane.AddTab(tab); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="tabProps"></param> /// <param name="infoBarButton"></param> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) { return; } SideBarTab tab = new SideBarTab(this, m_mediator, tabProps); tab.ItemImageListSmall = ItemImageListSmall; tab.ItemImageListLarge = ItemImageListLarge; tab.InfoBarButton.MouseEnter += new EventHandler(InfoBarButton_MouseEnter); m_dnbMngr.ContextMenus.Add(tab.Menu); m_infoBar.Controls.Add(tab.InfoBarButton); PositionInfoBarButtons(); // Add the new tab's configure menu item to the side bar's context menu. ButtonItem tabCfgMenuItem = (ButtonItem)tab.ConfigureMenuItem.Copy(); tabCfgMenuItem.Visible = true; m_contextMenu.SubItems.Add(tabCfgMenuItem); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a SideBarTab /// </summary> /// <param name="owningAdapter"></param> /// <param name="mediator"></param> /// <param name="tabProps"></param> /// ------------------------------------------------------------------------------------ internal SideBarTab(SIBAdapter owningAdapter, Mediator mediator, SBTabProperties tabProps) : base(tabProps.Name, tabProps.Text) { m_owningAdapter = owningAdapter; m_mediator = mediator; m_message = tabProps.Message; m_tag = tabProps.Tag; m_infoBarButtonToolTipFormat = tabProps.InfoBarButtonToolTipFormat; ImageIndex = tabProps.ImageIndex; OptionGroup = "FwNavPanelTabs"; ButtonStyle = eButtonStyle.ImageAndText; ThemeAware = owningAdapter.m_dnbMngr.IsThemeActive; Enabled = tabProps.Enabled; owningAdapter.m_navPane.Items.Add(this); // This has to be done after being added to the pane's item collection. // Add the panel (above the tab) that goes with the tab. This is a control // above the stack of buttons. NavigationPanePanel panel = new NavigationPanePanel(); panel.Name = tabProps.Name; panel.ParentItem = this; panel.Dock = DockStyle.Fill; owningAdapter.m_navPane.Controls.Add(panel); // Add to the panel that holds the DNB toolbar that holds the tab items. m_itemPanel = new ItemPanel(Name, owningAdapter); m_itemPanel.ImageListSmall = m_smallImageList; m_itemPanel.ImageListLarge = m_largeImageList; m_itemPanel.SmallIconMode = tabProps.SmallIconMode; panel.Controls.Add(m_itemPanel); InitMenuAndInfoBarButton(tabProps); Tooltip = Text; }
/// <summary> /// Setup the sidebar/info. bar adapter. - from TeMainWnd.cs /// </summary> private void SetupSideBarInfoBar() { // Null when running tests. if (SIBAdapter == null) { return; } SIBAdapter.ItemImageListLarge = TeResourceHelper.TeSideBarLargeImages; SIBAdapter.ItemImageListSmall = TeResourceHelper.TeSideBarSmallImages; SIBAdapter.TabImageList = TeResourceHelper.TeSideBarTabImages; SIBAdapter.LargeIconModeImageIndex = 4; SIBAdapter.SmallIconModeImageIndex = 5; string cfgMsg = "SideBarConfigure"; string cfgText = TeResourceHelper.GetResourceString("kstidSideBarConfigureItem"); string fmttooltip = TeResourceHelper.GetResourceString("kstidInfoBarButtonTooltipFormat"); // Add the scripture tab. SBTabProperties tabProps = new SBTabProperties(); tabProps.Name = kScrSBTabName; tabProps.Text = TeResourceHelper.GetResourceString("kstidScriptureTask"); tabProps.Message = "SideBarTabClicked"; tabProps.ConfigureMessage = cfgMsg; tabProps.ConfigureMenuText = cfgText; tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 0; SIBAdapter.AddTab(tabProps); // Add the back translation tab. tabProps = new SBTabProperties(); tabProps.Name = kBTSBTabName; tabProps.Text = TeResourceHelper.GetResourceString("kstidBackTransTask"); tabProps.Message = "SideBarTabClicked"; tabProps.ConfigureMessage = cfgMsg; tabProps.ConfigureMenuText = cfgText; tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 1; SIBAdapter.AddTab(tabProps); // Add the checking tab. tabProps = new SBTabProperties(); tabProps.Name = kChkSBTabName; tabProps.Text = TeResourceHelper.GetResourceString("kstidCheckingTask"); tabProps.Message = "SideBarTabClicked"; tabProps.ConfigureMessage = cfgMsg; tabProps.ConfigureMenuText = cfgText; tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 2; SIBAdapter.AddTab(tabProps); // Add the publications tab. tabProps = new SBTabProperties(); tabProps.Name = kPubSBTabName; tabProps.Text = TeResourceHelper.GetResourceString("kstidPublicationsTask"); tabProps.Message = "SideBarTabClicked"; tabProps.ConfigureMessage = cfgMsg; tabProps.ConfigureMenuText = cfgText; tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.Enabled = false; tabProps.ImageIndex = 3; SIBAdapter.AddTab(tabProps); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="tabProps"></param> /// <param name="infoBarButton"></param> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) return; SideBarTab tab = new SideBarTab(this, m_mediator, tabProps); tab.ItemImageListSmall = ItemImageListSmall; tab.ItemImageListLarge = ItemImageListLarge; tab.InfoBarButton.MouseEnter += new EventHandler(InfoBarButton_MouseEnter); m_dnbMngr.ContextMenus.Add(tab.Menu); m_infoBar.Controls.Add(tab.InfoBarButton); PositionInfoBarButtons(); // Add the new tab's configure menu item to the side bar's context menu. ButtonItem tabCfgMenuItem = (ButtonItem)tab.ConfigureMenuItem.Copy(); tabCfgMenuItem.Visible = true; m_contextMenu.SubItems.Add(tabCfgMenuItem); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Setup the sidebar/info. bar adapter. /// </summary> /// ------------------------------------------------------------------------------------ private void SetupSideBarInfoBar() { // Null when running tests. if (SIBAdapter == null) return; SIBAdapter.ItemImageListLarge = TeResourceHelper.TeSideBarLargeImages; SIBAdapter.ItemImageListSmall = TeResourceHelper.TeSideBarSmallImages; SIBAdapter.TabImageList = TeResourceHelper.TeSideBarTabImages; SIBAdapter.LargeIconModeImageIndex = 4; SIBAdapter.SmallIconModeImageIndex = 5; string fmttooltip = TeResourceHelper.GetResourceString("kstidInfoBarButtonTooltipFormat"); // Add the views tab. SBTabProperties tabProps = new SBTabProperties(); tabProps.Name = kViewsSBTabInternalName; tabProps.Text = TeResourceHelper.GetResourceString("kstidViews"); tabProps.Message = "SideBarTabClicked"; tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 0; SIBAdapter.AddTab(tabProps); // Add the filters tab. tabProps = new SBTabProperties(); tabProps.Name = kstidFilterSBTabInternalName; tabProps.Text = TeResourceHelper.GetResourceString("kstidFilters"); tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 6; SIBAdapter.AddTab(tabProps); // Add the "No filter" button to the filters tab SBTabItemProperties itemProps = new SBTabItemProperties(this); itemProps.Name = kstidNoFilter; itemProps.Text = TeResourceHelper.GetResourceString(kstidNoFilter); itemProps.ImageIndex = (int)TeResourceHelper.SideBarIndices.NoFilter; itemProps.Tag = null; itemProps.Message = "ChangeFilter"; itemProps.ClickAlways = true; AddSideBarTabItem(kstidFilterSBTabInternalName, itemProps); // Add the sort tab. tabProps = new SBTabProperties(); tabProps.Name = kstidSortSBTabInternalName; tabProps.Text = TeResourceHelper.GetResourceString("kstidSort"); tabProps.InfoBarButtonToolTipFormat = fmttooltip; tabProps.ImageIndex = 7; SIBAdapter.AddTab(tabProps); // Add the "Reference" button to the sort methods tab itemProps = new SBTabItemProperties(this); // REVIEW: When we implement sort orders defined in the DB, we'll need to consider // whether we want to have one hard-coded sort-order like this or not. itemProps.Name = kstidReferenceSort; itemProps.Text = TeResourceHelper.GetResourceString("kstidReferenceSort"); itemProps.ImageIndex = (int)TeResourceHelper.SideBarIndices.SortMethod; itemProps.Tag = null; itemProps.Message = "ChangeSortMethod"; AddSideBarTabItem(kstidSortSBTabInternalName, itemProps); // Set current tab and item - No filter by default SIBAdapter.SetCurrentTabItem(kstidFilterSBTabInternalName, kstidNoFilter, true); SIBAdapter.SetCurrentTabItem(kstidSortSBTabInternalName, kstidReferenceSort, true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add category tab to sidebar /// </summary> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) return; m_tabProps.Add(tabProps); Tab tab = new Tab(tabProps.Name); tab.Text = tabProps.Text; if (m_tabImageList != null) tab.Icon = m_tabImageList.Images[tabProps.ImageIndex]; tab.Enabled = tabProps.Enabled; m_sidePane.AddTab(tab); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Add category tab to sidebar /// </summary> /// ------------------------------------------------------------------------------------ public void AddTab(SBTabProperties tabProps) { if (tabProps == null) return; m_tabProps.Add(tabProps); ToolStrip toolStrip = new ToolStrip(); toolStrip.Name = tabProps.Name + "_toolstrip"; toolStrip.Dock = DockStyle.Fill; toolStrip.GripStyle = ToolStripGripStyle.Hidden; toolStrip.LayoutStyle = ToolStripLayoutStyle.VerticalStackWithOverflow; toolStrip.Location = new System.Drawing.Point(0, 0); toolStrip.Padding = new Padding(0); toolStrip.Margin = new Padding(0,0,0,0); toolStrip.GripMargin = new Padding(0); toolStrip.Paint += ItemAreaPaintDelegate; m_sidebarItemAreas.Add(toolStrip); m_sideBar.Panel1.Controls.Add(toolStrip); // Add a button to the category toolstrip ToolStripButton button = new ToolStripButton(); button.Name = tabProps.Name + "_category_button"; button.Overflow = ToolStripItemOverflow.AsNeeded; button.Text = tabProps.Text; button.TextImageRelation = TextImageRelation.ImageBeforeText; button.Click += HandleTabClick; button.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; button.Padding = new Padding(5); button.Margin = new Padding(-3); button.ImageScaling = ToolStripItemImageScaling.SizeToFit; button.Image = m_tabImageList.Images[tabProps.ImageIndex]; button.ImageAlign = ContentAlignment.MiddleLeft; m_categoryStrip.Items.Add(button); PositionInfoBarButtons(); }