Skip to content

Commit

Permalink
WatchItem - Fixed Linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan-Kudri committed Feb 18, 2024
1 parent c7b37f0 commit 34fbf71
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ public CheckBoxComboBoxItem this[string displayName]
protected void OnCheckBoxCheckedChanged(object sender, EventArgs e)
=> CheckBoxCheckedChanged?.Invoke(sender, e);

private void Item_CheckedChanged(object sender, EventArgs e)
=> OnCheckBoxCheckedChanged(sender, e);

[Obsolete("Do not add items to this list directly. Use the ComboBox items instead.", false)]
public new void Add(CheckBoxComboBoxItem item)

Check warning on line 75 in WatchList.WinForms/Control/CheckComboBox/Component/CheckBoxComboBoxItemList.cs

View workflow job for this annotation

GitHub Actions / Lint

'public' members should come before 'protected' members
{
Expand Down Expand Up @@ -107,5 +104,8 @@ private void Item_CheckedChanged(object sender, EventArgs e)
item.CheckedChanged -= Item_CheckedChanged;
return base.Remove(item);
}

private void Item_CheckedChanged(object sender, EventArgs e)
=> OnCheckBoxCheckedChanged(sender, e);
}
}
146 changes: 58 additions & 88 deletions WatchList.WinForms/Control/CheckComboBox/Popup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Control Content
}

/// <summary>
/// Gets a value indicating whether the <see cref="PopupControl.Popup"/> uses the fade effect.
/// Gets or sets a value indicating whether the <see cref="PopupControl.Popup"/> uses the fade effect.
/// </summary>
/// <value><c>true</c> if pop-up uses the fade effect; otherwise, <c>false</c>.</value>
/// <remarks>To use the fade effect, the FocusOnOpen property also has to be set to <c>true</c>.</remarks>
Expand All @@ -39,73 +39,33 @@ public bool UseFadeEffect
}
}

private bool _focusOnOpen = true;

/// <summary>
/// Gets or sets a value indicating whether to focus the content after the pop-up has been opened.
/// </summary>
/// <value><c>true</c> if the content should be focused after the pop-up has been opened; otherwise, <c>false</c>.</value>
/// <remarks>If the FocusOnOpen property is set to <c>false</c>, then pop-up cannot use the fade effect.</remarks>
public bool FocusOnOpen
{
get { return _focusOnOpen; }
set { _focusOnOpen = value; }
}

private bool acceptAlt = true;
public bool FocusOnOpen { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether presing the alt key should close the pop-up.
/// </summary>
/// <value><c>true</c> if presing the alt key does not close the pop-up; otherwise, <c>false</c>.</value>
public bool AcceptAlt
{
get { return acceptAlt; }
set { acceptAlt = value; }
}
public bool AcceptAlt { get; set; } = true;

private Popup _ownerPopup;
private Popup _childPopup;

private bool _resizable;
private bool resizable;
private bool _resizableTop;
private bool _resizableRight;

/// <summary>
/// Gets or sets a value indicating whether this <see cref="PopupControl.Popup" /> is resizable.
/// </summary>
/// <value><c>true</c> if resizable; otherwise, <c>false</c>.</value>
public bool Resizable
{
get { return resizable && _resizable; }
set { resizable = value; }
}
public bool Resizable { get; internal set; }

Check warning on line 65 in WatchList.WinForms/Control/CheckComboBox/Popup.cs

View workflow job for this annotation

GitHub Actions / Lint

Because the property only contains a visible get accessor, the documentation summary text should begin with 'Gets a value indicating whether'.

private readonly ToolStripControlHost _host;

private Size _minSize;

/// <summary>
/// Gets or sets the size that is the lower limit that <see cref="M:System.Windows.Forms.Control.GetPreferredSize(System.Drawing.Size)" /> can specify.
/// </summary>
/// <returns>An ordered pair of type <see cref="T:System.Drawing.Size" /> representing the width and height of a rectangle.</returns>
public new Size MinimumSize
{
get { return _minSize; }
set { _minSize = value; }
}

private Size _maxSize;

/// <summary>
/// Gets or sets the size that is the upper limit that <see cref="M:System.Windows.Forms.Control.GetPreferredSize(System.Drawing.Size)" /> can specify.
/// </summary>
/// <returns>An ordered pair of type <see cref="T:System.Drawing.Size" /> representing the width and height of a rectangle.</returns>
public new Size MaximumSize
{
get { return _maxSize; }
set { _maxSize = value; }
}

/// <summary>
/// Gets parameters of a new window.
/// </summary>
Expand All @@ -122,16 +82,31 @@ protected override CreateParams CreateParams
}

public VisualStyleRenderer SizeGripRenderer { get; set; }

public bool Fade { get; set; }

public DateTime LastClosedTimeStamp = DateTime.Now;

/// <summary>
/// Initializes a new instance of the <see cref="PopupControl.Popup"/> class.
/// Gets or sets the size that is the lower limit that <see cref="M:System.Windows.Forms.Control.GetPreferredSize(System.Drawing.Size)" /> can specify.
/// </summary>
/// <returns>An ordered pair of type <see cref="T:System.Drawing.Size" /> representing the width and height of a rectangle.</returns>
public new Size MinSize { get; private set; }

Check warning on line 94 in WatchList.WinForms/Control/CheckComboBox/Popup.cs

View workflow job for this annotation

GitHub Actions / Lint

Because the property only contains a visible get accessor, the documentation summary text should begin with 'Gets'.

/// <summary>
/// Gets or sets the size that is the upper limit that <see cref="M:System.Windows.Forms.Control.GetPreferredSize(System.Drawing.Size)" /> can specify.
/// </summary>
/// <returns>An ordered pair of type <see cref="T:System.Drawing.Size" /> representing the width and height of a rectangle.</returns>
public new Size MaxSize { get; private set; }

/// <summary>
/// Initializes a new instance of the <see cref="Popup"/> class.
/// </summary>
/// <param name="content">The content of the pop-up.</param>
/// <remarks>
/// Pop-up will be disposed immediately after disposion of the content control.
/// </remarks>
/// <exception cref="T:System.ArgumentNullException"><paramref name="content" /> is <code>null</code>.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="content" /> is.<code>null</code>.</exception>
public Popup(Control? content)
{
if (content == null)
Expand All @@ -141,16 +116,16 @@ public Popup(Control? content)

this.content = content;
Fade = SystemInformation.IsMenuAnimationEnabled && SystemInformation.IsMenuFadeEnabled;
_resizable = true;
Resizable = true;
InitializeComponent();
AutoSize = false;
DoubleBuffered = true;
ResizeRedraw = true;
_host = new ToolStripControlHost(content);
Padding = Margin = _host.Padding = _host.Margin = Padding.Empty;
MinimumSize = content.MinimumSize;
MinSize = content.MinimumSize;
content.MinimumSize = content.Size;
MaximumSize = content.MaximumSize;
MaxSize = content.MaximumSize;
content.MaximumSize = content.Size;
Size = content.Size;
content.Location = Point.Empty;
Expand Down Expand Up @@ -179,7 +154,7 @@ public Popup(Control? content)
/// true if the key was processed by the control; otherwise, false.
/// </returns>
protected override bool ProcessDialogKey(Keys keyData)
=> acceptAlt && ((keyData & Keys.Alt) == Keys.Alt) ? false : base.ProcessDialogKey(keyData);
=> AcceptAlt && ((keyData & Keys.Alt) == Keys.Alt) ? false : base.ProcessDialogKey(keyData);

/// <summary>
/// Updates the pop-up region.
Expand All @@ -205,7 +180,7 @@ protected void UpdateRegion()
/// <remarks>
/// When there is no space below the specified control, the pop-up control is shown above it.
/// </remarks>
/// <exception cref="T:System.ArgumentNullException"><paramref name="control"/> is <code>null</code>.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="control"/> is.<code>null</code>.</exception>
public void Show(Control control)
{
if (control == null)
Expand All @@ -225,7 +200,7 @@ public void Show(Control control)
/// <remarks>
/// When there is no space below specified area, the pop-up control is shown above it.
/// </remarks>
/// <exception cref="T:System.ArgumentNullException"><paramref name="control"/> is <code>null</code>.</exception>
/// <exception cref="T:System.ArgumentNullException"><paramref name="control"/> is.<code>null</code>.</exception>
public void Show(Control control, Rectangle area)
{
if (control == null)
Expand Down Expand Up @@ -265,13 +240,13 @@ public void Show(Control control, Rectangle area)
protected override void SetVisibleCore(bool visible)
{
double opacity = Opacity;
if (visible && Fade && _focusOnOpen)
if (visible && Fade && FocusOnOpen)
{
Opacity = 0;
}

base.SetVisibleCore(visible);
if (!visible || !Fade || !_focusOnOpen)
if (!visible || !Fade || !FocusOnOpen)
{
return;
}
Expand All @@ -289,31 +264,6 @@ protected override void SetVisibleCore(bool visible)
Opacity = opacity;
}

private bool _resizableTop;
private bool _resizableRight;

private void SetOwnerItem(Control control)
{
if (control == null)
{
return;
}

if (control is Popup)
{
Popup popupControl = control as Popup;
_ownerPopup = popupControl;
_ownerPopup._childPopup = this;
OwnerItem = popupControl.Items[0];
return;
}

if (control.Parent != null)
{
SetOwnerItem(control.Parent);
}
}

/// <summary>
/// Raises the <see cref="E:System.Windows.Forms.Control.SizeChanged" /> event.
/// </summary>
Expand Down Expand Up @@ -351,10 +301,10 @@ protected override void OnOpened(EventArgs e)
{
if (_ownerPopup != null)
{
_ownerPopup._resizable = false;
_ownerPopup.Resizable = false;
}

if (_focusOnOpen)
if (FocusOnOpen)
{
content.Focus();
}
Expand All @@ -366,13 +316,33 @@ protected override void OnClosed(ToolStripDropDownClosedEventArgs e)
{
if (_ownerPopup != null)
{
_ownerPopup._resizable = true;
_ownerPopup.Resizable = true;
}

base.OnClosed(e);
}

public DateTime LastClosedTimeStamp = DateTime.Now;
private void SetOwnerItem(Control control)
{
if (control == null)
{
return;
}

if (control is Popup)
{
Popup popupControl = control as Popup;
_ownerPopup = popupControl;
_ownerPopup._childPopup = this;
OwnerItem = popupControl.Items[0];
return;
}

if (control.Parent != null)
{
SetOwnerItem(control.Parent);
}
}

protected override void OnVisibleChanged(EventArgs e)
{
Expand Down Expand Up @@ -436,8 +406,8 @@ private bool InternalProcessResizing(ref Message m, bool contentControl)
private bool OnGetMinMaxInfo(ref Message m)
{
NativeMethods.MINMAXINFO minmax = (NativeMethods.MINMAXINFO)Marshal.PtrToStructure(m.LParam, typeof(NativeMethods.MINMAXINFO));
minmax.maxTrackSize = this.MaximumSize;
minmax.minTrackSize = this.MinimumSize;
minmax.maxTrackSize = this.MaxSize;
minmax.minTrackSize = this.MinSize;
Marshal.StructureToPtr(minmax, m.LParam, false);
return true;
}
Expand Down Expand Up @@ -487,7 +457,7 @@ private bool OnNcHitTest(ref Message m, bool contentControl)
/// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs" /> instance containing the event data.</param>
public void PaintSizeGrip(PaintEventArgs e)
{
if (e == null || e.Graphics == null || !resizable)
if (e == null || e.Graphics == null || !Resizable)
{
return;
}
Expand Down

0 comments on commit 34fbf71

Please sign in to comment.