HypernovaDesktop Components · docs
Binarymission
WinForms › Panel Bar › BinaryPanelBar

BinaryPanelBar

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.NavigationControls

An Outlook-style navigation pane: a stack of large section buttons – Mail, Calendar, Contacts – each showing its own page of controls above them, with overflow icons, a chevron menu and an optional collapse to a narrow rail.

public partial class BinaryPanelBar : UserControl

Inherits from / implements: UserControl

Remarks

What it is for

Use the bar down the side of a main window to switch between the sections of an application. Each section is a BinaryPanelBarButton; clicking it fills the area above the buttons with the section's BinaryPanelBarContainedPanel and puts its text in the header.

Key concepts

Appearance

XPThemeToEmulate picks a Windows XP palette (olive by default), or XPTheme.None for StartColor and EndColor. ItemColorRenderingStyle chooses a plain gradient, an Office-style finish or the system colours, and the Button...Color properties colour the hovered and selected buttons. Metrics are in logical pixels (1/96 inch) and are scaled with the display.

Examples

using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.NavigationControls;

public class MailForm : Form
{
    private readonly BinaryPanelBar navigation = new BinaryPanelBar();
    private readonly StatusStrip status = new StatusStrip();

    public MailForm()
    {
        Text = "Mail";
        Size = new Size(960, 640);
        status.Items.Add("Mail");

        navigation.Dock = DockStyle.Left;
        navigation.Width = 240;
        navigation.XPThemeToEmulate = XPTheme.Blue;
        navigation.ItemColorRenderingStyle = PanelBarItemColorRenderingStyle.OfficeStyleRenderer;
        navigation.RenderInOutlookStyleExpandCollapseMode = true;   // collapse arrow in the header
        navigation.AddShowNavigationOptionsMenuItem = true;

        var folders = new TreeView();
        folders.Nodes.Add("Inbox");
        folders.Nodes.Add("Sent Items");
        AddSection("Mail", "Images\\mail", folders);
        AddSection("Calendar", "Images\\calendar", new MonthCalendar());
        AddSection("Contacts", "Images\\contacts", new ListBox { Items = { "Accounts team", "Suppliers" } });
        navigation.HowManyPanelButtonsToShow = 2;                   // the third shows as a small icon

        navigation.BinaryPanelBarButtonClicked += (sender, e) =>
            status.Items[0].Text = ((BinaryPanelBarButton)sender).ButtonText;

        Controls.Add(navigation);
        Controls.Add(status);
    }

    private void AddSection(string title, string imagePath, Control content)
    {
        var page = new BinaryPanelBarContainedPanel();
        content.Dock = DockStyle.Fill;
        page.Controls.Add(content);

        var button = new BinaryPanelBarButton(navigation)   // the bar, for drawing on the collapsed rail
        {
            ButtonText = title,
            ButtonImage = new Bitmap(imagePath + "-24.png"),
            ButtonSmallImage = new Bitmap(imagePath + "-16.png"),
            ContainedPanel = page,                         // set before the button is added
        };

        navigation.AddBinaryPanelBarButton(button);
    }
}

See also

Members at a glance

Constructors
BinaryPanelBarInitialises a new, empty BinaryPanelBar with the olive XP theme, a thin border and one large button shown.
Properties
AddShowNavigationOptionsMenuItemGets or sets whether the bar's chevron menu has a "Navigation Pane Options..." item, which opens a dialog for reordering the buttons and choosing which are available.
AddShowNavigationOptionsMenuResourceProviderInstanceGets or sets the texts of the bar's chevron menu, so that the menu can be translated.
BorderStyleGets the standard Windows border, which is always BorderStyle.None; assigned values are ignored.
ButtonBorderStyleGets or sets the border drawn round each button, and sets it on every button on the bar.
ButtonHoverEndColorGets or sets the colour at the bottom of the gradient on a button under the pointer.
ButtonHoverSelectedEndColorGets or sets the other end of the gradient on the selected button while it is under the pointer.
ButtonHoverSelectedStartColorGets or sets one end of the gradient on the selected button while it is under the pointer.
ButtonHoverStartColorGets or sets the colour at the top of the gradient on a button under the pointer.
ButtonSelectedEndColorGets or sets the colour at the bottom of the gradient on the selected button.
ButtonSelectedStartColorGets or sets the colour at the top of the gradient on the selected button.
CollapseExpandButtonColorGets or sets the colour of the collapse and expand arrow in the header strip.
ContextMenuChevronColorGets or sets the colour of the built-in chevron on the button that opens the bar's menu.
ControlBorderStyleGets or sets the border drawn round the whole bar, and sets the same border on every button.
ControlInCollapsedModeGets or sets whether the bar is collapsed to a narrow rail at its docked edge.
CurrentlySelectedButtonGets the button most recently selected – by the user, from code, or automatically when the bar loads.
CustomChevronImageGets or sets a picture of your own for the chevron button at the right of the icon strip, which opens the bar's menu.
CustomImageTransparentColorGets or sets the colour made transparent in CustomChevronImage.
DropShadowColorGets or sets the colour of the drop shadow.
DropShadowDepthGets or sets how far the drop shadow reaches.
DropShadowOpacityGets or sets how dark the drop shadow is where it is strongest, next to the bar.
EndColorGets or sets the colour at the bottom of the header strip's gradient and, while XPThemeToEmulate is XPTheme.None, of every button's.
GripperColorGets or sets the colour of the gripper band above the stack of buttons, which the user drags to show more or fewer buttons.
GripperHeightGets or sets the height of the gripper band above the stack of buttons.
HowManyPanelButtonsToShowGets or sets how many buttons are shown as large buttons in the stack; the others appear as small icons in the strip under it.
ItemColorRenderingStyleGets or sets how the buttons and the header are filled: a plain gradient, an Office-style two-tone finish, or the system's colours.
ItemsGets a new list of the section buttons on the bar.
LeftMarginForDrawingMainHeaderTextGets or sets the space between the left edge of the header strip and its text.
MainHeaderHeightGets or sets the height of the header strip at the top of the bar.
MainHeaderTextColorGets or sets the colour of the text in the header strip.
MainHeaderTextFontGets or sets the font of the text in the header strip.
MenuItemAvailableButtonCheckedStateBorderColorGets or sets a border colour for the checked buttons listed under the chevron menu's "Add or Remove Buttons".
MenuItemSelectionBackgroundColorGets or sets a highlight colour for the items of the bar's chevron menu.
PanelBarButtonsGets a new list of every BinaryPanelBarButton among the bar's child controls.
PanelBarWindowFillColorWhenInCollapsedModeAndTheContainedPanelIsShowingGets or sets the background of the collapsed rail while the flyout showing the selected page is open.
PanelBarWindowFillColorWhenInCollpasedModeGets or sets the background of the collapsed rail while the flyout is closed.
PanelBarWindowTextColorWhenInCollpasedModeGets or sets the colour of the text written up the collapsed rail.
PanelTextGets or sets the text in the bar's header strip.
PanelWindowTextFontWhenInCollapsedModeGets or sets the font of the selected button's text written up the collapsed rail.
PanelWindowTextWhenGripperIsOnMoveGets or sets the text shown up the collapsed rail while the user drags the gripper.
ReflectCurrentXPThemeColorOnLoadGets or sets whether the bar chooses its XPThemeToEmulate from the Windows visual style when its window is created.
RenderInOutlookStyleExpandCollapseModeGets or sets whether the header strip has an arrow that collapses the bar to a narrow rail, as Outlook's navigation pane does.
SelectedButtonGets the selected button – the one whose page the bar is showing.
ShouldAutoResetFocusToControlAfterPopupWindowHideGets or sets whether the bar takes the keyboard focus back when the flyout opened from the collapsed rail closes.
ShouldDrawDropShadowGets or sets whether a soft shadow is drawn along the bar's bottom and right edges.
SizeGets or sets the size of the bar, keeping the collapsed state consistent with it.
StartColorGets or sets the colour at the top of the header strip's gradient and, while XPThemeToEmulate is XPTheme.None, of every button's.
TopMarginForDrawingMainHeaderTextGets or sets the space between the top edge of the header strip and its text area.
UpdateWhenSystemColorsChangesGets or sets whether the bar follows the Windows visual style, choosing its XPThemeToEmulate from it now and whenever the system colours change.
UseSolidBrushWhenPaintingButtonsGets or sets whether the buttons are filled with one flat colour, StartColor, rather than a gradient.
WirePanelBarButtonClickEventToBaseBarButtonGets or sets whether clicking a button's small icon in the strip under the stack also raises the button's own Control.Click event, as clicking the large button does.
XPThemeToEmulateGets or sets the Windows XP palette the bar and its buttons are drawn in.
Methods
AddBinaryPanelBarButtonAdds a section button to the bar, giving it the bar's theme, rendering style and button colours.
DeSelectBinaryPanelBarButtonDraws a button as not selected.
DeSelectBinaryPanelBarButtonDraws the button at a position in Items as not selected.
DisposeReleases the resources the bar uses.
GetPanelButtonAtReturns the button in the stack at a point.
ItemAtReturns the section button at a position in Items.
MakeAvailableAllBinaryPanelBarButtonObjectsMakes every button on the bar available.
MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtonsMakes the given buttons available and every other button unavailable, for example to match the sections a user's role allows.
MakeUnAvailableAllBinaryPanelBarButtonObjectsMakes every button on the bar unavailable, hiding them all from the stack and the icon strip.
MoveDownByOneIndexTheSpecifiedBinaryPanelBarButtonObjectMoves a button one place later among the bar's child controls, which sets the order the buttons are stacked and listed in.
MoveUpByOneIndexTheSpecifiedBinaryPanelBarButtonObjectMoves a button one place earlier among the bar's child controls, which sets the order the buttons are stacked and listed in.
OnDockChangedRaises the Control.DockChanged event, and removes the header's collapse arrow while the bar fills a form: a bar docked to fill has no width to give back.
OnHandleCreatedRaises the Control.HandleCreated event, then sizes the header and the icon strip for the display, and applies the system's theme when ReflectCurrentXPThemeColorOnLoad is on.
OnMouseDownRaises the Control.MouseDown event. In the designer, a click on a button selects that button for editing first.
OnPaintRaises the Control.Paint event, then draws the border that ControlBorderStyle chooses.
OnParentBackColorChangedRaises the Control.ParentBackColorChanged event, and repaints the shadow band, which is filled with the colour behind the bar.
OnResizeRaises the Control.Resize event, then redraws the header, the gripper, the icon strip and the buttons for the new size, keeping the selected button selected.
OnSizeChangedRaises the Control.SizeChanged event, and lays out the icon strip and the shadow for the new size.
OnSystemColorsChangedRaises the Control.SystemColorsChanged event, and applies the system's theme again when UpdateWhenSystemColorsChanges is on.
RemoveBinaryPanelBarButtonRemoves a section button from the bar.
RemoveBinaryPanelBarButtonRemoves the section button at a position in Items.
ResetAvailabilityStatusOfThePanelBarButtonObjectMakes one button available or unavailable.
ResetIndexForTheSpecifiedBinaryPanelBarButtonObjectMoves a button to a given position among the bar's child controls.
SelectBinaryPanelBarButtonSelects the button at a position in Items, as a click on it would.
SelectBinaryPanelBarButtonSelects a button, as a click on it would.
ShowSpecifiedBinaryPanelBarButtonsInMainViewListShows the given buttons as large buttons in the stack and moves every other button to the icon strip.
WndProcProcesses the window messages, keeping a band along the right and bottom edges for the drop shadow and painting the shadow into it.
Events
AboutToCollapseOrExpandOccurs when the header strip is clicked while collapsing is on, before the bar collapses or expands; the handler can cancel it.
BinaryPanelBarButtonClickedOccurs when a button becomes the selected one – clicked in the stack, clicked as an icon in the strip, or selected from code.
BinaryPanelBarButtonContainedPanelAppliedOrChangedOccurs when a page is given to a button already on the bar, through BinaryPanelBarButton.ContainedPanel.
BinaryPanelBarButtonImageChangedOccurs when a button's BinaryPanelBarButton.ButtonImage or BinaryPanelBarButton.ButtonSmallImage changes.
BinaryPanelBarButtonNotAvailableForUseChangedOccurs after a button has been made available or unavailable.
BinaryPanelBarButtonNotAvailableForUseChangingOccurs before a button is made available or unavailable, whether by code, the "Add or Remove Buttons" menu or the options dialog; the handler can refuse the change.
BinaryPanelBarButtonTextChangedOccurs when a button's BinaryPanelBarButton.ButtonText changes.
BinaryPanelBarButtonVisibleChangedOccurs when a button moves between the stack and the icon strip, or is hidden – when its Control.Visible changes.
CollapseExpandButtonClickedOccurs after the user has collapsed or expanded the bar with the arrow in the header strip.
ContextMenuShowNavigationPaneOptionsClickedOccurs when the user chooses "Navigation Pane Options..." from the chevron menu, before the built-in dialog opens.
GripperHandleMovedOccurs repeatedly while the user drags the gripper above the stack, before each step that shows or hides a button; the handler can cancel the step.
ShowFewerButtonsMenuItemClickedOccurs when the user chooses "Show Fewer Buttons" from the chevron menu, before a button moves from the stack to the icon strip; the handler can cancel it.
ShowMoreButtonsMenuItemClickedOccurs when the user chooses "Show More Buttons" from the chevron menu, before a button moves from the icon strip to the stack; the handler can cancel it.
XpThemeChangedOccurs after XPThemeToEmulate has been applied.
XpThemeChangingOccurs before XPThemeToEmulate is applied; the handler can keep the current theme.

Constructors

BinaryPanelBar

public BinaryPanelBar()

Initialises a new, empty BinaryPanelBar with the olive XP theme, a thin border and one large button shown.

Properties

AddShowNavigationOptionsMenuItem

public bool AddShowNavigationOptionsMenuItem

Gets or sets whether the bar's chevron menu has a "Navigation Pane Options..." item, which opens a dialog for reordering the buttons and choosing which are available.

Value
true to show the item. The default is false.
See also

AddShowNavigationOptionsMenuResourceProviderInstance

public PanelBarAddShowNavigationOptionsMenuResourceProvider AddShowNavigationOptionsMenuResourceProviderInstance

Gets or sets the texts of the bar's chevron menu, so that the menu can be translated.

Value
The default is a PanelBarAddShowNavigationOptionsMenuResourceProvider with the English texts.
Remarks

Assigning a provider renames the items of the menu at once. Changing a text on the provider already assigned takes effect when the menu is next rebuilt, for example when a button is added; assign the provider again to apply it straight away.

Example
navigation.AddShowNavigationOptionsMenuResourceProviderInstance = new PanelBarAddShowNavigationOptionsMenuResourceProvider
{
    ShowMoreButtonsText = "Mehr Schaltflächen anzeigen",
    ShowFewerButtonsText = "Weniger Schaltflächen anzeigen",
    NavigationPaneOptionsText = "Navigationsbereichsoptionen...",
    AddOrRemoveButtonsText = "Schaltflächen hinzufügen oder entfernen",
};

BorderStyle

public new System.Windows.Forms.BorderStyle BorderStyle

Gets the standard Windows border, which is always BorderStyle.None; assigned values are ignored.

Remarks

Use ControlBorderStyle for the bar's border.

ButtonBorderStyle

public PanelBarBorderStyle ButtonBorderStyle

Gets or sets the border drawn round each button, and sets it on every button on the bar.

Value
The default is PanelBarBorderStyle.Thin.
Remarks

ControlBorderStyle sets the buttons' borders too; whichever is set last wins.

See also

ButtonHoverEndColor

public Color ButtonHoverEndColor

Gets or sets the colour at the bottom of the gradient on a button under the pointer.

Value
The default is RGB(255, 195, 90), a light orange.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

ButtonHoverSelectedEndColor

public Color ButtonHoverSelectedEndColor

Gets or sets the other end of the gradient on the selected button while it is under the pointer.

Value
The default is RGB(255, 223, 132), a light gold.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

ButtonHoverSelectedStartColor

public Color ButtonHoverSelectedStartColor

Gets or sets one end of the gradient on the selected button while it is under the pointer.

Value
The default is RGB(239, 130, 8), a deep orange.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

ButtonHoverStartColor

public Color ButtonHoverStartColor

Gets or sets the colour at the top of the gradient on a button under the pointer.

Value
The default is RGB(255, 255, 231), a pale cream.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

See also

ButtonSelectedEndColor

public Color ButtonSelectedEndColor

Gets or sets the colour at the bottom of the gradient on the selected button.

Value
The default is RGB(247, 154, 25), an orange.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

ButtonSelectedStartColor

public Color ButtonSelectedStartColor

Gets or sets the colour at the top of the gradient on the selected button.

Value
The default is RGB(255, 235, 156), a pale gold.
Designer category
Colors
Remarks

Applies to every button on the bar at the time, and to buttons added later with AddBinaryPanelBarButton. Each button can also be given its own colour.

See also

CollapseExpandButtonColor

public Color CollapseExpandButtonColor

Gets or sets the colour of the collapse and expand arrow in the header strip.

Value
The default is Color.Black.
See also

ContextMenuChevronColor

public Color ContextMenuChevronColor

Gets or sets the colour of the built-in chevron on the button that opens the bar's menu.

Value
The default is Color.Black.
Remarks

Setting the colour redraws the built-in chevron and puts it on the button, replacing a CustomChevronImage.

ControlBorderStyle

public PanelBarBorderStyle ControlBorderStyle

Gets or sets the border drawn round the whole bar, and sets the same border on every button.

Value
The default is PanelBarBorderStyle.Thin: a one-pixel line in SystemColors.WindowText.
See also

ControlInCollapsedMode

public bool ControlInCollapsedMode

Gets or sets whether the bar is collapsed to a narrow rail at its docked edge.

Value
true while the bar is collapsed. The default is false.
Remarks

Collapsed, the bar keeps its height and shrinks to a rail showing the selected button's text, reading upwards. Clicking the rail opens the selected button's panel in a flyout beside it; expanding puts the bar back to the width it had when it collapsed.

Has no effect unless RenderInOutlookStyleExpandCollapseMode is true, which is also what puts the collapse button in the header. A request to collapse while that is off is ignored and this stays false. Nor does it collapse a bar whose Control.Dock is DockStyle.Fill: the header button refuses one, since a bar that fills its container has nowhere to give the width back to.

Setting it does not raise AboutToCollapseOrExpand or CollapseExpandButtonClicked; those report the user's click on the header button. This is runtime state, so the designer neither shows nor serialises it.

CurrentlySelectedButton

public BinaryPanelBarButton CurrentlySelectedButton

Gets the button most recently selected – by the user, from code, or automatically when the bar loads.

Value
The button, or null until one has been selected.
Remarks

Unlike SelectedButton, this keeps its value when the button is deselected with DeSelectBinaryPanelBarButton().

CustomChevronImage

public Bitmap CustomChevronImage

Gets or sets a picture of your own for the chevron button at the right of the icon strip, which opens the bar's menu.

Value
The default is null: the built-in chevron, drawn in ContextMenuChevronColor.
See also

CustomImageTransparentColor

public Color CustomImageTransparentColor

Gets or sets the colour made transparent in CustomChevronImage.

Value
The default is Color.Empty.
Remarks

The colour is applied to the bitmap itself when this property is set, and only when a CustomChevronImage has already been assigned – so set the image first.

DropShadowColor

public Color DropShadowColor

Gets or sets the colour of the drop shadow.

Value
The default is Color.Black. The colour's alpha component is ignored; DropShadowOpacity sets the strength.
Designer category
Appearance

DropShadowDepth

public int DropShadowDepth

Gets or sets how far the drop shadow reaches.

Value
The depth in logical pixels (1/96 inch), from 0 to 16. The default is 4. Values outside the range are clamped to it.
Default
DropShadowPainter.DefaultDepth
Designer category
Appearance
Remarks

The depth is scaled with the display. Used only while ShouldDrawDropShadow is true.

DropShadowOpacity

public int DropShadowOpacity

Gets or sets how dark the drop shadow is where it is strongest, next to the bar.

Value
From 0 (invisible) to 255 (solid DropShadowColor). The default is 96. Values outside the range are clamped to it.
Default
DropShadowPainter.DefaultOpacity
Designer category
Appearance

EndColor

public Color EndColor

Gets or sets the colour at the bottom of the header strip's gradient and, while XPThemeToEmulate is XPTheme.None, of every button's.

Value
The default is Color.White; assigning XPThemeToEmulate sets it to the theme's second colour.
See also

GripperColor

public Color GripperColor

Gets or sets the colour of the gripper band above the stack of buttons, which the user drags to show more or fewer buttons.

Value
The default is Color.Transparent, which uses StartColor.
Remarks

Used only while XPThemeToEmulate is XPTheme.None; each XP theme has a gripper colour of its own.

See also

GripperHeight

public int GripperHeight

Gets or sets the height of the gripper band above the stack of buttons.

Value
The height in logical pixels (1/96 inch), from 0 to 20. The default is 8. Values outside the range are clamped to it; 0 leaves no gripper to drag.
See also

HowManyPanelButtonsToShow

public int HowManyPanelButtonsToShow

Gets or sets how many buttons are shown as large buttons in the stack; the others appear as small icons in the strip under it.

Value
The default is 1.
Remarks

Setting the property shows the first value buttons in Items and hides the rest, counting unavailable buttons too. The user changes the number with the gripper or the chevron menu without changing this property.

ItemColorRenderingStyle

public PanelBarItemColorRenderingStyle ItemColorRenderingStyle

Gets or sets how the buttons and the header are filled: a plain gradient, an Office-style two-tone finish, or the system's colours.

Value
The default is PanelBarItemColorRenderingStyle.Default.
Remarks

Setting the property sets the same style on every button on the bar. PanelBarItemColorRenderingStyle.WindowsOSThemeSettings also sets XPThemeToEmulate to XPTheme.None and takes the colours from the system, using the highlight colour under high contrast.

See also

Items

public ArrayList Items

Gets a new list of the section buttons on the bar.

Value
An ArrayList of BinaryPanelBarButton objects in the order of the bar's child controls, without the bar's own icon strip. A snapshot, built on each read.
Remarks

The positions the index-based methods take are positions in this list.

LeftMarginForDrawingMainHeaderText

public int LeftMarginForDrawingMainHeaderText

Gets or sets the space between the left edge of the header strip and its text.

Value
The space in logical pixels (1/96 inch). The default is 2.

MainHeaderHeight

public int MainHeaderHeight

Gets or sets the height of the header strip at the top of the bar.

Value
The height in logical pixels (1/96 inch). The default is 0, which sizes the strip from MainHeaderTextFont: the font's height plus 8 logical pixels, and never less than 25. Negative values are stored as 0.
Default
0
Designer category
Appearance

MainHeaderTextColor

public Color MainHeaderTextColor

Gets or sets the colour of the text in the header strip.

Value
The default is SystemColors.WindowText.
Remarks
See also

MainHeaderTextFont

public Font MainHeaderTextFont

Gets or sets the font of the text in the header strip.

Value
The default is the system's message-box font family at 12 points, bold.
Remarks

Unless MainHeaderHeight is set, the strip's height follows the font.

MenuItemAvailableButtonCheckedStateBorderColor

public Color MenuItemAvailableButtonCheckedStateBorderColor

Gets or sets a border colour for the checked buttons listed under the chevron menu's "Add or Remove Buttons".

Value
The default is Color.Empty.
Remarks

The menu is drawn by Windows Forms' own renderer, which does not use this colour. Setting it rebuilds the menu and applies XPThemeToEmulate again, which raises XpThemeChanging and XpThemeChanged.

MenuItemSelectionBackgroundColor

public Color MenuItemSelectionBackgroundColor

Gets or sets a highlight colour for the items of the bar's chevron menu.

Value
The default is RGB(255, 187, 9), an amber.
Remarks

The menu is drawn by Windows Forms' own renderer, which does not use this colour. Setting it rebuilds the menu and applies XPThemeToEmulate again, which raises XpThemeChanging and XpThemeChanged.

PanelBarButtons

public System.Collections.Generic.List<BinaryPanelBarButton> PanelBarButtons

Gets a new list of every BinaryPanelBarButton among the bar's child controls.

Value
A snapshot, built on each read; changing it does not change the bar.
Remarks

The list includes the button that forms the bar's own icon strip. For only the section buttons you added, use Items.

PanelBarWindowFillColorWhenInCollapsedModeAndTheContainedPanelIsShowing

public Color PanelBarWindowFillColorWhenInCollapsedModeAndTheContainedPanelIsShowing

Gets or sets the background of the collapsed rail while the flyout showing the selected page is open.

Value
The default is SystemColors.Info.
See also

PanelBarWindowFillColorWhenInCollpasedMode

public Color PanelBarWindowFillColorWhenInCollpasedMode

Gets or sets the background of the collapsed rail while the flyout is closed.

Value
The default is SystemColors.Window.
Remarks

Takes effect the next time the rail is drawn.

See also

PanelBarWindowTextColorWhenInCollpasedMode

public Color PanelBarWindowTextColorWhenInCollpasedMode

Gets or sets the colour of the text written up the collapsed rail.

Value
The default is SystemColors.Highlight.
Remarks

Takes effect the next time the rail is drawn.

PanelText

public string PanelText

Gets or sets the text in the bar's header strip.

Value
The default is empty; once the bar is loaded it shows the selected button's BinaryPanelBarButton.ButtonText.
Remarks

Selecting a button replaces the text with that button's, so set this property to show a different title only until the next selection. The text is drawn in MainHeaderTextFont and MainHeaderTextColor, on one line, trimmed with an ellipsis; it is hidden while the bar is collapsed.

PanelWindowTextFontWhenInCollapsedMode

public Font PanelWindowTextFontWhenInCollapsedMode

Gets or sets the font of the selected button's text written up the collapsed rail.

Value
The default is a bold version of the bar's Control.Font when the bar was created; null uses the bar's current font.
Remarks

Takes effect the next time the rail is drawn.

PanelWindowTextWhenGripperIsOnMove

public string PanelWindowTextWhenGripperIsOnMove

Gets or sets the text shown up the collapsed rail while the user drags the gripper.

Value
The default is "Working...".

ReflectCurrentXPThemeColorOnLoad

public bool ReflectCurrentXPThemeColorOnLoad

Gets or sets whether the bar chooses its XPThemeToEmulate from the Windows visual style when its window is created.

Value
true to follow the system on creation. The default is false.
Default
false
Remarks

Not applied while XPThemeToEmulate is XPTheme.None. The mapping is the one UpdateWhenSystemColorsChanges describes: outside Windows XP's Olive Green and Silver styles the bar is drawn XPTheme.Blue.

RenderInOutlookStyleExpandCollapseMode

public bool RenderInOutlookStyleExpandCollapseMode

Gets or sets whether the header strip has an arrow that collapses the bar to a narrow rail, as Outlook's navigation pane does.

Value
true to offer collapsing. The default is false.
Remarks

Clicking the arrow collapses or expands the bar (ControlInCollapsedMode). The arrow is not shown while the bar's Control.Dock is DockStyle.Fill. Turning the property off while the bar is collapsed expands it first.

Example
navigation.Dock = DockStyle.Left;
navigation.RenderInOutlookStyleExpandCollapseMode = true;
navigation.CollapseExpandButtonColor = Color.Navy;
navigation.AboutToCollapseOrExpand += (s, e) =>
    e.ShouldCancel = !e.IsAboutToExpand && composeWindowIsDocked;   // keep the pane open
See also

SelectedButton

public BinaryPanelBarButton SelectedButton

Gets the selected button – the one whose page the bar is showing.

Value
The selected BinaryPanelBarButton. When none is selected, the last button in Items; null only when the bar has no buttons.
See also

ShouldAutoResetFocusToControlAfterPopupWindowHide

public bool ShouldAutoResetFocusToControlAfterPopupWindowHide

Gets or sets whether the bar takes the keyboard focus back when the flyout opened from the collapsed rail closes.

Value
true to focus the bar. The default is false.
Remarks

Useful when the bar is on a tool window, which otherwise loses the focus when the flyout closes.

ShouldDrawDropShadow

public bool ShouldDrawDropShadow

Gets or sets whether a soft shadow is drawn along the bar's bottom and right edges.

Value
true to draw the shadow. The default is false.
Default
false
Designer category
Appearance
Remarks

A control cannot paint outside its own bounds, so the shadow is drawn in a band DropShadowDepth deep inside the bar's bottom and right edges, and the header, buttons and pages shrink by that much. The part of the band the shadow does not cover is painted in the nearest opaque parent's Control.BackColor.

See also

Size

public new Size Size

Gets or sets the size of the bar, keeping the collapsed state consistent with it.

Value
The size in pixels, as for Size. A size with no width or height is ignored.
Remarks

A new width is remembered as the width to expand to, except a rail-wide width set while the bar is collapsed. Assigning Control.Width or Size through a Control reference bypasses this.

StartColor

public Color StartColor

Gets or sets the colour at the top of the header strip's gradient and, while XPThemeToEmulate is XPTheme.None, of every button's.

Value
The default is Color.Empty; assigning XPThemeToEmulate sets it to the theme's first colour.
Remarks

Setting the colour sets it on every button on the bar and redraws them. Assign it after XPThemeToEmulate, which replaces it.

See also

TopMarginForDrawingMainHeaderText

public int TopMarginForDrawingMainHeaderText

Gets or sets the space between the top edge of the header strip and its text area.

Value
The space in logical pixels (1/96 inch). The default is 2.
Remarks

The text is centred vertically in the area below the margin.

UpdateWhenSystemColorsChanges

public bool UpdateWhenSystemColorsChanges

Gets or sets whether the bar follows the Windows visual style, choosing its XPThemeToEmulate from it now and whenever the system colours change.

Value
true to follow the system. The default is false.
Default
false
Remarks

The XP Olive Green style gives XPTheme.Olive, the XP Silver style XPTheme.Silver, and every other style – including those of later Windows versions – XPTheme.Blue. Turning this on applies the theme at once, replacing XPTheme.None and colours of your own.

See also

UseSolidBrushWhenPaintingButtons

public bool UseSolidBrushWhenPaintingButtons

Gets or sets whether the buttons are filled with one flat colour, StartColor, rather than a gradient.

Value
The default is false.
Remarks

Setting it to true works only while XPThemeToEmulate is XPTheme.None, and does it by copying StartColor into EndColor. Setting it to false puts back the EndColor remembered then – white, if it was never set to true.

WirePanelBarButtonClickEventToBaseBarButton

public bool WirePanelBarButtonClickEventToBaseBarButton

Gets or sets whether clicking a button's small icon in the strip under the stack also raises the button's own Control.Click event, as clicking the large button does.

Value
true to raise it. The default is true.
Remarks

Setting this property sets BinaryPanelBarButton.WirePanelBarButtonClickEventToBaseBarButton on every button on the bar at that moment. Clicking the icon selects the button either way.

XPThemeToEmulate

public XPTheme XPThemeToEmulate

Gets or sets the Windows XP palette the bar and its buttons are drawn in.

Value
The default is XPTheme.Olive.
Remarks

Assigning a theme raises XpThemeChanging, which can cancel it, applies the theme to every button, the icon strip and the gripper, sets StartColor and EndColor to the theme's pair of colours, and raises XpThemeChanged.

XPTheme.None draws the buttons with StartColor and EndColor instead. Choosing it leaves those two as they are, so set them after it.

Example
// Corporate colours rather than an XP palette.
navigation.XPThemeToEmulate = XPTheme.None;
navigation.StartColor = Color.FromArgb(0, 84, 147);
navigation.EndColor = Color.FromArgb(214, 230, 245);
navigation.GripperColor = Color.FromArgb(0, 84, 147);

Methods

AddBinaryPanelBarButton

public void AddBinaryPanelBarButton(BinaryPanelBarButton tempObject)

Adds a section button to the bar, giving it the bar's theme, rendering style and button colours.

Parameters
tempObject
The button to add. Set its BinaryPanelBarButton.ContainedPanel first.
Remarks

The button joins the stack as a large button while fewer than HowManyPanelButtonsToShow are showing, and otherwise as an icon in the strip. Adding a button selects the bar's first button again.

Adding the button through Control.Controls also works, but does not give it the bar's rendering style and button colours.

Example
var tasks = new BinaryPanelBarButton(navigation)
{
    ButtonText = "Tasks",
    ButtonImage = new Bitmap("Images\\tasks-24.png"),
    ContainedPanel = tasksPage,
};
navigation.AddBinaryPanelBarButton(tasks);

DeSelectBinaryPanelBarButton

public void DeSelectBinaryPanelBarButton(BinaryPanelBarButton theObject)

Draws a button as not selected.

Parameters
theObject
The button. null is ignored.
Remarks

No other button is selected in its place, the page shown does not change and no event is raised.

DeSelectBinaryPanelBarButton

public void DeSelectBinaryPanelBarButton(int objectIndex)

Draws the button at a position in Items as not selected.

Parameters
objectIndex
The zero-based position of the button in Items. A position outside the list is ignored.

Dispose

protected override void Dispose(bool disposing)

Releases the resources the bar uses.

Parameters
disposing
true to release managed resources as well as unmanaged ones.

GetPanelButtonAt

public BinaryPanelBarButton GetPanelButtonAt(Point thePoint)

Returns the button in the stack at a point.

Parameters
thePoint
The point, in the bar's client coordinates.
Returns

The visible button whose bounds contain the point, or null when there is none there. Buttons shown only as icons in the strip under the stack are not returned.

ItemAt

public BinaryPanelBarButton ItemAt(int index)

Returns the section button at a position in Items.

Parameters
index
The zero-based position.
Returns

The button, or null when index is outside the list.

MakeAvailableAllBinaryPanelBarButtonObjects

public void MakeAvailableAllBinaryPanelBarButtonObjects()

Makes every button on the bar available.

See also

MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons

public void MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons(ArrayList buttonObjects)

Makes the given buttons available and every other button unavailable, for example to match the sections a user's role allows.

Parameters
buttonObjects
The BinaryPanelBarButton objects to keep available.
Remarks
Example
if (!currentUser.IsManager)
    navigation.MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons(
        new ArrayList { mailButton, calendarButton });

MakeUnAvailableAllBinaryPanelBarButtonObjects

public void MakeUnAvailableAllBinaryPanelBarButtonObjects()

Makes every button on the bar unavailable, hiding them all from the stack and the icon strip.

See also

MoveDownByOneIndexTheSpecifiedBinaryPanelBarButtonObject

public void MoveDownByOneIndexTheSpecifiedBinaryPanelBarButtonObject( BinaryPanelBarButton theObject)

Moves a button one place later among the bar's child controls, which sets the order the buttons are stacked and listed in.

Parameters
theObject
The button to move.
Remarks

The index counts the bar's child controls, which include the bar's own header, gripper and icon strip and the buttons' pages as well as the buttons, so a move that lands next to one of those does not change the order of the buttons on screen. Errors, such as a button not on the bar, are ignored.

MoveUpByOneIndexTheSpecifiedBinaryPanelBarButtonObject

public void MoveUpByOneIndexTheSpecifiedBinaryPanelBarButtonObject( BinaryPanelBarButton theObject)

Moves a button one place earlier among the bar's child controls, which sets the order the buttons are stacked and listed in.

Parameters
theObject
The button to move.
Remarks

The index counts the bar's child controls, which include the bar's own header, gripper and icon strip and the buttons' pages as well as the buttons, so a move that lands next to one of those does not change the order of the buttons on screen. Errors, such as a button not on the bar, are ignored.

OnDockChanged

protected override void OnDockChanged(EventArgs e)

Raises the Control.DockChanged event, and removes the header's collapse arrow while the bar fills a form: a bar docked to fill has no width to give back.

Parameters
e
The data for the event.

OnHandleCreated

protected override void OnHandleCreated(EventArgs e)

Raises the Control.HandleCreated event, then sizes the header and the icon strip for the display, and applies the system's theme when ReflectCurrentXPThemeColorOnLoad is on.

Parameters
e
The data for the event.

OnMouseDown

protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)

Raises the Control.MouseDown event. In the designer, a click on a button selects that button for editing first.

Parameters
e
The data for the event.

OnPaint

protected override void OnPaint(PaintEventArgs e)

Raises the Control.Paint event, then draws the border that ControlBorderStyle chooses.

Parameters
e
The data for the event.

OnParentBackColorChanged

protected override void OnParentBackColorChanged(EventArgs e)

Raises the Control.ParentBackColorChanged event, and repaints the shadow band, which is filled with the colour behind the bar.

Parameters
e
The data for the event.

OnResize

protected override void OnResize(EventArgs e)

Raises the Control.Resize event, then redraws the header, the gripper, the icon strip and the buttons for the new size, keeping the selected button selected.

Parameters
e
The data for the event.

OnSizeChanged

protected override void OnSizeChanged(EventArgs e)

Raises the Control.SizeChanged event, and lays out the icon strip and the shadow for the new size.

Parameters
e
The data for the event.

OnSystemColorsChanged

protected override void OnSystemColorsChanged(EventArgs e)

Raises the Control.SystemColorsChanged event, and applies the system's theme again when UpdateWhenSystemColorsChanges is on.

Parameters
e
The data for the event.

RemoveBinaryPanelBarButton

public void RemoveBinaryPanelBarButton(BinaryPanelBarButton tempObject)

Removes a section button from the bar.

Parameters
tempObject
The button to remove. null is ignored.
Remarks

The button is not disposed, and its page stays among the bar's child controls; remove or dispose them yourself when they are no longer needed.

RemoveBinaryPanelBarButton

public void RemoveBinaryPanelBarButton(int objectIndex)

Removes the section button at a position in Items.

Parameters
objectIndex
The zero-based position of the button in Items. A position outside the list is ignored.
Remarks

The button is not disposed.

ResetAvailabilityStatusOfThePanelBarButtonObject

public void ResetAvailabilityStatusOfThePanelBarButtonObject(BinaryPanelBarButton theObject, bool makeItAvailable)

Makes one button available or unavailable.

Parameters
theObject
The button. Must not be null.
makeItAvailable
true to make it available; false to hide it from the stack and the icon strip.
Remarks

Does the same as setting the button's BinaryPanelBarButton.NotAvailableForUse.

ResetIndexForTheSpecifiedBinaryPanelBarButtonObject

public void ResetIndexForTheSpecifiedBinaryPanelBarButtonObject( BinaryPanelBarButton theObject, int newIndex)

Moves a button to a given position among the bar's child controls.

Parameters
theObject
The button to move.
newIndex
The new zero-based position in the bar's Control.Controls.
Remarks

The index counts the bar's child controls, which include the bar's own header, gripper and icon strip and the buttons' pages as well as the buttons, so a move that lands next to one of those does not change the order of the buttons on screen. Errors, such as a button not on the bar, are ignored.

SelectBinaryPanelBarButton

public void SelectBinaryPanelBarButton(int objectIndex)

Selects the button at a position in Items, as a click on it would.

Parameters
objectIndex
The zero-based position of the button in Items. A position outside the list is ignored.
Remarks

The button's page is shown, its text goes into the header, and the button's Control.Click event and the bar's BinaryPanelBarButtonClicked are raised.

SelectBinaryPanelBarButton

public void SelectBinaryPanelBarButton(BinaryPanelBarButton theObject)

Selects a button, as a click on it would.

Parameters
theObject
The button. null is ignored.
Remarks

The button's page is shown, its text goes into the header, and the button's Control.Click event and the bar's BinaryPanelBarButtonClicked are raised.

Example
// Open the Calendar section when a reminder is clicked.
reminderLink.Click += (s, e) => navigation.SelectBinaryPanelBarButton(calendarButton);

ShowSpecifiedBinaryPanelBarButtonsInMainViewList

public void ShowSpecifiedBinaryPanelBarButtonsInMainViewList(ArrayList theObjectsToShow)

Shows the given buttons as large buttons in the stack and moves every other button to the icon strip.

Parameters
theObjectsToShow
The BinaryPanelBarButton objects to show in the stack.
Remarks

WndProc

protected override void WndProc(ref Message m)

Processes the window messages, keeping a band along the right and bottom edges for the drop shadow and painting the shadow into it.

Parameters
m
The window message to process.
Remarks

An override must call the base method for every message, or the shadow is lost.

Events

AboutToCollapseOrExpand

public event EventHandler<PanelBarAboutToCollapseOrExpandEventArgs> AboutToCollapseOrExpand

Occurs when the header strip is clicked while collapsing is on, before the bar collapses or expands; the handler can cancel it.

Remarks

PanelBarAboutToCollapseOrExpandEventArgs.IsAboutToExpand says which way the bar would go; set PanelBarAboutToCollapseOrExpandEventArgs.ShouldCancel to leave it as it is.

The event is raised for a click anywhere on the header, before the bar checks whether the click was on the arrow, so it can occur without the bar then changing. Setting ControlInCollapsedMode from code does not raise it.

BinaryPanelBarButtonClicked

public event EventHandler BinaryPanelBarButtonClicked

Occurs when a button becomes the selected one – clicked in the stack, clicked as an icon in the strip, or selected from code.

Remarks

The sender is the BinaryPanelBarButton. By the time the event is raised, the button's page is showing and its text is in the header.

Example
navigation.BinaryPanelBarButtonClicked += (sender, e) =>
{
    var section = (BinaryPanelBarButton)sender;
    Text = "Mail - " + section.ButtonText;
};

BinaryPanelBarButtonContainedPanelAppliedOrChanged

public event EventHandler BinaryPanelBarButtonContainedPanelAppliedOrChanged

Occurs when a page is given to a button already on the bar, through BinaryPanelBarButton.ContainedPanel.

Remarks

The sender is the button.

BinaryPanelBarButtonImageChanged

public event EventHandler BinaryPanelBarButtonImageChanged
Remarks

The sender is the button; the EventArgs argument is EventArgs.Empty.

BinaryPanelBarButtonNotAvailableForUseChanged

public event EventHandler BinaryPanelBarButtonNotAvailableForUseChanged

Occurs after a button has been made available or unavailable.

Remarks

The sender is the BinaryPanelBarButton.

BinaryPanelBarButtonNotAvailableForUseChanging

public event BinaryPanelBarButtonNotAvailableForUseChangingHandler BinaryPanelBarButtonNotAvailableForUseChanging

Occurs before a button is made available or unavailable, whether by code, the "Add or Remove Buttons" menu or the options dialog; the handler can refuse the change.

Remarks

The sender is the BinaryPanelBarButton.

See also

BinaryPanelBarButtonTextChanged

public event EventHandler BinaryPanelBarButtonTextChanged

Occurs when a button's BinaryPanelBarButton.ButtonText changes.

Remarks

The sender is the button; the EventArgs argument is EventArgs.Empty.

BinaryPanelBarButtonVisibleChanged

public event EventHandler BinaryPanelBarButtonVisibleChanged

Occurs when a button moves between the stack and the icon strip, or is hidden – when its Control.Visible changes.

Remarks

The sender is the button.

CollapseExpandButtonClicked

public event EventHandler<PanelBarCollapseExpandEventArgs> CollapseExpandButtonClicked

Occurs after the user has collapsed or expanded the bar with the arrow in the header strip.

Remarks

PanelBarCollapseExpandEventArgs.IsExpanded gives the new state. Setting ControlInCollapsedMode from code does not raise the event.

ContextMenuShowNavigationPaneOptionsClicked

public event PanelBarContextMenuShowNavigationPaneOptionsHandler ContextMenuShowNavigationPaneOptionsClicked

Occurs when the user chooses "Navigation Pane Options..." from the chevron menu, before the built-in dialog opens.

Remarks

The menu item is there only while AddShowNavigationOptionsMenuItem is on. Set PanelBarNavigationOptions.CancelTheEvent to show your own dialog instead; the built-in one lets the user reorder the buttons and choose which are available.

GripperHandleMoved

public event PanelBarGripperHandleMovedHandler GripperHandleMoved

Occurs repeatedly while the user drags the gripper above the stack, before each step that shows or hides a button; the handler can cancel the step.

Remarks

Dragging down hides the lowest-placed large button; dragging up shows a hidden one.

ShowFewerButtonsMenuItemClicked

public event ShowMoreOrFewerPanelBarButtonsMenuItemClickedHandler ShowFewerButtonsMenuItemClicked

Occurs when the user chooses "Show Fewer Buttons" from the chevron menu, before a button moves from the stack to the icon strip; the handler can cancel it.

ShowMoreButtonsMenuItemClicked

public event ShowMoreOrFewerPanelBarButtonsMenuItemClickedHandler ShowMoreButtonsMenuItemClicked

Occurs when the user chooses "Show More Buttons" from the chevron menu, before a button moves from the icon strip to the stack; the handler can cancel it.

XpThemeChanged

public event PanelBarXPThemeChangedHandler XpThemeChanged

Occurs after XPThemeToEmulate has been applied.

Remarks

The handler receives the theme in use before the assignment and the theme just applied.

XpThemeChanging

public event PanelBarXPThemeChangingHandler XpThemeChanging

Occurs before XPThemeToEmulate is applied; the handler can keep the current theme.

Remarks

Raised on every assignment, even of the theme already in use – which includes setting MenuItemSelectionBackgroundColor or MenuItemAvailableButtonCheckedStateBorderColor, which apply the theme again.