/// <summary> /// Initialize a new instance of the ViewLayoutMenuItemsPile class. /// </summary> /// <param name="provider">Provider of context menu values.</param> /// <param name="items">Reference to the owning collection.</param> /// <param name="standardStyle">Draw items with standard or alternate style.</param> /// <param name="imageColumn">Draw an image background for the item images.</param> public ViewLayoutMenuItemsPile(IContextMenuProvider provider, KryptonContextMenuItems items, bool standardStyle, bool imageColumn) { // Cache access to the highlight item palette _paletteItemHighlight = provider.ProviderStateCommon.ItemHighlight; // Create and place an image column inside a docker so it appears on the left side _imageColumn = new ViewDrawMenuImageColumn(items, provider.ProviderStateCommon.ItemImageColumn); ViewLayoutDocker imageDocker = new ViewLayoutDocker { { _imageColumn, ViewDockStyle.Left } }; // Only show the image column when in a standard collection of items imageDocker.Visible = imageColumn; // Create a vertical stack that contains each individual menu item ItemStack = new ViewLayoutStack(false) { FillLastChild = false }; // Use a docker with the item stack as the fill ViewLayoutDocker stackDocker = new ViewLayoutDocker { { ItemStack, ViewDockStyle.Fill } }; // Grab the padding for around the item stack Padding itemsPadding = _paletteItemHighlight.GetMetricPadding(PaletteState.Normal, PaletteMetricPadding.ContextMenuItemsCollection); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Left), ViewDockStyle.Left); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Right), ViewDockStyle.Right); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Top), ViewDockStyle.Top); stackDocker.Add(new ViewLayoutSeparator(itemsPadding.Bottom), ViewDockStyle.Bottom); // The background of the pile is the image column Add(imageDocker); // The foreground of the pile is the stack of menu items Add(stackDocker); }