Skip to content

Commit

Permalink
- Make it Net4.62 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
Smurf-IV committed Dec 16, 2024
1 parent 0ce5d74 commit dc37ad4
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ public NavigatorHeader([DisallowNull] KryptonNavigator navigator,

private float GetDpiFactor()
{
#if NET462
return PI.GetDpiForWindow(_navigator.Handle) / 96F;
#else
return _navigator.DeviceDpi / 96F;
#endif
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ protected KryptonRibbonGroupItem() =>
private float GetDpiFactor()
{
return (Ribbon != null)
#if NET462
? PI.GetDpiForWindow(Ribbon.Handle) / 96F
#else
? Ribbon.DeviceDpi / 96F
#endif
: 1.0f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,11 @@ private void CreateViewElements(PaletteRedirect? redirect)
private float GetDpiFactor()
{
return (_visualPopupToolTip != null)
#if NET462
? PI.GetDpiForWindow(_visualPopupToolTip.Handle) / 96F
#else
? _visualPopupToolTip.DeviceDpi / 96F
#endif
: 1F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected ButtonSpecRemapByContentBase(PaletteBase? target,
: base(target)
{
Debug.Assert(buttonSpec != null);
_buttonSpec = buttonSpec;
_buttonSpec = buttonSpec!;
}
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ protected KryptonContextMenuItemBase()
private float GetDpiFactor()
{
return (_visualPopupToolTip != null)
#if NET462
? PI.GetDpiForWindow(_visualPopupToolTip.Handle) / 96F
#else
? _visualPopupToolTip.DeviceDpi / 96F
#endif
: 1F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ public KryptonForm()
private float GetDpiFactor()
{
return (_visualPopupToolTip != null)
#if NET462
? PI.GetDpiForWindow(_visualPopupToolTip.Handle) / 96F
#else
? _visualPopupToolTip.DeviceDpi / 96F
#endif
: 1F;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ public KryptonGroupBox()
private float GetDpiFactor()
{
return (Panel != null)
#if NET462
? PI.GetDpiForWindow(Panel.Handle) / 96F
#else
? Panel.DeviceDpi / 96F
#endif
: 1f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ public KryptonHeader()

private float GetDpiFactor()
{
#if NET462
return PI.GetDpiForWindow(Handle) / 96F;
#else
return DeviceDpi / 96F;
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ public KryptonHeaderGroup()
private float GetDpiFactor()
{
return (Panel != null)
#if NET462
? PI.GetDpiForWindow(Panel.Handle) / 96F
#else
? Panel.DeviceDpi / 96F
#endif
: 1f;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ protected VisualControlBase()

private float GetDpiFactor()
{
#if NET462
return PI.GetDpiForWindow(Handle) / 96F;
#else
return DeviceDpi / 96F;
#endif
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2839,6 +2839,10 @@ private static KEY_ GetKeyState(Keys key)
#endregion

#region Static User32
[DllImport(Libraries.User32)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern uint GetDpiForWindow(IntPtr hWnd);

[DllImport(Libraries.User32)]
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
internal static extern BOOL EndDialog(IntPtr hDlg, IntPtr nResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ private protected virtual void WndMessage(object sender, CWPRETSTRUCT e, out boo
if (e.message == PI.WM_.INITDIALOG)
{
#if NET462
using var g = _commonDialogHandler._wrapperForm.CreateGraphics();
_scaleFactor = g.DpiX / 96.0f;
_scaleFactor = PI.GetDpiForWindow(_commonDialogHandler._wrapperForm.Handle) / 96F;
#else
_scaleFactor = _commonDialogHandler._wrapperForm.DeviceDpi / 96.0f;
#endif
Expand Down Expand Up @@ -178,7 +177,7 @@ private protected virtual bool WndActivated(object sender, CbtEventArgs e)
return true;
}

#endregion Do_CBT
#endregion Do_CBT

/// <summary>
/// Runs a common dialog box, parented to the given IWin32Window.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ public ViewLayoutMonths(IContextMenuProvider provider,
private float GetDpiFactor()
{
return (_visualPopupToolTip != null)
#if NET462
? PI.GetDpiForWindow(_visualPopupToolTip.Handle) / 96F
#else
? _visualPopupToolTip.DeviceDpi / 96F
#endif
: 1F;
}

Expand Down Expand Up @@ -480,10 +484,10 @@ public Size GetSingleMonthSize([DisallowNull] ViewLayoutContext context)
{
Debug.Assert(context != null);

SyncData(context);
SyncData(context!);
SyncMonths();

return this[1].GetPreferredSize(context);
return this[1].GetPreferredSize(context!);
}

/// <summary>
Expand Down

0 comments on commit dc37ad4

Please sign in to comment.