/// <summary> /// Create new Stacked items at the panel /// </summary> /// <param name="action">Action where you must add items to the stacked panel</param> /// <returns>Panel where stacked items were created</returns> public CustomPanel CreateStackedItems(Action <CustomStackedItem> action) { if (action is null) { throw new ArgumentNullException(nameof(action)); } var stackedItem = new CustomStackedItem(this); action.Invoke(stackedItem); if (stackedItem.ItemsCount < 2 || stackedItem.ItemsCount > 3) { throw new InvalidOperationException("You must create 2 or three items in the StackedItems"); } var item1 = stackedItem.Items[0].GetButtonData(); var item2 = stackedItem.Items[1].GetButtonData(); if (stackedItem.ItemsCount == 3) { var item3 = stackedItem.Items[2].GetButtonData(); try { _panel.AddStackedItems(item1, item2, item3); } catch { } } else { try { _panel.AddStackedItems(item1, item2); } catch { } } return(this); }
public CustomPanel CreateSplitButton(string name, string text, Action <CustomStackedItem> itemsAction) { var buttonControl = new CustomSplitButton(this, name, text); var splitButton = buttonControl.Create(); var stackedItem = new CustomStackedItem(this); itemsAction.Invoke(stackedItem); var pushButtons = stackedItem .Items .Select(x => x.GetItemData()) .Cast <PushButtonData>() .Select(x => splitButton.AddPushButton(x)) .ToList(); splitButton.CurrentButton = pushButtons[stackedItem.GetDefaultButtonIndex()]; return(this); }
//The maxi button of stackedItem accepted is 3 public CustomPanel CreateStackedItems(Action <CustomStackedItem> action) { if (action is null) { throw new ArgumentNullException(nameof(action)); } var stackedItem = new CustomStackedItem(this); action.Invoke(stackedItem); if (stackedItem.ItemsCount < 2 || stackedItem.ItemsCount > 3) { throw new InvalidOperationException("You must create 2 or three items in the StackedItems"); } var item1 = stackedItem.Items[0].GetItemData(); var item2 = stackedItem.Items[1].GetItemData(); IList <RibbonItem> ribbonItems; if (stackedItem.ItemsCount == 3) { RibbonItemData item3 = stackedItem.Items[2].GetItemData(); ribbonItems = _panel.AddStackedItems(item1, item2, item3); } else { ribbonItems = _panel.AddStackedItems(item1, item2); } for (var i = 0; i < stackedItem.Items.Count; ++i) { stackedItem.Items[i].DoPostProcessing(ribbonItems[i]);//? } return(this); }