/// <summary>Adds a button to the form.</summary> /// <param name="caption">The caption to display on the button.</param> /// <param name="clickHandler">The click event handler.</param> /// <param name="buttonWidth">Width of the button.</param> public SimpleButton AddButton(string caption, MultiControlEventHandler clickHandler, int buttonWidth = -1) { var btn = new Button() { Dock = DockStyle.Left, Text = caption, TextAlign = ContentAlignment.MiddleCenter }; // set the button's width if (buttonWidth > 0) { btn.Width = buttonWidth; } else { btn.AutoSize = true; btn.AutoSizeMode = AutoSizeMode.GrowOnly; btn.MinimumSize = new Size(Math.Max(btn.Size.Width, btn.PreferredSize.Width), 0); btn.MaximumSize = new Size(0, Math.Max(btn.Size.Height, btn.PreferredSize.Height)); } this.Form.AddToControls(btn); var sbtn = new SimpleButton(btn); if (clickHandler != null) btn.Click += (o, e) => clickHandler.Invoke(sbtn); return sbtn; }
/// <summary>Adds a button to the form.</summary> /// <param name="caption">The caption to display on the button.</param> /// <param name="clickHandler">The click event handler.</param> /// <param name="buttonWidth">Width of the button.</param> public SimpleButton AddButton(string caption, MultiControlEventHandler clickHandler, int buttonWidth = -1) { var btn = new Button() { Dock = DockStyle.Left, Text = caption, TextAlign = ContentAlignment.MiddleCenter }; // set the button's width if (buttonWidth > 0) { btn.Width = buttonWidth; } else { btn.AutoSize = true; btn.AutoSizeMode = AutoSizeMode.GrowOnly; btn.MinimumSize = new Size(Math.Max(btn.Size.Width, btn.PreferredSize.Width), 0); btn.MaximumSize = new Size(0, Math.Max(btn.Size.Height, btn.PreferredSize.Height)); } this.Form.AddToControls(btn); var sbtn = new SimpleButton(btn); if (clickHandler != null) { btn.Click += (o, e) => clickHandler.Invoke(sbtn); } return(sbtn); }
/// <summary>Creates timer associated with the form.</summary> /// <param name="interval"> /// The interval in milliseconds between consecutive ticks of the timer. /// </param> /// <param name="tickHandler">The event handler for the timer's tick.</param> /// <returns></returns> private SimpleTimer CreateTimer(int interval, MultiControlEventHandler tickHandler) { var tmr = new Timer() { Interval = interval }; var sTmr = new SimpleTimer(tmr); timers.Add(tmr); tmr.Tick += (o, e) => tickHandler(sTmr); return(sTmr); }
/// <summary>Creates timer associated with the form.</summary> /// <param name="interval"> /// The interval in milliseconds between consecutive ticks of the timer. /// </param> /// <param name="tickHandler">The event handler for the timer's tick.</param> /// <returns></returns> private SimpleTimer CreateTimer(int interval, MultiControlEventHandler tickHandler) { var tmr = new Timer() { Interval = interval }; var sTmr = new SimpleTimer(tmr); timers.Add(tmr); tmr.Tick += (o, e) => tickHandler(sTmr); return sTmr; }