Updates to DropDownPanel, Baseline, & Controls

This commit is contained in:
2026-08-05 15:16:53 -04:00
parent 6f0fcdded2
commit 6d7d127b63
14 changed files with 356 additions and 453 deletions
+28 -40
View File
@@ -13,22 +13,19 @@ namespace AT.STO.UI.Win
internal partial class DropDownForm : Form, IDropDownAware
{
#region Private Variable Declaration
private IDropDownAware _control = null;
#endregion
#region Constructor / Destructor
/// <summary>
/// Default Constructor
/// </summary>
public DropDownForm()
{
InitializeComponent();
}
private readonly IDropDownAware _control = null;
#endregion
#region Constructor / Destructor
/// <summary>
/// Default Constructor
/// </summary>
public DropDownForm() => InitializeComponent();
/// <summary>
/// Constructor to initialize the for with the control to display.
/// </summary>
/// <param name="Ctrl">The control to display.</param>
public DropDownForm(IDropDownAware Ctrl) : this()
/// <summary>
/// Constructor to initialize the for with the control to display.
/// </summary>
/// <param name="Ctrl">The control to display.</param>
public DropDownForm(IDropDownAware Ctrl) : this()
{
if (Ctrl != null)
{
@@ -41,7 +38,7 @@ namespace AT.STO.UI.Win
#region Form Events
protected override void OnClosing(CancelEventArgs e)
{
this.Controls.Remove(_control as Control);
Controls.Remove(_control as Control);
base.OnClosing(e);
}
@@ -58,29 +55,20 @@ namespace AT.STO.UI.Win
#region Event Handler
private void Ctrl_FinishEditing(object sender, DropDownValueChangedEventArgs e)
{
if (this.FinishEditing != null)
{
this.FinishEditing(this, e);
}
FinishEditing?.Invoke(this, e);
_control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing);
_control.FinishEditing -= new DropDownValueChangedEventHandler(Ctrl_FinishEditing);
_control.ValueChanged -= new DropDownValueChangedEventHandler(Ctrl_ValueChanged);
}
private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e)
{
if (this.ValueChanged != null)
{
this.ValueChanged(this, e);
}
}
#endregion
#region IDropDownAware Implementation
/// <summary>
/// Fired either on OK, Cancel or a click outside the control to indicate
/// that the user has finished editing.
/// </summary>
public event DropDownValueChangedEventHandler FinishEditing;
private void Ctrl_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
#endregion
#region IDropDownAware Implementation
/// <summary>
/// Fired either on OK, Cancel or a click outside the control to indicate
/// that the user has finished editing.
/// </summary>
public event DropDownValueChangedEventHandler FinishEditing;
/// <summary>
/// Fired on any change of the controls's value during the editing process.
@@ -100,15 +88,15 @@ namespace AT.STO.UI.Win
private void InitializeControl(Control Ctrl)
{
Size size = Ctrl.Size;
Size inner = this.ClientRectangle.Size;
Size outer = this.Size;
Size inner = ClientRectangle.Size;
Size outer = Size;
int gap = outer.Width - inner.Width;
size.Width += gap;
size.Height += gap;
this.Size = size;
this.Controls.Add(Ctrl);
Size = size;
Controls.Add(Ctrl);
Ctrl.Location = new Point(0, 0);
Ctrl.Visible = true;
Ctrl.Invalidate();