/// <summary> /// 创建消息框按钮 /// </summary> /// <param name="text">按钮文本</param> /// <param name="shortcut"></param> /// <param name="dialogResult">按钮触发的消息框返回值</param> /// <returns>按钮实例</returns> private static XButton CreateButton(string text, char shortcut, DialogResult dialogResult) { XButton btn = new XButton { Text = text, Size = new Size(ButtonWidth, ButtonHeight), Shortcut = shortcut, RoundedRectangleCornerRadius = 4, BorderColor = Color.White, BorderWidth = 0, StartColor = ButtonStartColor, EndColor = ButtonEndColor, ForeColor = ButtonForeColor, HoldingStartColor = ButtonHoldingStartColor, HoldingEndColor = ButtonHoldingEndColor, HoldingForeColor = ButtonHoldingForeColor }; btn.Click += (s1, e1) => { Form f = ((XButton)s1)?.FindForm(); if (f == null) { return; } f.DialogResult = dialogResult; }; return(btn); }
/// <summary> /// 初始化可下拉按钮的实例 /// </summary> public DropDownButtonItem() { _button = new XButton { Dock = DockStyle.Fill, Location = new System.Drawing.Point(0, 0) }; Caption = Name; Controls.Add(_button); }