HypernovaDesktop Components · docs
Binarymission
WinForms › Panel Bar

Panel Bar

.NET Framework 4.8.NET 6 / 8 / 10v4.0.0WinForms

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.

17public types
156public members
2namespaces

Assembly

AssemblyBinarymission.WinForms.Controls.PanelBar.dll
Root namespaceBinarymission.WinForms.Controls.NavigationControls
Target frameworks.NET Framework 4.8, .NET 6 / 8 / 10
Depends onBinaryMenu

Overview

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.

Getting started

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);
    }
}

API reference

Binarymission.WinForms.Controls.NavigationControls

class BinaryPanelBarAn 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.
class BinaryPanelBarButtonOne section of a BinaryPanelBar: a large button with an image and a title which, when clicked, shows its page of controls - its ContainedPanel - in the bar.
delegate BinaryPanelBarButtonNotAvailableForUseChangingHandlerRepresents the method that handles BinaryPanelBarButtonNotAvailableForUseChanging.
class BinaryPanelBarContainedPanelThe page of a BinaryPanelBarButton: a scrolling panel holding a section's controls, which the BinaryPanelBar shows while that button is selected.
class PanelBarAboutToCollapseOrExpandEventArgsProvides data for AboutToCollapseOrExpand, and lets the handler stop the bar collapsing or expanding.
class PanelBarAddShowNavigationOptionsMenuResourceProviderThe texts of a BinaryPanelBar's chevron menu, settable so that an application can translate the menu.
enum PanelBarBorderStyleSpecifies the border drawn round a BinaryPanelBar or one of its buttons.
class PanelBarCollapseExpandEventArgsProvides data for CollapseExpandButtonClicked.
delegate PanelBarContextMenuShowNavigationPaneOptionsHandlerRepresents the method that handles ContextMenuShowNavigationPaneOptionsClicked.
delegate PanelBarGripperHandleMovedHandlerRepresents the method that handles GripperHandleMoved.
enum PanelBarItemColorRenderingStyleSpecifies how a BinaryPanelBar fills its buttons and header strip.
class PanelBarNavigationOptionsCarries the data of ContextMenuShowNavigationPaneOptionsClicked: the bar's buttons, and whether to keep the built-in options dialog closed.
delegate PanelBarXPThemeChangedHandlerRepresents the method that handles XpThemeChanged.
delegate PanelBarXPThemeChangingHandlerRepresents the method that handles XpThemeChanging.
delegate ShowMoreOrFewerPanelBarButtonsMenuItemClickedHandlerRepresents the method that handles ShowMoreButtonsMenuItemClicked and ShowFewerButtonsMenuItemClicked.
enum XPThemeSpecifies the Windows XP palette a BinaryPanelBar is drawn in, or none.

Binarymission.WinForms.Controls.NavigationControls.Designers

class BinaryPanelBarControlActionListSupplies the smart tag panel shown for a BinaryPanelBar on the Windows Forms designer surface: the theme, rendering style, borders, collapsing, gripper and header settings.