Overview

Namespace: TheTechIdea.Beep.Winform.Controls.Design.Server.Designers
Inheritance: BaseBeepControlDesigner | Visibility: public sealed

BeepMenuBarDesigner provides the design-time experience for BeepMenuBar. It wraps all property mutations in DesignerTransaction with IComponentChangeService notifications for clean undo support and .designer.cs serialization. The smart-tag (BeepMenuBarActionList) exposes 5 properties, item manipulation actions, style presets, and height presets.

BeepMenuBarDesigner

MemberSignatureDescription
MenuBarBeepMenuBar? (get)Casts Component to BeepMenuBar
GetControlSpecificActionLists()overrideReturns new BeepMenuBarActionList(this)
ExecuteAction(desc, Action)internal voidWraps action in DesignerTransaction + IComponentChangeService, commits on success, cancels on exception, then calls RefreshDesignerActionUI()
SetPropertyWithTransaction(name, value, desc)internal voidSame transaction pattern for per-property writes. Uses TypeDescriptor to read/write. No-op when old==new.

Transaction-Wrapped Mutations

internal void SetPropertyWithTransaction(string name, object? value, string desc)
{
    var prop = TypeDescriptor.GetProperties(MenuBar)[name];
    var old = prop.GetValue(MenuBar);
    if (Equals(old, value)) return;

    using (var tx = DesignerHost.CreateTransaction(desc))
    {
        ChangeService.OnComponentChanging(MenuBar, prop);
        prop.SetValue(MenuBar, value);
        ChangeService.OnComponentChanged(MenuBar, prop, old, value);
        tx.Commit();
    }
    RefreshDesignerActionUI();
}

BeepMenuBarActionList — Smart-Tag

Properties

PropertyTypeCategoryDescription
ItemCountintItemsNumber of top-level menu items (read-only)
ControlStyleBeepControlStyleStyleVisual style of top-level menu items
HeightintLayoutMenu bar height in pixels
TextFontFont?AppearanceFont for menu item text
ShowImageboolAppearanceToggle per-item image/icon column

Action Methods

MethodDescription
LoadSampleMenuItems()Populates the menu bar with a representative sample menu tree (File > New/Open/Save + separator + Exit, Edit > Undo/Redo/Cut/Copy/Paste, Help > About)
ClearAllItems()Removes every top-level item from the menu bar
SetMaterialStyle()Sets ControlStyle to Material3
SetFluentStyle()Sets ControlStyle to Fluent2
SetOfficeStyle()Sets ControlStyle to Office
SetStandardHeight()Sets Height to 44 px
SetCompactHeight()Sets Height to 32 px
SetComfortableHeight()Sets Height to 56 px

Smart-Tag Sections (4 Sections, 16 Items)

SectionItems
ItemsLoad Sample Items (action), Clear All Items (action), Item Count (read-only)
StyleSet Material 3 Style (action), Set Fluent 2 Style (action), Set Office Style (action), Control Style (property)
LayoutStandard 44px (action), Compact 32px (action), Comfortable 56px (action), Height (property)
AppearanceText Font (property), Show Image (property)

Examples

// At design time, use smart-tag:
// Smart-tag > Items > "Load Sample Items"
// -> Creates File/Edit/Help menu structure with icons and shortcuts

// Smart-tag > Layout > "Compact (32 px)"
// -> Sets Height=32 for a compact toolbar appearance

// Equivalent at runtime:
var menu = new BeepMenuBar();
menu.ControlStyle = BeepControlStyle.Material3;
menu.Height = 44;
menu.ShowImage = true;
menu.Items.Add(new BeepMenuItem("File", null, new List<BeepMenuItem>
{
    new BeepMenuItem("New", Icons.NewFile, () => NewFile()),
    new BeepMenuItem("Open", Icons.OpenFolder, () => OpenFile()),
    new BeepMenuItem("Save", Icons.Save, () => SaveFile()),
    new BeepMenuSeparator(),
    new BeepMenuItem("Exit", null, () => Application.Exit())
}));