Updates to DropDownPanel, Baseline, & Controls
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -15,7 +14,7 @@ namespace AT.STO.UI.Win
|
||||
{
|
||||
#region Private Variable Declarations
|
||||
private IDropDownAware _dropDownControl = null;
|
||||
private DropDownWindowHelper _dropDownHelper = null;
|
||||
private readonly DropDownWindowHelper _dropDownHelper = null;
|
||||
private Form _owner = null;
|
||||
#endregion
|
||||
#region Constructor / Destructor
|
||||
@@ -47,7 +46,7 @@ namespace AT.STO.UI.Win
|
||||
/// <param name="e"></param>
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
_owner = this.FindForm();
|
||||
_owner = FindForm();
|
||||
_dropDownHelper.ReleaseHandle();
|
||||
|
||||
if (_owner != null)
|
||||
@@ -66,8 +65,8 @@ namespace AT.STO.UI.Win
|
||||
{
|
||||
base.OnResize(e);
|
||||
combo.Location = new Point(0, 0);
|
||||
combo.Width = this.ClientRectangle.Width;
|
||||
this.Height = combo.Height;
|
||||
combo.Width = ClientRectangle.Width;
|
||||
Height = combo.Height;
|
||||
}
|
||||
#endregion
|
||||
#region Event Handler
|
||||
@@ -96,7 +95,7 @@ namespace AT.STO.UI.Win
|
||||
else
|
||||
{
|
||||
_dropDownHelper.CloseDropDown();
|
||||
this.Focus();
|
||||
Focus();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ namespace AT.STO.UI.Win
|
||||
|
||||
private void DropDownHelper_DropDownCancel(object sender, DropDownCancelEventArgs e)
|
||||
{
|
||||
if (this.Bounds.Contains(Parent.PointToClient(e.CursorLocation)))
|
||||
if (Bounds.Contains(Parent.PointToClient(e.CursorLocation)))
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
@@ -137,31 +136,22 @@ namespace AT.STO.UI.Win
|
||||
{
|
||||
SetValue<long>(e.Value as ILookupItem<long>);
|
||||
}
|
||||
|
||||
if (this.FinishEditing != null)
|
||||
{
|
||||
this.FinishEditing(this, e);
|
||||
}
|
||||
|
||||
_dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing);
|
||||
|
||||
FinishEditing?.Invoke(this, e);
|
||||
|
||||
_dropDownControl.FinishEditing -= new DropDownValueChangedEventHandler(DropDown_FinishEditing);
|
||||
_dropDownControl.ValueChanged -= new DropDownValueChangedEventHandler(DropDown_ValueChanged);
|
||||
_dropDownHelper.CloseDropDown();
|
||||
}
|
||||
|
||||
private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e)
|
||||
{
|
||||
if (this.ValueChanged != null)
|
||||
{
|
||||
this.ValueChanged(this, e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Get or set the control (has to implement IDropDownAware) that is to
|
||||
/// be displayed as the dropdown portion of the combobox.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
|
||||
private void DropDown_ValueChanged(object sender, DropDownValueChangedEventArgs e) => ValueChanged?.Invoke(this, e);
|
||||
#endregion
|
||||
#region Public Properties
|
||||
/// <summary>
|
||||
/// Get or set the control (has to implement IDropDownAware) that is to
|
||||
/// be displayed as the dropdown portion of the combobox.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public IDropDownAware DropDownControl
|
||||
{
|
||||
get { return _dropDownControl; }
|
||||
@@ -169,24 +159,21 @@ namespace AT.STO.UI.Win
|
||||
{
|
||||
_dropDownControl = value;
|
||||
|
||||
this.Controls.Add(_dropDownControl as Control);
|
||||
Controls.Add(_dropDownControl as Control);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Public Methods
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Name;
|
||||
}
|
||||
#endregion
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Calculate an acceptable position of the DropDownForm even in a
|
||||
/// multi screen environment.
|
||||
/// </summary>
|
||||
/// <param name="DropDown"></param>
|
||||
/// <returns></returns>
|
||||
private Point GetDropDownPosition(DropDownForm DropDown)
|
||||
#endregion
|
||||
#region Public Methods
|
||||
public override string ToString() => Name;
|
||||
#endregion
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Calculate an acceptable position of the DropDownForm even in a
|
||||
/// multi screen environment.
|
||||
/// </summary>
|
||||
/// <param name="DropDown"></param>
|
||||
/// <returns></returns>
|
||||
private Point GetDropDownPosition(DropDownForm DropDown)
|
||||
{
|
||||
Point lt = Parent.PointToScreen(new Point(Left, Top));
|
||||
Point rb = Parent.PointToScreen(new Point(Right, Bottom));
|
||||
|
||||
Reference in New Issue
Block a user