BinaryPanelBar
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
- Buttons and pages. Give each button a
BinaryPanelBarButton.ButtonText, an image and aBinaryPanelBarButton.ContainedPanelholding the section's controls, and add it withAddBinaryPanelBarButton. One button is selected at a time. - Shown and hidden buttons.
HowManyPanelButtonsToShowlarge buttons are stacked at the bottom; the rest appear as small icons in the strip under them. The user moves buttons between the two by dragging the gripper above the stack or with the chevron menu's "Show More Buttons" and "Show Fewer Buttons". - Available buttons. A button whose
BinaryPanelBarButton.NotAvailableForUseis set is hidden altogether. The user chooses which are available from the chevron menu's "Add or Remove Buttons", or the "Navigation Pane Options" dialog (AddShowNavigationOptionsMenuItem). - Collapsing. With
RenderInOutlookStyleExpandCollapseModeon, an arrow in the header collapses the bar to a narrow rail; clicking the rail opens the selected page in a flyout beside it.
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 | |
|---|---|
BinaryPanelBar | Initialises a new, empty BinaryPanelBar with the olive XP theme, a thin border and one
large button shown. |
| Properties | |
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. |
AddShowNavigationOptionsMenuResourceProviderInstance | Gets or sets the texts of the bar's chevron menu, so that the menu can be translated. |
BorderStyle | Gets the standard Windows border, which is always BorderStyle.None;
assigned values are ignored. |
ButtonBorderStyle | Gets or sets the border drawn round each button, and sets it on every button on the bar. |
ButtonHoverEndColor | Gets or sets the colour at the bottom of the gradient on a button under the pointer. |
ButtonHoverSelectedEndColor | Gets or sets the other end of the gradient on the selected button while it is under the pointer. |
ButtonHoverSelectedStartColor | Gets or sets one end of the gradient on the selected button while it is under the pointer. |
ButtonHoverStartColor | Gets or sets the colour at the top of the gradient on a button under the pointer. |
ButtonSelectedEndColor | Gets or sets the colour at the bottom of the gradient on the selected button. |
ButtonSelectedStartColor | Gets or sets the colour at the top of the gradient on the selected button. |
CollapseExpandButtonColor | Gets or sets the colour of the collapse and expand arrow in the header strip. |
ContextMenuChevronColor | Gets or sets the colour of the built-in chevron on the button that opens the bar's menu. |
ControlBorderStyle | Gets or sets the border drawn round the whole bar, and sets the same border on every button. |
ControlInCollapsedMode | Gets or sets whether the bar is collapsed to a narrow rail at its docked edge. |
CurrentlySelectedButton | Gets the button most recently selected – by the user, from code, or automatically when the bar loads. |
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. |
CustomImageTransparentColor | Gets or sets the colour made transparent in CustomChevronImage. |
DropShadowColor | Gets or sets the colour of the drop shadow. |
DropShadowDepth | Gets or sets how far the drop shadow reaches. |
DropShadowOpacity | Gets or sets how dark the drop shadow is where it is strongest, next to the bar. |
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. |
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. |
GripperHeight | Gets or sets the height of the gripper band above the stack of buttons. |
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. |
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. |
Items | Gets a new list of the section buttons on the bar. |
LeftMarginForDrawingMainHeaderText | Gets or sets the space between the left edge of the header strip and its text. |
MainHeaderHeight | Gets or sets the height of the header strip at the top of the bar. |
MainHeaderTextColor | Gets or sets the colour of the text in the header strip. |
MainHeaderTextFont | Gets or sets the font of the text in the header strip. |
MenuItemAvailableButtonCheckedStateBorderColor | Gets or sets a border colour for the checked buttons listed under the chevron menu's "Add or Remove Buttons". |
MenuItemSelectionBackgroundColor | Gets or sets a highlight colour for the items of the bar's chevron menu. |
PanelBarButtons | Gets a new list of every BinaryPanelBarButton among the bar's child controls. |
PanelBarWindowFillColorWhenInCollapsedModeAndTheContainedPanelIsShowing | Gets or sets the background of the collapsed rail while the flyout showing the selected page is open. |
PanelBarWindowFillColorWhenInCollpasedMode | Gets or sets the background of the collapsed rail while the flyout is closed. |
PanelBarWindowTextColorWhenInCollpasedMode | Gets or sets the colour of the text written up the collapsed rail. |
PanelText | Gets or sets the text in the bar's header strip. |
PanelWindowTextFontWhenInCollapsedMode | Gets or sets the font of the selected button's text written up the collapsed rail. |
PanelWindowTextWhenGripperIsOnMove | Gets or sets the text shown up the collapsed rail while the user drags the gripper. |
ReflectCurrentXPThemeColorOnLoad | Gets or sets whether the bar chooses its XPThemeToEmulate from the Windows visual style
when its window is created. |
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. |
SelectedButton | Gets the selected button – the one whose page the bar is showing. |
ShouldAutoResetFocusToControlAfterPopupWindowHide | Gets or sets whether the bar takes the keyboard focus back when the flyout opened from the collapsed rail closes. |
ShouldDrawDropShadow | Gets or sets whether a soft shadow is drawn along the bar's bottom and right edges. |
Size | Gets or sets the size of the bar, keeping the collapsed state consistent with it. |
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. |
TopMarginForDrawingMainHeaderText | Gets or sets the space between the top edge of the header strip and its text area. |
UpdateWhenSystemColorsChanges | Gets or sets whether the bar follows the Windows visual style, choosing its
XPThemeToEmulate from it now and whenever the system colours change. |
UseSolidBrushWhenPaintingButtons | Gets or sets whether the buttons are filled with one flat colour, StartColor, rather than
a gradient. |
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. |
XPThemeToEmulate | Gets or sets the Windows XP palette the bar and its buttons are drawn in. |
| Methods | |
AddBinaryPanelBarButton | Adds a section button to the bar, giving it the bar's theme, rendering style and button colours. |
DeSelectBinaryPanelBarButton | Draws a button as not selected. |
DeSelectBinaryPanelBarButton | Draws the button at a position in Items as not selected. |
Dispose | Releases the resources the bar uses. |
GetPanelButtonAt | Returns the button in the stack at a point. |
ItemAt | Returns the section button at a position in Items. |
MakeAvailableAllBinaryPanelBarButtonObjects | Makes every button on the bar available. |
MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons | Makes the given buttons available and every other button unavailable, for example to match the sections a user's role allows. |
MakeUnAvailableAllBinaryPanelBarButtonObjects | Makes every button on the bar unavailable, hiding them all from the stack and the icon strip. |
MoveDownByOneIndexTheSpecifiedBinaryPanelBarButtonObject | Moves a button one place later among the bar's child controls, which sets the order the buttons are stacked and listed in. |
MoveUpByOneIndexTheSpecifiedBinaryPanelBarButtonObject | Moves a button one place earlier among the bar's child controls, which sets the order the buttons are stacked and listed in. |
OnDockChanged | 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. |
OnHandleCreated | 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. |
OnMouseDown | Raises the Control.MouseDown event. In the designer, a click on a button selects that
button for editing first. |
OnPaint | Raises the Control.Paint event, then draws the border that
ControlBorderStyle chooses. |
OnParentBackColorChanged | Raises the Control.ParentBackColorChanged event, and repaints the shadow band, which is
filled with the colour behind the bar. |
OnResize | 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. |
OnSizeChanged | Raises the Control.SizeChanged event, and lays out the icon strip and the shadow for the
new size. |
OnSystemColorsChanged | Raises the Control.SystemColorsChanged event, and applies the system's theme again when
UpdateWhenSystemColorsChanges is on. |
RemoveBinaryPanelBarButton | Removes a section button from the bar. |
RemoveBinaryPanelBarButton | Removes the section button at a position in Items. |
ResetAvailabilityStatusOfThePanelBarButtonObject | Makes one button available or unavailable. |
ResetIndexForTheSpecifiedBinaryPanelBarButtonObject | Moves a button to a given position among the bar's child controls. |
SelectBinaryPanelBarButton | Selects the button at a position in Items, as a click on it would. |
SelectBinaryPanelBarButton | Selects a button, as a click on it would. |
ShowSpecifiedBinaryPanelBarButtonsInMainViewList | Shows the given buttons as large buttons in the stack and moves every other button to the icon strip. |
WndProc | Processes the window messages, keeping a band along the right and bottom edges for the drop shadow and painting the shadow into it. |
| Events | |
AboutToCollapseOrExpand | Occurs when the header strip is clicked while collapsing is on, before the bar collapses or expands; the handler can cancel it. |
BinaryPanelBarButtonClicked | Occurs when a button becomes the selected one – clicked in the stack, clicked as an icon in the strip, or selected from code. |
BinaryPanelBarButtonContainedPanelAppliedOrChanged | Occurs when a page is given to a button already on the bar, through
BinaryPanelBarButton.ContainedPanel. |
BinaryPanelBarButtonImageChanged | Occurs when a button's BinaryPanelBarButton.ButtonImage or
BinaryPanelBarButton.ButtonSmallImage changes. |
BinaryPanelBarButtonNotAvailableForUseChanged | Occurs after a button has been made available or unavailable. |
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. |
BinaryPanelBarButtonTextChanged | Occurs when a button's BinaryPanelBarButton.ButtonText changes. |
BinaryPanelBarButtonVisibleChanged | Occurs when a button moves between the stack and the icon strip, or is hidden – when its
Control.Visible changes. |
CollapseExpandButtonClicked | Occurs after the user has collapsed or expanded the bar with the arrow in the header strip. |
ContextMenuShowNavigationPaneOptionsClicked | Occurs when the user chooses "Navigation Pane Options..." from the chevron menu, before the built-in dialog opens. |
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. |
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 | 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 | Occurs after XPThemeToEmulate has been applied. |
XpThemeChanging | Occurs before XPThemeToEmulate is applied; the handler can keep the current theme. |
Constructors
BinaryPanelBar
Initialises a new, empty BinaryPanelBar with the olive XP theme, a thin border and one
large button shown.
Properties
BorderStyle
Gets the standard Windows border, which is always BorderStyle.None;
assigned values are ignored.
Remarks
Use ControlBorderStyle for the bar's border.
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
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
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
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
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
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
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
Gets or sets the colour of the collapse and expand arrow in the header strip.
- Value
- The default is
Color.Black.
See also
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 inSystemColors.WindowText.
See also
ControlInCollapsedMode
Gets or sets whether the bar is collapsed to a narrow rail at its docked edge.
- Value
truewhile the bar is collapsed. The default isfalse.
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
Gets the button most recently selected – by the user, from code, or automatically when the bar loads.
- Value
- The button, or
nulluntil one has been selected.
Remarks
Unlike SelectedButton, this keeps its value when the button is deselected with
DeSelectBinaryPanelBarButton().
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 inContextMenuChevronColor.
See also
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
Gets or sets the colour of the drop shadow.
- Value
- The default is
Color.Black. The colour's alpha component is ignored;DropShadowOpacitysets the strength. - Designer category
- Appearance
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
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
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; assigningXPThemeToEmulatesets it to the theme's second colour.
See also
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 usesStartColor.
Remarks
Used only while XPThemeToEmulate is XPTheme.None; each XP theme
has a gripper colour of its own.
See also
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
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
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
Gets a new list of the section buttons on the bar.
- Value
- An
ArrayListofBinaryPanelBarButtonobjects 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
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
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
Gets or sets the colour of the text in the header strip.
- Value
- The default is
SystemColors.WindowText.
Remarks
With PanelBarItemColorRenderingStyle.WindowsOSThemeSettings under high
contrast the text is always SystemColors.WindowText.
See also
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.
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
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
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
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
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
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.Fontwhen the bar was created;nulluses the bar's current font.
Remarks
Takes effect the next time the rail is drawn.
PanelWindowTextWhenGripperIsOnMove
Gets or sets the text shown up the collapsed rail while the user drags the gripper.
- Value
- The default is
"Working...".
ReflectCurrentXPThemeColorOnLoad
Gets or sets whether the bar chooses its XPThemeToEmulate from the Windows visual style
when its window is created.
- Value
trueto follow the system on creation. The default isfalse.- 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
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
trueto offer collapsing. The default isfalse.
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 openSee also
SelectedButton
Gets the selected button – the one whose page the bar is showing.
- Value
- The selected
BinaryPanelBarButton. When none is selected, the last button inItems;nullonly when the bar has no buttons.
See also
ShouldAutoResetFocusToControlAfterPopupWindowHide
Gets or sets whether the bar takes the keyboard focus back when the flyout opened from the collapsed rail closes.
- Value
trueto focus the bar. The default isfalse.
Remarks
Useful when the bar is on a tool window, which otherwise loses the focus when the flyout closes.
ShouldDrawDropShadow
Gets or sets whether a soft shadow is drawn along the bar's bottom and right edges.
- Value
trueto draw the shadow. The default isfalse.- 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
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
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; assigningXPThemeToEmulatesets 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
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
Gets or sets whether the bar follows the Windows visual style, choosing its
XPThemeToEmulate from it now and whenever the system colours change.
- Value
trueto follow the system. The default isfalse.- 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
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
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
trueto raise it. The default istrue.
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
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
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.ContainedPanelfirst.
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
Draws a button as not selected.
Parameters
theObject- The button.
nullis ignored.
Remarks
No other button is selected in its place, the page shown does not change and no event is raised.
DeSelectBinaryPanelBarButton
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
Releases the resources the bar uses.
Parameters
disposingtrueto release managed resources as well as unmanaged ones.
GetPanelButtonAt
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
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
Makes every button on the bar available.
See also
MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons
Makes the given buttons available and every other button unavailable, for example to match the sections a user's role allows.
Parameters
buttonObjects- The
BinaryPanelBarButtonobjects to keep available.
Remarks
Each change goes through BinaryPanelBarButton.NotAvailableForUse, so
BinaryPanelBarButtonNotAvailableForUseChanging can refuse it.
Example
if (!currentUser.IsManager)
navigation.MakeAvailableForUseOnlyTheSpecifiedBinaryPanelBarButtons(
new ArrayList { mailButton, calendarButton });MoveDownByOneIndexTheSpecifiedBinaryPanelBarButtonObject
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
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
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
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
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
Raises the Control.Paint event, then draws the border that
ControlBorderStyle chooses.
Parameters
e- The data for the event.
OnParentBackColorChanged
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
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
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
Raises the Control.SystemColorsChanged event, and applies the system's theme again when
UpdateWhenSystemColorsChanges is on.
Parameters
e- The data for the event.
RemoveBinaryPanelBarButton
Removes a section button from the bar.
Parameters
tempObject- The button to remove.
nullis 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
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
Makes one button available or unavailable.
Parameters
theObject- The button. Must not be
null. makeItAvailabletrueto make it available;falseto hide it from the stack and the icon strip.
Remarks
Does the same as setting the button's BinaryPanelBarButton.NotAvailableForUse.
ResetIndexForTheSpecifiedBinaryPanelBarButtonObject
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
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
Selects a button, as a click on it would.
Parameters
theObject- The button.
nullis 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
Shows the given buttons as large buttons in the stack and moves every other button to the icon strip.
Parameters
theObjectsToShow- The
BinaryPanelBarButtonobjects to show in the stack.
Remarks
HowManyPanelButtonsToShow is not changed.
WndProc
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
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
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
Occurs when a page is given to a button already on the bar, through
BinaryPanelBarButton.ContainedPanel.
Remarks
The sender is the button.
BinaryPanelBarButtonImageChanged
Occurs when a button's BinaryPanelBarButton.ButtonImage or
BinaryPanelBarButton.ButtonSmallImage changes.
Remarks
The sender is the button; the EventArgs argument is EventArgs.Empty.
BinaryPanelBarButtonNotAvailableForUseChanged
Occurs after a button has been made available or unavailable.
Remarks
The sender is the BinaryPanelBarButton.
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
Occurs when a button's BinaryPanelBarButton.ButtonText changes.
Remarks
The sender is the button; the EventArgs argument is EventArgs.Empty.
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
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.
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.
XpThemeChanged
Occurs after XPThemeToEmulate has been applied.
Remarks
The handler receives the theme in use before the assignment and the theme just applied.
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.