/// <summary> /// Removes an item from the list /// </summary> /// <param name="value">The button to remove</param> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="ArgumentNullExceptions">Raised when the button argument is null</exception> internal void Remove(NaviButton value) { if (value == null) { throw new ArgumentNullException(); } base.List.Remove(value); }
/// <summary> /// Changes the active button to the button on which this event occured /// </summary> /// <param name="sender">The button on which this event occured</param> /// <param name="e">Additional info</param> void button_Click(object sender, EventArgs e) { NaviButton button = sender as NaviButton; if (button != null) { foreach (NaviBand band in bands) { if (band.Button == button) { SetActiveBand(band); return; } } } }
/// <summary> /// Adds the band button to the collection of controls /// </summary> /// <param name="band">The band</param> private void AddButton(NaviBand band) { if (band.Button == null) { NaviButton button = new NaviButton(); button.SmallImage = band.SmallImage; button.LargeImage = band.LargeImage; button.Text = band.Text; button.Click += new EventHandler(button_Click); band.Button = button; } if (!Controls.Contains(band.Button)) { Controls.Add(band.Button); } if (!buttons.Contains(band.Button)) { buttons.Add(band.Button); } }
/// <summary> /// Determines whether the list contains a specific value /// </summary> /// <param name="button">The button.</param> /// <returns>Returns true if the list contains the item; false otherwise</returns> public bool Contains(NaviButton button) { return(base.List.Contains(button)); }
/// <summary> /// Calculates the position of the buttons /// </summary> protected virtual void LayoutButtons() { int buttonCount = 0; // Gently lays out the position of the large buttons int flow = (splitterPosition + smallButtonRectangle.Height + 1) - splitterHeight; // 1px extra marge for the border of the control // The optionButtonWidth is the space reserved for the options button int compactFlow = ((visibleButtons - Bar.VisibleLargeButtons) * Bar.MinimizedButtonWidth) + 1; if (Bar.ShowMoreOptionsButton) { // Initializes the options button optionsButton.Small = true; optionsButton.Height = smallButtonRectangle.Height; optionsButton.Width = optionButtonWidth; optionsButton.Visible = true; compactFlow += optionButtonWidth; if (Bar.RightToLeft == RightToLeft.Yes) { optionsButton.Location = new Point(1, smallButtonRectangle.Top); } else { optionsButton.Location = new Point(Bar.Width - (optionButtonWidth + 1), smallButtonRectangle.Top); } } else { optionsButton.Visible = false; } // Order of bands can be different than ordering of the list of buttons foreach (NaviBand band in Bar.Bands) { if (band.Button == null) { continue; } NaviButton button = band.Button; if (button.Visible) { buttonCount++; // Require if ((Bar.ActiveBand != null) && (Bar.ActiveBand.Button == button) && (button.Active == false)) { button.Active = true; } // Regular 'hot' buttons which are part of the main Bar if (buttonCount <= Bar.VisibleLargeButtons) { button.Location = new Point(1, Bar.Height - flow); button.Height = Bar.ButtonHeight; button.Width = Bar.Width - 2; // extra space for border on both sides button.Small = false; flow -= Bar.ButtonHeight; } else { // Additional buttons presented at the bottom as small rectangles if (!Bar.Collapsed) { button.Small = true; button.Height = smallButtonRectangle.Height; button.Width = Bar.MinimizedButtonWidth; if (Bar.RightToLeft == RightToLeft.Yes) { button.Location = new Point(compactFlow - Bar.MinimizedButtonWidth, smallButtonRectangle.Top); } else { button.Location = new Point(Bar.Width - compactFlow, smallButtonRectangle.Top); } compactFlow -= Bar.MinimizedButtonWidth; } else { button.Location = new Point(0, 0); button.Size = new Size(0, 0); } } } } // Collapse button collapseButton.Visible = Bar.ShowCollapseButton && (!showNeverCollapse); collapseButton.Size = new Size(Bar.HeaderHeight, Bar.HeaderHeight - 3); if (Bar.RightToLeft == RightToLeft.Yes) { collapseButton.Location = new Point(2, 2); // (Bar.HeaderHeight / 2) + 3); } else { collapseButton.Location = new Point(Bar.Width - Bar.HeaderHeight - 1, 2); // (Bar.HeaderHeight / 2) + 3); } }