Skip to content

Commit

Permalink
Merge pull request #945 from Krypton-Suite/alpha-fr#927
Browse files Browse the repository at this point in the history
Alpha fr#927
  • Loading branch information
Smurf-IV authored Feb 14, 2023
2 parents 7ebfc44 + 928b48d commit 1b90c1c
Show file tree
Hide file tree
Showing 15 changed files with 341 additions and 128 deletions.
44 changes: 44 additions & 0 deletions Scripts/build-nightly-2022-custom.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@echo off

if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin" goto vs17prev
if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin" goto vs17ent
if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin" goto vs17pro
if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin" goto vs17com
if exist "%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin" goto vs17build

echo "Unable to detect suitable environment. Check if VS 2022 is installed."

pause

:vs17prev
set msbuildpath=%ProgramFiles%\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin
goto build

:vs17ent
set msbuildpath=%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin
goto build

:vs17pro
set msbuildpath=%ProgramFiles%\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin
goto build

:vs17com
set msbuildpath=%ProgramFiles%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin
goto build

:vs17build
set msbuildpath=%ProgramFiles%\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin
goto build

:build
for /f "tokens=* usebackq" %%A in (`tzutil /g`) do (
set "zone=%%A"
)

@echo Started: %date% %time% %zone%
@echo
set targets=Build
if not "%~1" == "" set targets=%~1
"%msbuildpath%\msbuild.exe" /t:%targets% nightly.proj /fl /flp:logfile=build.log

@echo Build Completed: %date% %time% %zone%
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class ButtonSpecNavFormClose : ButtonSpecNavFixed

private bool _enabled = true;

private KryptonNavigator _navigator;

#endregion

#region Identity
Expand All @@ -23,13 +25,13 @@ public class ButtonSpecNavFormClose : ButtonSpecNavFixed
/// <param name="navigator">The navigator.</param>
public ButtonSpecNavFormClose(KryptonNavigator navigator) : base(navigator, PaletteButtonSpecStyle.FormClose)
{
_navigator = navigator;
}

#endregion

#region Implementation

/*
/// <summary>
/// Form Close Button Enabled: This will also Disable the System Menu `Close` BUT NOT the `Alt+F4` key action
/// </summary>
Expand All @@ -44,32 +46,66 @@ public bool Enabled
if (_enabled != value)
{
_enabled = value;
IntPtr hSystemMenu = PI.GetSystemMenu(KryptonForm.Handle, false);
IntPtr hSystemMenu = PI.GetSystemMenu(_navigator.Owner!.Handle, false);
if (hSystemMenu != IntPtr.Zero)
{
PI.EnableMenuItem(hSystemMenu, PI.SC_.CLOSE, _enabled ? PI.MF_.ENABLED : PI.MF_.DISABLED);
}
}
}
}
*/

#endregion

#region ButtonSpecNavFixed Implementation

public override bool GetVisible(PaletteBase palette)
{
throw new NotImplementedException();
}
// We do not show if the custom chrome is combined with composition,
// in which case the form buttons are handled by the composition
if (_navigator.Owner!.ApplyComposition && _navigator.Owner.ApplyCustomChrome)
{
return false;
}

public override ButtonCheckState GetChecked(PaletteBase palette)
{
throw new NotImplementedException();
// Have all buttons been turned off?
return _navigator.Owner.ControlBox && _navigator.Owner.CloseBox;
}

public override ButtonEnabled GetEnabled(PaletteBase palette)
public override ButtonCheckState GetChecked(PaletteBase palette) => ButtonCheckState.NotCheckButton;

public override ButtonEnabled GetEnabled(PaletteBase palette) => _navigator.Owner!.CloseBox && Enabled ? ButtonEnabled.True : ButtonEnabled.False;

#endregion

#region Protected Overrides

protected override void OnClick(EventArgs e)
{
throw new NotImplementedException();
if (GetViewEnabled())
{
if (!_navigator.Owner.InertForm)
{
MouseEventArgs mea = (MouseEventArgs)e;

if (GetView().ClientRectangle.Contains(mea.Location))
{
PropertyInfo? propertyInfo = typeof(Form).GetProperty(nameof(CloseReason),
BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.NonPublic);

propertyInfo.SetValue(_navigator.Owner, CloseReason.UserClosing, null);

Point screenPosition = Control.MousePosition;

IntPtr lParam = (IntPtr)(PI.MAKELOWORD(screenPosition.X) | PI.MAKEHIWORD(screenPosition.Y));

// Note: Do I need to make 'SC_' public?
//? Navigator.Owner.SendSysCommand(PI.SC_.CLOSE, lParam);

base.OnClick(e);
}
}
}
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,86 @@ namespace Krypton.Navigator
{
public class ButtonSpecNavFormMaximize : ButtonSpecNavFixed
{
#region Instance Fields

private KryptonNavigator _navigator;

#endregion

#region Identity

/// <summary>Initializes a new instance of the <see cref="ButtonSpecNavFormMaximize" /> class.</summary>
/// <param name="navigator">The navigator.</param>
public ButtonSpecNavFormMaximize(KryptonNavigator navigator) : base(navigator, PaletteButtonSpecStyle.FormMax)
{
_navigator = navigator;
}

#endregion

#region ButtonSpecNavFixed Implementation

public override bool GetVisible(PaletteBase palette)
{
throw new NotImplementedException();
}
// We do not show if the custom chrome is combined with composition,
// in which case the form buttons are handled by the composition
if (_navigator.Owner!.ApplyComposition && _navigator.Owner!.ApplyCustomChrome)
{
return false;
}

public override ButtonCheckState GetChecked(PaletteBase palette)
{
throw new NotImplementedException();
// The maximize button is never present on tool windows
switch (_navigator.Owner!.FormBorderStyle)
{
case FormBorderStyle.FixedToolWindow:
case FormBorderStyle.SizableToolWindow:
return false;
}

// Have all buttons been turned off?
if (!_navigator.Owner!.ControlBox)
{
return false;
}

// Has the minimize/maximize buttons been turned off?
return _navigator.Owner!.MinimizeBox || _navigator.Owner!.MaximizeBox;
}

public override ButtonEnabled GetEnabled(PaletteBase palette)
public override ButtonCheckState GetChecked(PaletteBase palette) => ButtonCheckState.NotCheckButton;

public override ButtonEnabled GetEnabled(PaletteBase palette) =>
// Has the maximize buttons been turned off?
_navigator.Owner!.MaximizeBox ? ButtonEnabled.True : ButtonEnabled.False;

#endregion

#region Protected Overrides

protected override void OnClick(EventArgs e)
{
throw new NotImplementedException();
// Only if associated view is enabled to we perform an action
if (GetViewEnabled())
{
// If we do not provide an inert form
if (!_navigator.Owner!.InertForm)
{
// Only if the mouse is still within the button bounds do we perform action
MouseEventArgs mea = (MouseEventArgs)e;
if (GetView().ClientRectangle.Contains(mea.Location))
{
// Toggle between maximized and restored
/*_navigator.Owner!.SendSysCommand(_navigator.Owner!.WindowState == FormWindowState.Maximized
? PI.SC_.RESTORE
: PI.SC_.MAXIMIZE);*/

// Let base class fire any other attached events
base.OnClick(e);
}
}
}
}

#endregion
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ public class KryptonNavigator : VisualSimple,
private VisualPopupPage? _visualPopupPage;
private VisualPopupToolTip? _visualPopupToolTip;
private KryptonPage[]? _dragPages;
private KryptonForm? _owner;
private bool _forcedLayout;
private bool _layingOut;
private bool _pageDragging;
private bool _ignorePageVisibleChange;
private bool _allowTabFocus;
private bool _allowTabSelect;
private bool _tabHoverStarted;
private bool _controlKryptonFormFeatures;
private int _cachePageCount;
private int _cachePageVisibleCount;

Expand Down Expand Up @@ -507,6 +509,10 @@ public KryptonPage? SelectedPage
}
}

public KryptonForm? Owner { get => _owner; set => _owner = value ?? null; }

public bool ControlKryptonFormFeatures { get => _controlKryptonFormFeatures; set => _controlKryptonFormFeatures = value; }

/// <summary>
/// Gets access to the bar specific settings.
/// </summary>
Expand Down Expand Up @@ -1204,8 +1210,8 @@ protected override void OnMouseDown(MouseEventArgs e)
ViewBase? element = ViewManager?.Root?.ViewFromPoint(new Point(e.X, e.Y));

// Ask the view builder if pressing the element needs to give us focus
if (ViewBuilder != null
&& element != null
if (ViewBuilder != null
&& element != null
&& ViewBuilder.GiveNavigatorFocus(element)
)
{
Expand Down Expand Up @@ -1237,7 +1243,7 @@ protected override bool ProcessKeyPreview(ref Message m)
if (CommonHelper.IsShiftKeyPressed)
{
// If the focus has been moved to a page that does not have the focus
if (SelectedPage is { ContainsFocus: false } )
if (SelectedPage is { ContainsFocus: false })
{
// We need to force another TAB+SHIFT to move the focus backwards
foreach (KryptonPage page in Pages)
Expand Down Expand Up @@ -1292,7 +1298,7 @@ protected override bool ProcessDialogKey(Keys keyData)
{
// CONTROL tabbing around the pages in the navigator
// is handled in a view specific way
if (ViewBuilder != null)
if (ViewBuilder != null)
handled = ViewBuilder.ProcessDialogKey(keyData);
}
}
Expand Down Expand Up @@ -2190,6 +2196,8 @@ private void AssignDefaultFields()
_allowTabFocus = true;
_allowTabSelect = true;
UseMnemonic = true;
_owner = null;
_controlKryptonFormFeatures = false;
}

private void CreatePageCollection()
Expand Down Expand Up @@ -2896,7 +2904,7 @@ private void OnShowToolTip(object sender, ToolTipEventArgs e)
{
// Do not show tooltips when the form we are in does not have focus
Form? topForm = FindForm();
if (topForm is { ContainsFocus: false } )
if (topForm is { ContainsFocus: false })
{
return;
}
Expand Down Expand Up @@ -2995,7 +3003,7 @@ private void OnStartHover(object sender, ToolTipEventArgs e)
{
// We do not provide hover support when the form does not have the focus
Form? topForm = FindForm();
if (topForm is { ContainsFocus: false } )
if (topForm is { ContainsFocus: false })
{
return;
}
Expand Down Expand Up @@ -3133,9 +3141,9 @@ internal bool SelectNextPageControl(bool forward, bool onlyCurrentPage)
else
{
// We can only be the next control if we accept the focus
if (ViewBuilder != null
&& ((next != this)
|| ((next == this)
if (ViewBuilder != null
&& ((next != this)
|| ((next == this)
&& ViewBuilder.CanFocus)
)
)
Expand Down Expand Up @@ -3221,7 +3229,7 @@ private bool NextOnUnselectedKryptonPage(Control? next)
next = next.Parent;

// Keep going until we reach the top of the parent chain
}
}

// Did not find the control is on a KryptonPage, so definitely not on an unselected KryptonPage
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@
[assembly: Dependency(nameof(System), LoadHint.Always)]
[assembly: Dependency("System.Drawing", LoadHint.Always)]
[assembly: Dependency("System.Windows.Forms", LoadHint.Always)]
[assembly: Dependency("Krypton.Toolkit", LoadHint.Always)]
[assembly: Dependency("Krypton.Toolkit", LoadHint.Always)]
Loading

0 comments on commit 1b90c1c

Please sign in to comment.