Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- completing checks for ?.Invoke( usages #1046

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void StorePages(string[]? uniqueNames)
{
// If a matching page exists and it is not a store placeholder already
KryptonPage? page = Pages[uniqueName];
if ((page is { } and not KryptonStorePage))
if ((page is not null and not KryptonStorePage))
{
// Notify that we are storing a page, so handlers can ensure it will be unique to the auto hidden location
OnStoringPage(new UniqueNameEventArgs(page.UniqueName));
Expand All @@ -132,7 +132,7 @@ public void RestorePages(KryptonPage[] pages)
foreach (KryptonPage page in pages)
{
// If a matching page exists and it is not a store placeholder already
if (page.UniqueName != null)
if (!string.IsNullOrWhiteSpace(page.UniqueName))
{
KryptonPage? storePage = Pages[page.UniqueName];
if (storePage is KryptonStorePage)
Expand All @@ -151,10 +151,7 @@ public void RestorePages(KryptonPage[] pages)
/// Raises the StoringPage event.
/// </summary>
/// <param name="e">An StorePageEventArgs containing the event data.</param>
protected virtual void OnStoringPage(UniqueNameEventArgs e)
{
StoringPage?.Invoke(this, e);
}
protected virtual void OnStoringPage(UniqueNameEventArgs e) => StoringPage?.Invoke(this, e);

/// <summary>
/// Raises the TabCountChanged event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public override KryptonContextMenu? KryptonContextMenu
/// <summary>
/// Gets and sets the unique name of the page.
/// </summary>
[DisallowNull]
public override string UniqueName
{
get => Page?.UniqueName ?? string.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public class KryptonAutoHiddenSlidePanel : KryptonPanel,
private readonly KryptonAutoHiddenPanel _panel;
private KryptonAutoHiddenGroup? _group;
private readonly KryptonDockspaceSlide _dockspaceSlide;
private readonly EventHandler _checkMakeHidden;
private readonly KryptonPanel _inner;
private readonly EventHandler? _checkMakeHidden;
private readonly KryptonPanel? _inner;
private readonly Button _dummyTarget;
private DockingAutoHiddenShowState _state;
private Rectangle _startRect;
Expand Down Expand Up @@ -587,7 +587,9 @@ protected override void OnLeave(EventArgs e)
// during its operation. Doing so can cause problems with the mouse down not working when
// that is the cause of the leave event. Plus the focus might enter here again before the
// next windows message.
if (IsHandleCreated)
if (IsHandleCreated
&& _checkMakeHidden != null
)
{
BeginInvoke(_checkMakeHidden);
}
Expand Down Expand Up @@ -913,28 +915,21 @@ private void OnDockspaceCellLosesFocus(object sender, WorkspaceCellEventArgs e)
case DockingAutoHiddenShowState.SlidingIn:
// No sliding required, nothing to do
break;

case DockingAutoHiddenShowState.SlidingOut:
case DockingAutoHiddenShowState.Showing:
MakeSlideIn();
break;
}
}

private void OnControlSizeChanged(object sender, EventArgs e)
{
private void OnControlSizeChanged(object sender, EventArgs e) =>
// Change in parent control size means we always hide
MakeHidden();
}

private void OnDockspaceSeparatorMoving(object sender, SplitterCancelEventArgs e)
{
SplitterMoving?.Invoke(sender, e);
}
private void OnDockspaceSeparatorMoving(object sender, SplitterCancelEventArgs e) => SplitterMoving?.Invoke(sender, e);

private void OnDockspaceSeparatorMoved(object sender, SplitterEventArgs e)
{
SplitterMoved?.Invoke(sender, e);
}
private void OnDockspaceSeparatorMoved(object sender, SplitterEventArgs e) => SplitterMoved?.Invoke(sender, e);

private void OnDockspaceSeparatorMoveRect(object sender, SplitterMoveRectMenuArgs e)
{
Expand All @@ -947,15 +942,9 @@ private void OnDockspaceSeparatorMoveRect(object sender, SplitterMoveRectMenuArg
SplitterMoveRect?.Invoke(sender, e);
}

private void OnDockspacePageCloseClicked(object sender, UniqueNameEventArgs e)
{
PageCloseClicked?.Invoke(sender, e);
}
private void OnDockspacePageCloseClicked(object sender, UniqueNameEventArgs e) => PageCloseClicked?.Invoke(sender, e);

private void OnDockspacePageAutoHiddenClicked(object sender, UniqueNameEventArgs e)
{
PageAutoHiddenClicked?.Invoke(sender, e);
}
private void OnDockspacePageAutoHiddenClicked(object sender, UniqueNameEventArgs e) => PageAutoHiddenClicked?.Invoke(sender, e);

private void OnDockspacePageDropDownClicked(object sender, CancelDropDownEventArgs e)
{
Expand All @@ -966,10 +955,7 @@ private void OnDockspacePageDropDownClicked(object sender, CancelDropDownEventAr
PageDropDownClicked?.Invoke(sender, e);
}

private void OnAutoHiddenShowingStateChanged(AutoHiddenShowingStateEventArgs e)
{
AutoHiddenShowingStateChanged?.Invoke(this, e);
}
private void OnAutoHiddenShowingStateChanged(AutoHiddenShowingStateEventArgs e) => AutoHiddenShowingStateChanged?.Invoke(this, e);
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,19 @@ public KryptonDockableNavigator()
/// Raises the CellPageInserting event.
/// </summary>
/// <param name="e">An KryptonPageEventArgs containing the event data.</param>
protected virtual void OnCellPageInserting(KryptonPageEventArgs e)
{
CellPageInserting?.Invoke(this, e);
}
protected virtual void OnCellPageInserting(KryptonPageEventArgs e) => CellPageInserting?.Invoke(this, e);

/// <summary>
/// Raises the PageDropDownClicked event.
/// </summary>
/// <param name="e">An CancelDropDownEventArgs containing the event data.</param>
protected virtual void OnPageDropDownClicked(CancelDropDownEventArgs e)
{
PageDropDownClicked?.Invoke(this, e);
}
protected virtual void OnPageDropDownClicked(CancelDropDownEventArgs e) => PageDropDownClicked?.Invoke(this, e);
#endregion

#region Private
private void OnPagesInserting(object sender, TypedCollectionEventArgs<KryptonPage> e)
{
private void OnPagesInserting(object sender, TypedCollectionEventArgs<KryptonPage> e) =>
// Generate event so the docking element can decide on extra actions to be taken
OnCellPageInserting(new KryptonPageEventArgs(e.Item, e.Index));
}

private void OnShowContextMenu(object sender, ShowContextMenuArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ protected override void OnActiveCellChanged(ActiveCellChangedEventArgs e)
#region Implementation
private void OnCellCloseAction(object sender, CloseActionEventArgs e)
{
if (e.Item?.UniqueName != null)
if (!string.IsNullOrWhiteSpace(e.Item?.UniqueName))
{
OnPageCloseClicked(new UniqueNameEventArgs(e.Item.UniqueName));
OnPageCloseClicked(new UniqueNameEventArgs(e.Item!.UniqueName));
}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,13 @@ protected override void WndProc(ref Message m)
/// Raises the WindowCloseClicked event.
/// </summary>
/// <param name="e">An UniqueNamesEventArgs that contains the event data.</param>
protected virtual void OnWindowCloseClicked(UniqueNamesEventArgs e)
{
WindowCloseClicked?.Invoke(this, e);
}
protected virtual void OnWindowCloseClicked(UniqueNamesEventArgs e) => WindowCloseClicked?.Invoke(this, e);

/// <summary>
/// Raises the WindowCaptionDragging event.
/// </summary>
/// <param name="e">An ScreenAndOffsetEventArgs that contains the event data.</param>
protected virtual void OnWindowCaptionDragging(ScreenAndOffsetEventArgs e)
{
WindowCaptionDragging?.Invoke(this, e);
}
protected virtual void OnWindowCaptionDragging(ScreenAndOffsetEventArgs e) => WindowCaptionDragging?.Invoke(this, e);

/// <summary>
/// Raises the Load event.
Expand Down Expand Up @@ -217,21 +211,15 @@ protected override void OnDeactivate(EventArgs e)
private void OnFloatspaceCellCountChanged(object sender, EventArgs e)
{
// When all the cells (and so pages) have been removed we kill ourself
if (FloatspaceControl != null && FloatspaceControl.CellCount == 0)
if (FloatspaceControl is { CellCount: 0 })
{
FloatspaceControl.Dispose();
}
}

private void OnFloatspaceCellVisibleCountChanged(object sender, EventArgs e)
{
UpdateCellSettings();
}
private void OnFloatspaceCellVisibleCountChanged(object sender, EventArgs e) => UpdateCellSettings();

private void OnTabVisibleCountChanged(object sender, EventArgs e)
{
UpdateCellSettings();
}
private void OnTabVisibleCountChanged(object sender, EventArgs e) => UpdateCellSettings();

private void OnFloatspaceCellAdding(object sender, WorkspaceCellEventArgs e)
{
Expand All @@ -242,23 +230,17 @@ private void OnFloatspaceCellAdding(object sender, WorkspaceCellEventArgs e)
ClientSize = MinimumSize;
}

private void OnFloatspaceCellRemoved(object sender, WorkspaceCellEventArgs e)
{
e.Cell.TabVisibleCountChanged -= OnTabVisibleCountChanged!;
}
private void OnFloatspaceCellRemoved(object sender, WorkspaceCellEventArgs e) => e.Cell.TabVisibleCountChanged -= OnTabVisibleCountChanged!;

private void OnLayoutWorkspace(object sender, EventArgs e)
{
FloatspaceControl?.PerformNeedPaint(true);
}
private void OnLayoutWorkspace(object sender, EventArgs e) => FloatspaceControl?.PerformNeedPaint(true);

private void UpdateCellSettings()
{
KryptonWorkspaceCell? cell = FloatspaceControl?.FirstVisibleCell();
if (cell != null)
{
// If there is only a single cell inside the floating window
if (FloatspaceControl.CellVisibleCount <= 1)
if (FloatspaceControl!.CellVisibleCount <= 1)
{
// Cell display mode depends on the number of tabs in the cell
cell.NavigatorMode = cell.Pages.VisibleCount == 1 ? NavigatorMode.HeaderGroup : NavigatorMode.HeaderGroupTab;
Expand Down
Loading