void init(String text, String caption, ButtonAlign buttonAlign, params String[] buttons) { this.HelpButton = false; this.Text = caption; yPos = 0; maxWid = 0; AddText(text); Panel buttonArea = addButtons(buttonAlign, buttons); int textWid = L_TextArea.Width; int buttonWid = buttonArea.Width; int height = yPos; this.SuspendLayout(); if (textWid > buttonWid) { buttonArea.SetBounds(0, 0, textWid, 0, BoundsSpecified.Width); this.SetBounds(0, 0, textWid + 30, height + 30, BoundsSpecified.Size); } else { this.SetBounds(0, 0, buttonWid + 30, height + 30, BoundsSpecified.Size); } if (buttonAlign == ButtonAlign.Vertical) { ResetChildrenWidth(buttonArea, this.Width - this.Margin.Left - this.Margin.Right); } this.ResumeLayout(); }
public int ShowDialog(String text, String caption, ButtonAlign buttonAlign, params String[] buttons) { _text = text; _caption = caption; _btnAlign = buttonAlign; _buttons = buttons; return(ShowDialog()); }
public MyDialog(String text, String caption, ButtonAlign buttonAlign, params String[] buttons) { InitializeComponent(); _text = text; _caption = caption; _btnAlign = buttonAlign; _buttons = buttons; }
/// <summary> /// Sets button text and align /// </summary> /// <param name="buttonText"></param> /// <param name="buttonAlign"></param> /// <returns></returns> public DialogContextConfigureOptionsBuilder <TContext> HasButton(string buttonText, ButtonAlign buttonAlign) { Base.Data.ButtonAlign = buttonAlign; return(HasButton(buttonText)); }
public Panel addButtons(ButtonAlign buttonAlign, params String[] buttons) { _btnAlign = buttonAlign; _buttons = buttons; Panel panel = P_Buttons; P_Buttons.Controls.Clear(); int width = 80; int margin = 5; int height = 30; int panelHeight; int panelWidth; //P_TopDown.SuspendLayout(); //this.Controls.Add(panel); if (buttonAlign == ButtonAlign.Horizon) { // panel.BorderStyle = BorderStyle.FixedSingle; panelHeight = height + margin; panelWidth = ((width + margin) * buttons.Length); panel.SetBounds(0, yPos, panelWidth, panelHeight); } else { panelHeight = (height + margin) * buttons.Length; panelWidth = width + margin; panel.SetBounds(0, yPos, panelWidth, panelHeight); } panel.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0); panel.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0); panel.SuspendLayout(); for (int i = 0; i < buttons.Length; i++) { Button btn = new Button(); btn.Anchor = AnchorStyles.Left; btn.Text = buttons[i]; if (buttonAlign == ButtonAlign.Horizon) { btn.SetBounds(i * (width + margin), 0, width, height); } else { btn.SetBounds(0, i * (height + margin), width, height); } panel.Controls.Add(btn); btn.Tag = i; btn.Click += new EventHandler(btn_Click); } panel.ResumeLayout(); this.ResumeLayout(); yPos += panelHeight; maxWid = (maxWid < panelWidth) ? panelWidth : maxWid; return(panel); }