From c4bddafd2e4983d8b5d3685074a1ed034e0048da Mon Sep 17 00:00:00 2001 From: Mohmed Abd-El Fatah Date: Sun, 27 Nov 2022 12:59:19 +0200 Subject: [PATCH] Improve PInvoke WinApi and add DPI Support --- SkinFramWorkCore.sln | 19 +- SkinFramWorkCore/CaptionButton.cs | 12 - SkinFramWorkCore/CaptionButtons.cs | 68 -- SkinFramWorkCore/DebugConsole.cs | 2 +- SkinFramWorkCore/DwmButtonState.cs | 10 - .../Inetrop.DwmExtendFrameIntoClientArea.cs | 20 + .../Gdi32/Interop.CreateRoundRectRgn.cs | 13 + .../Interop/Gdi32/Interop.CreateSolidBrush.cs | 14 + .../Interop/Gdi32/Interop.DeleteObject.cs | 16 + .../Interop/Gdi32/Interop.ExcludeClipRect.cs | 13 + .../Interop/Gdi32/Interop.GetObjectType.cs | 23 + .../Interop/Gdi32/Interop.GetRegionData.cs | 14 + .../Interop/Gdi32/Interop.HBRUSH.cs | 23 + SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs | 29 + .../Interop/Gdi32/Interop.HGDIOBJ.cs | 30 + .../Interop/Gdi32/Interop.HRGN.cs | 47 + SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs | 27 + .../Interop/Gdi32/Interop.RGNDATAHEADER.cs | 31 + .../Interop/Gdi32/Interop.SelectObject.cs | 29 + SkinFramWorkCore/Interop/IHandle.cs | 71 ++ SkinFramWorkCore/Interop/Interop.BOOL.cs | 30 + SkinFramWorkCore/Interop/Interop.ERROR.cs | 15 + SkinFramWorkCore/Interop/Interop.HIWORD.cs | 11 + SkinFramWorkCore/Interop/Interop.HRESULT.cs | 89 ++ SkinFramWorkCore/Interop/Interop.LOWORD.cs | 11 + SkinFramWorkCore/Interop/Interop.Libraries.cs | 31 + SkinFramWorkCore/Interop/Interop.RECT.cs | 101 ++ .../Interop.WindowsMessages.cs} | 597 +---------- SkinFramWorkCore/Interop/LRESULT.cs | 19 + .../Interop/User32/Interop.GCL.cs | 27 + .../Interop/User32/Interop.GWLIndex.cs | 46 + .../Interop/User32/Interop.GetClientRect.cs | 28 + .../Interop/User32/Interop.GetParent.cs | 28 + .../Interop/User32/Interop.GetWindowDC.cs | 21 + .../Interop/User32/Interop.GetWindowLong.cs | 42 + .../Interop/User32/Interop.GetWindowRect.cs | 28 + .../User32/Interop.NCCALCSIZE_PARAMS.cs | 18 + .../Interop/User32/Interop.OffsetRect.cs | 14 + .../Interop/User32/Interop.ReleaseDC.cs | 21 + .../Interop/User32/Interop.SWPFlags.cs | 43 + .../Interop/User32/Interop.SetClassLong.cs | 28 + .../Interop/User32/Interop.SetWindowLong.cs | 53 + .../Interop/User32/Interop.SetWindowPos.cs | 56 + .../Interop/User32/Interop.SetWindowRgn.cs | 21 + .../Interop/User32/Interop.SystemMetric.cs | 552 ++++++++++ .../Interop/User32/Interop.TME.cs | 21 + .../Interop/User32/Interop.TrackMouseEvent.cs | 29 + .../Interop/User32/Interp.GetSystemMetrics.cs | 17 + SkinFramWorkCore/Interop/User32/NCHITTEST.cs | 79 ++ .../Interop/UxTheme/Interop.BPPF.cs | 24 + .../UxTheme/Interop.BP_BUFFERFORMAT.cs | 29 + .../Interop/UxTheme/Interop.BP_PAINTPARAMS.cs | 96 ++ .../UxTheme/Interop.BeginBufferedPaint.cs | 24 + .../Interop/UxTheme/Interop.CloseThemeData.cs | 15 + .../Interop/UxTheme/Interop.DTTOPTS.cs | 32 + .../UxTheme/Interop.DrawThemeTextEx.cs | 14 + .../UxTheme/Interop.EndBufferedPaint.cs | 12 + .../Interop/UxTheme/Interop.GetThemeInt.cs | 22 + .../Interop/UxTheme/Interop.GetThemeRect.cs | 14 + .../Interop/UxTheme/Interop.GetThemeStream.cs | 14 + .../Interop/UxTheme/Interop.HPAINTBUFFER.cs | 28 + .../Interop/UxTheme/Interop.MARGINS.cs | 17 + .../Interop/UxTheme/Interop.OpenThemeData.cs | 15 + .../Interop/UxTheme/Interop.SetWindowTheme.cs | 15 + .../Interop/interop.WindowStyles.cs | 173 +++ .../Interop/kernel32/Interop.FreeLibrary.cs | 15 + .../kernel32/Interop.GetModuleHandle.cs | 14 + .../Interop/kernel32/Interop.LoadLibrary.cs | 41 + .../kernel32/Interop.LoadLibraryFlags.cs | 62 ++ SkinFramWorkCore/MdiNativeWindow.cs | 36 + SkinFramWorkCore/NonClientTheme.cs | 871 ---------------- SkinFramWorkCore/Platform.cs | 12 - .../{Extensions.cs => SkinExtensions.cs} | 441 ++++---- SkinFramWorkCore/SkinForm.Designer.cs | 15 +- SkinFramWorkCore/SkinForm.cs | 981 +++++++++++++++++- SkinFramWorkCore/SkinFramWorkCore.csproj | 44 +- TestApp/Form1.Designer.cs | 50 - TestApp/Form1.cs | 39 - TestApp/MDIParent1.Designer.cs | 618 ----------- TestApp/MDIParent1.cs | 143 --- TestApp/MDIParent1.resx | 343 ------ TestApp/Program.cs | 23 - TestApp1/App.config | 15 + TestApp1/MDIParent1.Designer.cs | 316 ++++++ TestApp1/MDIParent1.cs | 382 +++++++ .../Form1.resx => TestApp1/MDIParent1.resx | 16 +- TestApp1/Program.cs | 22 + .../Properties/Resources.Designer.cs | 6 +- .../Properties/Resources.resx | 0 TestApp1/Properties/Settings.Designer.cs | 38 + TestApp1/Properties/Settings.settings | 9 + ...75e73c885921925f61fcf123c7c8c1f93e1c0c.jpg | Bin .../TestApp1.csproj | 18 +- 93 files changed, 4691 insertions(+), 3010 deletions(-) delete mode 100644 SkinFramWorkCore/CaptionButton.cs delete mode 100644 SkinFramWorkCore/CaptionButtons.cs delete mode 100644 SkinFramWorkCore/DwmButtonState.cs create mode 100644 SkinFramWorkCore/Interop/Dwmapi/Inetrop.DwmExtendFrameIntoClientArea.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.CreateRoundRectRgn.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.CreateSolidBrush.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.DeleteObject.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.ExcludeClipRect.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.GetObjectType.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.GetRegionData.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.HBRUSH.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.HGDIOBJ.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.HRGN.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.RGNDATAHEADER.cs create mode 100644 SkinFramWorkCore/Interop/Gdi32/Interop.SelectObject.cs create mode 100644 SkinFramWorkCore/Interop/IHandle.cs create mode 100644 SkinFramWorkCore/Interop/Interop.BOOL.cs create mode 100644 SkinFramWorkCore/Interop/Interop.ERROR.cs create mode 100644 SkinFramWorkCore/Interop/Interop.HIWORD.cs create mode 100644 SkinFramWorkCore/Interop/Interop.HRESULT.cs create mode 100644 SkinFramWorkCore/Interop/Interop.LOWORD.cs create mode 100644 SkinFramWorkCore/Interop/Interop.Libraries.cs create mode 100644 SkinFramWorkCore/Interop/Interop.RECT.cs rename SkinFramWorkCore/{NativeMethods.cs => Interop/Interop.WindowsMessages.cs} (76%) create mode 100644 SkinFramWorkCore/Interop/LRESULT.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GCL.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GWLIndex.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GetClientRect.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GetParent.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GetWindowDC.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GetWindowLong.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.GetWindowRect.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.NCCALCSIZE_PARAMS.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.OffsetRect.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.ReleaseDC.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SWPFlags.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SetClassLong.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SetWindowLong.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SetWindowPos.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SetWindowRgn.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.SystemMetric.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.TME.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interop.TrackMouseEvent.cs create mode 100644 SkinFramWorkCore/Interop/User32/Interp.GetSystemMetrics.cs create mode 100644 SkinFramWorkCore/Interop/User32/NCHITTEST.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.BPPF.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.BP_BUFFERFORMAT.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.BP_PAINTPARAMS.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.BeginBufferedPaint.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.CloseThemeData.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.DTTOPTS.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.DrawThemeTextEx.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.EndBufferedPaint.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeInt.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeRect.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeStream.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.HPAINTBUFFER.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.MARGINS.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.OpenThemeData.cs create mode 100644 SkinFramWorkCore/Interop/UxTheme/Interop.SetWindowTheme.cs create mode 100644 SkinFramWorkCore/Interop/interop.WindowStyles.cs create mode 100644 SkinFramWorkCore/Interop/kernel32/Interop.FreeLibrary.cs create mode 100644 SkinFramWorkCore/Interop/kernel32/Interop.GetModuleHandle.cs create mode 100644 SkinFramWorkCore/Interop/kernel32/Interop.LoadLibrary.cs create mode 100644 SkinFramWorkCore/Interop/kernel32/Interop.LoadLibraryFlags.cs create mode 100644 SkinFramWorkCore/MdiNativeWindow.cs delete mode 100644 SkinFramWorkCore/NonClientTheme.cs delete mode 100644 SkinFramWorkCore/Platform.cs rename SkinFramWorkCore/{Extensions.cs => SkinExtensions.cs} (58%) delete mode 100644 TestApp/Form1.Designer.cs delete mode 100644 TestApp/Form1.cs delete mode 100644 TestApp/MDIParent1.Designer.cs delete mode 100644 TestApp/MDIParent1.cs delete mode 100644 TestApp/MDIParent1.resx delete mode 100644 TestApp/Program.cs create mode 100644 TestApp1/App.config create mode 100644 TestApp1/MDIParent1.Designer.cs create mode 100644 TestApp1/MDIParent1.cs rename TestApp/Form1.resx => TestApp1/MDIParent1.resx (74%) create mode 100644 TestApp1/Program.cs rename {TestApp => TestApp1}/Properties/Resources.Designer.cs (93%) rename {TestApp => TestApp1}/Properties/Resources.resx (100%) create mode 100644 TestApp1/Properties/Settings.Designer.cs create mode 100644 TestApp1/Properties/Settings.settings rename {TestApp => TestApp1}/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg (100%) rename TestApp/TestApp.csproj => TestApp1/TestApp1.csproj (53%) diff --git a/SkinFramWorkCore.sln b/SkinFramWorkCore.sln index 43376fa..d7605be 100644 --- a/SkinFramWorkCore.sln +++ b/SkinFramWorkCore.sln @@ -1,11 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.32929.386 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkinFramWorkCore", "SkinFramWorkCore\SkinFramWorkCore.csproj", "{2D1532E1-CB47-467C-AB40-3C910A0100AE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkinFramWorkCore", "SkinFramWorkCore\SkinFramWorkCore.csproj", "{2D1532E1-CB47-467C-AB40-3C910A0100AE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{28D26C77-C889-4603-9F5C-8234A8C0690E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp1", "TestApp1\TestApp1.csproj", "{12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}" + ProjectSection(ProjectDependencies) = postProject + {2D1532E1-CB47-467C-AB40-3C910A0100AE} = {2D1532E1-CB47-467C-AB40-3C910A0100AE} + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -17,10 +20,10 @@ Global {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {2D1532E1-CB47-467C-AB40-3C910A0100AE}.Release|Any CPU.Build.0 = Release|Any CPU - {28D26C77-C889-4603-9F5C-8234A8C0690E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28D26C77-C889-4603-9F5C-8234A8C0690E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28D26C77-C889-4603-9F5C-8234A8C0690E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {28D26C77-C889-4603-9F5C-8234A8C0690E}.Release|Any CPU.Build.0 = Release|Any CPU + {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {12A05D1D-6EFC-49D0-9C58-28DBE9EE743B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SkinFramWorkCore/CaptionButton.cs b/SkinFramWorkCore/CaptionButton.cs deleted file mode 100644 index 3338939..0000000 --- a/SkinFramWorkCore/CaptionButton.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SkinFramWorkCore -{ - public enum CaptionButton - { - Close, - Minimize, - Maximize, - Restore, - Help, - - } -} diff --git a/SkinFramWorkCore/CaptionButtons.cs b/SkinFramWorkCore/CaptionButtons.cs deleted file mode 100644 index d34929f..0000000 --- a/SkinFramWorkCore/CaptionButtons.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Drawing; -using static SkinFramWorkCore.NativeMethods; -using static SkinFramWorkCore.Extensions; -namespace SkinFramWorkCore -{ - - public abstract class CaptionButtons - { - public CaptionButtons() - { - - } - public static DwmWindowCaption WindowCaption - { - get - { - switch (GetMsstylePlatform()) - { - case Platform.Vista: - case Platform.Win7: - case Platform.Win8: - case Platform.Win81: - return new Windows8Caption(); - case Platform.Win10: - case Platform.Win11: - default: - return new Windows10Caption(); - } - } - } - - public static DwmButtonState ButtonState { get; set; } - public abstract Image BackgrounImage { get; set; } - public abstract Image GlyphImage { get; set; } - public abstract Rectangle Bounds { get; set; } - public abstract Color BackgroundColor { get; set; } - public abstract bool IsActive { get; set; } - } - - public class CloseButton : CaptionButtons - { - - public CloseButton() - { - - } - - public override Image BackgrounImage { get; set; } = GetDwmWindowButton(WindowCaption.BUTTONACTIVECLOS, (int)ButtonState); - public override Image GlyphImage { get; set; } = GetDwmWindowButton(WindowCaption.BUTTONCLOSEGLYPH96, (int)ButtonState); - public override Rectangle Bounds { get; set; } - public override Color BackgroundColor { get; set; } - public static new DwmButtonState ButtonState { get; set; } - public override bool IsActive { get; set; } - - private void dr(Graphics graphics) - { - //Rectangle bounRect; - //BackgrounImage = GetDwmWindowButton(active ? windowCaption.BUTTONACTIVECLOS : windowCaption.BUTTONAINCTIVECLOS, (int)state); - //Image = GetDwmWindowButton(windowCaption.BUTTONCLOSEGLYPH96, active ? (int)state : (int)ButtonState.Disabled); - //if (BackgrounImage == null || Image == null) return; - //graphics.DrawImage(BackgrounImage, rect); - //bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); - //bounRect.Offset(rect.Location); - //graphics.DrawImage(Image, bounRect); - } - } -} diff --git a/SkinFramWorkCore/DebugConsole.cs b/SkinFramWorkCore/DebugConsole.cs index 70117d8..5cd9d31 100644 --- a/SkinFramWorkCore/DebugConsole.cs +++ b/SkinFramWorkCore/DebugConsole.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; namespace SkinFramWorkCore { - public class DebugConsole + internal class DebugConsole { #region Methods /// diff --git a/SkinFramWorkCore/DwmButtonState.cs b/SkinFramWorkCore/DwmButtonState.cs deleted file mode 100644 index 282ee60..0000000 --- a/SkinFramWorkCore/DwmButtonState.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace SkinFramWorkCore -{ - public enum DwmButtonState - { - Normal = 1, - Hot = 2, - Pressed = 3, - Disabled = 4 - } -} diff --git a/SkinFramWorkCore/Interop/Dwmapi/Inetrop.DwmExtendFrameIntoClientArea.cs b/SkinFramWorkCore/Interop/Dwmapi/Inetrop.DwmExtendFrameIntoClientArea.cs new file mode 100644 index 0000000..e0800ee --- /dev/null +++ b/SkinFramWorkCore/Interop/Dwmapi/Inetrop.DwmExtendFrameIntoClientArea.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + internal static partial class Dwmapi + { + [DllImport(Libraries.Dwmapi, CharSet = CharSet.Auto, ExactSpelling = false)] + public static extern HRESULT DwmExtendFrameIntoClientArea(IntPtr hWnd, ref UxTheme.MARGINS pMarInset); + public static HRESULT DwmExtendFrameIntoClientArea(IHandle hWnd, ref UxTheme.MARGINS pMarInset) + { + var result = DwmExtendFrameIntoClientArea(hWnd.Handle, ref pMarInset); + GC.KeepAlive(hWnd); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.CreateRoundRectRgn.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.CreateRoundRectRgn.cs new file mode 100644 index 0000000..40f7754 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.CreateRoundRectRgn.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32)] + public static extern HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse); + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.CreateSolidBrush.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.CreateSolidBrush.cs new file mode 100644 index 0000000..63e4e45 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.CreateSolidBrush.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32, ExactSpelling = true, SetLastError = true)] + public static extern HBRUSH CreateSolidBrush(int crColor); + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.DeleteObject.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.DeleteObject.cs new file mode 100644 index 0000000..0b65122 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.DeleteObject.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32, ExactSpelling = true)] + public static extern BOOL DeleteObject(IntPtr hObject); + + public static BOOL DeleteObject(HGDIOBJ hObject) => DeleteObject(hObject.Handle); + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.ExcludeClipRect.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.ExcludeClipRect.cs new file mode 100644 index 0000000..92b9186 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.ExcludeClipRect.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32)] + public static extern int ExcludeClipRect(HDC hdc, int left, int top, int right, int bottom); + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.GetObjectType.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.GetObjectType.cs new file mode 100644 index 0000000..352508e --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.GetObjectType.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + // This does set last error but *only* in one error case that doesn't add any real value. + [DllImport(Libraries.Gdi32, ExactSpelling = true)] + public static extern OBJ GetObjectType(HGDIOBJ h); + + public static OBJ GetObjectType(HandleRef h) + { + OBJ result = GetObjectType((HGDIOBJ)h.Handle); + GC.KeepAlive(h.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.GetRegionData.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.GetRegionData.cs new file mode 100644 index 0000000..cf6b209 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.GetRegionData.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32, ExactSpelling = true)] + public static extern uint GetRegionData(IntPtr hRgn, uint nCount, IntPtr lpRgnData); + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.HBRUSH.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.HBRUSH.cs new file mode 100644 index 0000000..9a7f695 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.HBRUSH.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public readonly struct HBRUSH + { + public IntPtr Handle { get; } + + public HBRUSH(IntPtr handle) => Handle = handle; + + public bool IsNull => Handle == IntPtr.Zero; + + public static explicit operator IntPtr(HBRUSH hbrush) => hbrush.Handle; + public static explicit operator HBRUSH(IntPtr hbrush) => new HBRUSH(hbrush); + public static implicit operator HGDIOBJ(HBRUSH hbrush) => new HGDIOBJ(hbrush.Handle); + public static explicit operator HBRUSH(HGDIOBJ hbrush) => new HBRUSH(hbrush.Handle); + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs new file mode 100644 index 0000000..d4fb021 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.HDC.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public readonly struct HDC + { + public IntPtr Handle { get; } + + public HDC(IntPtr handle) => Handle = handle; + + public bool IsNull => Handle == IntPtr.Zero; + + public static explicit operator IntPtr(HDC hdc) => hdc.Handle; + public static explicit operator HDC(IntPtr hdc) => new HDC(hdc); + public static implicit operator HGDIOBJ(HDC hdc) => new HGDIOBJ(hdc.Handle); + + public static bool operator ==(HDC value1, HDC value2) => value1.Handle == value2.Handle; + public static bool operator !=(HDC value1, HDC value2) => value1.Handle != value2.Handle; + public override bool Equals(object? obj) => obj is HDC hdc && hdc.Handle == Handle; + public override int GetHashCode() => Handle.GetHashCode(); + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.HGDIOBJ.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.HGDIOBJ.cs new file mode 100644 index 0000000..e5df073 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.HGDIOBJ.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public struct HGDIOBJ + { + public IntPtr Handle { get; } + + public HGDIOBJ(IntPtr handle) => Handle = handle; + + public bool IsNull => Handle == IntPtr.Zero; + + public static explicit operator IntPtr(HGDIOBJ hgdiobj) => hgdiobj.Handle; + public static explicit operator HGDIOBJ(IntPtr hgdiobj) => new HGDIOBJ(hgdiobj); + + public static bool operator ==(HGDIOBJ value1, HGDIOBJ value2) => value1.Handle == value2.Handle; + public static bool operator !=(HGDIOBJ value1, HGDIOBJ value2) => value1.Handle != value2.Handle; + public override bool Equals(object? obj) => obj is HGDIOBJ hgdiobj && hgdiobj.Handle == Handle; + public override int GetHashCode() => Handle.GetHashCode(); + + public OBJ ObjectType => GetObjectType(this); + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.HRGN.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.HRGN.cs new file mode 100644 index 0000000..66f218d --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.HRGN.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Buffers; +using System; +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public readonly struct HRGN + { + public IntPtr Handle { get; } + + public HRGN(IntPtr handle) => Handle = handle; + + public bool IsNull => Handle == IntPtr.Zero; + + public static implicit operator HGDIOBJ(HRGN hrgn) => new HGDIOBJ(hrgn.Handle); + public static explicit operator IntPtr(HRGN hrgn) => hrgn.Handle; + public static explicit operator HRGN(IntPtr hrgn) => new HRGN(hrgn); + + public unsafe RECT[] GetRegionRects() + { + uint regionDataSize = GetRegionData(Handle, 0, IntPtr.Zero); + if (regionDataSize == 0) + { + return Array.Empty(); + } + + byte[] buffer = ArrayPool.Shared.Rent((int)regionDataSize); + + fixed (byte* b = buffer) + { + if (GetRegionData(Handle, regionDataSize, (IntPtr)b) != regionDataSize) + { + return Array.Empty(); + } + + RECT[] result = RGNDATAHEADER.GetRegionRects((RGNDATAHEADER*)b); + ArrayPool.Shared.Return(buffer); + return result; + } + } + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs new file mode 100644 index 0000000..9f74d55 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.OBJ.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public enum OBJ : int + { + PEN = 1, + BRUSH = 2, + DC = 3, + METADC = 4, + PAL = 5, + FONT = 6, + BITMAP = 7, + REGION = 8, + METAFILE = 9, + MEMDC = 10, + EXTPEN = 11, + ENHMETADC = 12, + ENHMETAFILE = 13, + COLORSPACE = 14 + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.RGNDATAHEADER.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.RGNDATAHEADER.cs new file mode 100644 index 0000000..b5ad9ee --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.RGNDATAHEADER.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +#pragma warning disable CS0649 +using System; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + public struct RGNDATAHEADER + { + public uint dwSize; + public uint iType; + public uint nCount; + public uint nRgnSize; + public RECT rcBound; + + public unsafe static RECT[] GetRegionRects(RGNDATAHEADER* regionData) + { + if (regionData is null || regionData->nCount == 0) + { + return Array.Empty(); + } + + // Region RECTs directly follow the header + return new Span((byte*)regionData + regionData->dwSize, (int)regionData->nCount).ToArray(); + } + } + } +} diff --git a/SkinFramWorkCore/Interop/Gdi32/Interop.SelectObject.cs b/SkinFramWorkCore/Interop/Gdi32/Interop.SelectObject.cs new file mode 100644 index 0000000..8f4a5f4 --- /dev/null +++ b/SkinFramWorkCore/Interop/Gdi32/Interop.SelectObject.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Gdi32 + { + [DllImport(Libraries.Gdi32, SetLastError = true, ExactSpelling = true)] + public static extern HGDIOBJ SelectObject(HDC hdc, HGDIOBJ h); + + public static HGDIOBJ SelectObject(IHandle hdc, HGDIOBJ h) + { + HGDIOBJ lastObject = SelectObject((HDC)hdc.Handle, h); + GC.KeepAlive(hdc); + return lastObject; + } + + public static HGDIOBJ SelectObject(HandleRef hdc, HGDIOBJ h) + { + HGDIOBJ lastObject = SelectObject((HDC)hdc.Handle, h); + GC.KeepAlive(hdc.Wrapper); + return lastObject; + } + } +} diff --git a/SkinFramWorkCore/Interop/IHandle.cs b/SkinFramWorkCore/Interop/IHandle.cs new file mode 100644 index 0000000..863780c --- /dev/null +++ b/SkinFramWorkCore/Interop/IHandle.cs @@ -0,0 +1,71 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +/// +/// Used to abstract access to classes that contain a potentially owned handle. +/// NOTE: This ultimately should be replaced by . +/// +/// +/// +/// The key benefit of this is that we can keep the owning class from being +/// collected during interop calls. wraps arbitrary +/// owners with target handles. Having this interface allows implicit use +/// of the classes (such as System.Windows.Forms.Control) that +/// meet this common pattern in interop and encourages correct alignment +/// with the proper owner. +/// +/// +/// Note that keeping objects alive is necessary ONLY when the object has +/// a finalizer that will explicitly close the handle. +/// +/// +internal interface IHandle +{ + public IntPtr Handle { get; } +} + +/// +/// Used to abstract access to classes that contain a potentially owned handle. +/// +/// +/// +/// The key benefit of this is that we can keep the owning class from being collected during interop calls. +/// wraps arbitrary owners with target handles. Having this interface allows implicit use +/// of the classes (such as System.Windows.Forms.Control) that meet this common pattern in interop and encourages +/// correct alignment with the proper owner. +/// +/// +/// Note that keeping objects alive is necessary ONLY when the object has a finalizer that will explicitly +/// close the handle. +/// +/// +/// When implementing P/Invoke wrappers that take this interface they should not directly take +/// , but should take a generic "T" that is constrained to IHandle{T}. Doing +/// it this way prevents boxing of structs. The "T" parameters should also be marked as +/// to allow structs to be passed by reference instead of by value. +/// +/// +/// When implementing this on a struct it is important that either the struct itself is marked as readonly +/// or these properties are to avoid extra struct copies. +/// +/// +internal interface IHandle where THandle : unmanaged +{ + THandle Handle { get; } + + /// + /// Owner of the that might close it when finalized. Default is the + /// implementer. + /// + /// + /// + /// This allows decoupling the owner from the provider and avoids boxing when + /// is on a struct. See for a concrete usage. + /// + /// + object? Wrapper => this; +} diff --git a/SkinFramWorkCore/Interop/Interop.BOOL.cs b/SkinFramWorkCore/Interop/Interop.BOOL.cs new file mode 100644 index 0000000..5cabc38 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.BOOL.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using static Interop; + +internal partial class Interop +{ + /// + /// Blittable version of Windows BOOL type. It is convenient in situations where + /// manual marshalling is required, or to avoid overhead of regular bool marshalling. + /// + /// + /// Some Windows APIs return arbitrary integer values although the return type is defined + /// as BOOL. It is best to never compare BOOL to TRUE. Always use bResult != BOOL.FALSE + /// or bResult == BOOL.FALSE . + /// + internal enum BOOL : int + { + FALSE = 0, + TRUE = 1, + } +} + +internal static class BoolExtensions +{ + public static bool IsTrue(this BOOL b) => b != BOOL.FALSE; + public static bool IsFalse(this BOOL b) => b == BOOL.FALSE; + public static BOOL ToBOOL(this bool b) => b ? BOOL.TRUE : BOOL.FALSE; +} diff --git a/SkinFramWorkCore/Interop/Interop.ERROR.cs b/SkinFramWorkCore/Interop/Interop.ERROR.cs new file mode 100644 index 0000000..eb05133 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.ERROR.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal partial class Interop +{ + // https://docs.microsoft.com/windows/win32/debug/system-error-codes--0-499- + internal static class ERROR + { + public const int ACCESS_DENIED = 0x0005; + public const int INVALID_HANDLE = 0x0006; + public const int INVALID_PARAMETER = 0x0057; + public const int INSUFFICIENT_BUFFER = 0x007A; + } +} diff --git a/SkinFramWorkCore/Interop/Interop.HIWORD.cs b/SkinFramWorkCore/Interop/Interop.HIWORD.cs new file mode 100644 index 0000000..352d4a3 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.HIWORD.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static int HIWORD(int i) + { + return (short)(i >> 16); + } +} diff --git a/SkinFramWorkCore/Interop/Interop.HRESULT.cs b/SkinFramWorkCore/Interop/Interop.HRESULT.cs new file mode 100644 index 0000000..8539873 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.HRESULT.cs @@ -0,0 +1,89 @@ +using System; +using static Interop; + +internal static partial class Interop +{ + internal enum HRESULT : int + { + S_OK = 0, + S_FALSE = 1, + DRAGDROP_S_DROP = 0x00040100, + DRAGDROP_S_CANCEL = 0x00040101, + DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102, + + E_NOTIMPL = unchecked((int)0x80004001), + E_NOINTERFACE = unchecked((int)0x80004002), + E_POINTER = unchecked((int)0x80004003), + E_ABORT = unchecked((int)0x80004004), + E_FAIL = unchecked((int)0x80004005), + + // These are CLR HRESULTs + InvalidArgFailure = unchecked((int)0x80008081), + CoreHostLibLoadFailure = unchecked((int)0x80008082), + CoreHostLibMissingFailure = unchecked((int)0x80008083), + CoreHostEntryPointFailure = unchecked((int)0x80008084), + CoreHostCurHostFindFailure = unchecked((int)0x80008085), + CoreClrResolveFailure = unchecked((int)0x80008087), + CoreClrBindFailure = unchecked((int)0x80008088), + CoreClrInitFailure = unchecked((int)0x80008089), + CoreClrExeFailure = unchecked((int)0x8000808a), + LibHostExecModeFailure = unchecked((int)0x80008090), + LibHostSdkFindFailure = unchecked((int)0x80008091), + LibHostInvalidArgs = unchecked((int)0x80008092), + InvalidConfigFile = unchecked((int)0x80008093), + AppArgNotRunnable = unchecked((int)0x80008094), + AppHostExeNotBoundFailure = unchecked((int)0x80008095), + FrameworkMissingFailure = unchecked((int)0x80008096), + HostApiFailed = unchecked((int)0x80008097), + HostApiBufferTooSmall = unchecked((int)0x80008098), + LibHostUnknownCommand = unchecked((int)0x80008099), + LibHostAppRootFindFailure = unchecked((int)0x8000809a), + SdkResolverResolveFailure = unchecked((int)0x8000809b), + FrameworkCompatFailure = unchecked((int)0x8000809c), + FrameworkCompatRetry = unchecked((int)0x8000809d), + + RPC_E_CHANGED_MODE = unchecked((int)0x80010106), + DISP_E_MEMBERNOTFOUND = unchecked((int)0x80020003), + DISP_E_PARAMNOTFOUND = unchecked((int)0x80020004), + DISP_E_UNKNOWNNAME = unchecked((int)0x80020006), + DISP_E_EXCEPTION = unchecked((int)0x80020009), + DISP_E_UNKNOWNLCID = unchecked((int)0x8002000C), + DISP_E_DIVBYZERO = unchecked((int)0x80020012), + TYPE_E_BADMODULEKIND = unchecked((int)0x800288BD), + STG_E_INVALIDFUNCTION = unchecked((int)0x80030001), + STG_E_FILENOTFOUND = unchecked((int)0x80030002), + STG_E_ACCESSDENIED = unchecked((int)0x80030005), + STG_E_INVALIDPOINTER = unchecked((int)0x80030009), + STG_E_INVALIDPARAMETER = unchecked((int)0x80030057), + STG_E_INVALIDFLAG = unchecked((int)0x800300FF), + OLE_E_ADVISENOTSUPPORTED = unchecked((int)0x80040003), + OLE_E_NOCONNECTION = unchecked((int)0x80040004), + OLE_E_PROMPTSAVECANCELLED = unchecked((int)0x8004000C), + OLE_E_INVALIDRECT = unchecked((int)0x8004000D), + DV_E_FORMATETC = unchecked((int)0x80040064), + DV_E_TYMED = unchecked((int)0x80040069), + DV_E_DVASPECT = unchecked((int)0x8004006B), + DRAGDROP_E_NOTREGISTERED = unchecked((int)0x80040100), + DRAGDROP_E_ALREADYREGISTERED = unchecked((int)0x80040101), + VIEW_E_DRAW = unchecked((int)0x80040140), + INPLACE_E_NOTOOLSPACE = unchecked((int)0x800401A1), + CO_E_OBJNOTREG = unchecked((int)0x800401FB), + CO_E_OBJISREG = unchecked((int)0x800401FC), + E_ACCESSDENIED = unchecked((int)0x80070005), + E_OUTOFMEMORY = unchecked((int)0x8007000E), + E_INVALIDARG = unchecked((int)0x80070057), + ERROR_CANCELLED = unchecked((int)0x800704C7), + } +} + +internal static class HResultExtensions +{ + public static bool Succeeded(this HRESULT hr) => hr >= 0; + + public static bool Failed(this HRESULT hr) => hr < 0; + + public static string AsString(this HRESULT hr) + => Enum.IsDefined(typeof(HRESULT), hr) + ? $"HRESULT {hr} [0x{(int)hr:X} ({(int)hr:D})]" + : $"HRESULT [0x{(int)hr:X} ({(int)hr:D})]"; +} \ No newline at end of file diff --git a/SkinFramWorkCore/Interop/Interop.LOWORD.cs b/SkinFramWorkCore/Interop/Interop.LOWORD.cs new file mode 100644 index 0000000..ea3f6c5 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.LOWORD.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static int LOWORD(int i) + { + return (short)(i & 0xFFFF); + } +} diff --git a/SkinFramWorkCore/Interop/Interop.Libraries.cs b/SkinFramWorkCore/Interop/Interop.Libraries.cs new file mode 100644 index 0000000..cc6fde0 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.Libraries.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + public static class Libraries + { + public const string Comctl32 = "comctl32.dll"; + public const string Comdlg32 = "comdlg32.dll"; + public const string Gdi32 = "gdi32.dll"; + public const string Gdiplus = "gdiplus.dll"; + public const string Hhctrl = "hhctrl.ocx"; + public const string Imm32 = "imm32.dll"; + public const string Kernel32 = "kernel32.dll"; + public const string NtDll = "ntdll.dll"; + public const string Ole32 = "ole32.dll"; + public const string Oleacc = "oleacc.dll"; + public const string Oleaut32 = "oleaut32.dll"; + public const string Powrprof = "Powrprof.dll"; + public const string Propsys = "Propsys.dll"; + public const string RichEdit41 = "MsftEdit.DLL"; + public const string SHCore = "SHCore.dll"; + public const string Shell32 = "shell32.dll"; + public const string Shlwapi = "shlwapi.dll"; + public const string UiaCore = "UIAutomationCore.dll"; + public const string User32 = "user32.dll"; + public const string UxTheme = "uxtheme.dll"; + public const string Dwmapi = "dwmapi.dll"; + } +} diff --git a/SkinFramWorkCore/Interop/Interop.RECT.cs b/SkinFramWorkCore/Interop/Interop.RECT.cs new file mode 100644 index 0000000..50a3aa7 --- /dev/null +++ b/SkinFramWorkCore/Interop/Interop.RECT.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Drawing; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + /// + /// The RECT structure defines a rectangle by the coordinates of its upper-left and lower-right corners. + /// + [StructLayout(LayoutKind.Sequential)] + public struct RECT + { + /// + /// Specifies the x-coordinate of the upper-left corner of the rectangle. + /// + public int left; + /// + /// Specifies the y-coordinate of the upper-left corner of the rectangle. + /// + public int top; + /// + /// Specifies the x-coordinate of the lower-right corner of the rectangle. + /// + public int right; + /// + /// Specifies the y-coordinate of the lower-right corner of the rectangle. + /// + public int bottom; + /// + /// Initializes a new instance of the RECT class with the specified location and size + /// + /// Specifies the x-coordinate of the upper-left corner of the rectangle. + /// Specifies the y-coordinate of the upper-left corner of the rectangle. + /// Specifies the x-coordinate of the lower-right corner of the rectangle. + /// Specifies the y-coordinate of the lower-right corner of the rectangle. + public RECT(int left, int top, int right, int bottom) + { + this.left = left; + this.top = top; + this.right = right; + this.bottom = bottom; + } + /// + /// Initializes a new instance of the RECT class from specified + /// + /// Rectangle that will convert to RECT + public RECT(Rectangle rectangle) + { + left = rectangle.Left; + top = rectangle.Top; + right = rectangle.Right; + bottom = rectangle.Bottom; + } + /// + /// Initializes a new instance of the Rectangle class from specified + /// + /// Rectangle that will convert to RECT + public static implicit operator Rectangle(RECT r) + => Rectangle.FromLTRB(r.left, r.top, r.right, r.bottom); + /// + /// Initializes a new instance of the RECT class from specified + /// + /// Rectangle that will convert to RECT + public static implicit operator RECT(Rectangle r) + => new RECT(r); + public RECT RtlRect(int width) + { + return new RECT(width - Width - left, top, width - left, bottom); + } + /// + /// Specifies the x-coordinate of the upper-left corner of the rectangle. + /// + public int X => left; + /// + /// Specifies the y-coordinate of the upper-left corner of the rectangle. + /// + public int Y => top; + /// + /// The width of the rectangle. + /// + public int Width + => right - left; + /// + /// The height of the rectangle. + /// + public int Height + => bottom - top; + /// + /// The of the rectangle. + /// + public Size Size + => new Size(Width, Height); + + public override string ToString() + => $"{{{left}, {top}, {right}, {bottom} (LTRB)}}"; + } + +} diff --git a/SkinFramWorkCore/NativeMethods.cs b/SkinFramWorkCore/Interop/Interop.WindowsMessages.cs similarity index 76% rename from SkinFramWorkCore/NativeMethods.cs rename to SkinFramWorkCore/Interop/Interop.WindowsMessages.cs index 3bff4dc..ceb6761 100644 --- a/SkinFramWorkCore/NativeMethods.cs +++ b/SkinFramWorkCore/Interop/Interop.WindowsMessages.cs @@ -1,140 +1,13 @@ -using System; -using System.Drawing; -using System.Runtime.InteropServices; -namespace SkinFramWorkCore +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +internal static partial class Interop { - public partial class NativeMethods - { - #region Enums /// - /// Location of cursor hot spot returnet in WM_NCHITTEST. + /// processes messages sent to a window. used by WNDPROC type defines a pointer to this callback function /// - public enum NCHITTEST - { - /// - /// On the screen background or on a dividing line between windows - /// (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). - /// - HTERROR = (-2), - /// - /// In a window currently covered by another window in the same thread - /// (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). - /// - HTTRANSPARENT = (-1), - /// - /// On the screen background or on a dividing line between windows. - /// - HTNOWHERE = 0, - /// In a client area. - HTCLIENT = 1, - /// In a title bar. - HTCAPTION = 2, - /// In a window menu or in a Close button in a child window. - HTSYSMENU = 3, - /// In a size box (same as HTSIZE). - HTGROWBOX = 4, - /// In a menu. - HTMENU = 5, - /// In a horizontal scroll bar. - HTHSCROLL = 6, - /// In the vertical scroll bar. - HTVSCROLL = 7, - /// In a Minimize button. - HTMINBUTTON = 8, - /// In a Maximize button. - HTMAXBUTTON = 9, - /// In the left border of a resizable window - /// (the user can click the mouse to resize the window horizontally). - HTLEFT = 10, - /// - /// In the right border of a resizable window - /// (the user can click the mouse to resize the window horizontally). - /// - HTRIGHT = 11, - /// In the upper-horizontal border of a window. - HTTOP = 12, - /// In the upper-left corner of a window border. - HTTOPLEFT = 13, - /// In the upper-right corner of a window border. - HTTOPRIGHT = 14, - /// In the lower-horizontal border of a resizable window - /// (the user can click the mouse to resize the window vertically). - HTBOTTOM = 15, - /// In the lower-left corner of a border of a resizable window - /// (the user can click the mouse to resize the window diagonally). - HTBOTTOMLEFT = 16, - /// In the lower-right corner of a border of a resizable window - /// (the user can click the mouse to resize the window diagonally). - HTBOTTOMRIGHT = 17, - /// In the border of a window that does not have a sizing border. - HTBORDER = 18, - - HTOBJECT = 19, - /// In a Close button. - HTCLOSE = 20, - /// In a Help button. - HTHELP = 21, - } - [Flags] - public enum SWPFlags - { - SWP_NOSIZE = 0x0001, - SWP_NOMOVE = 0x0002, - SWP_NOZORDER = 0x0004, - SWP_NOREDRAW = 0x0008, - SWP_NOACTIVATE = 0x0010, - SWP_FRAMECHANGED = 0x0020, - } - - [Flags] - public enum LoadLibraryFlags : uint - { - None = 0, - DONT_RESOLVE_DLL_REFERENCES = 0x00000001, - LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, - LOAD_LIBRARY_AS_DATAFILE = 0x00000002, - LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, - LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, - LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200, - LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000, - LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100, - LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800, - LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400, - LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 - } - public enum GWLIndex - { - GWL_STYLE = -16, - GWL_EXSTYLE = -20 - } - public enum BPPF : uint - { - Erase = 1, - NoClip = 2, - NonClient = 4 - } - public enum RedrawWindowOptions - { - RDW_INVALIDATE = 0x0001, - RDW_INTERNALPAINT = 0x0002, - RDW_ERASE = 0x0004, - RDW_VALIDATE = 0x0008, - RDW_NOINTERNALPAINT = 0x0010, - RDW_NOERASE = 0x0020, - RDW_NOCHILDREN = 0x0040, - RDW_ALLCHILDREN = 0x0080, - RDW_UPDATENOW = 0x0100, - RDW_ERASENOW = 0x0200, - RDW_FRAME = 0x0400, - RDW_NOFRAME = 0x0800 - } - public enum BP_BUFFERFORMAT - { - CompatibleBitmap, - DIB, - TopDownDIB, - TopDownMonoDIB - } public enum WindowsMessages : uint { /// @@ -1031,11 +904,11 @@ public enum WindowsMessages : uint PENWINFIRST = 0x0380, PENWINLAST = 0x038F, /// - /// The WM_APP constant is used by applications to help define private messages, usually of the form WM_APP+X, where X is an integer value. + /// The WM_APP constant is used by applications to help define public messages, usually of the form WM_APP+X, where X is an integer value. /// APP = 0x8000, /// - /// The WM_USER constant is used by applications to help define private messages for use by private window classes, usually of the form WM_USER+X, where X is an integer value. + /// The WM_USER constant is used by applications to help define public messages for use by public window classes, usually of the form WM_USER+X, where X is an integer value. /// USER = 0x0400, @@ -1107,455 +980,5 @@ public enum WindowsMessages : uint NCUAHDRAWFRAME = 0x00AF } - - [Flags] - public enum WindowStyles : uint - { - WS_OVERLAPPED = 0x00000000, - WS_POPUP = 0x80000000, - WS_CHILD = 0x40000000, - WS_MINIMIZE = 0x20000000, - WS_VISIBLE = 0x10000000, - WS_DISABLED = 0x08000000, - WS_CLIPSIBLINGS = 0x04000000, - WS_CLIPCHILDREN = 0x02000000, - WS_MAXIMIZE = 0x01000000, - WS_BORDER = 0x00800000, - WS_DLGFRAME = 0x00400000, - WS_VSCROLL = 0x00200000, - WS_HSCROLL = 0x00100000, - WS_SYSMENU = 0x00080000, - WS_THICKFRAME = 0x00040000, - WS_GROUP = 0x00020000, - WS_TABSTOP = 0x00010000, - - WS_MINIMIZEBOX = 0x00020000, - WS_MAXIMIZEBOX = 0x00010000, - - WS_CAPTION = WS_BORDER | WS_DLGFRAME, - WS_TILED = WS_OVERLAPPED, - WS_ICONIC = WS_MINIMIZE, - WS_SIZEBOX = WS_THICKFRAME, - WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, - - WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, - WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, - WS_CHILDWINDOW = WS_CHILD, - - //Extended Window Styles - - WS_EX_DLGMODALFRAME = 0x00000001, - WS_EX_NOPARENTNOTIFY = 0x00000004, - WS_EX_TOPMOST = 0x00000008, - WS_EX_ACCEPTFILES = 0x00000010, - WS_EX_TRANSPARENT = 0x00000020, - - //#if(WINVER >= 0x0400) - - WS_EX_MDICHILD = 0x00000040, - WS_EX_TOOLWINDOW = 0x00000080, - WS_EX_WINDOWEDGE = 0x00000100, - WS_EX_CLIENTEDGE = 0x00000200, - WS_EX_CONTEXTHELP = 0x00000400, - - WS_EX_RIGHT = 0x00001000, - WS_EX_LEFT = 0x00000000, - WS_EX_RTLREADING = 0x00002000, - WS_EX_LTRREADING = 0x00000000, - WS_EX_LEFTSCROLLBAR = 0x00004000, - WS_EX_RIGHTSCROLLBAR = 0x00000000, - - WS_EX_CONTROLPARENT = 0x00010000, - WS_EX_STATICEDGE = 0x00020000, - WS_EX_APPWINDOW = 0x00040000, - - WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE), - WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST), - //#endif /* WINVER >= 0x0400 */ - - //#if(WIN32WINNT >= 0x0500) - - WS_EX_LAYERED = 0x00080000, - //#endif /* WIN32WINNT >= 0x0500 */ - - //#if(WINVER >= 0x0500) - - WS_EX_NOINHERITLAYOUT = 0x00100000, // Disable inheritence of mirroring by children - WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring - //#endif /* WINVER >= 0x0500 */ - - //#if(WIN32WINNT >= 0x0500) - - WS_EX_COMPOSITED = 0x02000000, - WS_EX_NOACTIVATE = 0x08000000 - //#endif /* WIN32WINNT >= 0x0500 */ - - } - - #endregion - - #region Structors - [StructLayout(LayoutKind.Sequential)] - public struct BP_PAINTPARAMS : IDisposable - { - private int cbSize; - public BPPF Flags; - private IntPtr prcExclude; - private IntPtr pBlendFunction; - - public BP_PAINTPARAMS(BPPF flags) - { - cbSize = Marshal.SizeOf(typeof(BP_PAINTPARAMS)); - Flags = flags; - prcExclude = pBlendFunction = IntPtr.Zero; - } - - - - [StructLayout(LayoutKind.Sequential)] - public struct BLENDFUNCTION - { - public byte BlendOp; - public byte BlendFlags; - public byte SourceConstantAlpha; - public byte AlphaFormat; - - public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) - { - BlendOp = op; - BlendFlags = flags; - SourceConstantAlpha = alpha; - AlphaFormat = format; - } - } - - public Rectangle Exclude - { - get { return (Rectangle)Marshal.PtrToStructure(prcExclude, typeof(RECT)); } - set - { - if (prcExclude == IntPtr.Zero) - prcExclude = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RECT))); - Marshal.StructureToPtr(value, prcExclude, false); - } - } - - public BLENDFUNCTION BlendFunction - { - get { return (BLENDFUNCTION)Marshal.PtrToStructure(pBlendFunction, typeof(BLENDFUNCTION)); } - set - { - if (pBlendFunction == IntPtr.Zero) - pBlendFunction = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BLENDFUNCTION))); - Marshal.StructureToPtr(value, pBlendFunction, false); - } - } - - public void Dispose() - { - if (prcExclude != IntPtr.Zero) Marshal.FreeHGlobal(prcExclude); - if (pBlendFunction != IntPtr.Zero) Marshal.FreeHGlobal(pBlendFunction); - } - } - - - - [StructLayout(LayoutKind.Sequential)] - public struct BLENDFUNCTION - { - byte BlendOp; - byte BlendFlags; - byte SourceConstantAlpha; - byte AlphaFormat; - - public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) - { - BlendOp = op; - BlendFlags = flags; - SourceConstantAlpha = alpha; - AlphaFormat = format; - } - } - - [StructLayout(LayoutKind.Sequential)] - public struct POINT - { - public int x; - - public int y; - - internal Point Location - { - get - { - return new Point(x, y); - } - } - - public POINT(int x1, int y1) - { - x = x1; - y = y1; - } - public static implicit operator Point(POINT point) - { - return new Point(point.x, point.y); - } - } - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int left; - - public int top; - - public int right; - - public int bottom; - - public int Height - { - get - { - return bottom - top; - } - } - - public Point Location - { - get - { - return new Point(left, top); - } - } - public Size Size - { - get - { - return new Size(Width, Height); - } - } - public int Width - { - get - { - return right - left; - } - } - - public RECT(int l, int t, int r, int b) - { - left = l; - top = t; - right = r; - bottom = b; - } - - public static RECT FromRectangle(Rectangle r) - { - return new RECT(r.Left, r.Top, r.Right, r.Bottom); - } - - - - public Rectangle ToRectangle() - { - return new Rectangle(left, top, (right - left), (bottom - top)); - } - - public bool IsEmpty => left == 0 & top == 0 & right == 0 & bottom == 0; - - public static RECT FromXYWH(int x, int y, int width, int height) - { - return new RECT(x, y, x + width, y + height); - } - - public RECT GetRtlRect(int width) - { - return new RECT(width - Width - left, top, width - left, bottom); - } - } - public struct MARGINS - { - internal int cxLeftWidth; - - internal int cxRightWidth; - - internal int cyTopHeight; - - internal int cyBottomHeight; - - public MARGINS(int cxLeftWidth, int cxRightWidth, int cyTopHeight, int cyBottomHeight) : this() - { - this.cxLeftWidth = cxRightWidth; - this.cxRightWidth = cxRightWidth; - this.cyTopHeight = cyTopHeight; - this.cyBottomHeight = cyBottomHeight; - } - - - } - - public struct TrackmouseEvent - { - public uint cbSize; - public uint dwFlags; - public IntPtr hwndTrack; - public uint dwHoverTime; - public static readonly TrackmouseEvent Empty; - } - public struct NCCALCSIZE_PARAMS - { - public RECT rgrc0; - - public RECT rgrc1; - - public RECT rgrc2; - - public IntPtr lppos; - } - #endregion - - #region User32 - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool IsWindowVisible(IntPtr hWnd); - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); - - [DllImport("user32.dll", SetLastError = true)] - public static extern int GetWindowLong(IntPtr hWnd, GWLIndex nIndex); - - [DllImport("user32.dll", SetLastError = true)] - public static extern int SetWindowLong(IntPtr hWnd, GWLIndex nIndex, int dwNewLong); - [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)] - public static extern IntPtr GetParent(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern int TrackMouseEvent(ref TrackmouseEvent lpEventTrack); - - [DllImport("user32.dll", SetLastError = false)] - public static extern IntPtr GetDesktopWindow(); - [DllImport("user32.dll")] - public static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw); - - [DllImport("User32.dll")] - public static extern IntPtr GetWindowDC(IntPtr hWnd); - - [DllImport("user32.dll")] - public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); - [DllImport("user32.dll")] - public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); - - [DllImport("user32.dll")] - public static extern int OffsetRect(ref RECT lpRect, int x, int y); - - [DllImport("User32.dll", SetLastError = true)] - public static extern int GetWindowRect(IntPtr hWnd, out RECT lpRect); - [DllImport("User32.dll", SetLastError = true)] - public static extern int GetWindowRect(IntPtr hWnd, out Rectangle lpRect); - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool PtInRect(ref RECT lprc, POINT pt); - [DllImport("user32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool RedrawWindow(IntPtr hWnd, IntPtr rectUpdate, IntPtr hrgnUpdate, uint flags); - #endregion - - #region kernel32 - [DllImport("kernel32.dll", SetLastError = true)] - public static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, LoadLibraryFlags dwFlags); - [DllImport("kernel32.dll", SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool FreeLibrary(IntPtr hModule); - #endregion - - #region UxTheme - [DllImport("uxtheme.dll", SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)] - public static extern int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); - - [DllImport("uxtheme.dll", SetLastError = true)] - [PreserveSig] - public static extern IntPtr BufferedPaintInit(); - - [DllImport("uxtheme.dll", SetLastError = true)] - [PreserveSig] - public static extern IntPtr BufferedPaintUnInit(); - [DllImport("uxtheme.dll", SetLastError = true)] - - public static extern IntPtr BeginBufferedPaint(IntPtr hdc, ref RECT prcTarget, BP_BUFFERFORMAT dwFormat, - ref BP_PAINTPARAMS pPaintParams, out IntPtr phdc); - [DllImport("uxtheme.dll", SetLastError = true)] - - public static extern IntPtr BeginBufferedPaint(IntPtr hdc, ref RECT prcTarget, BP_BUFFERFORMAT dwFormat, - IntPtr pPaintParams, out IntPtr phdc); - [DllImport("uxtheme.dll", EntryPoint = "BufferedPaintClear")] - public static extern int BufferedPaintClear(IntPtr hBufferedPaint, ref RECT prc); - [DllImport("uxtheme.dll", EntryPoint = "BufferedPaintClear")] - public static extern int BufferedPaintClear(IntPtr hBufferedPaint, IntPtr prc); - [DllImport("uxtheme.dll")] - public static extern IntPtr EndBufferedPaint(IntPtr hBufferedPaint, bool fUpdateTarget); - [DllImport("uxtheme.dll")] - public static extern int BufferedPaintSetAlpha(IntPtr hBufferedPaint, [In] ref RECT prc, byte alpha); - - - [DllImport("uxtheme", ExactSpelling = true)] - public extern static int GetThemeRect(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out RECT pRect); - - [DllImport("uxtheme.dll", EntryPoint = "GetThemeStream")] - public static extern int GetThemeStream(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out IntPtr ppvStream, out uint pcbStream, IntPtr hInst); - [DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)] - public static extern int GetThemeInt(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal); - [DllImport("uxtheme.dll", ExactSpelling = true, CharSet = CharSet.Unicode)] - public static extern IntPtr OpenThemeData(IntPtr hWnd, string classList); - [DllImport("uxtheme.dll", ExactSpelling = true)] - [return: MarshalAs(UnmanagedType.Bool)] - public extern static bool IsThemeActive(); - #endregion - - #region Dwmapi - - [DllImport("dwmapi.dll")] - public static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out RECT pvAttribute, int cbAttribute); - [DllImport("dwmapi.dll")] - public static extern int DwmSetWindowAttribute(IntPtr hWnd, uint dwAttribute, IntPtr pvAttribute, uint cbAttribute); - - [DllImport("dwmapi.dll", CharSet = CharSet.Auto, ExactSpelling = false)] - internal static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset); - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern bool DwmIsCompositionEnabled(); - - #endregion - - #region Gdi32 - [DllImport("gdi32.dll")] - public static extern int ExcludeClipRect(IntPtr hdc, int left, int top, int right, int bottom); - /// - /// The CreateRoundRectRgn function creates a rectangular region with rounded corners. - /// - /// x-coordinate of upper-left corner - /// y-coordinate of upper-left corner - /// x-coordinate of lower-right corner - /// y-coordinate of lower-right corner - /// height of ellipse - /// width of ellipse - /// - [DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")] - public static extern IntPtr CreateRoundRectRgn (int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse); - #endregion - - #region Methods - public static int HIWORD(int i) - { - return (short)(i >> 16); - } - public static int LOWORD(int i) - { - return (short)(i & 0xFFFF); - } - #endregion } -} + diff --git a/SkinFramWorkCore/Interop/LRESULT.cs b/SkinFramWorkCore/Interop/LRESULT.cs new file mode 100644 index 0000000..0e9a07c --- /dev/null +++ b/SkinFramWorkCore/Interop/LRESULT.cs @@ -0,0 +1,19 @@ + +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +#pragma warning disable CS8765 +using System; + internal readonly partial struct LRESULT : IEquatable + { + internal readonly IntPtr Value; + internal LRESULT(IntPtr value) => this.Value = value; + public static implicit operator IntPtr(LRESULT value) => value.Value; + public static explicit operator LRESULT(IntPtr value) => new LRESULT(value); + public static bool operator ==(LRESULT left, LRESULT right) => left.Value == right.Value; + public static bool operator !=(LRESULT left, LRESULT right) => !(left == right); + + public bool Equals(LRESULT other) => this.Value == other.Value; + public override bool Equals(object obj) => obj is LRESULT other && this.Equals(other); + public override int GetHashCode() => this.Value.GetHashCode(); + } diff --git a/SkinFramWorkCore/Interop/User32/Interop.GCL.cs b/SkinFramWorkCore/Interop/User32/Interop.GCL.cs new file mode 100644 index 0000000..2f4bc46 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GCL.cs @@ -0,0 +1,27 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static partial class User32 + { + public enum GCL : int + { + /// + /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. + /// + GCLP_WNDPROC = -24, + + /// + /// Retrieves an ATOM value that uniquely identifies the window class. This is the same atom that the RegisterClassEx function returns. + /// + GCW_ATOM = -32, + /// + /// Retrieves a handle to the background brush associated with the class. + /// + GCLP_HBRBACKGROUND=-10 + + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GWLIndex.cs b/SkinFramWorkCore/Interop/User32/Interop.GWLIndex.cs new file mode 100644 index 0000000..ad0fada --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GWLIndex.cs @@ -0,0 +1,46 @@ +// Licensed to the.NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class User32 + { + /// + /// The zero-based offset to the value to be retrieved. Valid values are in the range zero through the number of bytes of extra window memory, minus the size of a LONG_PTR. used by and + /// + public enum GWLIndex + { + /// + /// Retrieves the . + /// + GWL_STYLE = -16, + /// + /// Retrieves the extended window styles. + /// + GWL_EXSTYLE = -20, + /// + /// Retrieves a handle to the application instance. + /// + GWL_HINSTANCE = -6, + /// + /// Retrieves a handle to the parent window, if any. + /// + GWL_HWNDPARENT = -8, + /// + /// Retrieves the identifier of the window. + /// + GWL_ID = -12, + /// + /// Retrieves the user data associated with the window. This data is intended for use by the application that created the window. Its value is initially zero. + /// + GWL_USERDATA = -21, + /// + /// Retrieves the address of the window procedure, or a handle representing the address of the window procedure. You must use the CallWindowProc function to call the window procedure. + /// + GWL_WNDPROC = -4 + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GetClientRect.cs b/SkinFramWorkCore/Interop/User32/Interop.GetClientRect.cs new file mode 100644 index 0000000..a9abf66 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GetClientRect.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern BOOL GetClientRect(IntPtr hWnd, ref RECT lpRect); + + public static BOOL GetClientRect(IHandle hWnd, ref RECT lpRect) + { + BOOL result = GetClientRect(hWnd.Handle, ref lpRect); + GC.KeepAlive(hWnd); + return result; + } + + public static BOOL GetClientRect(HandleRef hWnd, ref RECT lpRect) + { + BOOL result = GetClientRect(hWnd.Handle, ref lpRect); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GetParent.cs b/SkinFramWorkCore/Interop/User32/Interop.GetParent.cs new file mode 100644 index 0000000..0d4c505 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GetParent.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern IntPtr GetParent(IntPtr hWnd); + + public static IntPtr GetParent(IHandle hWnd) + { + IntPtr result = GetParent(hWnd.Handle); + GC.KeepAlive(hWnd); + return result; + } + + public static IntPtr GetParent(HandleRef hWnd) + { + IntPtr result = GetParent(hWnd.Handle); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GetWindowDC.cs b/SkinFramWorkCore/Interop/User32/Interop.GetWindowDC.cs new file mode 100644 index 0000000..37d95b7 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GetWindowDC.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32)] + public static extern Gdi32.HDC GetWindowDC(IntPtr hWnd); + + public static Gdi32.HDC GetWindowDC(IHandle hWnd) + { + Gdi32.HDC result = GetWindowDC(hWnd.Handle); + GC.KeepAlive(hWnd); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GetWindowLong.cs b/SkinFramWorkCore/Interop/User32/Interop.GetWindowLong.cs new file mode 100644 index 0000000..56fa03b --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GetWindowLong.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + // We only ever call this on 32 bit so IntPtr is correct + [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] + private static extern IntPtr GetWindowLongW(IntPtr hWnd, GWLIndex nIndex); + + [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] + public static extern IntPtr GetWindowLongPtrW(IntPtr hWnd, GWLIndex nIndex); + + public static IntPtr GetWindowLong(IntPtr hWnd, GWLIndex nIndex) + { + if (IntPtr.Size == 4) + { + return GetWindowLongW(hWnd, nIndex); + } + + return GetWindowLongPtrW(hWnd, nIndex); + } + + public static IntPtr GetWindowLong(IHandle hWnd, GWLIndex nIndex) + { + IntPtr result = GetWindowLong(hWnd.Handle, nIndex); + GC.KeepAlive(hWnd); + return result; + } + + public static IntPtr GetWindowLong(HandleRef hWnd, GWLIndex nIndex) + { + IntPtr result = GetWindowLong(hWnd.Handle, nIndex); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.GetWindowRect.cs b/SkinFramWorkCore/Interop/User32/Interop.GetWindowRect.cs new file mode 100644 index 0000000..84ac2a3 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.GetWindowRect.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public unsafe static extern BOOL GetWindowRect(IntPtr hWnd, ref RECT rect); + + public static BOOL GetWindowRect(HandleRef hWnd, ref RECT rect) + { + BOOL result = GetWindowRect(hWnd.Handle, ref rect); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + + public static BOOL GetWindowRect(IHandle hWnd, ref RECT rect) + { + BOOL result = GetWindowRect(hWnd.Handle, ref rect); + GC.KeepAlive(hWnd); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.NCCALCSIZE_PARAMS.cs b/SkinFramWorkCore/Interop/User32/Interop.NCCALCSIZE_PARAMS.cs new file mode 100644 index 0000000..565b8b1 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.NCCALCSIZE_PARAMS.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +#pragma warning disable CS0649 +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + internal struct NCCALCSIZE_PARAMS + { + public RECT rgrc0; + public RECT rgrc1; + public RECT rgrc2; + public IntPtr lppos; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.OffsetRect.cs b/SkinFramWorkCore/Interop/User32/Interop.OffsetRect.cs new file mode 100644 index 0000000..6df6eda --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.OffsetRect.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32)] + public static extern int OffsetRect(ref RECT lpRect, int x, int y); + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.ReleaseDC.cs b/SkinFramWorkCore/Interop/User32/Interop.ReleaseDC.cs new file mode 100644 index 0000000..70be8bd --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.ReleaseDC.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern int ReleaseDC(IntPtr hWnd, Gdi32.HDC hDC); + + public static int ReleaseDC(HandleRef hWnd, Gdi32.HDC hDC) + { + int result = ReleaseDC(hWnd.Handle, hDC); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SWPFlags.cs b/SkinFramWorkCore/Interop/User32/Interop.SWPFlags.cs new file mode 100644 index 0000000..12483fd --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SWPFlags.cs @@ -0,0 +1,43 @@ +// Licensed to the.NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class User32 + { + /// + /// The window sizing and positioning flags used in function. + /// + [Flags] + public enum SWPFlags + { + /// + /// Retains the current size (ignores the cx and cy parameters). + /// + SWP_NOSIZE = 0x0001, + /// + /// Retains the current position (ignores X and Y parameters). + /// + SWP_NOMOVE = 0x0002, + /// + /// Retains the current Z order (ignores the hWndInsertAfter parameter). + /// + SWP_NOZORDER = 0x0004, + /// + /// Does not redraw changes. If this flag is set, no repainting of any kind occurs. This applies to the client area, the nonclient area (including the title bar and scroll bars), and any part of the parent window uncovered as a result of the window being moved. When this flag is set, the application must explicitly invalidate or redraw any parts of the window and parent window that need redrawing. + /// + SWP_NOREDRAW = 0x0008, + /// + /// Does not activate the window. If this flag is not set, the window is activated and moved to the top of either the topmost or non-topmost group (depending on the setting of the hWndInsertAfter parameter). + /// + SWP_NOACTIVATE = 0x0010, + /// + /// Applies new frame styles set using the SetWindowLong function. Sends a WM_NCCALCSIZE message to the window, even if the window's size is not being changed. If this flag is not specified, WM_NCCALCSIZE is sent only when the window's size is being changed. + /// + SWP_FRAMECHANGED = 0x0020, + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SetClassLong.cs b/SkinFramWorkCore/Interop/User32/Interop.SetClassLong.cs new file mode 100644 index 0000000..e52ebb6 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SetClassLong.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + // We only ever call this on 32 bit so IntPtr is correct + [DllImport(Libraries.User32, ExactSpelling = true)] + private static extern IntPtr SetClassLongW(IntPtr hwnd, GCL nIndex, IntPtr dwNewLong); + + [DllImport(Libraries.User32, ExactSpelling = true)] + private static extern IntPtr SetClassLongPtrW(IntPtr hwnd, GCL nIndex, IntPtr dwNewLong); + + public static IntPtr SetClassLong(IntPtr hWnd, GCL nIndex, IntPtr dwNewLong) + { + if (IntPtr.Size == 4) + { + return SetClassLongW(hWnd, nIndex, dwNewLong); + } + + return SetClassLongPtrW(hWnd, nIndex, dwNewLong); + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SetWindowLong.cs b/SkinFramWorkCore/Interop/User32/Interop.SetWindowLong.cs new file mode 100644 index 0000000..8317fbd --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SetWindowLong.cs @@ -0,0 +1,53 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + // We only ever call this on 32 bit so IntPtr is correct + [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] + private static extern IntPtr SetWindowLongW(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong); + + [DllImport(Libraries.User32, ExactSpelling = true, SetLastError = true)] + public static extern IntPtr SetWindowLongPtrW(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong); + + public static IntPtr SetWindowLong(IntPtr hWnd, GWLIndex nIndex, IntPtr dwNewLong) + { + if (IntPtr.Size == 4) + { + return SetWindowLongW(hWnd, nIndex, dwNewLong); + } + + return SetWindowLongPtrW(hWnd, nIndex, dwNewLong); + } + + public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, IntPtr dwNewLong) + { + IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong); + GC.KeepAlive(hWnd); + return result; + } + + public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, IHandle dwNewLong) + { + IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong.Handle); + GC.KeepAlive(hWnd); + GC.KeepAlive(dwNewLong); + return result; + } + + public static IntPtr SetWindowLong(IHandle hWnd, GWLIndex nIndex, HandleRef dwNewLong) + { + IntPtr result = SetWindowLong(hWnd.Handle, nIndex, dwNewLong.Handle); + GC.KeepAlive(hWnd); + GC.KeepAlive(dwNewLong.Wrapper); + return result; + } + + + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SetWindowPos.cs b/SkinFramWorkCore/Interop/User32/Interop.SetWindowPos.cs new file mode 100644 index 0000000..0c46a88 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SetWindowPos.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + public static IntPtr HWND_TOP = (IntPtr)0; + public static IntPtr HWND_BOTTOM = (IntPtr)1; + public static IntPtr HWND_TOPMOST = (IntPtr)(-1); + public static IntPtr HWND_NOTOPMOST = (IntPtr)(-2); + public static IntPtr HWND_MESSAGE = (IntPtr)(-3); + + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern BOOL SetWindowPos( + IntPtr hWnd, + IntPtr hWndInsertAfter, + int x = 0, + int y = 0, + int cx = 0, + int cy = 0, + SWPFlags flags = (SWPFlags)0); + + public static BOOL SetWindowPos( + HandleRef hWnd, + IntPtr hWndInsertAfter, + int x = 0, + int y = 0, + int cx = 0, + int cy = 0, + SWPFlags flags = (SWPFlags)0) + { + BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter, x, y, cx, cy, flags); + GC.KeepAlive(hWnd.Wrapper); + return result; + } + + public static BOOL SetWindowPos( + HandleRef hWnd, + HandleRef hWndInsertAfter, + int x = 0, + int y = 0, + int cx = 0, + int cy = 0, + SWPFlags flags = (SWPFlags)0) + { + BOOL result = SetWindowPos(hWnd.Handle, hWndInsertAfter.Handle, x, y, cx, cy, flags); + GC.KeepAlive(hWnd.Wrapper); + GC.KeepAlive(hWndInsertAfter.Wrapper); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SetWindowRgn.cs b/SkinFramWorkCore/Interop/User32/Interop.SetWindowRgn.cs new file mode 100644 index 0000000..707ed5b --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SetWindowRgn.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern int SetWindowRgn(IntPtr hwnd, Gdi32.HRGN hrgn, bool fRedraw); + + public static int SetWindowRgn(IHandle hwnd, Gdi32.HRGN hrgn, bool fRedraw) + { + int result = SetWindowRgn(hwnd.Handle, hrgn, fRedraw); + GC.KeepAlive(hwnd); + return result; + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.SystemMetric.cs b/SkinFramWorkCore/Interop/User32/Interop.SystemMetric.cs new file mode 100644 index 0000000..f4ee841 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.SystemMetric.cs @@ -0,0 +1,552 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +internal static partial class Interop +{ + internal static partial class User32 + { + /// + /// Flags used with the Windows API + /// + public enum SystemMetric + { + /// + /// The flags that specify how the system arranged minimized windows. For more information, see the Remarks section in this topic. + /// + SM_ARRANGE = 56, + + /// + /// The value that specifies how the system is started: + /// 0 Normal boot + /// 1 Fail-safe boot + /// 2 Fail-safe with network boot + /// A fail-safe boot (also called SafeBoot, Safe Mode, or Clean Boot) bypasses the user startup files. + /// + SM_CLEANBOOT = 67, + + /// + /// The number of display monitors on a desktop. For more information, see the Remarks section in this topic. + /// + SM_CMONITORS = 80, + + /// + /// The number of buttons on a mouse, or zero if no mouse is installed. + /// + SM_CMOUSEBUTTONS = 43, + + /// + /// The width of a window border, in pixels. This is equivalent to the SM_CXEDGE value for windows with the 3-D look. + /// + SM_CXBORDER = 5, + + /// + /// The width of a cursor, in pixels. The system cannot create cursors of other sizes. + /// + SM_CXCURSOR = 13, + + /// + /// This value is the same as SM_CXFIXEDFRAME. + /// + SM_CXDLGFRAME = 7, + + /// + /// The width of the rectangle around the location of a first click in a double-click sequence, in pixels. , + /// The second click must occur within the rectangle that is defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system + /// to consider the two clicks a double-click. The two clicks must also occur within a specified time. + /// To set the width of the double-click rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKWIDTH. + /// + SM_CXDOUBLECLK = 36, + + /// + /// The number of pixels on either side of a mouse-down point that the mouse pointer can move before a drag operation begins. + /// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation. + /// If this value is negative, it is subtracted from the left of the mouse-down point and added to the right of it. + /// + SM_CXDRAG = 68, + + /// + /// The width of a 3-D border, in pixels. This metric is the 3-D counterpart of SM_CXBORDER. + /// + SM_CXEDGE = 45, + + /// + /// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. + /// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border. + /// This value is the same as SM_CXDLGFRAME. + /// + SM_CXFIXEDFRAME = 7, + + /// + /// The width of the left and right edges of the focus rectangle that the DrawFocusRectdraws. + /// This value is in pixels. + /// Windows 2000: This value is not supported. + /// + SM_CXFOCUSBORDER = 83, + + /// + /// This value is the same as SM_CXSIZEFRAME. + /// + SM_CXFRAME = 32, + + /// + /// The width of the client area for a full-screen window on the primary display monitor, in pixels. + /// To get the coordinates of the portion of the screen that is not obscured by the system taskbar or by application desktop toolbars, + /// call the SystemParametersInfofunction with the SPI_GETWORKAREA value. + /// + SM_CXFULLSCREEN = 16, + + /// + /// The width of the arrow bitmap on a horizontal scroll bar, in pixels. + /// + SM_CXHSCROLL = 21, + + /// + /// The width of the thumb box in a horizontal scroll bar, in pixels. + /// + SM_CXHTHUMB = 10, + + /// + /// The default width of an icon, in pixels. The LoadIcon function can load only icons with the dimensions + /// that SM_CXICON and SM_CYICON specifies. + /// + SM_CXICON = 11, + + /// + /// The width of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size + /// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CXICON. + /// + SM_CXICONSPACING = 38, + + /// + /// The default width, in pixels, of a maximized top-level window on the primary display monitor. + /// + SM_CXMAXIMIZED = 61, + + /// + /// The default maximum width of a window that has a caption and sizing borders, in pixels. + /// This metric refers to the entire desktop. The user cannot drag the window frame to a size larger than these dimensions. + /// A window can override this value by processing the WM_GETMINMAXINFO message. + /// + SM_CXMAXTRACK = 59, + + /// + /// The width of the default menu check-mark bitmap, in pixels. + /// + SM_CXMENUCHECK = 71, + + /// + /// The width of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels. + /// + SM_CXMENUSIZE = 54, + + /// + /// The minimum width of a window, in pixels. + /// + SM_CXMIN = 28, + + /// + /// The width of a minimized window, in pixels. + /// + SM_CXMINIMIZED = 57, + + /// + /// The width of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. + /// This value is always greater than or equal to SM_CXMINIMIZED. + /// + SM_CXMINSPACING = 47, + + /// + /// The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. + /// A window can override this value by processing the WM_GETMINMAXINFO message. + /// + SM_CXMINTRACK = 34, + + /// + /// The amount of border padding for captioned windows, in pixels. Windows XP/2000: This value is not supported. + /// + SM_CXPADDEDBORDER = 92, + + /// + /// The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling + /// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES). + /// + SM_CXSCREEN = 0, + + /// + /// The width of a button in a window caption or title bar, in pixels. + /// + SM_CXSIZE = 30, + + /// + /// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels. + /// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border. + /// This value is the same as SM_CXFRAME. + /// + SM_CXSIZEFRAME = 32, + + /// + /// The recommended width of a small icon, in pixels. Small icons typically appear in window captions and in small icon view. + /// + SM_CXSMICON = 49, + + /// + /// The width of small caption buttons, in pixels. + /// + SM_CXSMSIZE = 52, + + /// + /// The width of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. + /// The SM_XVIRTUALSCREEN metric is the coordinates for the left side of the virtual screen. + /// + SM_CXVIRTUALSCREEN = 78, + + /// + /// The width of a vertical scroll bar, in pixels. + /// + SM_CXVSCROLL = 2, + + /// + /// The height of a window border, in pixels. This is equivalent to the SM_CYEDGE value for windows with the 3-D look. + /// + SM_CYBORDER = 6, + + /// + /// The height of a caption area, in pixels. + /// + SM_CYCAPTION = 4, + + /// + /// The height of a cursor, in pixels. The system cannot create cursors of other sizes. + /// + SM_CYCURSOR = 14, + + /// + /// This value is the same as SM_CYFIXEDFRAME. + /// + SM_CYDLGFRAME = 8, + + /// + /// The height of the rectangle around the location of a first click in a double-click sequence, in pixels. + /// The second click must occur within the rectangle defined by SM_CXDOUBLECLK and SM_CYDOUBLECLK for the system to consider + /// the two clicks a double-click. The two clicks must also occur within a specified time. To set the height of the double-click + /// rectangle, call SystemParametersInfo with SPI_SETDOUBLECLKHEIGHT. + /// + SM_CYDOUBLECLK = 37, + + /// + /// The number of pixels above and below a mouse-down point that the mouse pointer can move before a drag operation begins. + /// This allows the user to click and release the mouse button easily without unintentionally starting a drag operation. + /// If this value is negative, it is subtracted from above the mouse-down point and added below it. + /// + SM_CYDRAG = 69, + + /// + /// The height of a 3-D border, in pixels. This is the 3-D counterpart of SM_CYBORDER. + /// + SM_CYEDGE = 46, + + /// + /// The thickness of the frame around the perimeter of a window that has a caption but is not sizable, in pixels. + /// SM_CXFIXEDFRAME is the height of the horizontal border, and SM_CYFIXEDFRAME is the width of the vertical border. + /// This value is the same as SM_CYDLGFRAME. + /// + SM_CYFIXEDFRAME = 8, + + /// + /// The height of the top and bottom edges of the focus rectangle drawn byDrawFocusRect. + /// This value is in pixels. + /// Windows 2000: This value is not supported. + /// + SM_CYFOCUSBORDER = 84, + + /// + /// This value is the same as SM_CYSIZEFRAME. + /// + SM_CYFRAME = 33, + + /// + /// The height of the client area for a full-screen window on the primary display monitor, in pixels. + /// To get the coordinates of the portion of the screen not obscured by the system taskbar or by application desktop toolbars, + /// call the SystemParametersInfo function with the SPI_GETWORKAREA value. + /// + SM_CYFULLSCREEN = 17, + + /// + /// The height of a horizontal scroll bar, in pixels. + /// + SM_CYHSCROLL = 3, + + /// + /// The default height of an icon, in pixels. The LoadIcon function can load only icons with the dimensions SM_CXICON and SM_CYICON. + /// + SM_CYICON = 12, + + /// + /// The height of a grid cell for items in large icon view, in pixels. Each item fits into a rectangle of size + /// SM_CXICONSPACING by SM_CYICONSPACING when arranged. This value is always greater than or equal to SM_CYICON. + /// + SM_CYICONSPACING = 39, + + /// + /// For double byte character set versions of the system, this is the height of the Kanji window at the bottom of the screen, in pixels. + /// + SM_CYKANJIWINDOW = 18, + + /// + /// The default height, in pixels, of a maximized top-level window on the primary display monitor. + /// + SM_CYMAXIMIZED = 62, + + /// + /// The default maximum height of a window that has a caption and sizing borders, in pixels. This metric refers to the entire desktop. + /// The user cannot drag the window frame to a size larger than these dimensions. A window can override this value by processing + /// the WM_GETMINMAXINFO message. + /// + SM_CYMAXTRACK = 60, + + /// + /// The height of a single-line menu bar, in pixels. + /// + SM_CYMENU = 15, + + /// + /// The height of the default menu check-mark bitmap, in pixels. + /// + SM_CYMENUCHECK = 72, + + /// + /// The height of menu bar buttons, such as the child window close button that is used in the multiple document interface, in pixels. + /// + SM_CYMENUSIZE = 55, + + /// + /// The minimum height of a window, in pixels. + /// + SM_CYMIN = 29, + + /// + /// The height of a minimized window, in pixels. + /// + SM_CYMINIMIZED = 58, + + /// + /// The height of a grid cell for a minimized window, in pixels. Each minimized window fits into a rectangle this size when arranged. + /// This value is always greater than or equal to SM_CYMINIMIZED. + /// + SM_CYMINSPACING = 48, + + /// + /// The minimum tracking height of a window, in pixels. The user cannot drag the window frame to a size smaller than these dimensions. + /// A window can override this value by processing the WM_GETMINMAXINFO message. + /// + SM_CYMINTRACK = 35, + + /// + /// The height of the screen of the primary display monitor, in pixels. This is the same value obtained by calling + /// GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, VERTRES). + /// + SM_CYSCREEN = 1, + + /// + /// The height of a button in a window caption or title bar, in pixels. + /// + SM_CYSIZE = 31, + + /// + /// The thickness of the sizing border around the perimeter of a window that can be resized, in pixels. + /// SM_CXSIZEFRAME is the width of the horizontal border, and SM_CYSIZEFRAME is the height of the vertical border. + /// This value is the same as SM_CYFRAME. + /// + SM_CYSIZEFRAME = 33, + + /// + /// The height of a small caption, in pixels. + /// + SM_CYSMCAPTION = 51, + + /// + /// The recommended height of a small icon, in pixels. Small icons typically appear in window captions and in small icon view. + /// + SM_CYSMICON = 50, + + /// + /// The height of small caption buttons, in pixels. + /// + SM_CYSMSIZE = 53, + + /// + /// The height of the virtual screen, in pixels. The virtual screen is the bounding rectangle of all display monitors. + /// The SM_YVIRTUALSCREEN metric is the coordinates for the top of the virtual screen. + /// + SM_CYVIRTUALSCREEN = 79, + + /// + /// The height of the arrow bitmap on a vertical scroll bar, in pixels. + /// + SM_CYVSCROLL = 20, + + /// + /// The height of the thumb box in a vertical scroll bar, in pixels. + /// + SM_CYVTHUMB = 9, + + /// + /// Nonzero if User32.dll supports DBCS; otherwise, 0. + /// + SM_DBCSENABLED = 42, + + /// + /// Nonzero if the debug version of User.exe is installed; otherwise, 0. + /// + SM_DEBUG = 22, + + /// + /// Nonzero if the current operating system is Windows 7 or Windows Server 2008 R2 and the Tablet PC Input + /// service is started; otherwise, 0. The return value is a bitmask that specifies the type of digitizer input supported by the device. + /// For more information, see Remarks. + /// Windows Server 2008, Windows Vista, and Windows XP/2000: This value is not supported. + /// + SM_DIGITIZER = 94, + + /// + /// Nonzero if Input Method Manager/Input Method Editor features are enabled; otherwise, 0. + /// SM_IMMENABLED indicates whether the system is ready to use a Unicode-based IME on a Unicode application. + /// To ensure that a language-dependent IME works, check SM_DBCSENABLED and the system ANSI code page. + /// Otherwise the ANSI-to-Unicode conversion may not be performed correctly, or some components like fonts + /// or registry settings may not be present. + /// + SM_IMMENABLED = 82, + + /// + /// Nonzero if there are digitizers in the system; otherwise, 0. SM_MAXIMUMTOUCHES returns the aggregate maximum of the + /// maximum number of contacts supported by every digitizer in the system. If the system has only single-touch digitizers, + /// the return value is 1. If the system has multi-touch digitizers, the return value is the number of simultaneous contacts + /// the hardware can provide. Windows Server 2008, Windows Vista, and Windows XP/2000: This value is not supported. + /// + SM_MAXIMUMTOUCHES = 95, + + /// + /// Nonzero if the current operating system is the Windows XP, Media Center Edition, 0 if not. + /// + SM_MEDIACENTER = 87, + + /// + /// Nonzero if drop-down menus are right-aligned with the corresponding menu-bar item; 0 if the menus are left-aligned. + /// + SM_MENUDROPALIGNMENT = 40, + + /// + /// Nonzero if the system is enabled for Hebrew and Arabic languages, 0 if not. + /// + SM_MIDEASTENABLED = 74, + + /// + /// Nonzero if a mouse is installed; otherwise, 0. This value is rarely zero, because of support for virtual mice and because + /// some systems detect the presence of the port instead of the presence of a mouse. + /// + SM_MOUSEPRESENT = 19, + + /// + /// Nonzero if a mouse with a horizontal scroll wheel is installed; otherwise 0. + /// + SM_MOUSEHORIZONTALWHEELPRESENT = 91, + + /// + /// Nonzero if a mouse with a vertical scroll wheel is installed; otherwise 0. + /// + SM_MOUSEWHEELPRESENT = 75, + + /// + /// The least significant bit is set if a network is present; otherwise, it is cleared. The other bits are reserved for future use. + /// + SM_NETWORK = 63, + + /// + /// Nonzero if the Microsoft Windows for Pen computing extensions are installed; zero otherwise. + /// + SM_PENWINDOWS = 41, + + /// + /// This system metric is used in a Terminal Services environment to determine if the current Terminal Server session is + /// being remotely controlled. Its value is nonzero if the current session is remotely controlled; otherwise, 0. + /// You can use terminal services management tools such as Terminal Services Manager (tsadmin.msc) and shadow.exe to + /// control a remote session. When a session is being remotely controlled, another user can view the contents of that session + /// and potentially interact with it. + /// + SM_REMOTECONTROL = 0x2001, + + /// + /// This system metric is used in a Terminal Services environment. If the calling process is associated with a Terminal Services + /// client session, the return value is nonzero. If the calling process is associated with the Terminal Services console session, + /// the return value is 0. + /// Windows Server 2003 and Windows XP: The console session is not necessarily the physical console. + /// For more information, seeWTSGetActiveConsoleSessionId. + /// + SM_REMOTESESSION = 0x1000, + + /// + /// Nonzero if all the display monitors have the same color format, otherwise, 0. Two displays can have the same bit depth, + /// but different color formats. For example, the red, green, and blue pixels can be encoded with different numbers of bits, + /// or those bits can be located in different places in a pixel color value. + /// + SM_SAMEDISPLAYFORMAT = 81, + + /// + /// This system metric should be ignored; it always returns 0. + /// + SM_SECURE = 44, + + /// + /// The build number if the system is Windows Server 2003 R2; otherwise, 0. + /// + SM_SERVERR2 = 89, + + /// + /// Nonzero if the user requires an application to present information visually in situations where it would otherwise present + /// the information only in audible form; otherwise, 0. + /// + SM_SHOWSOUNDS = 70, + + /// + /// Nonzero if the current session is shutting down; otherwise, 0. Windows 2000: This value is not supported. + /// + SM_SHUTTINGDOWN = 0x2000, + + /// + /// Nonzero if the computer has a low-end (slow) processor; otherwise, 0. + /// + SM_SLOWMACHINE = 73, + + /// + /// Nonzero if the current operating system is Windows 7 Starter Edition, Windows Vista Starter, or Windows XP Starter Edition; otherwise, 0. + /// + SM_STARTER = 88, + + /// + /// Nonzero if the meanings of the left and right mouse buttons are swapped; otherwise, 0. + /// + SM_SWAPBUTTON = 23, + + /// + /// Nonzero if the current operating system is the Windows XP Tablet PC edition or if the current operating system is Windows Vista + /// or Windows 7 and the Tablet PC Input service is started; otherwise, 0. The SM_DIGITIZER setting indicates the type of digitizer + /// input supported by a device running Windows 7 or Windows Server 2008 R2. For more information, see Remarks. + /// + SM_TABLETPC = 86, + + /// + /// The coordinates for the left side of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. + /// The SM_CXVIRTUALSCREEN metric is the width of the virtual screen. + /// + SM_XVIRTUALSCREEN = 76, + + /// + /// The coordinates for the top of the virtual screen. The virtual screen is the bounding rectangle of all display monitors. + /// The SM_CYVIRTUALSCREEN metric is the height of the virtual screen. + /// + SM_YVIRTUALSCREEN = 77, + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.TME.cs b/SkinFramWorkCore/Interop/User32/Interop.TME.cs new file mode 100644 index 0000000..7baeca0 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.TME.cs @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +internal static partial class Interop +{ + internal static partial class User32 + { + [Flags] + public enum TME : uint + { + HOVER = 0x00000001, + LEAVE = 0x00000002, + NONCLIENT = 0x00000010, + QUERY = 0x40000000, + CANCEL = 0x80000000, + } + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interop.TrackMouseEvent.cs b/SkinFramWorkCore/Interop/User32/Interop.TrackMouseEvent.cs new file mode 100644 index 0000000..5fc34b1 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interop.TrackMouseEvent.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock; + +internal static partial class Interop +{ + internal static partial class User32 + { + public struct TRACKMOUSEEVENT + { + public uint cbSize; + public TME dwFlags; + public IntPtr hwndTrack; + public uint dwHoverTime; + + public bool IsDefault() + { + return cbSize == 0 && dwFlags == 0 && hwndTrack == IntPtr.Zero && dwHoverTime == 0; + } + } + + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern BOOL TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack); + } +} diff --git a/SkinFramWorkCore/Interop/User32/Interp.GetSystemMetrics.cs b/SkinFramWorkCore/Interop/User32/Interp.GetSystemMetrics.cs new file mode 100644 index 0000000..63a473d --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/Interp.GetSystemMetrics.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class User32 + { + [DllImport(Libraries.User32, ExactSpelling = true)] + public static extern int GetSystemMetrics(SystemMetric nIndex); + + [DllImport(Libraries.User32, ExactSpelling = true)] + private static extern int GetSystemMetricsForDpi(SystemMetric nIndex, uint dpi); + } +} \ No newline at end of file diff --git a/SkinFramWorkCore/Interop/User32/NCHITTEST.cs b/SkinFramWorkCore/Interop/User32/NCHITTEST.cs new file mode 100644 index 0000000..265c180 --- /dev/null +++ b/SkinFramWorkCore/Interop/User32/NCHITTEST.cs @@ -0,0 +1,79 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + internal static partial class User32 + { + /// + /// Location of cursor hot spot returnet in WM_NCHITTEST. + /// + public enum NCHITTEST + { + /// + /// On the screen background or on a dividing line between windows + /// (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error). + /// + HTERROR = (-2), + /// + /// In a window currently covered by another window in the same thread + /// (the message will be sent to underlying windows in the same thread until one of them returns a code that is not HTTRANSPARENT). + /// + HTTRANSPARENT = (-1), + /// + /// On the screen background or on a dividing line between windows. + /// + HTNOWHERE = 0, + /// In a client area. + HTCLIENT = 1, + /// In a title bar. + HTCAPTION = 2, + /// In a window menu or in a Close button in a child window. + HTSYSMENU = 3, + /// In a size box (same as HTSIZE). + HTGROWBOX = 4, + /// In a menu. + HTMENU = 5, + /// In a horizontal scroll bar. + HTHSCROLL = 6, + /// In the vertical scroll bar. + HTVSCROLL = 7, + /// In a Minimize button. + HTMINBUTTON = 8, + /// In a Maximize button. + HTMAXBUTTON = 9, + /// In the left border of a resizable window + /// (the user can click the mouse to resize the window horizontally). + HTLEFT = 10, + /// + /// In the right border of a resizable window + /// (the user can click the mouse to resize the window horizontally). + /// + HTRIGHT = 11, + /// In the upper-horizontal border of a window. + HTTOP = 12, + /// In the upper-left corner of a window border. + HTTOPLEFT = 13, + /// In the upper-right corner of a window border. + HTTOPRIGHT = 14, + /// In the lower-horizontal border of a resizable window + /// (the user can click the mouse to resize the window vertically). + HTBOTTOM = 15, + /// In the lower-left corner of a border of a resizable window + /// (the user can click the mouse to resize the window diagonally). + HTBOTTOMLEFT = 16, + /// In the lower-right corner of a border of a resizable window + /// (the user can click the mouse to resize the window diagonally). + HTBOTTOMRIGHT = 17, + /// In the border of a window that does not have a sizing border. + HTBORDER = 18, + + HTOBJECT = 19, + /// In a Close button. + HTCLOSE = 20, + /// In a Help button. + HTHELP = 21, + } + } +} \ No newline at end of file diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.BPPF.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.BPPF.cs new file mode 100644 index 0000000..f740b48 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.BPPF.cs @@ -0,0 +1,24 @@ +internal static partial class Interop +{ + public static partial class UxTheme + { + /// + /// value used in struct + /// + public enum BPPF : uint + { + /// + /// Initialize the buffer to ARGB = {0, 0, 0, 0} during B This erases the previous contents of the buffer. + /// + Erase = 1, + /// + /// Do not apply the clip region of the target DC to the double buffer. If this flag is not set and if the target DC is a window DC, then clipping due to overlapping windows is applied to the double buffer. + /// + NoClip = 2, + /// + /// A non-client DC is being used. + /// + NonClient = 4 + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.BP_BUFFERFORMAT.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.BP_BUFFERFORMAT.cs new file mode 100644 index 0000000..165380f --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.BP_BUFFERFORMAT.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + public static partial class UxTheme + { + public enum BP_BUFFERFORMAT + { + /// + /// Compatible bitmap. The number of bits per pixel is based on the color format of the device associated with the HDC specified with BeginBufferedPaint or BeginBufferedAnimation—typically, this is the display device. + /// + CompatibleBitmap, + /// + /// Bottom-up device-independent bitmap. The origin of the bitmap is the lower-left corner. Uses 32 bits per pixel. + /// + DIB, + /// + /// Top-down device-independent bitmap. The origin of the bitmap is the upper-left corner. Uses 32 bits per pixel. + /// + TopDownDIB, + /// + /// Top-down, monochrome, device-independent bitmap. Uses 1 bit per pixel. + /// + TopDownMonoDIB + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.BP_PAINTPARAMS.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.BP_PAINTPARAMS.cs new file mode 100644 index 0000000..5a6b950 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.BP_PAINTPARAMS.cs @@ -0,0 +1,96 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System.Drawing; +using System; + +internal static partial class Interop +{ + public static partial class UxTheme + { + + + /// + /// Defines paint operation parameters for . + /// + [StructLayout(LayoutKind.Sequential)] + public struct BP_PAINTPARAMS : IDisposable + { + /// + /// The size, in bytes, of this structure + /// + private readonly int cbSize; + /// + /// + /// + private readonly BPPF Flags; + /// + /// A pointer to exclusion RECT structure. This rectangle is excluded from the clipping region. May be NULL for no exclusion rectangle. + /// + private IntPtr prcExclude; + /// + /// A pointer to BLENDFUNCTION structure, which controls blending by specifying the blending functions for source and destination bitmaps. If NULL, the source buffer is copied to the destination with no blending. + /// + private IntPtr pBlendFunction; + + public BP_PAINTPARAMS(BPPF flags) + { + cbSize = Marshal.SizeOf(typeof(BP_PAINTPARAMS)); + Flags = flags; + prcExclude = pBlendFunction = IntPtr.Zero; + } + + [StructLayout(LayoutKind.Sequential)] + public struct BLENDFUNCTION + { + public byte BlendOp; + public byte BlendFlags; + public byte SourceConstantAlpha; + public byte AlphaFormat; + + public BLENDFUNCTION(byte op, byte flags, byte alpha, byte format) + { + BlendOp = op; + BlendFlags = flags; + SourceConstantAlpha = alpha; + AlphaFormat = format; + } + } + + public Rectangle Exclude + { + get + { + return Marshal.PtrToStructure(prcExclude); + } + set + { + if (prcExclude == IntPtr.Zero) + prcExclude = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(RECT))); + Marshal.StructureToPtr(value, prcExclude, false); + } + } + + public BLENDFUNCTION BlendFunction + { + get { return Marshal.PtrToStructure(pBlendFunction); } + set + { + if (pBlendFunction == IntPtr.Zero) + pBlendFunction = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BLENDFUNCTION))); + Marshal.StructureToPtr(value, pBlendFunction, false); + } + } + + public void Dispose() + { + if (prcExclude != IntPtr.Zero) + Marshal.FreeHGlobal(prcExclude); + if (pBlendFunction != IntPtr.Zero) + Marshal.FreeHGlobal(pBlendFunction); + } + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.BeginBufferedPaint.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.BeginBufferedPaint.cs new file mode 100644 index 0000000..05731f8 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.BeginBufferedPaint.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + /// + /// Begins a buffered paint operation. + /// + /// The handle of the target DC on which the buffer will be painted. + /// A pointer to a RECT structure that specifies the area of the target DC in which to paint. + /// A member of the enumeration that specifies the format of the buffer. + /// A pointer to a structure that defines the paint operation parameters. This value can be NULL. + /// When this function returns, points to the handle of the new device context. + /// Type: + /// A handle to the buffered paint context. If this function fails, the return value is NULL, and phdc is NULL. To get extended error information, call GetLastError. + [DllImport(Libraries.UxTheme, SetLastError = true)] + + public static extern HPAINTBUFFER BeginBufferedPaint(Gdi32.HDC hdc, ref RECT prcTarget, BP_BUFFERFORMAT dwFormat, ref BP_PAINTPARAMS pPaintParams, out Gdi32.HDC phdc); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.CloseThemeData.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.CloseThemeData.cs new file mode 100644 index 0000000..cf3e076 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.CloseThemeData.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme, ExactSpelling = true)] + public static extern HRESULT CloseThemeData(IntPtr hTheme); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.DTTOPTS.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.DTTOPTS.cs new file mode 100644 index 0000000..8e22c27 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.DTTOPTS.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Drawing; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + [StructLayout(LayoutKind.Sequential)] + public struct DTTOPTS + { + public int dwSize; + public int dwFlags; + public int crText; + public int crBorder; + public int crShadow; + public int iTextShadowType; + public Point ptShadowOffset; + public int iBorderSize; + public int iFontPropId; + public int iColorPropId; + public int iStateId; + public bool fApplyOverlay; + public int iGlowSize; + public int pfnDrawTextCallback; + public IntPtr lParam; + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.DrawThemeTextEx.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.DrawThemeTextEx.cs new file mode 100644 index 0000000..6f6ed76 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.DrawThemeTextEx.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme, CharSet = CharSet.Unicode)] + public static extern HRESULT DrawThemeTextEx(IntPtr hTheme, Gdi32.HDC hdc, int iPartId, int iStateId, string text, int iCharCount, int dwFlags, ref RECT pRect, ref DTTOPTS pOptions); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.EndBufferedPaint.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.EndBufferedPaint.cs new file mode 100644 index 0000000..a1a2567 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.EndBufferedPaint.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme)] + public static extern HRESULT EndBufferedPaint(HPAINTBUFFER hBufferedPaint, [MarshalAs(UnmanagedType.Bool)] bool fUpdateTarget); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeInt.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeInt.cs new file mode 100644 index 0000000..4a00750 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeInt.cs @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme, ExactSpelling = true)] + public static extern HRESULT GetThemeInt(IntPtr hTheme, int iPartId, int iStateId, int iPropId, ref int piVal); + + public static HRESULT GetThemeInt(IHandle hTheme, int iPartId, int iStateId, int iPropId, ref int piVal) + { + HRESULT hr = GetThemeInt(hTheme.Handle, iPartId, iStateId, iPropId, ref piVal); + GC.KeepAlive(hTheme); + return hr; + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeRect.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeRect.cs new file mode 100644 index 0000000..dcbfa1d --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeRect.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme)] + public static extern HRESULT GetThemeRect(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out RECT pRect); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeStream.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeStream.cs new file mode 100644 index 0000000..d32321e --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.GetThemeStream.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme)] + public static extern int GetThemeStream(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out IntPtr ppvStream, out uint pcbStream, IntPtr hInst); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.HPAINTBUFFER.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.HPAINTBUFFER.cs new file mode 100644 index 0000000..ca99c90 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.HPAINTBUFFER.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +#pragma warning disable CS8765 +using System; +using System.Reflection.Metadata; +using System.Runtime.InteropServices; +internal static partial class Interop +{ + public static partial class UxTheme + { + /// Provides a handle to a paint buffer. + [StructLayout(LayoutKind.Sequential)] + public struct HPAINTBUFFER : IHandle, IEquatable + { + public IntPtr Handle { get; } + public HPAINTBUFFER(IntPtr preHandle) => Handle = preHandle; + public bool IsNull => Handle == IntPtr.Zero; + public static explicit operator IntPtr(HPAINTBUFFER h) => h.Handle; + public static implicit operator HPAINTBUFFER(IntPtr h) => new HPAINTBUFFER(h); + public static bool operator !=(HPAINTBUFFER h1, HPAINTBUFFER h2) => !(h1 == h2); + public static bool operator ==(HPAINTBUFFER h1, HPAINTBUFFER h2) => h1.Equals(h2); + public bool Equals(HPAINTBUFFER other) => Handle == other.Handle; + public override bool Equals(object obj) => obj is HPAINTBUFFER h && Equals(h); + public override int GetHashCode() => Handle.GetHashCode(); + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.MARGINS.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.MARGINS.cs new file mode 100644 index 0000000..f6951af --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.MARGINS.cs @@ -0,0 +1,17 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +internal static partial class Interop +{ + public static partial class UxTheme + { + public struct MARGINS + { + public int cxLeftWidth; + public int cxRightWidth; + public int cyTopHeight; + public int cyBottomHeight; + } + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.OpenThemeData.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.OpenThemeData.cs new file mode 100644 index 0000000..5344516 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.OpenThemeData.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme, ExactSpelling = true, CharSet = CharSet.Unicode)] + public static extern IntPtr OpenThemeData(IntPtr hwnd, string pszClassList); + } +} diff --git a/SkinFramWorkCore/Interop/UxTheme/Interop.SetWindowTheme.cs b/SkinFramWorkCore/Interop/UxTheme/Interop.SetWindowTheme.cs new file mode 100644 index 0000000..8a6e930 --- /dev/null +++ b/SkinFramWorkCore/Interop/UxTheme/Interop.SetWindowTheme.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + public static partial class UxTheme + { + [DllImport(Libraries.UxTheme, CharSet = CharSet.Unicode, ExactSpelling = true)] + public static extern HRESULT SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); + } +} diff --git a/SkinFramWorkCore/Interop/interop.WindowStyles.cs b/SkinFramWorkCore/Interop/interop.WindowStyles.cs new file mode 100644 index 0000000..0c78180 --- /dev/null +++ b/SkinFramWorkCore/Interop/interop.WindowStyles.cs @@ -0,0 +1,173 @@ +using System; +internal static partial class Interop +{ + [Flags] + public enum WindowStyles : uint + { + /// + /// The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style. + /// + WS_OVERLAPPED = 0x00000000, + /// + /// The window is a pop-up window. This style cannot be used with the WS_CHILD style. + /// + WS_POPUP = 0x80000000, + /// + /// The window is a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style. + /// + WS_CHILD = 0x40000000, + /// + /// The window is initially minimized. Same as the WS_ICONIC style. + /// + WS_MINIMIZE = 0x20000000, + /// + /// The window is initially visible. + /// This style can be turned on and off by using the ShowWindow or SetWindowPos function. + /// + WS_VISIBLE = 0x10000000, + /// + /// The window is initially disabled. A disabled window cannot receive input from the user. To change this after a window has been created, use the EnableWindow function. + /// + WS_DISABLED = 0x08000000, + /// + /// Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window. + /// + WS_CLIPSIBLINGS = 0x04000000, + /// + /// Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window. + /// + WS_CLIPCHILDREN = 0x02000000, + /// + /// The window is initially maximized. + /// + WS_MAXIMIZE = 0x01000000, + /// + /// The window has a thin-line border + /// + WS_BORDER = 0x00800000, + /// + /// The window has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. + /// + WS_DLGFRAME = 0x00400000, + WS_VSCROLL = 0x00200000, + /// + /// The window has a horizontal scroll bar. + /// + WS_HSCROLL = 0x00100000, + WS_SYSMENU = 0x00080000, + /// + /// The window has a sizing border. Same as the WS_SIZEBOX style. + /// + WS_THICKFRAME = 0x00040000, + /// + /// The window is the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. + /// + WS_GROUP = 0x00020000, + /// + /// The window is a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. + /// + WS_TABSTOP = 0x00010000, + /// + /// The window has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. + /// + + WS_MINIMIZEBOX = 0x00020000, + /// + /// The window has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. + /// + WS_MAXIMIZEBOX = 0x00010000, + /// + /// The window has a title bar (includes the WS_BORDER style). + /// + WS_CAPTION = WS_BORDER | WS_DLGFRAME, + /// + /// The window is an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. + /// + WS_TILED = WS_OVERLAPPED, + /// + /// The window is initially minimized. Same as the WS_MINIMIZE style. + /// + WS_ICONIC = WS_MINIMIZE, + WS_SIZEBOX = WS_THICKFRAME, + /// + /// The window is an overlapped window. Same as the WS_OVERLAPPEDWINDOW style. + /// + WS_TILEDWINDOW = WS_OVERLAPPEDWINDOW, + /// + /// The window is an overlapped window. Same as the WS_TILEDWINDOW style. + /// + WS_OVERLAPPEDWINDOW = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX, + /// + /// The window is a pop-up window. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. + /// + WS_POPUPWINDOW = WS_POPUP | WS_BORDER | WS_SYSMENU, + /// + /// Same as the WS_CHILD style. + /// + WS_CHILDWINDOW = WS_CHILD, + + //Extended Window Styles + + /// + /// The window has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter. + /// + WS_EX_DLGMODALFRAME = 0x00000001, + /// + /// The window does not pass its window layout to its child windows. + /// + WS_EX_NOPARENTNOTIFY = 0x00000004, + /// + /// The window should be placed above all non-topmost windows and should stay above them, even when the window is deactivated. To add or remove this style, use the SetWindowPos function. + /// + WS_EX_TOPMOST = 0x00000008, + /// + /// The window accepts drag-drop files. + /// + WS_EX_ACCEPTFILES = 0x00000010, + /// + /// The window should not be painted until siblings beneath the window (that were created by the same thread) have been painted. The window appears transparent because the bits of underlying sibling windows have already been painted. + ///To achieve transparency without these restrictions, use the SetWindowRgn function. + /// + WS_EX_TRANSPARENT = 0x00000020, + + /// + /// The window is a MDI child window. + /// + + WS_EX_MDICHILD = 0x00000040, + WS_EX_TOOLWINDOW = 0x00000080, + WS_EX_WINDOWEDGE = 0x00000100, + WS_EX_CLIENTEDGE = 0x00000200, + WS_EX_CONTEXTHELP = 0x00000400, + + WS_EX_RIGHT = 0x00001000, + WS_EX_LEFT = 0x00000000, + WS_EX_RTLREADING = 0x00002000, + WS_EX_LTRREADING = 0x00000000, + WS_EX_LEFTSCROLLBAR = 0x00004000, + WS_EX_RIGHTSCROLLBAR = 0x00000000, + + WS_EX_CONTROLPARENT = 0x00010000, + WS_EX_STATICEDGE = 0x00020000, + WS_EX_APPWINDOW = 0x00040000, + + WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE), + WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST), + + WS_EX_LAYERED = 0x00080000, + + WS_EX_NOINHERITLAYOUT = 0x00100000, + WS_EX_LAYOUTRTL = 0x00400000, + + /// + /// Paints all descendants of a window in bottom-to-top painting order using double-buffering. Bottom-to-top painting order allows a descendent window to have translucency (alpha) and transparency (color-key) effects, but only if the descendent window also has the WS_EX_TRANSPARENT bit set. Double-buffering allows the window and its descendents to be painted without flicker. This cannot be used if the window has a class style of either CS_OWNDC or CS_CLASSDC. + /// + + WS_EX_COMPOSITED = 0x02000000, + WS_EX_NOACTIVATE = 0x08000000 + //#endif /* WIN32WINNT >= 0x0500 */ + + } + + +} diff --git a/SkinFramWorkCore/Interop/kernel32/Interop.FreeLibrary.cs b/SkinFramWorkCore/Interop/kernel32/Interop.FreeLibrary.cs new file mode 100644 index 0000000..e8a30c0 --- /dev/null +++ b/SkinFramWorkCore/Interop/kernel32/Interop.FreeLibrary.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + +internal partial class Interop +{ + internal partial class Kernel32 + { + [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)] + public static extern BOOL FreeLibrary(IntPtr hModule); + } +} diff --git a/SkinFramWorkCore/Interop/kernel32/Interop.GetModuleHandle.cs b/SkinFramWorkCore/Interop/kernel32/Interop.GetModuleHandle.cs new file mode 100644 index 0000000..18302f3 --- /dev/null +++ b/SkinFramWorkCore/Interop/kernel32/Interop.GetModuleHandle.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Runtime.InteropServices; +using System; +internal partial class Interop +{ + internal partial class Kernel32 + { + [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] + public static extern IntPtr GetModuleHandleW(string moduleName); + } +} diff --git a/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibrary.cs b/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibrary.cs new file mode 100644 index 0000000..bcb21a5 --- /dev/null +++ b/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibrary.cs @@ -0,0 +1,41 @@ +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + + +internal partial class Interop +{ + internal partial class Kernel32 + { + + private const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002; + + [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] + private static extern IntPtr LoadLibraryExW(string lpModuleName, IntPtr hFile, uint dwFlags); + + public static IntPtr LoadLibraryAsDataFile(string libraryName) + { + IntPtr kernel32 = GetModuleHandleW(Libraries.Kernel32); + if (kernel32 == IntPtr.Zero) + { + return IntPtr.Zero; + } + + // LOAD_LIBRARY_SEARCH_SYSTEM32 was introduced in KB2533623. Check for its presence + // to preserve compat with Windows 7 SP1 without this patch. + IntPtr result = LoadLibraryExW(libraryName, IntPtr.Zero, LOAD_LIBRARY_AS_DATAFILE); + if (result != IntPtr.Zero) + { + return result; + } + + // Load without this flag. + if (Marshal.GetLastWin32Error() != ERROR.INVALID_PARAMETER) + { + return IntPtr.Zero; + } + + return LoadLibraryExW(libraryName, IntPtr.Zero, 0); + } + } +} diff --git a/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibraryFlags.cs b/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibraryFlags.cs new file mode 100644 index 0000000..645c4c5 --- /dev/null +++ b/SkinFramWorkCore/Interop/kernel32/Interop.LoadLibraryFlags.cs @@ -0,0 +1,62 @@ +// Licensed to the.NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +internal static partial class Interop +{ + internal static partial class kernel32 + { + /// + /// The action to be taken when loading the module. If no flags are specified, the behavior of this function is identical to that of the function. + /// + [Flags] + public enum LoadLibraryFlags : uint + { + None = 0, + /// + /// If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module. + /// + DONT_RESOLVE_DLL_REFERENCES = 0x00000001, + /// + /// If this value is used, the system does not check AppLocker rules or apply Software Restriction Policies for the DLL. This action applies only to the DLL being loaded and not to its dependencies. This value is recommended for use in setup programs that must run extracted DLLs during installation. + /// + LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, + /// + /// If this value is used, the system maps the file into the calling process's virtual address space as if it were a data file. Nothing is done to execute or prepare to execute the mapped file. + /// + LOAD_LIBRARY_AS_DATAFILE = 0x00000002, + /// + /// Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file is opened with exclusive write access for the calling process. Other processes cannot open the DLL file for write access while it is in use. However, the DLL can still be opened by other processes. + /// + LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, + /// + /// If this value is used, the system maps the file into the process's virtual address space as an image file. However, the loader does not load the static imports or perform the other usual initialization steps. Use this flag when you want to load a DLL only to extract messages or resources from it. + /// + LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, + /// + /// If this value is used, the application's installation directory is searched for the DLL and its dependencies. Directories in the standard search path are not searched + /// + LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200, + /// + /// This value is a combination of LOAD_LIBRARY_SEARCH_APPLICATION_DIR, LOAD_LIBRARY_SEARCH_SYSTEM32, and LOAD_LIBRARY_SEARCH_USER_DIRS. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. + /// + LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000, + /// + /// If this value is used, the directory that contains the DLL is temporarily added to the beginning of the list of directories that are searched for the DLL's dependencies. Directories in the standard search path are not searched. + /// + LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100, + /// + /// If this value is used, %windows%\system32 is searched for the DLL and its dependencies. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. + /// + LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800, + /// + /// If this value is used, directories added using the AddDllDirectory or the SetDllDirectory function are searched for the DLL and its dependencies. If more than one directory has been added, the order in which the directories are searched is unspecified. Directories in the standard search path are not searched. This value cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH. + /// + LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400, + /// + /// If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy discussed in the Remarks section to find associated executable modules that the specified module causes to be loaded. If this value is used and lpFileName specifies a relative path, the behavior is undefined. + /// + LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 + } + } +} diff --git a/SkinFramWorkCore/MdiNativeWindow.cs b/SkinFramWorkCore/MdiNativeWindow.cs new file mode 100644 index 0000000..b056db5 --- /dev/null +++ b/SkinFramWorkCore/MdiNativeWindow.cs @@ -0,0 +1,36 @@ +using System.Windows.Forms; +using static Interop; + +namespace SkinFramWorkCore +{ + internal class MdiNativeWindow:NativeWindow + { + private MdiClient _mdiClient; + public MdiNativeWindow(MdiClient mdiClient) + { + _mdiClient = mdiClient; + AssignHandle(_mdiClient.Handle); + _mdiClient.HandleDestroyed += delegate { ReleaseHandle(); }; + } + + protected override void WndProc(ref Message m) + { + switch ((WindowsMessages)m.Msg) + { + case WindowsMessages.ERASEBKGND: + base.WndProc(ref m); + + if (((int)User32.GetWindowLong(_mdiClient.Handle, User32.GWLIndex.GWL_EXSTYLE) & (int)WindowStyles.WS_EX_COMPOSITED) == (int)WindowStyles.WS_EX_COMPOSITED) + { + _mdiClient.Invalidate(); + } + + break; + default: + base.WndProc(ref m); + break; + } + + } + } +} diff --git a/SkinFramWorkCore/NonClientTheme.cs b/SkinFramWorkCore/NonClientTheme.cs deleted file mode 100644 index a0f70c6..0000000 --- a/SkinFramWorkCore/NonClientTheme.cs +++ /dev/null @@ -1,871 +0,0 @@ -using System; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using static SkinFramWorkCore.NativeMethods; -using static SkinFramWorkCore.Extensions; -using Microsoft.Win32; -using System.Linq; - -namespace SkinFramWorkCore -{ - [DesignerCategory("Code")] - public partial class NonClientTheme : Form - { - public NonClientTheme() - { - ActiveCaptionColor = activeCaption; - } - #region Fields - private const int TME_HOVER = 0x1; - private const int TME_NONCLIENT = 0x10; - private bool _bMouseTracking; - private const uint TME_LEAVE = 0x00000002; - private TrackmouseEvent _tme = TrackmouseEvent.Empty; - private DwmButtonState _buttonState = DwmButtonState.Normal; - private CaptionButton? _captionButton = null; - private static bool _isColorEnable = (int) - Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorPrevalence", 0) == 1; - private int _captionHeight = 31; - private int _borderWidth = 8; - private Color _activeCaptionColor = SystemColors.ActiveCaption; - private int _ncOpacity = 255; - private int _borderRadius =0; - #endregion - - #region Properties - public new FormBorderStyle FormBorderStyle - { - get - { - return base.FormBorderStyle; - } - set - { - base.FormBorderStyle = value; - if (DesignMode) - { - Message m = Message.Create(Handle, (int)WindowsMessages.NCPAINT, IntPtr.Zero, IntPtr.Zero); - OnWmNcPaint(ref m); - - } - } - } - private bool DrawRtl => RightToLeftLayout && RightToLeft == RightToLeft.Yes; - private static RECT DefultControlBoxBounds - { - get - { - switch (GetMsstylePlatform()) - { - - case Platform.Win8: - case Platform.Win81: - return RECT.FromRectangle(new Rectangle(7, 0, 105, 22)); - case Platform.Win10: - case Platform.Win11: - return RECT.FromRectangle(new Rectangle(7, 0, 146, 30)); - default: - return RECT.FromRectangle(new Rectangle(7, 0, 146, 30)); - } - } - } - private RECT ControlBoxBounds { get; set; } = DefultControlBoxBounds; - private bool IsActive { get; set; } - [DefaultValue(31)] - [Description("Caption hight of nonclient area.")] - [Category("Theme")] - public int CaptionHight - { - get - { - return _captionHeight; - - } - set - { - - _captionHeight = value; - //Fix .Net Core designer does not return immediately - InvalidateWindow(); - } - } - - - [DefaultValue(8)] - [Description("Border Width around nonclient area.")] - [Category("Theme")] - public int BorderWidth - { - get - { - - return _borderWidth; - } - set - { - _borderWidth = value; - InvalidateWindow(); - } - } - - [DefaultValue(8)] - [Description("Border Width around nonclient area.")] - [Category("Opacity of nonclient area Color")] - public int NcOpacity - { - get - { - return _ncOpacity; - } - set - { - _ncOpacity = value; - InvalidateWindow(); - } - } - [DefaultValue(true)] - [Description("Allow nonclient area transparency.")] - [Category("Theme")] - public bool AllowNcTransparency { get; set; } = true; - - [Category("Theme")] - [Description("Set nonclient area active caption color.")] - public Color ActiveCaptionColor - { - get - { - return _activeCaptionColor; - } - set - { - _activeCaptionColor = value; - InvalidateWindow(); - } - } - - [Category("Theme")] - [Description("Set nonclient area inactive caption color.")] - public Color InActiveCaptionColor { get; set; } = GetMsstylePlatform() == Platform.Win10 || GetMsstylePlatform() == Platform.Win11 ? Color.White : Color.FromArgb(235, 235, 235); - [Category("Theme")] - [Description("Set nonclient area round corners.")] - public int BorderRadius - { get - { - return _borderRadius; - } set - { - _borderRadius = value; - InvalidateWindow(); - } - } - private static Color activeCaption - { - get - { - if (GetMsstylePlatform() == Platform.Win10 || GetMsstylePlatform() == Platform.Win11) - { - int ColorizationColor; - int ColorizationColorBalance; - try - { - ColorizationColor = - (int) - Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", 0); - ColorizationColorBalance = - (int) - Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColorBalance", 0); - - int ALPHA = (255 * ColorizationColorBalance / 100); // Convert from 0-100 to 0-255 - int RED = (byte)((ColorizationColor >> 16) & 0xFF); - int GREEN = (byte)((ColorizationColor >> 8) & 0xFF); - int BLUE = (byte)(ColorizationColor & 0xFF); - - int r = (((RED * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); - int g = (byte)(((GREEN * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); - int b = (byte)(((BLUE * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); - return _isColorEnable ? Color.FromArgb(r, g, b) : Color.White; - } - catch (Exception ex) - { - DebugConsole.WriteLine(ex); - return SystemColors.ActiveBorder; - } - } - - else if (GetMsstylePlatform() == Platform.Win8 || GetMsstylePlatform() == Platform.Win81) - { - try - { - int ColorizationColor = (int) - Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", 0); - int ColorizationColorBalance = (int) - Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColorBalance", 0); - - var ALPHA = 255 * ColorizationColorBalance / 100; // Convert from 0-100 to 0-255 - var RED = (ColorizationColor >> 16) & 0xFF; - var GREEN = (ColorizationColor >> 8) & 0xFF; - var BLUE = ColorizationColor & 0xFF; - - var r = ((RED * ALPHA) + (0xD9 * (255 - ALPHA))) / 255; - var g = ((GREEN * ALPHA) + (0xD9 * (255 - ALPHA))) / 255; - var b = ((BLUE * ALPHA) + (0xD9 * (255 - ALPHA))) / 255; - return Color.FromArgb(r, g, b); - } - catch (Exception ex) - { - DebugConsole.WriteLine(ex); - return SystemColors.ActiveBorder; - } - } - - else - return SystemColors.ActiveBorder; - } - - - } - #endregion - - #region Overrides - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - - var mdiClient = Controls.Cast().OfType().FirstOrDefault(); - - if (mdiClient != null && RightToLeftLayout) - { - mdiClient.Paint += Rtl_Paint; - } - - } - protected override void OnRightToLeftLayoutChanged(EventArgs e) - { - base.OnRightToLeftLayoutChanged(e); - var mdiClient = Controls.Cast().OfType().FirstOrDefault(); - - if (mdiClient != null && RightToLeftLayout) - { - mdiClient.Paint += Rtl_Paint; - } - - - } - - - protected override CreateParams CreateParams - { - get - { - var cp = base.CreateParams; - if (IsMdiChild && AllowNcTransparency) - cp.ExStyle |= (int)WindowStyles.WS_EX_TRANSPARENT; - return cp; - } - } - - protected override void WndProc(ref Message m) - { - switch ((WindowsMessages)m.Msg) - { - - case WindowsMessages.NCCREATE: - OnWmNcCreate(ref m); - SetWindowRegion(m.HWnd, BorderRadius); - break; - case WindowsMessages.NCACTIVATE: - OnWmNcActive(ref m); - - break; - case WindowsMessages.MDIACTIVATE: - base.WndProc(ref m); - if (m.WParam == Handle) - IsActive = false; - else if (m.LParam == Handle) - IsActive = true; - OnWmNcPaint(ref m); - break; - case WindowsMessages.NCPAINT: - OnWmNcPaint(ref m); - break; - case WindowsMessages.NCCALCSIZE: - OnWmNcCalcSize(ref m); - break; - case WindowsMessages.NCHITTEST: - OnWmNcHitTest(ref m); - break; - case WindowsMessages.NCMOUSEMOVE: - OnWmNcMouseTracking(m.HWnd); - OnWmNcMouseMove(ref m); - break; - case WindowsMessages.NCLBUTTONDOWN: - switch ((NCHITTEST)m.WParam) - { - - case NCHITTEST.HTMINBUTTON: - _captionButton = CaptionButton.Minimize; - _buttonState = DwmButtonState.Pressed; - OnWmNcPaint(ref m); - break; - case NCHITTEST.HTMAXBUTTON: - _captionButton = CaptionButton.Maximize; - _buttonState = DwmButtonState.Pressed; - OnWmNcPaint(ref m); - break; - - case NCHITTEST.HTCLOSE: - _captionButton = CaptionButton.Close; - _buttonState = DwmButtonState.Pressed; - OnWmNcPaint(ref m); - break; - - default: - base.WndProc(ref m); - - break; - - } - break; - case WindowsMessages.NCLBUTTONUP: - switch ((NCHITTEST)m.WParam) - { - - case NCHITTEST.HTMINBUTTON: - if(this.IsDrawMinimizeBox()) - WindowState = WindowState == FormWindowState.Minimized ? FormWindowState.Normal : FormWindowState.Minimized; - break; - case NCHITTEST.HTMAXBUTTON: - if(this.IsDrawMaximizeBox()) - WindowState = WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized; - break; - - case NCHITTEST.HTCLOSE: - Close(); - break; - default: - _captionButton = null; - base.WndProc(ref m); - OnWmNcPaint(ref m); - break; - - } - break; - case WindowsMessages.NCMOUSELEAVE: - ResetNcTracking(m.HWnd); - _captionButton = null; - _buttonState = DwmButtonState.Normal; - OnWmNcPaint(ref m); - break; - case WindowsMessages.NCUAHDRAWCAPTION: - case WindowsMessages.NCUAHDRAWFRAME: - _captionButton = null; - OnWmNcPaint(ref m); - break; - case WindowsMessages.SIZE: - base.WndProc(ref m); - SetWindowRegion(m.HWnd, BorderRadius); - break; - default: - base.WndProc(ref m); - break; - } - - } - - protected override void OnPaintBackground(PaintEventArgs e) - { - if (DrawRtl) - { - Rtl_Paint(this, e); - } - else - { - base.OnPaintBackground(e); - } - - } - #endregion - - #region Methods - private void InvalidateWindow() - { - if (!IsDisposed && IsHandleCreated) - { - SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, - (int)(SWPFlags.SWP_NOACTIVATE | SWPFlags.SWP_NOMOVE | SWPFlags.SWP_NOSIZE | - SWPFlags.SWP_NOZORDER | SWPFlags.SWP_FRAMECHANGED)); - - RedrawWindow(this.Handle, IntPtr.Zero, IntPtr.Zero, - (int)(NativeMethods.RedrawWindowOptions.RDW_FRAME | NativeMethods.RedrawWindowOptions.RDW_UPDATENOW | NativeMethods.RedrawWindowOptions.RDW_INVALIDATE)); - } - } - private void Rtl_Paint(object sender, PaintEventArgs e) - { - e.Graphics.Clear(BackColor); - if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) - { - e.Graphics.Transform = new Matrix(-1, 0, 0, 1, Width - BorderWidth*2 + 1, 0); - - } - var clipRectangle = e.ClipRectangle.RtlRectangle(Width - BorderWidth*2 + 1); - if ((HScroll || VScroll) && BackgroundImage != null && - (BackgroundImageLayout == ImageLayout.Zoom || BackgroundImageLayout == ImageLayout.Stretch || - BackgroundImageLayout == ImageLayout.Center)) - { - if (IsImageTransparent(BackgroundImage)) - PaintTransparentBackground(e, clipRectangle); - e.Graphics.DrawBackgroundImage(BackgroundImage, BackColor, BackgroundImageLayout, clipRectangle, - clipRectangle, clipRectangle.Location, RightToLeft); - } - else - { - - PaintBackground(e, clipRectangle, BackColor); - } - } - private void PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor) - { - if (BackColor == Color.Transparent) - PaintTransparentBackground(e, rectangle); - if (BackgroundImage != null && !SystemInformation.HighContrast) - { - if (BackgroundImageLayout == ImageLayout.Tile && IsImageTransparent(BackgroundImage)) - PaintTransparentBackground(e, rectangle); - e.Graphics.DrawBackgroundImage(BackgroundImage, backColor, BackgroundImageLayout, ClientRectangle, - ClientRectangle, Point.Empty, RightToLeft); - } - - } - - private void PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion = null) - { - Graphics graphics = e.Graphics; - Control parentInternal = Parent; - if (parentInternal != null) - { - if (Application.RenderWithVisualStyles /*&& parentInternal.RenderTransparencyWithVisualStyles*/) - { - GraphicsState gstate = null; - if (transparentRegion != null) - gstate = graphics.Save(); - try - { - if (transparentRegion != null) - graphics.Clip = transparentRegion; - ButtonRenderer.DrawParentBackground(graphics, rectangle, this); - } - finally - { - if (gstate != null) - graphics.Restore(gstate); - } - } - else - { - Rectangle rectangle1 = new Rectangle(-Left, -Top, parentInternal.Width, parentInternal.Height); - Rectangle clipRect = new Rectangle(rectangle.Left + Left, rectangle.Top + Top, rectangle.Width, rectangle.Height); - using (Graphics windowsGraphics = graphics) - { - windowsGraphics.TranslateTransform(-Left, -Top); - using (PaintEventArgs e1 = new PaintEventArgs(windowsGraphics, clipRect)) - { - if (transparentRegion != null) - { - e1.Graphics.Clip = transparentRegion; - e1.Graphics.TranslateClip(-rectangle1.X, -rectangle1.Y); - } - try - { - InvokePaintBackground(parentInternal, e1); - InvokePaint(parentInternal, e1); - } - finally - { - if (transparentRegion != null) - e1.Graphics.TranslateClip(rectangle1.X, rectangle1.Y); - } - } - } - } - } - else - graphics.FillRectangle(SystemBrushes.Control, rectangle); - } - - - private static bool IsImageTransparent(Image backgroundImage) - { - return backgroundImage != null && (backgroundImage.Flags & 2) > 0; - } - private void ResetNcTracking(IntPtr hwnd) - { - _bMouseTracking = false; - } - private void OnWmNcHitTest(ref Message m) - { - POINT point; - point.x = LOWORD(m.LParam.ToInt32()); - point.y = HIWORD(m.LParam.ToInt32()); - RECT winRect; - GetWindowRect(m.HWnd, out winRect); - int width = winRect.right - winRect.left; - point.x -= winRect.left; - point.y -= winRect.top; - var btnWidth = ControlBoxBounds.Width / 3; - var btnbottom = ControlBoxBounds.Height; - var closeRect = new RECT(width - 45 - BorderWidth, 1, width - BorderWidth, btnbottom); - var restoreRect = new RECT(width - btnWidth * 2, 1, width - btnWidth + 1, btnbottom); - var minRect = new RECT(width - ControlBoxBounds.Width, 1, width - btnWidth * 2 + 1, btnbottom); - - - if (IsMdiChild && WindowState == FormWindowState.Minimized) - { - - base.WndProc(ref m); - - } - else - { - if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) - { - closeRect = closeRect.GetRtlRect(width); - - restoreRect = restoreRect.GetRtlRect(width); - minRect = minRect.GetRtlRect(width); - } - - if (PtInRect(ref closeRect, point)) - { - m.Result = (IntPtr)NCHITTEST.HTCLOSE; - - } - else if (PtInRect(ref restoreRect, point)) - { - m.Result = (IntPtr)NCHITTEST.HTMAXBUTTON; - - } - else if (PtInRect(ref minRect, point)) - { - m.Result = (IntPtr)NCHITTEST.HTMINBUTTON; - } - else - base.WndProc(ref m); - } - } - private void OnWmNcMouseTracking(IntPtr hwnd) - { - if (_bMouseTracking) return; - _tme.cbSize = (uint)Marshal.SizeOf(_tme); - _tme.hwndTrack = hwnd; - _tme.dwFlags = /*TME_HOVER |*/ TME_LEAVE | TME_NONCLIENT; - _tme.dwHoverTime = 1/*HOVER_DEFAULT*/; - TrackMouseEvent(ref _tme); - _bMouseTracking = true; - } - private void OnWmNcMouseMove(ref Message m) - { - - switch ((NCHITTEST)m.WParam) - { - case NCHITTEST.HTMINBUTTON: - if(this.IsDrawMinimizeBox()) - { - _captionButton = CaptionButton.Minimize; - _buttonState = DwmButtonState.Hot; - OnWmNcPaint(ref m); - } - - break; - case NCHITTEST.HTMAXBUTTON: - - if(this.IsDrawMaximizeBox()) - { - _captionButton = CaptionButton.Maximize; - _buttonState = DwmButtonState.Hot; - OnWmNcPaint(ref m); - - } - - break; - case NCHITTEST.HTCLOSE: - _buttonState = DwmButtonState.Hot; - _captionButton = CaptionButton.Close; - OnWmNcPaint(ref m); - break; - default: - _captionButton = null; - base.WndProc(ref m); - OnWmNcPaint(ref m); - break; - - } - } - private void OnWmNcCreate(ref Message m) - { - base.WndProc(ref m); - SetWindowTheme(m.HWnd, "Window", "DWmWindow"); - if (AllowNcTransparency && !IsMdiChild) - { - MARGINS win10Margins = new MARGINS(BorderWidth, BorderWidth, CaptionHight, BorderWidth); - MARGINS win11Margins = new MARGINS(1, 1, 1, 1); - MARGINS margins = GetMsstylePlatform() == Platform.Win11 ? win11Margins : win10Margins; - DwmExtendFrameIntoClientArea(m.HWnd, ref margins); - } - if ((IsMdiChild && AllowNcTransparency)) - { - - Composited(GetParent(m.HWnd)); - } - - } - private void OnWmNcActive(ref Message m) - { - base.WndProc(ref m); - IsActive = m.WParam.ToInt32() > 0; - OnWmNcPaint(ref m); - - } - private void OnWmNcPaint(ref Message m) - { - - - //Windows 8 High Contrast theme not work with OpenThemeData its required app manifest so let's do default - //See https://learn.microsoft.com/en-us/windows/win32/controls/supporting-high-contrast-themes - - if (FormBorderStyle == FormBorderStyle.None || !IsThemeActive()) - { - base.WndProc(ref m); - return; - } - IntPtr hdc = GetWindowDC(m.HWnd); - RECT winRect; - GetWindowRect(m.HWnd, out winRect); - OffsetRect(ref winRect, -winRect.left, -winRect.top); - int width = winRect.right - winRect.left; - RECT clientRect; - GetClientRect(m.HWnd, out clientRect); - - OffsetRect(ref clientRect, BorderWidth, CaptionHight); - if (m.Msg == (int)WindowsMessages.NCPAINT) - { - if (!(BorderRadius > 0 && !AllowNcTransparency)) - { - SetWindowRgn(m.HWnd, IntPtr.Zero, false); - } - } - - - if (!(IsMdiChild && WindowState == FormWindowState.Minimized && FormBorderStyle != FormBorderStyle.None)) - ExcludeClipRect(hdc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom); - var paintParams = new BP_PAINTPARAMS(BPPF.NoClip | BPPF.Erase | BPPF.NonClient); - if (IsMdiChild && AllowNcTransparency) - { - paintParams.BlendFunction = new BP_PAINTPARAMS.BLENDFUNCTION(0, 0, 255, 1); - } - IntPtr memdc; - var hbuff = BeginBufferedPaint(hdc, ref winRect, BP_BUFFERFORMAT.DIB, ref paintParams, out memdc); - var color = IsActive ? ActiveCaptionColor : InActiveCaptionColor; - var ncColor = Color.FromArgb(NcOpacity, color); - using (var nCGraphics = Graphics.FromHdc(memdc)) - { - if (BorderRadius > 0) - { - nCGraphics.Clip = new Region(RoundedRect(winRect.ToRectangle(), BorderRadius)); - } - nCGraphics.Clear(ncColor); - - - if (ControlBox) - { - DrawCaptionButtons(width, nCGraphics); - } - if (ShowIcon) - { - nCGraphics.DrawIcon(new Icon(Icon, SystemInformation.SmallIconSize), 9, 7); - } - if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) - { - nCGraphics.Transform = new Matrix(-1, 0, 0, 1, width, 0); - } - - if (Text != null) - { - var stringFormat = new StringFormat - { - Trimming = StringTrimming.EllipsisCharacter, - - }; - if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) - { - nCGraphics.Transform = new Matrix(-1, 0, 0, 1, width - 17, 0); - stringFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft; - } - - - var i = RightToLeftLayout && RightToLeft == RightToLeft.Yes ? width - 17 - 31 : 31; - nCGraphics.DrawString(Text, SystemFonts.CaptionFont, IsActive ? Brushes.White : Brushes.Black, i, 10, - stringFormat); - - } - } - - EndBufferedPaint(hbuff, true); - - ReleaseDC(Handle, hdc); - } - - public static void Composited(IntPtr hwnd) - { - - int extendedStyle = GetWindowLong(hwnd, GWLIndex.GWL_EXSTYLE); - var dwNewLong = extendedStyle | (int)WindowStyles.WS_EX_COMPOSITED; - SetWindowLong(hwnd, GWLIndex.GWL_EXSTYLE, dwNewLong); - } - - private void OnWmNcCalcSize(ref Message m) - { - if (FormBorderStyle == FormBorderStyle.None) - { - base.WndProc(ref m); - return; - } - NCCALCSIZE_PARAMS ncc; - - - if (m.WParam == new IntPtr(1)) - { - ncc = - (NCCALCSIZE_PARAMS) - Marshal.PtrToStructure(m.LParam, - typeof(NCCALCSIZE_PARAMS)); - ncc.rgrc0.left += BorderWidth; - ncc.rgrc0.top += CaptionHight; - ncc.rgrc0.right -= BorderWidth; - ncc.rgrc0.bottom -= BorderWidth; - - Marshal.StructureToPtr(ncc, m.LParam, true); - m.Result = IntPtr.Zero; - } - else - { - base.WndProc(ref m); - } - - } - - private void DrawCaptionButtons(int width, Graphics nCGraphics) - { - var btnWidth = ControlBoxBounds.Width / 3; - var btnbottom = ControlBoxBounds.Height; - var closeRect = new Rectangle(width - BorderWidth - 45, 1, 45, btnbottom); - var maxBtnRect = new RECT(width - btnWidth * 2, 1, width - btnWidth + 1, btnbottom); - var minBtnRect = new RECT(width - ControlBoxBounds.Width, 1, width - btnWidth * 2 + 1, btnbottom); - var isMinimizedChild = IsMdiChild && WindowState == FormWindowState.Minimized; - switch (GetMsstylePlatform()) - { - case Platform.Vista: - case Platform.Win7: - case Platform.Win8: - case Platform.Win81: - closeRect = new Rectangle(width - BorderWidth - 45, 1, 45, btnbottom); - maxBtnRect = new RECT(width - BorderWidth - closeRect.Width - 25, 1, width - BorderWidth - closeRect.Width + 1, btnbottom); - minBtnRect = new RECT(width - BorderWidth - closeRect.Width - 50, 1, width - BorderWidth - closeRect.Width - 25 + 1, btnbottom); - break; - case Platform.Win10: - case Platform.Win11: - closeRect = new Rectangle(width - BorderWidth - 45, 1, 45, btnbottom); - maxBtnRect = new RECT(width - btnWidth * 2, 1, width - btnWidth + 1, btnbottom); - minBtnRect = new RECT(width - ControlBoxBounds.Width, 1, width - btnWidth * 2 + 1, btnbottom); - break; - } - if (isMinimizedChild) - { - closeRect = new Rectangle(width - BorderWidth - 35, 1, 45, btnbottom); - maxBtnRect = new RECT(width - 35 - closeRect.Width, 1, width - closeRect.Width + 1, 35); - minBtnRect = new RECT(width - 35 - closeRect.Width * 2, 1, width + 2 - closeRect.Width * 2, 35); - } - var resMaxBtn = WindowState == FormWindowState.Maximized - ? CaptionButton.Restore - : CaptionButton.Maximize; - var minresBtn = isMinimizedChild - ? CaptionButton.Restore - : CaptionButton.Minimize; - var disableState = IsActive - ? DwmButtonState.Normal - : DwmButtonState.Disabled; - switch (_captionButton) - { - case CaptionButton.Close: - nCGraphics.DrawCaptionButton(closeRect, CaptionButton.Close, _buttonState, IsActive); - if (this.IsDrawMinimizeBox()) - nCGraphics.DrawCaptionButton(minBtnRect.ToRectangle(), minresBtn, disableState, IsActive); - if (this.IsDrawMaximizeBox()) - nCGraphics.DrawCaptionButton(maxBtnRect.ToRectangle(), resMaxBtn, disableState, IsActive); - break; - case CaptionButton.Minimize: - if (this.IsDrawMinimizeBox()) - nCGraphics.DrawCaptionButton(minBtnRect.ToRectangle(), minresBtn, _buttonState, IsActive); - nCGraphics.DrawCaptionButton(closeRect, CaptionButton.Close, disableState, IsActive); - if (this.IsDrawMaximizeBox()) - nCGraphics.DrawCaptionButton(maxBtnRect.ToRectangle(), resMaxBtn, disableState, IsActive); - break; - case CaptionButton.Maximize: - if (this.IsDrawMaximizeBox()) - nCGraphics.DrawCaptionButton(maxBtnRect.ToRectangle(), resMaxBtn, _buttonState, IsActive); - nCGraphics.DrawCaptionButton(closeRect, CaptionButton.Close, disableState, IsActive); - if (this.IsDrawMinimizeBox()) - nCGraphics.DrawCaptionButton(minBtnRect.ToRectangle(), minresBtn, disableState, IsActive); - break; - case CaptionButton.Restore: - break; - case CaptionButton.Help: - break; - - case null: - nCGraphics.DrawCaptionButton(closeRect, CaptionButton.Close, disableState, IsActive); - if (this.IsDrawMinimizeBox()) - nCGraphics.DrawCaptionButton(minBtnRect.ToRectangle(), minresBtn, disableState, IsActive); - if (this.IsDrawMaximizeBox()) - nCGraphics.DrawCaptionButton(maxBtnRect.ToRectangle(), resMaxBtn, disableState, IsActive); - - - break; - default: - throw new IndexOutOfRangeException(); - } - - - } - public void SetWindowRegion(IntPtr handle, int borderRadius = 0) - { - if (AllowNcTransparency) return; - RECT rWindow; - GetWindowRect(handle, out rWindow); - OffsetRect(ref rWindow, -rWindow.left, -rWindow.top); - if (RightToLeftLayout) - { - OffsetRect(ref rWindow, -BorderWidth * 2 + 1, -rWindow.top); - } - var p = RoundedRect(rWindow.ToRectangle(), borderRadius); - if (!AllowNcTransparency | !DesignMode) - { - Region = new Region(p); - } - else - { - var hrgn = CreateRoundRectRgn(rWindow.left, rWindow.top, rWindow.right, rWindow.bottom, borderRadius, - borderRadius); - SetWindowRgn(handle, hrgn, IsWindowVisible(handle)); - - } - - } - #endregion - } - -} diff --git a/SkinFramWorkCore/Platform.cs b/SkinFramWorkCore/Platform.cs deleted file mode 100644 index 9da932a..0000000 --- a/SkinFramWorkCore/Platform.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace SkinFramWorkCore -{ - public enum Platform - { - Vista, - Win7, - Win8, - Win81, - Win10, - Win11 - } -} diff --git a/SkinFramWorkCore/Extensions.cs b/SkinFramWorkCore/SkinExtensions.cs similarity index 58% rename from SkinFramWorkCore/Extensions.cs rename to SkinFramWorkCore/SkinExtensions.cs index 5f196d2..0d81f76 100644 --- a/SkinFramWorkCore/Extensions.cs +++ b/SkinFramWorkCore/SkinExtensions.cs @@ -1,116 +1,91 @@ -using Microsoft.Win32; -using System; -using System.Collections.Generic; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; +using System.Runtime.InteropServices; +using Microsoft.Win32; +using static Interop; +using System; using System.IO; using System.Linq; -using System.Runtime.InteropServices; -using System.Text; using System.Windows.Forms; -using static SkinFramWorkCore.NativeMethods; + namespace SkinFramWorkCore { - public static class Extensions + internal static class SkinExtensions { + internal static IntPtr hTheme; + internal enum SkinPlatform + { + Vista, + Win7, + Win8, + Win81, + Win10, + Win11 + } - private static IntPtr hTheme = OpenThemeData(GetDesktopWindow(), "DWMWINDOW"); - public static Image GetImageAtlasFromTheme() + internal enum DwmButtonState { - var path = (string)Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", - "DllName", - string.Empty); + Normal = 1, + Hot = 2, + Pressed = 3, + Disabled = 4 + } - var hInstance = NativeMethods.LoadLibraryEx(path, IntPtr.Zero, NativeMethods.LoadLibraryFlags.LOAD_LIBRARY_AS_DATAFILE); + + internal static Bitmap GetImageAtlasFromTheme() + { + hTheme = UxTheme.OpenThemeData(IntPtr.Zero, "DWMWINDOW"); + var path = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", string.Empty)?.ToString(); + if (path == null) + return new Bitmap(1, 1); + var hInstance = Kernel32.LoadLibraryAsDataFile(path); try { - IntPtr themeStream; uint streamSize; - - GetThemeStream(hTheme, 0, 0, 213, out themeStream, out streamSize, hInstance); + UxTheme.GetThemeStream(hTheme, 0, 0, 213, out themeStream, out streamSize, hInstance); var bufferStream = new byte[streamSize]; Marshal.Copy(themeStream, bufferStream, 0, bufferStream.Length); - - using (var ms = new MemoryStream(bufferStream)) { return new Bitmap(Image.FromStream(ms)); } - - } - catch (ArgumentNullException ex) - { - //ignore - DebugConsole.WriteLine(ex); } - catch (NullReferenceException ex) - { - //ignore - DebugConsole.WriteLine(ex); - } - catch (OutOfMemoryException ex) + + catch (Exception ex) { //ignore - DebugConsole.WriteLine(ex); + Debug.WriteLine(ex); + if (hTheme != IntPtr.Zero) + UxTheme.CloseThemeData(hTheme); + return new Bitmap(1, 1); } finally { - FreeLibrary(hInstance); + Kernel32.FreeLibrary(hInstance); + if (hTheme != IntPtr.Zero) + UxTheme.CloseThemeData(hTheme); } - return null; - } - public static Image Slice(this Bitmap original, Point loc, Size size) - { - return original.Clone(new Rectangle(loc, size), original.PixelFormat); } - public static Image GetDwmWindowButton(int button, int state) - { - try - { - const int tmtAtlasrect = 8002; - const int tmtImagecount = 2401; - var hWnd = GetDesktopWindow(); - - var hTheme = OpenThemeData(hWnd, "DWMWINDOW"); - - - var atlas = GetImageAtlasFromTheme(); - - if (atlas == null) return null; - RECT rect; - GetThemeRect(hTheme, (int)button, (int)state, tmtAtlasrect, out rect); - - var result = Slice((Bitmap)atlas, rect.Location, rect.Size); - if (state == 0) return result; - int count; - GetThemeInt(hTheme, (int)button, (int)state, tmtImagecount, out count); - var buttonSize = rect.Height / count; - var startPoint = Point.Empty; - var btnSize = new Size(rect.Width, buttonSize); - startPoint.Offset(0, buttonSize * ((int)state - 1)); - var buttonRect = new Rectangle(startPoint, btnSize); - buttonRect.Inflate(-1, -1); - result = Slice((Bitmap)result, buttonRect.Location, buttonRect.Size); - return result; - } - catch - { - // ignored - return new Bitmap(27, 27); - } - } - public static Platform GetMsstylePlatform() + internal static SkinPlatform GetMsstylePlatform() { - var currentMsstylePath = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", string.Empty).ToString(); - var fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(currentMsstylePath); + var currentMsstylePath = Registry.GetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ThemeManager", "DllName", string.Empty)?.ToString(); + if(string.IsNullOrEmpty(currentMsstylePath)) + return SkinPlatform.Win10; + var fileVersionInfo = FileVersionInfo.GetVersionInfo(currentMsstylePath); var fileVersion = fileVersionInfo.FileVersion; - DebugConsole.WriteLine(fileVersion); + if (fileVersion == null) + return SkinPlatform.Win10; var versionToken = fileVersion.Split('.'); - if (versionToken.Count() > 0) + if (versionToken.Length > 0) { switch (versionToken[0]) { @@ -118,123 +93,104 @@ public static Platform GetMsstylePlatform() switch (versionToken[1]) { case "0": - return Platform.Vista; + return SkinPlatform.Vista; case "1": - return Platform.Win7; + return SkinPlatform.Win7; case "2": - return Platform.Win8; + return SkinPlatform.Win8; case "3": - return Platform.Win81; + return SkinPlatform.Win81; } + break; case "10": - if (int.Parse(versionToken[2]) < 22000) - { - return Platform.Win10; - } - else - { - return Platform.Win11; - } - default: - return Platform.Win10; + return int.Parse(versionToken[2]) < 22000 ? SkinPlatform.Win10 : SkinPlatform.Win11; + default: + return SkinPlatform.Win10; } } - return Platform.Win10; + + return SkinPlatform.Win10; } - private static DwmWindowCaption WindowCaption + + internal static DwmWindowCaption WindowCaption { get { switch (GetMsstylePlatform()) { - case Platform.Win81: - case Platform.Win8: + case SkinPlatform.Vista: + case SkinPlatform.Win7: + case SkinPlatform.Win81: + case SkinPlatform.Win8: return new Windows8Caption(); - - case Platform.Win10: + case SkinPlatform.Win10: + case SkinPlatform.Win11: return new Windows10Caption(); default: - return new Windows8Caption(); + return new Windows10Caption(); } } } - public static void DrawCaptionButton(this Graphics graphics, Rectangle rect, CaptionButton captionButton, DwmButtonState state, bool active) + internal static Bitmap Slice(this Bitmap original, Point loc, Size size) { - - switch (captionButton) - { - - case CaptionButton.Close: - DrawCloseButton(graphics, rect, (int)state, active); - break; - case CaptionButton.Minimize: - DrawMinimizeButton(graphics, rect, (int)state, active); - break; - case CaptionButton.Maximize: - DrawMaximizeButton(graphics, rect, (int)state, active); - break; - case CaptionButton.Restore: - DrawRestorButton(graphics, rect, (int)state, active); - break; - case CaptionButton.Help: - break; - } + return original.Clone(new Rectangle(loc, size), original.PixelFormat); } - public static void DrawCloseButton(Graphics graphics, Rectangle rect, int state, bool active) + internal static Bitmap GetDwmWindowButton(int button, int state) { + try + { + hTheme = UxTheme.OpenThemeData(IntPtr.Zero, "DWMWINDOW"); + const int tmtAtlasrect = 8002; + const int tmtImagecount = 2401; + var atlas = GetImageAtlasFromTheme(); + if (atlas.IsEmpty()) + return new Bitmap(1, 1); + UxTheme.GetThemeRect(hTheme, button, state, tmtAtlasrect, out RECT rect); - var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECLOS : WindowCaption.BUTTONAINCTIVECLOS, (int)state); - - var Image = GetDwmWindowButton(WindowCaption.BUTTONCLOSEGLYPH96, active ? (int)state : (int)DwmButtonState.Disabled); - if (BackgrounImage == null || Image == null) return; - graphics.DrawImage(BackgrounImage, rect); - var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); - bounRect.Offset(rect.Location); - graphics.DrawImage(Image, bounRect); - } - public static void DrawMinimizeButton(Graphics graphics, Rectangle rect, int state, bool active) - { - + var result = Slice(atlas, new Point(rect.X, rect.Y), rect.Size); + if (state == 0) + return result; + int count = 0; + UxTheme.GetThemeInt(hTheme, button, state, tmtImagecount, ref count); + var buttonSize = rect.Height / count; + var startPoint = Point.Empty; + var btnSize = new Size(rect.Width, buttonSize); + startPoint.Offset(0, buttonSize * (state - 1)); + var buttonRect = new Rectangle(startPoint, btnSize); + buttonRect.Inflate(-1, -1); + result = Slice(result, buttonRect.Location, buttonRect.Size); + return result; + } + catch + { + if (hTheme != IntPtr.Zero) + UxTheme.CloseThemeData(hTheme); + return new Bitmap(0, 0); + } - var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, (int)state); - var Image = GetDwmWindowButton(WindowCaption.BUTTONMINGLYPH96, active ? (int)state : (int)DwmButtonState.Disabled); - if (BackgrounImage == null || Image == null) return; - graphics.DrawImage(BackgrounImage, rect); - var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); - bounRect.Offset(rect.Location); - graphics.DrawImage(Image, bounRect); + finally + { + if (hTheme != IntPtr.Zero) + UxTheme.CloseThemeData(hTheme); + } } - public static void DrawMaximizeButton(Graphics graphics, Rectangle rect, int state, bool active) - { - - var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, (int)state); - var Image = GetDwmWindowButton(WindowCaption.BUTTONMAXGLYPH96, active ? (int)state : (int)DwmButtonState.Disabled); - if (BackgrounImage == null || Image == null) return; - graphics.DrawImage(BackgrounImage, rect); - var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); - bounRect.Offset(rect.Location); - graphics.DrawImage(Image, bounRect); - } - public static void DrawRestorButton(Graphics graphics, Rectangle rect, int state, bool active) + internal static bool IsEmpty(this Bitmap image) { - - - var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, (int)state); - var Image = GetDwmWindowButton(WindowCaption.BUTTONRESTOREGLYPH96, active ? (int)state : (int)DwmButtonState.Disabled); - if (BackgrounImage == null || Image == null) return; - graphics.DrawImage(BackgrounImage, rect); - var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); - bounRect.Offset(rect.Location); - graphics.DrawImage(Image, bounRect); + var data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), + ImageLockMode.ReadOnly, image.PixelFormat); + var bytes = new byte[data.Height * data.Stride]; + Marshal.Copy(data.Scan0, bytes, 0, bytes.Length); + image.UnlockBits(data); + return bytes.All(x => x == 0); } - public static GraphicsPath RoundedRect(Rectangle bounds, int radius) + internal static GraphicsPath RoundedRect(Rectangle bounds, int radius) { var diameter = radius * 2; var size = new Size(diameter, diameter); @@ -247,18 +203,18 @@ public static GraphicsPath RoundedRect(Rectangle bounds, int radius) return path; } - // top left arc + // top left arc path.AddArc(arc, 180, 90); - // top right arc + // top right arc arc.X = bounds.Right - diameter; path.AddArc(arc, 270, 90); - // bottom right arc - arc.Y = bounds.Bottom - diameter; + // bottom right arc + arc.Y = bounds.Bottom /*- diameter*/; path.AddArc(arc, 0, 90); - // bottom left arc + // bottom left arc arc.X = bounds.Left; path.AddArc(arc, 90, 90); @@ -266,20 +222,119 @@ public static GraphicsPath RoundedRect(Rectangle bounds, int radius) return path; } - public static void FillRoundedRectangle(this Graphics graphics, Brush brush, Rectangle bounds, int cornerRadius) + internal static Color ContrastColor(this Color iColor) { - if (graphics == null) - throw new ArgumentNullException("graphics"); - if (brush == null) - throw new ArgumentNullException("brush"); + // Calculate the perceptive luminance (aka luma) - human eye favors green color... + double luma = ((0.299 * iColor.R) + (0.587 * iColor.G) + (0.114 * iColor.B)) / 255; + // Return black for bright colors, white for dark colors + return luma > 0.5 ? Color.Black : Color.White; + } - using (var path = RoundedRect(bounds, cornerRadius)) + internal static void DrawCloseButton(Graphics graphics, Rectangle rect, int state, bool active) + { + var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECLOS : WindowCaption.BUTTONAINCTIVECLOS, state); + int BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH96; + switch (graphics.DpiX) { - // graphics.Clear(Color.Transparent); - // graphics.FillRegion(brush,graphics.Clip); - graphics.FillPath(brush, path); + case 96: + BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH96; + break; + case 120: + BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH120; + break; + case 144: + BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH144; + break; + case 168: + case 192: + BUTTONCLOSEGLYPH = WindowCaption.BUTTONCLOSEGLYPH192; + break; + } + + var Image = GetDwmWindowButton(BUTTONCLOSEGLYPH, active ? state : (int)DwmButtonState.Disabled); + if (BackgrounImage == null || Image == null) + return; + graphics.DrawImage(BackgrounImage, rect); + var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); + bounRect.Offset(rect.Location); + graphics.DrawImage(Image, bounRect); + } + internal static void DrawMinimizeButton(Graphics graphics, Rectangle rect, int state, bool active) + { + var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); + int BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH96; + switch (graphics.DpiX) + { + case 96: + BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH96; + break; + case 120: + BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH120; + break; + case 144: + BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH144; + break; + case 168: + case 192: + BUTTONMINGLYPH = WindowCaption.BUTTONMINGLYPH192; + break; } + + var Image = GetDwmWindowButton(BUTTONMINGLYPH, active ? state : (int)DwmButtonState.Disabled); + if (BackgrounImage == null || Image == null) + return; + graphics.DrawImage(BackgrounImage, rect); + var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); + bounRect.Offset(rect.Location); + graphics.DrawImage(Image, bounRect); + } + + internal static void DrawMaximizeButton(Graphics graphics, Rectangle rect, int state, bool active) + { + var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); + int BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH96; + switch (graphics.DpiX) + { + case 96: + BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH96; + break; + case 120: + BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH120; + break; + case 144: + BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH144; + break; + case 168: + case 192: + BUTTONMAXGLYPH = WindowCaption.BUTTONMAXGLYPH192; + break; + } + + var Image = GetDwmWindowButton(BUTTONMAXGLYPH, active ? state : (int)DwmButtonState.Disabled); + if (BackgrounImage == null || Image == null) + return; + graphics.DrawImage(BackgrounImage, rect); + var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); + bounRect.Offset(rect.Location); + graphics.DrawImage(Image, bounRect); + } + + internal static void DrawRestorButton(Graphics graphics, Rectangle rect, int state, bool active) + { + var BackgrounImage = GetDwmWindowButton(active ? WindowCaption.BUTTONACTIVECAPTION : WindowCaption.BUTTONINACTIVECAPTION, state); + var Image = GetDwmWindowButton(WindowCaption.BUTTONRESTOREGLYPH96, active ? state : (int)DwmButtonState.Disabled); + if (BackgrounImage == null || Image == null) + return; + graphics.DrawImage(BackgrounImage, rect); + var bounRect = new Rectangle((rect.Width - Image.Width) / 2, (rect.Height - Image.Height) / 2, Image.Width, Image.Height); + bounRect.Offset(rect.Location); + graphics.DrawImage(Image, bounRect); + } + + internal static Rectangle RtlRectangle(this Rectangle rectangle, int width) + { + return new Rectangle(width - rectangle.Width - rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); } internal static Rectangle CalculateBackgroundImageRectangle(Rectangle bounds, Image backgroundImage, ImageLayout imageLayout) @@ -396,30 +451,38 @@ public static void DrawBackgroundImage(this Graphics g, Image backgroundImage, C } } - public static Rectangle RtlRectangle(this Rectangle rectangle, int width) + + internal static void DrawCaptionButton(this Graphics graphics, Rectangle rect, CaptionButton captionButton, DwmButtonState state, bool active) { - return new Rectangle( - width - rectangle.Width - rectangle.X, - rectangle.Y, - rectangle.Width, - rectangle.Height); + switch (captionButton) + { + case CaptionButton.Close: + DrawCloseButton(graphics, rect, (int)state, active); + break; + case CaptionButton.Minimize: + DrawMinimizeButton(graphics, rect, (int)state, active); + break; + case CaptionButton.Maximize: + DrawMaximizeButton(graphics, rect, (int)state, active); + break; + case CaptionButton.Restore: + DrawRestorButton(graphics, rect, (int)state, active); + break; + case CaptionButton.Help: + break; + } } - public static bool IsDrawMaximizeBox(this Form form) + internal static bool IsDrawMaximizeBox(this Form form) { return form.MaximizeBox && form.FormBorderStyle != FormBorderStyle.SizableToolWindow && form.FormBorderStyle != FormBorderStyle.FixedToolWindow; } - /// - /// Gets a value indicating if the minimize box needs to be drawn on the specified form. - /// - /// The form to check . - /// - public static bool IsDrawMinimizeBox(this Form form) + + internal static bool IsDrawMinimizeBox(this Form form) { return form.MinimizeBox && form.FormBorderStyle != FormBorderStyle.SizableToolWindow && form.FormBorderStyle != FormBorderStyle.FixedToolWindow; } - } } diff --git a/SkinFramWorkCore/SkinForm.Designer.cs b/SkinFramWorkCore/SkinForm.Designer.cs index 7f18d9b..bbe6803 100644 --- a/SkinFramWorkCore/SkinForm.Designer.cs +++ b/SkinFramWorkCore/SkinForm.Designer.cs @@ -1,4 +1,4 @@ - +using System; namespace SkinFramWorkCore { partial class SkinForm @@ -29,19 +29,12 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.SuspendLayout(); - // - // SkinForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Name = "SkinForm"; - this.Text = "SkinForm"; - this.ResumeLayout(false); - + this.Text = "Form2"; } #endregion } -} \ No newline at end of file +} diff --git a/SkinFramWorkCore/SkinForm.cs b/SkinFramWorkCore/SkinForm.cs index c331c89..f2f0e3c 100644 --- a/SkinFramWorkCore/SkinForm.cs +++ b/SkinFramWorkCore/SkinForm.cs @@ -1,20 +1,987 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + using System.Drawing; -using System.Text; +using System.Runtime.InteropServices; +using System.Windows.Forms.VisualStyles; +using Microsoft.Win32; +using static Interop; +using System.Diagnostics; +using SkinFramWorkCore; +using static SkinFramWorkCore.SkinExtensions; +using System.ComponentModel; +using System.Linq; using System.Windows.Forms; +using System; +using System.Drawing.Drawing2D; namespace SkinFramWorkCore { - [DesignerCategory("Form")] - public partial class SkinForm : NonClientTheme + public partial class SkinForm : Form { + #region fields + private User32.TRACKMOUSEEVENT _trackMouseEvent; + private bool _trackingMouseEvent; + private int _captionHieght; + private int _borderWidth; + private Color _activeCaptionColor = SystemColors.ActiveCaption; + private DwmButtonState _buttonState = DwmButtonState.Normal; + private CaptionButton? _captionButton; + private int _ncOpacity = 255; + private int _borderRadius; + private const int DTT_COMPOSITED = 8192; + private const int DTT_GLOWSIZE = 2048; + private const int DTT_TEXTCOLOR = 1; + #endregion + + #region Constructor public SkinForm() { InitializeComponent(); + ActiveCaptionColor = DefaultCaptionColor; + CaptionHieght = DefaultCaptionHieght(this); + ControlBoxBounds = DefaultControlBoxBounds; + BorderWidth = DefaultBorderWidth; + } + #endregion + + #region Properties + private static int DefaultBorderWidth + { + get + { + return User32.GetSystemMetrics(User32.SystemMetric.SM_CXFRAME) * 2; + } + } + + /// + /// return Defualt Caption Height per Dpi + /// + private static int DefaultCaptionHieght(Form form) + { + + var isToolWindow = form.FormBorderStyle == FormBorderStyle.SizableToolWindow || form.FormBorderStyle == FormBorderStyle.FixedToolWindow; + int height = isToolWindow ? + User32.GetSystemMetrics(User32.SystemMetric.SM_CYSMCAPTION) : User32.GetSystemMetrics(User32.SystemMetric.SM_CYCAPTION); + return User32.GetSystemMetrics(User32.SystemMetric.SM_CYFRAME) + height + User32.GetSystemMetrics(User32.SystemMetric.SM_CXPADDEDBORDER); + } + + /// + /// check if there is Maxmize child + /// this used to draw internal mdi menu in case MainMenuStrip is not present + /// + private bool Ismaxchild => ActiveMdiChild != null && ActiveMdiChild.WindowState is FormWindowState.Maximized; + + /// + /// check is is Active + /// + private bool IsActive { get; set; } + private static bool IsColoredTitleBar + { + get + { + int? colorPrevalence = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorPrevalence", 0) as int?; + return colorPrevalence.HasValue && colorPrevalence.Value == 1; + } + } + + /// + /// return ControlBox Bounds + /// + private RECT ControlBoxBounds { get; set; } + /// + /// return Default ControlBox Bounds + /// + private Rectangle DefaultControlBoxBounds + { + get + { + switch (GetMsstylePlatform()) + { + case SkinPlatform.Win8: + case SkinPlatform.Win81: + return new Rectangle(7, 0, 105, 22); + case SkinPlatform.Win10: + case SkinPlatform.Win11: + return new Rectangle(7, 0, User32.GetSystemMetrics(User32.SystemMetric.SM_CXMINTRACK) + DefaultBorderWidth, _captionHieght); + default: + return new Rectangle(7, 0, User32.GetSystemMetrics(User32.SystemMetric.SM_CXMINTRACK) + DefaultBorderWidth, _captionHieght); + } + + } + } + + /// + /// return Default Caption Color + /// + private static Color DefaultCaptionColor + { + get + { + int? ColorizationColor; + int? ColorizationColorBalance; + try + { + ColorizationColor = (int?)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", 0); + ColorizationColorBalance = (int?)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColorBalance", 0); + if (!ColorizationColor.HasValue || !ColorizationColorBalance.HasValue) + return SystemColors.ActiveBorder; + int ALPHA = (255 * ColorizationColorBalance.Value / 100); // Convert from 0-100 to 0-255 + int RED = (byte)((ColorizationColor.Value >> 16) & 0xFF); + int GREEN = (byte)((ColorizationColor.Value >> 8) & 0xFF); + int BLUE = (byte)(ColorizationColor.Value & 0xFF); + int r = (((RED * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); + int g = (byte)(((GREEN * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); + int b = (byte)(((BLUE * ALPHA) + (0xD9 * (255 - ALPHA))) / 255); + return IsColoredTitleBar || GetMsstylePlatform() is SkinPlatform.Win8 || GetMsstylePlatform() is SkinPlatform.Win81 ? Color.FromArgb(r, g, b) : Color.White; + } + catch (Exception ex) + { + Debug.WriteLine(ex); + return SystemColors.ActiveBorder; + } + } + } + + public new FormBorderStyle FormBorderStyle + { + get + { + return base.FormBorderStyle; + } + set + { + + base.FormBorderStyle = value; + if (DesignMode) + { + Message m = Message.Create(Handle, (int)WindowsMessages.NCPAINT, IntPtr.Zero, IntPtr.Zero); + OnWmNcPaint(ref m); + } + } + } + + + + public int CaptionHieght + { + get + { + return _captionHieght; + } + + set + { + _captionHieght = value; + + if (DesignMode) + { + InvalidateWindow(); + } + } + } + + + public int BorderWidth + { + get + { + return _borderWidth; + } + set + { + _borderWidth = value; + if (DesignMode) + { + InvalidateWindow(); + } + } + } + + + public Color InActiveCaptionColor { get; set; } = (GetMsstylePlatform() == SkinPlatform.Win10 || GetMsstylePlatform() == SkinPlatform.Win11) ? Color.White : Color.FromArgb(235, 235, 235); + + + public Color ActiveCaptionColor + { + get + { + return _activeCaptionColor; + } + set + { + _activeCaptionColor = value; + if (DesignMode) + { + InvalidateWindow(); + } + } + } + + + public int NcOpacity + { + get + { + return _ncOpacity; + } + set + { + _ncOpacity = value; + if (DesignMode) + { + InvalidateWindow(); + } + } + } + + + public bool AllowNcTransparency { get; set; } = true; + + + public int BorderRadius + { + get + { + return _borderRadius; + } + set + { + _borderRadius = value; + if (DesignMode) + { + InvalidateWindow(); + } + } + } + #endregion + + #region Overrides + + protected override void WndProc(ref Message m) + { + switch ((WindowsMessages)m.Msg) + { + case WindowsMessages.NCACTIVATE: + OnWmNcActive(ref m); + break; + case WindowsMessages.NCCREATE: + OnWmNcCreate(ref m); + break; + case WindowsMessages.NCPAINT: + OnWmNcPaint(ref m); + break; + case WindowsMessages.NCMOUSEMOVE: + OnWmNcMouseMove(ref m); + break; + case WindowsMessages.NCMOUSELEAVE: + OnWmNcMouseLeave(ref m); + break; + case WindowsMessages.NCCALCSIZE: + OnWmNcCalcSize(ref m); + break; + case WindowsMessages.NCLBUTTONDOWN: + OnWmNclButtonDown(ref m); + break; + case WindowsMessages.NCLBUTTONUP: + OnWmNclButtonUp(ref m); + break; + case WindowsMessages.NCHITTEST: + OnWmNcHitTest(ref m); + break; + case WindowsMessages.MDIACTIVATE: + base.WndProc(ref m); + if (m.WParam == Handle) + IsActive = false; + else if (m.LParam == Handle) + IsActive = true; + OnWmNcPaint(ref m); + break; + case WindowsMessages.SIZE: + base.WndProc(ref m); + SetRoundRegion(); + break; + + default: + base.WndProc(ref m); + break; + } + } + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + var mdiClient = Controls.Cast().OfType().FirstOrDefault(); + + if (mdiClient != null) + { + new MdiNativeWindow(mdiClient); + } + } + protected override CreateParams CreateParams + { + get + { + var cp = base.CreateParams; + if (IsMdiChild && AllowNcTransparency) + cp.ExStyle |= (int)WindowStyles.WS_EX_TRANSPARENT; + return cp; + } + } + + protected override void OnRightToLeftLayoutChanged(EventArgs e) + { + base.OnRightToLeftLayoutChanged(e); + if (RightToLeft == RightToLeft.Yes && RightToLeftLayout) + { + var mdiClient = Controls.Cast().OfType().FirstOrDefault(); + + if (mdiClient != null) + { + mdiClient.Paint += Rtl_Paint; + } + + else + { + Paint += Rtl_Paint; + } + } + } + + #endregion + + #region Methods + private void Rtl_Paint(object? sender, PaintEventArgs e) + { + e.Graphics.Clear( IsMdiContainer ? SystemColors.AppWorkspace: BackColor); + if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) + { + e.Graphics.Transform = new Matrix(-1, 0, 0, 1, Width - BorderWidth * 2 + 1, 0); + + } + var clipRectangle = e.ClipRectangle.RtlRectangle(Width - BorderWidth * 2 + 1); + if ((HScroll || VScroll) && BackgroundImage != null && + (BackgroundImageLayout == ImageLayout.Zoom || BackgroundImageLayout == ImageLayout.Stretch || + BackgroundImageLayout == ImageLayout.Center)) + { + if (IsImageTransparent(BackgroundImage)) + PaintTransparentBackground(e, clipRectangle); + e.Graphics.DrawBackgroundImage(BackgroundImage, BackColor, BackgroundImageLayout, clipRectangle, + clipRectangle, clipRectangle.Location, RightToLeft); + } + else + { + + PaintBackground(e, clipRectangle, BackColor); + } + } + private void PaintBackground(PaintEventArgs e, Rectangle rectangle, Color backColor) + { + if (BackColor == Color.Transparent) + PaintTransparentBackground(e, rectangle); + if (BackgroundImage != null && !SystemInformation.HighContrast) + { + if (BackgroundImageLayout == ImageLayout.Tile && IsImageTransparent(BackgroundImage)) + PaintTransparentBackground(e, rectangle); + e.Graphics.DrawBackgroundImage(BackgroundImage, backColor, BackgroundImageLayout, ClientRectangle, + ClientRectangle, Point.Empty, RightToLeft); + } + + } + + private void PaintTransparentBackground(PaintEventArgs e, Rectangle rectangle, Region transparentRegion = null) + { + Graphics graphics = e.Graphics; + Control parentInternal = Parent; + if (parentInternal != null) + { + if (Application.RenderWithVisualStyles) + { + GraphicsState gstate = null; + if (transparentRegion != null) + gstate = graphics.Save(); + try + { + if (transparentRegion != null) + graphics.Clip = transparentRegion; + ButtonRenderer.DrawParentBackground(graphics, rectangle, this); + } + finally + { + if (gstate != null) + graphics.Restore(gstate); + } + } + else + { + Rectangle rectangle1 = new Rectangle(-Left, -Top, parentInternal.Width, parentInternal.Height); + Rectangle clipRect = new Rectangle(rectangle.Left + Left, rectangle.Top + Top, rectangle.Width, rectangle.Height); + using (Graphics windowsGraphics = graphics) + { + windowsGraphics.TranslateTransform(-Left, -Top); + using (PaintEventArgs e1 = new PaintEventArgs(windowsGraphics, clipRect)) + { + if (transparentRegion != null) + { + e1.Graphics.Clip = transparentRegion; + e1.Graphics.TranslateClip(-rectangle1.X, -rectangle1.Y); + } + try + { + InvokePaintBackground(parentInternal, e1); + InvokePaint(parentInternal, e1); + } + finally + { + if (transparentRegion != null) + e1.Graphics.TranslateClip(rectangle1.X, rectangle1.Y); + } + } + } + } + } + else + graphics.FillRectangle(SystemBrushes.Control, rectangle); + } + + + private static bool IsImageTransparent(Image backgroundImage) + { + return backgroundImage != null && (backgroundImage.Flags & 2) > 0; + } + /// + /// Invalidate the and make it repaint immediately use to fix .net core Designer. + /// see https://github.com/dotnet/winforms/issues/8107 + /// + private void InvalidateWindow() + { + if (!IsDisposed && IsHandleCreated) + { + User32.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, User32.SWPFlags.SWP_NOMOVE | User32.SWPFlags.SWP_NOSIZE | + User32.SWPFlags.SWP_NOZORDER | User32.SWPFlags.SWP_FRAMECHANGED); + } + } + + /// + /// Hook the Nonclient area Mouse Event + /// + /// + private void HookNcMouseEvent(IntPtr hwnd) + { + if (!_trackingMouseEvent) + { + _trackingMouseEvent = true; + if (_trackMouseEvent.IsDefault()) + { + _trackMouseEvent = new User32.TRACKMOUSEEVENT + { + cbSize = (uint)Marshal.SizeOf(), + dwFlags = User32.TME.LEAVE | User32.TME.NONCLIENT, + hwndTrack = hwnd, + dwHoverTime = 1 + }; + } + + User32.TrackMouseEvent(ref _trackMouseEvent); + } + } + + /// + /// UnHook the Mouse Event + /// + private void UnHookNcMouseEvent() => _trackingMouseEvent = false; + /// + /// Draw NonClient area Caption Buttons in specified + /// + /// the Width of in pixel + /// Caption buttons will be drawn on it + /// + private void DrawCaptionButtons(int width, Graphics nCGraphics) + { + int btnWidth = ControlBoxBounds.Width / 3; + int btnbottom = ControlBoxBounds.Height; + Rectangle closeBtnRect = new Rectangle(width - BorderWidth - btnWidth, 1, btnWidth, btnbottom); + Rectangle maxBtnRect = new Rectangle(width - btnWidth * 2, 1, btnWidth, btnbottom); + Rectangle minBtnRect = new Rectangle(width - ControlBoxBounds.Width, 1, btnWidth, btnbottom); + bool isMinimizedChild = IsMdiChild && WindowState == FormWindowState.Minimized; + switch (GetMsstylePlatform()) + { + case SkinPlatform.Vista: + case SkinPlatform.Win7: + case SkinPlatform.Win8: + case SkinPlatform.Win81: + closeBtnRect = new Rectangle(width - BorderWidth - 45, 1, 45, btnbottom); + maxBtnRect = new Rectangle(width - BorderWidth - closeBtnRect.Width - 25, 1, 25, btnbottom); + minBtnRect = new Rectangle(width - BorderWidth - closeBtnRect.Width - 50, 1, 25, btnbottom); + break; + case SkinPlatform.Win10: + case SkinPlatform.Win11: + closeBtnRect = new Rectangle(width - BorderWidth - btnWidth, 1, btnWidth, btnbottom); + maxBtnRect = new Rectangle(width - btnWidth * 2 - BorderWidth, 1, btnWidth, btnbottom); + minBtnRect = new Rectangle(width - btnWidth * 3 - BorderWidth, 1, btnWidth, btnbottom); + break; + } + + if (isMinimizedChild) + { + btnWidth = 35; + closeBtnRect = new Rectangle(width - BorderWidth - btnWidth, 1, btnWidth, btnbottom); + maxBtnRect = new Rectangle(width - btnWidth * 2, 1, closeBtnRect.Width, btnWidth); + minBtnRect = new Rectangle(width - btnWidth * 3, 1, closeBtnRect.Width, btnWidth); + } + + CaptionButton resMaxBtn = WindowState == FormWindowState.Maximized ? CaptionButton.Restore : CaptionButton.Maximize; + CaptionButton minresBtn = isMinimizedChild ? CaptionButton.Restore : CaptionButton.Minimize; + DwmButtonState disableState = IsActive ? DwmButtonState.Normal : DwmButtonState.Disabled; + switch (_captionButton) + { + case CaptionButton.Close: + nCGraphics.DrawCaptionButton(closeBtnRect, CaptionButton.Close, _buttonState, IsActive); + if (this.IsDrawMinimizeBox()) + nCGraphics.DrawCaptionButton(minBtnRect, minresBtn, disableState, IsActive); + if (this.IsDrawMaximizeBox()) + nCGraphics.DrawCaptionButton(maxBtnRect, resMaxBtn, disableState, IsActive); + break; + case CaptionButton.Minimize: + if (this.IsDrawMinimizeBox()) + nCGraphics.DrawCaptionButton(minBtnRect, minresBtn, _buttonState, IsActive); + nCGraphics.DrawCaptionButton(closeBtnRect, CaptionButton.Close, disableState, IsActive); + if (this.IsDrawMaximizeBox()) + nCGraphics.DrawCaptionButton(maxBtnRect, resMaxBtn, disableState, IsActive); + break; + case CaptionButton.Maximize: + if (this.IsDrawMaximizeBox()) + nCGraphics.DrawCaptionButton(maxBtnRect, resMaxBtn, _buttonState, IsActive); + nCGraphics.DrawCaptionButton(closeBtnRect, CaptionButton.Close, disableState, IsActive); + if (this.IsDrawMinimizeBox()) + nCGraphics.DrawCaptionButton(minBtnRect, minresBtn, disableState, IsActive); + break; + case CaptionButton.Restore: + break; + case CaptionButton.Help: + break; + + case null: + nCGraphics.DrawCaptionButton(closeBtnRect, CaptionButton.Close, disableState, IsActive); + if (this.IsDrawMinimizeBox()) + nCGraphics.DrawCaptionButton(minBtnRect, minresBtn, disableState, IsActive); + if (this.IsDrawMaximizeBox()) + nCGraphics.DrawCaptionButton(maxBtnRect, resMaxBtn, disableState, IsActive); + break; + default: + throw new IndexOutOfRangeException(); + } + } + + /// + /// Handel + /// + /// + private void OnWmNcCalcSize(ref Message m) + { + if (FormBorderStyle == FormBorderStyle.None || (IsMdiChild && WindowState == FormWindowState.Maximized) || m.WParam.ToInt32() != 1) + { + base.WndProc(ref m); + return; + } + + + int mdiMenuHeghit = Ismaxchild && MainMenuStrip is null ? User32.GetSystemMetrics(User32.SystemMetric.SM_CYMENUSIZE) : 0; + int defaultCaptionHeight = Ismaxchild && MainMenuStrip is null ? DefaultCaptionHieght(this) : _captionHieght; + int captionHeight = defaultCaptionHeight + mdiMenuHeghit; + User32.NCCALCSIZE_PARAMS nccParama = Marshal.PtrToStructure(m.LParam); + nccParama.rgrc0.left += BorderWidth; + nccParama.rgrc0.top += captionHeight; + nccParama.rgrc0.right -= BorderWidth; + nccParama.rgrc0.bottom -= BorderWidth; + Marshal.StructureToPtr(nccParama, m.LParam, true); + if (AllowNcTransparency && !IsMdiChild) + { + UxTheme.MARGINS winMargins = new UxTheme.MARGINS { cxLeftWidth = BorderWidth, cxRightWidth = BorderWidth, cyTopHeight = CaptionHieght, cyBottomHeight = BorderWidth }; + UxTheme.MARGINS win11Margins = new UxTheme.MARGINS { cxLeftWidth = 1, cxRightWidth = 1, cyTopHeight = 1, cyBottomHeight = 1 }; + UxTheme.MARGINS margins = GetMsstylePlatform() == SkinPlatform.Win11 ? win11Margins : winMargins; + Dwmapi.DwmExtendFrameIntoClientArea(this.Handle, ref margins); + } + + m.Result = IntPtr.Zero; + } + + /// + /// Handel + /// + /// + private void OnWmNcPaint(ref Message m) + { + //Windows 8,8.1 High Contrast theme not work with OpenThemeData and IsThemeActive return false its required app manifest so let's do default + //See https://learn.microsoft.com/en-us/windows/win32/controls/supporting-high-contrast-themes + + if ((IsMdiChild && WindowState == FormWindowState.Maximized) || !VisualStyleRenderer.IsSupported || FormBorderStyle == FormBorderStyle.None) + { + base.WndProc(ref m); + return; + } + + + //Very good at resizing Form when resizing Form from left in Desktop in windows 10 and windows 11 + //no flicker at all but it can't use without Dwm Frame and with rounded corner + if (m.Msg == (int)WindowsMessages.NCPAINT) + { + if (!(!AllowNcTransparency && BorderRadius > 0)) + { + User32.SetWindowRgn(Handle, default, false); + } + } + + Gdi32.HDC hdc = User32.GetWindowDC(Handle); + if (!hdc.IsNull) + { + RECT currentBounds = new RECT(); + User32.GetWindowRect(m.HWnd, ref currentBounds); + User32.OffsetRect(ref currentBounds, -currentBounds.left, -currentBounds.top); + RECT currentClient = new RECT(); + User32.GetClientRect(Handle, ref currentClient); + + int captionHieght = Ismaxchild && MainMenuStrip is null ? DefaultCaptionHieght(this) + User32.GetSystemMetrics(User32.SystemMetric.SM_CYMENUSIZE) : _captionHieght; + User32.OffsetRect(ref currentClient, BorderWidth, captionHieght); + + // if minimized child there is no client Rectangle + if (!(IsMdiChild && WindowState == FormWindowState.Minimized)) + Gdi32.ExcludeClipRect(hdc, currentClient.left, currentClient.top, currentClient.right, currentClient.bottom); + + UxTheme.BP_PAINTPARAMS paintParams = new UxTheme.BP_PAINTPARAMS(UxTheme.BPPF.NonClient); + + // if Child Form and Allow Nonclient area transparency Blend the buffer to get transparency effect. + if (IsMdiChild && AllowNcTransparency) + { + paintParams.BlendFunction = new UxTheme.BP_PAINTPARAMS.BLENDFUNCTION(0, 0, 255, 1); + } + + //The best buffer to use in drawing at Nonclient area is Uxtheme BufferedPaint + //it's better than BitBlt,BufferedGraphics and it's allow Nonclient transparency in Child Form + //DrawThemeTextEx required BufferedPaint DIB to be TopDownDIB. + //see https://learn.microsoft.com/en-us/windows/win32/api/uxtheme/ns-uxtheme-dttopts DTT_COMPOSITED flag + UxTheme.HPAINTBUFFER bufferedPaint = UxTheme.BeginBufferedPaint(hdc, ref currentBounds, UxTheme.BP_BUFFERFORMAT.TopDownDIB, ref paintParams, out Gdi32.HDC memdc); + Color color = IsActive ? ActiveCaptionColor : InActiveCaptionColor; + Color ncColor = Color.FromArgb(NcOpacity, color); + using (Graphics nCGraphics = Graphics.FromHdcInternal(memdc.Handle)) + { + if (BorderRadius > 0) + { + nCGraphics.IntersectClip(new Region(RoundedRect(currentBounds, BorderRadius))); + } + + nCGraphics.Clear(ncColor); + + // The internal Mdi menu must be redrawn if the MainMenuStrip is not present because it is in the Nonclient area of the window + if (MainMenuStrip is null && Ismaxchild) + { + nCGraphics.FillRectangle(new SolidBrush(Color.White), new Rectangle(BorderWidth, _captionHieght, Width - BorderWidth * 2, captionHieght - _captionHieght)); + + if (ActiveMdiChild?.Icon is object) + { + nCGraphics.DrawIcon(new Icon(ActiveMdiChild.Icon, SystemInformation.SmallIconSize), BorderWidth + 2, DefaultCaptionHieght(this)); + } + + int mdiBtnWidth = User32.GetSystemMetrics(User32.SystemMetric.SM_CXMENUSIZE); + VisualStyleRenderer mdiCloseButtonReneder = new VisualStyleRenderer(VisualStyleElement.Window.MdiCloseButton.Normal); + VisualStyleRenderer mdiRestoreButtonReneder = new VisualStyleRenderer(VisualStyleElement.Window.MdiRestoreButton.Normal); + VisualStyleRenderer mdiMinButtonReneder = new VisualStyleRenderer(VisualStyleElement.Window.MdiMinButton.Normal); + mdiCloseButtonReneder.DrawBackground(nCGraphics, new Rectangle(Width - DefaultBorderWidth - mdiBtnWidth, DefaultCaptionHieght(this), mdiBtnWidth, mdiBtnWidth)); + mdiRestoreButtonReneder.DrawBackground(nCGraphics, new Rectangle(Width - DefaultBorderWidth - (mdiBtnWidth * 2) + 1, DefaultCaptionHieght(this), mdiBtnWidth, mdiBtnWidth)); + mdiMinButtonReneder.DrawBackground(nCGraphics, new Rectangle(Width - DefaultBorderWidth - (mdiBtnWidth * 3) + 1, DefaultCaptionHieght(this), mdiBtnWidth, mdiBtnWidth)); + } + + // Draw ControlBox + if (ControlBox) + { + DrawCaptionButtons(Width, nCGraphics); + } + + // Draw Icon + if (ShowIcon && Icon is object && FormBorderStyle != FormBorderStyle.FixedToolWindow && FormBorderStyle != FormBorderStyle.SizableToolWindow && FormBorderStyle != FormBorderStyle.FixedDialog) + { + nCGraphics.DrawIcon(new Icon(Icon, SystemInformation.SmallIconSize), 9, 7); + } + } + + //Draw Text + //Draw Text With nCGraphics.DrawString has very bad look in Transparency Form so we draw it with DrawThemeTextEx + if (!string.IsNullOrEmpty(Text)) + { + VisualStyleRenderer textRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active); + UxTheme.DTTOPTS dttOpts = default; + dttOpts.dwSize = Marshal.SizeOf(typeof(UxTheme.DTTOPTS)); + dttOpts.dwFlags = DTT_COMPOSITED | DTT_GLOWSIZE | DTT_TEXTCOLOR; + dttOpts.crText = ColorTranslator.ToWin32(ncColor.ContrastColor()); + dttOpts.iGlowSize = 8; + Font font = SystemFonts.CaptionFont ?? Font; + Gdi32.HGDIOBJ fontHandle = (Gdi32.HGDIOBJ)font.ToHfont(); + Gdi32.SelectObject(memdc, fontHandle); + RECT textBounds = new RECT(30, 6, Width - ControlBoxBounds.Width, 30); + if (IsMdiChild && WindowState == FormWindowState.Minimized) + textBounds = new RECT(30, 6, Width - 120, 30); + UxTheme.DrawThemeTextEx(textRenderer.Handle, memdc, 0, 0, Text, -1, (int)TextFormatFlags.WordEllipsis, ref textBounds, ref dttOpts); + Gdi32.DeleteObject(fontHandle); + } + + UxTheme.EndBufferedPaint(bufferedPaint, true); + } + + User32.ReleaseDC(m.HWnd, hdc); + } + + /// + /// Handel + /// + /// + private void OnWmNcActive(ref Message m) + { + base.WndProc(ref m); + IsActive = m.WParam.ToInt32() > 0; + OnWmNcPaint(ref m); + } + + /// + /// Handel + /// + /// + private void OnWmNcCreate(ref Message m) + { + base.WndProc(ref m); + UxTheme.SetWindowTheme(m.HWnd, "Window", "DwmWindow"); + + if (IsMdiChild && AllowNcTransparency) + { + Composited(User32.GetParent(m.HWnd)); + } + + SetRoundRegion(); + + // It's better to set background brush to WindowFrame color instead of Black + Gdi32.HBRUSH backgroundBrush = Gdi32.CreateSolidBrush(ColorTranslator.ToWin32(SystemColors.WindowFrame)); + User32.SetClassLong(m.HWnd, User32.GCL.GCLP_HBRBACKGROUND, backgroundBrush.Handle); + } + + /// + /// Handel + /// + /// + private void OnWmNcMouseMove(ref Message m) + { + base.WndProc(ref m); + HookNcMouseEvent(m.HWnd); + switch ((int)m.WParam) + { + case (int)User32.NCHITTEST.HTMINBUTTON: + if (this.IsDrawMinimizeBox()) + { + _captionButton = CaptionButton.Minimize; + _buttonState = DwmButtonState.Hot; + OnWmNcPaint(ref m); + } + + break; + case (int)User32.NCHITTEST.HTMAXBUTTON: + + if (this.IsDrawMaximizeBox()) + { + _captionButton = CaptionButton.Maximize; + _buttonState = DwmButtonState.Hot; + OnWmNcPaint(ref m); + } + + break; + case (int)User32.NCHITTEST.HTCLOSE: + _buttonState = DwmButtonState.Hot; + _captionButton = CaptionButton.Close; + OnWmNcPaint(ref m); + break; + default: + _captionButton = null; + base.WndProc(ref m); + OnWmNcPaint(ref m); + break; + } + } + + /// + /// Handel + /// + /// + private void OnWmNcMouseLeave(ref Message m) + { + base.WndProc(ref m); + UnHookNcMouseEvent(); + _captionButton = null; + _buttonState = DwmButtonState.Normal; + OnWmNcPaint(ref m); + } + + /// + /// Handel + /// + /// + private void OnWmNclButtonDown(ref Message m) + { + switch ((int)m.WParam) + { + case (int)User32.NCHITTEST.HTMINBUTTON: + _captionButton = CaptionButton.Minimize; + _buttonState = DwmButtonState.Pressed; + OnWmNcPaint(ref m); + break; + case (int)User32.NCHITTEST.HTMAXBUTTON: + _captionButton = CaptionButton.Maximize; + _buttonState = DwmButtonState.Pressed; + OnWmNcPaint(ref m); + break; + + case (int)User32.NCHITTEST.HTCLOSE: + _captionButton = CaptionButton.Close; + _buttonState = DwmButtonState.Pressed; + OnWmNcPaint(ref m); + break; + + default: + base.WndProc(ref m); + + break; + } + } + + /// + /// Handel + /// + /// + private void OnWmNclButtonUp(ref Message m) + { + switch ((int)m.WParam) + { + case (int)User32.NCHITTEST.HTMINBUTTON: + if (this.IsDrawMinimizeBox()) + WindowState = WindowState == FormWindowState.Minimized ? FormWindowState.Normal : FormWindowState.Minimized; + break; + case (int)User32.NCHITTEST.HTMAXBUTTON: + if (this.IsDrawMaximizeBox()) + WindowState = WindowState == FormWindowState.Maximized ? FormWindowState.Normal : FormWindowState.Maximized; + break; + + case (int)User32.NCHITTEST.HTCLOSE: + Close(); + break; + default: + _captionButton = null; + base.WndProc(ref m); + OnWmNcPaint(ref m); + break; + } + } + + /// + /// Handel + /// + /// + private void OnWmNcHitTest(ref Message m) + { + Point point = default; + point.X = LOWORD(m.LParam.ToInt32()); + point.Y = HIWORD(m.LParam.ToInt32()); + RECT winRect = new RECT(); + User32.GetWindowRect(Handle, ref winRect); + int width = winRect.right - winRect.left; + point.X -= winRect.left; + point.Y -= winRect.top; + int btnWidth = ControlBoxBounds.Width / 3; + int btnbottom = ControlBoxBounds.Height; + Rectangle closeBtnRect = new Rectangle(width - 45 - BorderWidth, 1, 45, btnbottom); + Rectangle restoreRect = new Rectangle(width - btnWidth * 2, 1, btnWidth, btnbottom); + Rectangle minRect = new Rectangle(width - ControlBoxBounds.Width, 1, btnWidth * 2 + 1, btnbottom); + + switch (GetMsstylePlatform()) + { + case SkinPlatform.Vista: + case SkinPlatform.Win7: + case SkinPlatform.Win8: + case SkinPlatform.Win81: + closeBtnRect = new Rectangle(width - BorderWidth - 45, 1, 45, btnbottom); + restoreRect = new Rectangle(width - BorderWidth - closeBtnRect.Width - 25, 1, 25, btnbottom); + minRect = new Rectangle(width - BorderWidth - closeBtnRect.Width - 50, 1, 25, btnbottom); + break; + case SkinPlatform.Win10: + case SkinPlatform.Win11: + closeBtnRect = new Rectangle(width - BorderWidth - btnWidth, 1, btnWidth, btnbottom); + restoreRect = new Rectangle(width - btnWidth * 2, 1, btnWidth, btnbottom); + minRect = new Rectangle(width - btnWidth * 3, 1, btnWidth, btnbottom); + break; + } + + if (IsMdiChild && WindowState == FormWindowState.Minimized) + { + base.WndProc(ref m); + } + + else + { + if (RightToLeftLayout && RightToLeft == RightToLeft.Yes) + { + closeBtnRect = closeBtnRect.RtlRectangle(width); + + restoreRect = restoreRect.RtlRectangle(width); + minRect = minRect.RtlRectangle(width); + } + + if (closeBtnRect.Contains(point)) + { + m.Result = (IntPtr)User32.NCHITTEST.HTCLOSE; + } + + else if (restoreRect.Contains(point)) + { + m.Result = (IntPtr)User32.NCHITTEST.HTMAXBUTTON; + } + + else if (minRect.Contains(point)) + { + m.Result = (IntPtr)User32.NCHITTEST.HTMINBUTTON; + } + else + base.WndProc(ref m); + } + } + + private static void Composited(IntPtr hwnd) + { + IntPtr exStyle = User32.GetWindowLong(hwnd, User32.GWLIndex.GWL_EXSTYLE); + int compositedStyle = (int)exStyle | 0x02000000; //WS_EX_COMPOSITED + User32.SetWindowLong(hwnd, User32.GWLIndex.GWL_EXSTYLE, (IntPtr)compositedStyle); + } + + /// + /// Set round in case is false and Round corners greater than 0. + /// this kind of is not recomended. + /// + private void SetRoundRegion() + { + if (BorderRadius <= 0 | AllowNcTransparency) + return; + RECT rWindow = new RECT(); + User32.GetWindowRect(Handle, ref rWindow); + int x = RightToLeftLayout && RightToLeft == RightToLeft.Yes ? -rWindow.left - BorderWidth * 2 - 1 : -rWindow.left; + User32.OffsetRect(ref rWindow, x, -rWindow.top); + Region = new Region(RoundedRect(rWindow, BorderRadius)); + } + + private static int HIWORD(int i) + { + + return (short)(i >> 16); + } + + private static int LOWORD(int i) + { + return (short)(i & 0xFFFF); } + #endregion } diff --git a/SkinFramWorkCore/SkinFramWorkCore.csproj b/SkinFramWorkCore/SkinFramWorkCore.csproj index b0a609c..390b7da 100644 --- a/SkinFramWorkCore/SkinFramWorkCore.csproj +++ b/SkinFramWorkCore/SkinFramWorkCore.csproj @@ -1,12 +1,34 @@ - + - - - net6.0-windows - net5.0-windows - netcoreapp3.1 - - true - - - + + net7.0-windows;net6.0-windows;net5.0-windows;netcoreapp3.1 + disable + enable + true + True + 1.2.0 + memoarfaa + https://github.com/memoarfaa/SkinFormCore + https://github.com/memoarfaa/SkinFormCore + git + LICENSE.txt + NonClient area Theme Form for .Net Core + AnyCPU + False + True + false + + + 3 + + + 3 + + + + True + \ + + + + \ No newline at end of file diff --git a/TestApp/Form1.Designer.cs b/TestApp/Form1.Designer.cs deleted file mode 100644 index 6971728..0000000 --- a/TestApp/Form1.Designer.cs +++ /dev/null @@ -1,50 +0,0 @@ - -namespace TestApp -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackgroundImage = global::TestApp.Properties.Resources._4475e73c885921925f61fcf123c7c8c1f93e1c0c; - this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(882, 472); - this.Name = "Form1"; - this.Text = "Form1"; - this.ResumeLayout(false); - - } - - #endregion - } -} - diff --git a/TestApp/Form1.cs b/TestApp/Form1.cs deleted file mode 100644 index 65a58d8..0000000 --- a/TestApp/Form1.cs +++ /dev/null @@ -1,39 +0,0 @@ -using SkinFramWorkCore; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace TestApp -{ - public partial class Form1 : SkinForm - { - public Form1() - { - InitializeComponent(); - if (GetDeskTopWallpaper() != null) - { - BackgroundImageLayout = ImageLayout.Stretch; - BackgroundImage = GetDeskTopWallpaper(); - } - } - - - private Image GetDeskTopWallpaper() - { - int SPI_GETDESKWALLPAPER = 0x73; - int MAX_PATH = 260; - string wallpaper = new string('\0', (int)MAX_PATH); - NativeMethods.SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaper, 0); - - wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0')); - return !string.IsNullOrEmpty(wallpaper) ? new Bitmap(Image.FromFile(wallpaper)) : null; - } - - } -} diff --git a/TestApp/MDIParent1.Designer.cs b/TestApp/MDIParent1.Designer.cs deleted file mode 100644 index aae5fc8..0000000 --- a/TestApp/MDIParent1.Designer.cs +++ /dev/null @@ -1,618 +0,0 @@ - -namespace TestApp -{ - partial class MDIParent1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MDIParent1)); - this.menuStrip = new System.Windows.Forms.MenuStrip(); - this.fileMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.newToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.printToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.printPreviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.printSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.redoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.viewMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.toolBarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.statusBarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolsMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.windowsMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.newWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tileVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.tileHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.arrangeIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.helpMenu = new System.Windows.Forms.ToolStripMenuItem(); - this.contentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.indexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); - this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStrip = new System.Windows.Forms.ToolStrip(); - this.newToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.openToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.saveToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.printToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.printPreviewToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.helpToolStripButton = new System.Windows.Forms.ToolStripButton(); - this.statusStrip = new System.Windows.Forms.StatusStrip(); - this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.toolTip = new System.Windows.Forms.ToolTip(this.components); - this.menuStrip.SuspendLayout(); - this.toolStrip.SuspendLayout(); - this.statusStrip.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip - // - this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.fileMenu, - this.editMenu, - this.viewMenu, - this.toolsMenu, - this.windowsMenu, - this.helpMenu}); - this.menuStrip.Location = new System.Drawing.Point(0, 0); - this.menuStrip.MdiWindowListItem = this.windowsMenu; - this.menuStrip.Name = "menuStrip"; - this.menuStrip.Padding = new System.Windows.Forms.Padding(7, 2, 0, 2); - this.menuStrip.Size = new System.Drawing.Size(867, 24); - this.menuStrip.TabIndex = 0; - this.menuStrip.Text = "MenuStrip"; - // - // fileMenu - // - this.fileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripMenuItem, - this.openToolStripMenuItem, - this.toolStripSeparator3, - this.saveToolStripMenuItem, - this.saveAsToolStripMenuItem, - this.toolStripSeparator4, - this.printToolStripMenuItem, - this.printPreviewToolStripMenuItem, - this.printSetupToolStripMenuItem, - this.toolStripSeparator5, - this.exitToolStripMenuItem}); - this.fileMenu.ImageTransparentColor = System.Drawing.SystemColors.ActiveBorder; - this.fileMenu.Name = "fileMenu"; - this.fileMenu.Size = new System.Drawing.Size(37, 20); - this.fileMenu.Text = "&File"; - // - // newToolStripMenuItem - // - this.newToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripMenuItem.Image"))); - this.newToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.newToolStripMenuItem.Text = "&New"; - this.newToolStripMenuItem.Click += new System.EventHandler(this.ShowNewForm); - // - // openToolStripMenuItem - // - this.openToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripMenuItem.Image"))); - this.openToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.openToolStripMenuItem.Name = "openToolStripMenuItem"; - this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.openToolStripMenuItem.Text = "&Open"; - this.openToolStripMenuItem.Click += new System.EventHandler(this.OpenFile); - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(143, 6); - // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripMenuItem.Image"))); - this.saveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.saveToolStripMenuItem.Text = "&Save"; - // - // saveAsToolStripMenuItem - // - this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; - this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.saveAsToolStripMenuItem.Text = "Save &As"; - this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.SaveAsToolStripMenuItem_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(143, 6); - // - // printToolStripMenuItem - // - this.printToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("printToolStripMenuItem.Image"))); - this.printToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.printToolStripMenuItem.Name = "printToolStripMenuItem"; - this.printToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); - this.printToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.printToolStripMenuItem.Text = "&Print"; - // - // printPreviewToolStripMenuItem - // - this.printPreviewToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("printPreviewToolStripMenuItem.Image"))); - this.printPreviewToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.printPreviewToolStripMenuItem.Name = "printPreviewToolStripMenuItem"; - this.printPreviewToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.printPreviewToolStripMenuItem.Text = "Print Pre&view"; - // - // printSetupToolStripMenuItem - // - this.printSetupToolStripMenuItem.Name = "printSetupToolStripMenuItem"; - this.printSetupToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.printSetupToolStripMenuItem.Text = "Print Setup"; - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(143, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(146, 22); - this.exitToolStripMenuItem.Text = "E&xit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolsStripMenuItem_Click); - // - // editMenu - // - this.editMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.undoToolStripMenuItem, - this.redoToolStripMenuItem, - this.toolStripSeparator6, - this.cutToolStripMenuItem, - this.copyToolStripMenuItem, - this.pasteToolStripMenuItem, - this.toolStripSeparator7, - this.selectAllToolStripMenuItem}); - this.editMenu.Name = "editMenu"; - this.editMenu.Size = new System.Drawing.Size(39, 20); - this.editMenu.Text = "&Edit"; - // - // undoToolStripMenuItem - // - this.undoToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("undoToolStripMenuItem.Image"))); - this.undoToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.undoToolStripMenuItem.Name = "undoToolStripMenuItem"; - this.undoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); - this.undoToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.undoToolStripMenuItem.Text = "&Undo"; - // - // redoToolStripMenuItem - // - this.redoToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("redoToolStripMenuItem.Image"))); - this.redoToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.redoToolStripMenuItem.Name = "redoToolStripMenuItem"; - this.redoToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); - this.redoToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.redoToolStripMenuItem.Text = "&Redo"; - // - // toolStripSeparator6 - // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(161, 6); - // - // cutToolStripMenuItem - // - this.cutToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("cutToolStripMenuItem.Image"))); - this.cutToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; - this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.cutToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.cutToolStripMenuItem.Text = "Cu&t"; - this.cutToolStripMenuItem.Click += new System.EventHandler(this.CutToolStripMenuItem_Click); - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("copyToolStripMenuItem.Image"))); - this.copyToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); - this.copyToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.copyToolStripMenuItem.Text = "&Copy"; - this.copyToolStripMenuItem.Click += new System.EventHandler(this.CopyToolStripMenuItem_Click); - // - // pasteToolStripMenuItem - // - this.pasteToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("pasteToolStripMenuItem.Image"))); - this.pasteToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; - this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); - this.pasteToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.pasteToolStripMenuItem.Text = "&Paste"; - this.pasteToolStripMenuItem.Click += new System.EventHandler(this.PasteToolStripMenuItem_Click); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(161, 6); - // - // selectAllToolStripMenuItem - // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); - this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(164, 22); - this.selectAllToolStripMenuItem.Text = "Select &All"; - // - // viewMenu - // - this.viewMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolBarToolStripMenuItem, - this.statusBarToolStripMenuItem}); - this.viewMenu.Name = "viewMenu"; - this.viewMenu.Size = new System.Drawing.Size(44, 20); - this.viewMenu.Text = "&View"; - // - // toolBarToolStripMenuItem - // - this.toolBarToolStripMenuItem.Checked = true; - this.toolBarToolStripMenuItem.CheckOnClick = true; - this.toolBarToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.toolBarToolStripMenuItem.Name = "toolBarToolStripMenuItem"; - this.toolBarToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.toolBarToolStripMenuItem.Text = "&Toolbar"; - this.toolBarToolStripMenuItem.Click += new System.EventHandler(this.ToolBarToolStripMenuItem_Click); - // - // statusBarToolStripMenuItem - // - this.statusBarToolStripMenuItem.Checked = true; - this.statusBarToolStripMenuItem.CheckOnClick = true; - this.statusBarToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.statusBarToolStripMenuItem.Name = "statusBarToolStripMenuItem"; - this.statusBarToolStripMenuItem.Size = new System.Drawing.Size(126, 22); - this.statusBarToolStripMenuItem.Text = "&Status Bar"; - this.statusBarToolStripMenuItem.Click += new System.EventHandler(this.StatusBarToolStripMenuItem_Click); - // - // toolsMenu - // - this.toolsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.optionsToolStripMenuItem}); - this.toolsMenu.Name = "toolsMenu"; - this.toolsMenu.Size = new System.Drawing.Size(46, 20); - this.toolsMenu.Text = "&Tools"; - // - // optionsToolStripMenuItem - // - this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(116, 22); - this.optionsToolStripMenuItem.Text = "&Options"; - // - // windowsMenu - // - this.windowsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newWindowToolStripMenuItem, - this.cascadeToolStripMenuItem, - this.tileVerticalToolStripMenuItem, - this.tileHorizontalToolStripMenuItem, - this.closeAllToolStripMenuItem, - this.arrangeIconsToolStripMenuItem}); - this.windowsMenu.Name = "windowsMenu"; - this.windowsMenu.Size = new System.Drawing.Size(68, 20); - this.windowsMenu.Text = "&Windows"; - // - // newWindowToolStripMenuItem - // - this.newWindowToolStripMenuItem.Name = "newWindowToolStripMenuItem"; - this.newWindowToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.newWindowToolStripMenuItem.Text = "&New Window"; - this.newWindowToolStripMenuItem.Click += new System.EventHandler(this.ShowNewForm); - // - // cascadeToolStripMenuItem - // - this.cascadeToolStripMenuItem.Name = "cascadeToolStripMenuItem"; - this.cascadeToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.cascadeToolStripMenuItem.Text = "&Cascade"; - this.cascadeToolStripMenuItem.Click += new System.EventHandler(this.CascadeToolStripMenuItem_Click); - // - // tileVerticalToolStripMenuItem - // - this.tileVerticalToolStripMenuItem.Name = "tileVerticalToolStripMenuItem"; - this.tileVerticalToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.tileVerticalToolStripMenuItem.Text = "Tile &Vertical"; - this.tileVerticalToolStripMenuItem.Click += new System.EventHandler(this.TileVerticalToolStripMenuItem_Click); - // - // tileHorizontalToolStripMenuItem - // - this.tileHorizontalToolStripMenuItem.Name = "tileHorizontalToolStripMenuItem"; - this.tileHorizontalToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.tileHorizontalToolStripMenuItem.Text = "Tile &Horizontal"; - this.tileHorizontalToolStripMenuItem.Click += new System.EventHandler(this.TileHorizontalToolStripMenuItem_Click); - // - // closeAllToolStripMenuItem - // - this.closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem"; - this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.closeAllToolStripMenuItem.Text = "C&lose All"; - this.closeAllToolStripMenuItem.Click += new System.EventHandler(this.CloseAllToolStripMenuItem_Click); - // - // arrangeIconsToolStripMenuItem - // - this.arrangeIconsToolStripMenuItem.Name = "arrangeIconsToolStripMenuItem"; - this.arrangeIconsToolStripMenuItem.Size = new System.Drawing.Size(150, 22); - this.arrangeIconsToolStripMenuItem.Text = "&Arrange Icons"; - this.arrangeIconsToolStripMenuItem.Click += new System.EventHandler(this.ArrangeIconsToolStripMenuItem_Click); - // - // helpMenu - // - this.helpMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.contentsToolStripMenuItem, - this.indexToolStripMenuItem, - this.searchToolStripMenuItem, - this.toolStripSeparator8, - this.aboutToolStripMenuItem}); - this.helpMenu.Name = "helpMenu"; - this.helpMenu.Size = new System.Drawing.Size(44, 20); - this.helpMenu.Text = "&Help"; - // - // contentsToolStripMenuItem - // - this.contentsToolStripMenuItem.Name = "contentsToolStripMenuItem"; - this.contentsToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F1))); - this.contentsToolStripMenuItem.Size = new System.Drawing.Size(168, 22); - this.contentsToolStripMenuItem.Text = "&Contents"; - // - // indexToolStripMenuItem - // - this.indexToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("indexToolStripMenuItem.Image"))); - this.indexToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.indexToolStripMenuItem.Name = "indexToolStripMenuItem"; - this.indexToolStripMenuItem.Size = new System.Drawing.Size(168, 22); - this.indexToolStripMenuItem.Text = "&Index"; - // - // searchToolStripMenuItem - // - this.searchToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("searchToolStripMenuItem.Image"))); - this.searchToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Black; - this.searchToolStripMenuItem.Name = "searchToolStripMenuItem"; - this.searchToolStripMenuItem.Size = new System.Drawing.Size(168, 22); - this.searchToolStripMenuItem.Text = "&Search"; - // - // toolStripSeparator8 - // - this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(165, 6); - // - // aboutToolStripMenuItem - // - this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; - this.aboutToolStripMenuItem.Size = new System.Drawing.Size(168, 22); - this.aboutToolStripMenuItem.Text = "&About ... ..."; - // - // toolStrip - // - this.toolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.newToolStripButton, - this.openToolStripButton, - this.saveToolStripButton, - this.toolStripSeparator1, - this.printToolStripButton, - this.printPreviewToolStripButton, - this.toolStripSeparator2, - this.helpToolStripButton}); - this.toolStrip.Location = new System.Drawing.Point(0, 24); - this.toolStrip.Name = "toolStrip"; - this.toolStrip.Size = new System.Drawing.Size(867, 25); - this.toolStrip.TabIndex = 1; - this.toolStrip.Text = "ToolStrip"; - // - // newToolStripButton - // - this.newToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.newToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("newToolStripButton.Image"))); - this.newToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.newToolStripButton.Name = "newToolStripButton"; - this.newToolStripButton.Size = new System.Drawing.Size(23, 22); - this.newToolStripButton.Text = "New"; - this.newToolStripButton.Click += new System.EventHandler(this.ShowNewForm); - // - // openToolStripButton - // - this.openToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.openToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("openToolStripButton.Image"))); - this.openToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.openToolStripButton.Name = "openToolStripButton"; - this.openToolStripButton.Size = new System.Drawing.Size(23, 22); - this.openToolStripButton.Text = "Open"; - this.openToolStripButton.Click += new System.EventHandler(this.OpenFile); - // - // saveToolStripButton - // - this.saveToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.saveToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("saveToolStripButton.Image"))); - this.saveToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.saveToolStripButton.Name = "saveToolStripButton"; - this.saveToolStripButton.Size = new System.Drawing.Size(23, 22); - this.saveToolStripButton.Text = "Save"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); - // - // printToolStripButton - // - this.printToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.printToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("printToolStripButton.Image"))); - this.printToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.printToolStripButton.Name = "printToolStripButton"; - this.printToolStripButton.Size = new System.Drawing.Size(23, 22); - this.printToolStripButton.Text = "Print"; - // - // printPreviewToolStripButton - // - this.printPreviewToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.printPreviewToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("printPreviewToolStripButton.Image"))); - this.printPreviewToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.printPreviewToolStripButton.Name = "printPreviewToolStripButton"; - this.printPreviewToolStripButton.Size = new System.Drawing.Size(23, 22); - this.printPreviewToolStripButton.Text = "Print Preview"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); - // - // helpToolStripButton - // - this.helpToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.helpToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("helpToolStripButton.Image"))); - this.helpToolStripButton.ImageTransparentColor = System.Drawing.Color.Black; - this.helpToolStripButton.Name = "helpToolStripButton"; - this.helpToolStripButton.Size = new System.Drawing.Size(23, 22); - this.helpToolStripButton.Text = "Help"; - // - // statusStrip - // - this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.toolStripStatusLabel}); - this.statusStrip.Location = new System.Drawing.Point(0, 620); - this.statusStrip.Name = "statusStrip"; - this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); - this.statusStrip.Size = new System.Drawing.Size(867, 22); - this.statusStrip.TabIndex = 2; - this.statusStrip.Text = "StatusStrip"; - // - // toolStripStatusLabel - // - this.toolStripStatusLabel.Name = "toolStripStatusLabel"; - this.toolStripStatusLabel.Size = new System.Drawing.Size(39, 17); - this.toolStripStatusLabel.Text = "Status"; - // - // MDIParent1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.BackgroundImage = global::TestApp.Properties.Resources._4475e73c885921925f61fcf123c7c8c1f93e1c0c; - this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.ClientSize = new System.Drawing.Size(867, 642); - this.Controls.Add(this.statusStrip); - this.Controls.Add(this.toolStrip); - this.Controls.Add(this.menuStrip); - this.IsMdiContainer = true; - this.MainMenuStrip = this.menuStrip; - this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); - this.Name = "MDIParent1"; - this.RightToLeft = System.Windows.Forms.RightToLeft.Yes; - this.RightToLeftLayout = true; - this.Text = "MDIParent1"; - this.menuStrip.ResumeLayout(false); - this.menuStrip.PerformLayout(); - this.toolStrip.ResumeLayout(false); - this.toolStrip.PerformLayout(); - this.statusStrip.ResumeLayout(false); - this.statusStrip.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - #endregion - - - private System.Windows.Forms.MenuStrip menuStrip; - private System.Windows.Forms.ToolStrip toolStrip; - private System.Windows.Forms.StatusStrip statusStrip; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; - private System.Windows.Forms.ToolStripMenuItem printSetupToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator8; - private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel; - private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tileHorizontalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem fileMenu; - private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem printToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem printPreviewToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editMenu; - private System.Windows.Forms.ToolStripMenuItem undoToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem redoToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem pasteToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem selectAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem viewMenu; - private System.Windows.Forms.ToolStripMenuItem toolBarToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem statusBarToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolsMenu; - private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem windowsMenu; - private System.Windows.Forms.ToolStripMenuItem newWindowToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem cascadeToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem tileVerticalToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem closeAllToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem arrangeIconsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem helpMenu; - private System.Windows.Forms.ToolStripMenuItem contentsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem indexToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem searchToolStripMenuItem; - private System.Windows.Forms.ToolStripButton newToolStripButton; - private System.Windows.Forms.ToolStripButton openToolStripButton; - private System.Windows.Forms.ToolStripButton saveToolStripButton; - private System.Windows.Forms.ToolStripButton printToolStripButton; - private System.Windows.Forms.ToolStripButton printPreviewToolStripButton; - private System.Windows.Forms.ToolStripButton helpToolStripButton; - private System.Windows.Forms.ToolTip toolTip; - } -} - - - diff --git a/TestApp/MDIParent1.cs b/TestApp/MDIParent1.cs deleted file mode 100644 index 2a017db..0000000 --- a/TestApp/MDIParent1.cs +++ /dev/null @@ -1,143 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using SkinFramWorkCore; -namespace TestApp -{ - public partial class MDIParent1 : SkinForm - { - private int childFormNumber = 0; - - public MDIParent1() - { - InitializeComponent(); - if (GetDeskTopWallpaper() != null) - { - BackgroundImageLayout = ImageLayout.Stretch; - BackgroundImage = GetDeskTopWallpaper(); - } - } - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - - } - - - private Image GetDeskTopWallpaper() - { - int SPI_GETDESKWALLPAPER = 0x73; - int MAX_PATH = 260; - string wallpaper = new string('\0', (int)MAX_PATH); - NativeMethods.SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaper, 0); - - wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0')); - return !string.IsNullOrEmpty(wallpaper) ? new Bitmap(Image.FromFile(wallpaper)) : null; - } - private void ShowNewForm(object sender, EventArgs e) - { - Form childForm = new SkinForm() { BackgroundImage = BackgroundImage, BackgroundImageLayout = BackgroundImageLayout, RightToLeft = RightToLeft,RightToLeftLayout= RightToLeftLayout,NcOpacity = NcOpacity,AllowNcTransparency = AllowNcTransparency,BorderRadius = BorderRadius,BorderWidth= BorderWidth}; - childForm.MdiParent = this; - childForm.Text = "Window " + childFormNumber++; - childForm.Show(); - } - - private void OpenFile(object sender, EventArgs e) - { - if (!RightToLeftLayout) - { - this.RightToLeft = RightToLeft.Yes; - RightToLeftLayout = true; - } - else - { - this.RightToLeft = RightToLeft.No; - RightToLeftLayout = false; - } - MdiChildren.ToList().ForEach(chield => - { - if (!chield.RightToLeftLayout) - { - chield.RightToLeft = RightToLeft.Yes; - chield.RightToLeftLayout = true; - } - else - { - chield.RightToLeft = RightToLeft.No; - chield.RightToLeftLayout = false; - } - }); - } - - private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e) - { - SaveFileDialog saveFileDialog = new SaveFileDialog(); - saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); - saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; - if (saveFileDialog.ShowDialog(this) == DialogResult.OK) - { - string FileName = saveFileDialog.FileName; - } - } - - private void ExitToolsStripMenuItem_Click(object sender, EventArgs e) - { - this.Close(); - } - - private void CutToolStripMenuItem_Click(object sender, EventArgs e) - { - } - - private void CopyToolStripMenuItem_Click(object sender, EventArgs e) - { - } - - private void PasteToolStripMenuItem_Click(object sender, EventArgs e) - { - } - - private void ToolBarToolStripMenuItem_Click(object sender, EventArgs e) - { - toolStrip.Visible = toolBarToolStripMenuItem.Checked; - } - - private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e) - { - statusStrip.Visible = statusBarToolStripMenuItem.Checked; - } - - private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.Cascade); - } - - private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.TileVertical); - } - - private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.TileHorizontal); - } - - private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) - { - LayoutMdi(MdiLayout.ArrangeIcons); - } - - private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e) - { - foreach (Form childForm in MdiChildren) - { - childForm.Close(); - } - } - } -} diff --git a/TestApp/MDIParent1.resx b/TestApp/MDIParent1.resx deleted file mode 100644 index 62d4f81..0000000 --- a/TestApp/MDIParent1.resx +++ /dev/null @@ -1,343 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAELSURBVDhPrZDJasJQGIXzUvoO9TX0jcQuSulCLUUECwot - KtrSAbQWRDTg0CLBCY1xqmkcYo7c8ItJYy9Z+MHhLu453+IXzkbypY6/SeRriKXLiKaKZqh6Gjb4j+v4 - M7y+AF9y/yRS3UkomkbmvcaXxLMVqjsJhh/N8SE0sXP38El1J1t9Z0oOIprYiSQLVLdjGAZUbYOhopoC - z4X/tOAm8UoTO+uNjslcgzSY8wVXsTxNjug7Awt1jb68RFOa8AWXtxmaHdFWW8jTX7R7M1RbMl/APq2w - w81+VugMF6i3FZTEgXuB9XBfnSkqjRHeyl33AuvhxO8xitU+ch+SOwF7eeEK2Keb0OQcCMIe3/X1lqrb - NIsAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJYSURBVDhPvZFbSBNQHIf30ENPFmlRCEWWhD0MA0Oqh5Ck - m6KUZoWRJpS3LhiKbVPbvE53c+pKh7lN19RptTIMK4RCkQgtdZSYmgVFpZgZKnn7GptokkEP0R9+L+ec - 7zs/zhH8l8kpMSPTWriSbyJPZ0WiNDK/9XcTnawjLF7lhC6IKsh0yFKyDUQllyCoN2tYLo218j/ekiAp - JTxRRWh8oUvQ22VkcrTOmR8jFqaHDFhNKmzm7GUlYQlqQuO0BMcWI6irVDMxUr0Env1UyrQ9ieqKfKrK - cjGUZKIvzOC6UkyxPHWptMaoYOKLcQGec8D0isEeu2x+E9wsl/P9o34BbqpXOPPAWkCDRc6dqlyshiws - ehkm3VVuaNMoU4vRKUQuWZU+l7F3Rc7aAy1SbNVqZgdkMJi9NG8da/0S6EmGV4l01kZwKSYEgUGXxbe+ - fHiv5G6NiraHStehX6u/jIL2cGZag5h8FMCbSiHnTx9wCcq1Ur6+ljHYmo7NomSuXwrdcS6wM8YBnmCm - LYTJ5v2MNe5huH4HsnhvTgZ6uN6iVJ3OcJeIW2YFHU8dTXqSHIKz0HGKuWdHmHpyiPGmvYzY/Phc40N7 - zmoig7zw2+bmEugKxHQ3Z3DbXAB9GfDCUff5MaZaghl/HMBogz9DViEfjFuxK92Rxm7Bd7vn4k8U5aVS - Z8rHfi+Bdo1gIW3KFTTLV3I/cxW1aWsxpHpy7fImIg9vxt9346JAk52CRnqOPFE0kovHnQ9zJiKQowd3 - sW+3kJ1Cb3y8PNm4wYN1a9xY7z5f/d+MQPATMS7uX9kMtOAAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIvSURBVDhPrZLdS9NRGMd//0L33QRddFtTYzgXq8GvXENZ - Ngwrwl5+kWZpukwTFSvTqPkG2QqXTlqtJuGkIl/AFCkRZSpZmrmiJQ41xSaCwdfznP3yuIouogeem8P5 - fM55XqT/Es+fhUHpa11Ci3cRD93zaGoM4a5jGnW1X2C/FcD18kmUloyjsOAt8nJHcP6cHyouSQR2dQK1 - NSv4WyyvrMKU2oVDqU95qrgkeZ8scEFlxTf16u9BcGh+GbssL6DRKLAe9AiB+8EcF5SWfFWvR8dP+GNw - ATFmHwouTeGApVkInA0zXHDR9kFFRGyEhydC2CZ7kZM9huQkpxDU3w5yQdbZERWLxK9wnz+IzQY3FGUA - ZrNDCGqqP3OBcmpARf8Md/Z/wqb4Rhw+8gqJiXVCcKNyCh3tYKMEjh1/A+vRXt5tahjVTN+mlyNwN1Ks - LyHLdiG4UjaBNh/YDgDNrh9s7t9Rfm2WN5UaRjVnZvjX4f3JrTAaK4TgcuEYPI+A+85VtjhhmNKyo9KS - bkPamaIInMTgfR4YDGVCYMsbZTBQXRXmLxNE5zE6GYPvZzA6OQsl9yr2mFo4rNvtgl5fJAS0lo47WP82 - CQg+nX8T7wJzCEwv4kKxHbEGF4ObEJtwD7r4fCHIzBhidS9xeKvRgy07ZDxu64GvvQ8d3f3ofT2IvWYr - NPoGxDF4u7YeWm1OtODkiR6+nrRhtCQ0ZxoVdZsaRjXTq5QE74zLEoJ/D0laA2xoOmtG+TV7AAAAAElF - TkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIqSURBVDhPrZL7T1JxAMVZP/b/tLa2Wm21mail1YZlRjid - k6JhTApClhGmktrDWlKjK3OBDrLAMWJaY9MZZJbo0umWQIEFXRPQMB6ne788HFpbW322s93d3fM598X5 - 7xjtUxh0vId5dOaPMY14kL18O6zgrcePrWz8TMIbWMGgbQIlZy6DW31pu4Qts0ml0gjRETjdH0iGHC4Y - LONwz/hQJVITQbZSiN7qxsfPdHYzA7u8Go1jdnEZJruLLP92XWsaB5sks+4LhgvWbc5puDxeVDaocOSs - HBrtM9zps21KFJ1PSHnENZ9fzS0HwzHML4XRa3CglC+Dsqsfj0xjKGVEpNzUpof6/hAoyxs8MDqhf/4a - tyk7rt4yQtyiBb+xA+U1ChSfluLkuevo1lkhUWlRnHuMm49fIBKLk+WtJJIprMcT5E6+0uv49CUKeTuF - OmkXcweyjEB1zwzLq3d46nCDMr/E3b5hqHsGIGvXQdTcA8HFDvAaWnBUIEfRKQnOM+cqhdew/7goI1B2 - D8AfCGU3C4msbcAbXMVOcEh2UBzwxW0oqZZi1+GajKC504DpuSUw7ywPe/wtmsCcfw1jszQpW7OCY7UK - 7KsQbgqUGgqaXhN8oTjoWBqB72ksLqcwsfADw5NR9DtXSDGXQzwxKecF9ZJWyG7oMDrpJ9/2b1IgYJGo - HqKiTokywRVwmd+0qKoJB3mNOHDiAvaWC7GnrB67ubX5YkH53+BwfgHgHTGbZU7qDAAAAABJRU5ErkJg - gg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHXSURBVDhPrZDdS1NhAIf3z4RXXkRqEd5IoCaKROWc6YVN - XMQkMFToZjcpQaatoVuiq+UkTTrFWR/OyuWmNaGoYDLtIkHUKfOjSJxuc0/7OHObx4+bHvjxvhe/33MO - r+K/IDpn2B9hzMOQ/RtW21Q8UvVgYoPD6B3+SF5J3dGSF45pqS6ny2pndNJztGT43Q+pLsfw5G18nIw0 - yeTpmy9SPUUouMX45DjGRxZu39NzR99Ffpn6YEG/6JZmCba3txBHRnjvnMDnX2V+2Y9VEFFrm6jR3pJL - zIJLmiZwTLiwO5zxeygMfwO7LK2HMZifoarVyAU9Q2PxcpJus4XFFf/eePl3iNnFIDbXDJXV1XJB98Co - NE3QaexhYWUtMd4IR8c7uGcDPHzu5mJFhVwQe+l0BNGGaHfg24h+eSnI558BXn/dpKFFR2VVFfrWpkxJ - uiASifBrbo67nQb6Bl/x0uXFJLhpaNahVF1m8H4NoulGpiRdsBMMs/4ngMfr5YHRiOa6lqt19VxRXsBw - 8xy+x0XsfqrF0tGYkiQFsfOwtLa1c60sh++6XBZMBazZlDRrylOC3PPqY1NYcglN6Sk+tJyhvjgbVelp - +YMeR+wv8k9mUXz2RHSsUPwDd10kHqNu+GEAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGmSURBVDhPvZHdS5MBFMb3p3TX6E7c1BTHUIc2xUbEqGUz - LaV5s6ViRvhuul0M9lFshFjmjV/bKLVajRAid6N3KYg3FkHDiWvNmXt3++udDiMd4nthD5ybc57nx+Ec - xbkqGM0TfCcysSgyuyQSlioSFymOT5d/QaRQnjmR4VAO+1SOlx8PASUhnkiKmZXDQSH05E2erkCGBtsK - NV0xKu9EaRz8xlisBKDQGJ7aYeKziD0k8vRtHrN3G51tGc39RdS3X9Fgfc/l9lmM7gzTkq8Y/au+sW16 - nu/zYDzHTe8e1XejVHUsSOHwgdkwFKPsxiS6h5s4pnMnAZ3+JM0jaW759hkYT6NsDqBqCx0ZL2gFND1x - dANfcYRLAK45t6jo+86VkdTBJh3eHwiTv/4FWOLohSTOUoC6wQTa3g2qLcuo2j9QZnqNsuXZkbHCPE+t - ZQmD6ye20cRJwHEdv/RFfUBaf5Pu4C4+6b3F9tlVde8T191ZjMIXeWGzfxetdZWrriytj9a5ZHghD9D0 - OCGFf9PUv0a5KSJ/dZP01vr+DdRtc/LD/0EKxR+XdBDBXAMPDQAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGVSURBVDhPzZHdK0NhHMf3p7jBknbBNpqbc+FtttrUrBim - LEJeRo0lzMsK2S6M5D3vJjXFJinhZu64WolQu9FaXjrnuf56nrOl5kTIhW99L56e7/dzfuf3yP5MO+cE - /jOCLeqlY4KJgADnioDk9ddiZebFI4KBdQGD2wLcOwJ6VimEOhn7XKw8e0hQ4nxAXt0BNLYQuNYwbD4e - 9gUB9sUEZPOCgOuMSIEbpwTm0SeoLcsobAtAVbMrWm3dRz2FNM7yaKGQJZoraAqL0yarCbk2BBR13yKz - bALGvkPxUlXjR65lC9nGeVSMvYqTNM/xUFqD0glcfga4Q4bWizSu/z2grN6GXDcJx0IcFg8P3VAcioo1 - KWCYAnQDjzTsSwFMBQmY2Ze1QzGou+4h109LAR0zUZS748ip3E0BsIVp6D8rrSEoTOtiOb14XArw7BE0 - +J5R5Lihe5hMCUgW9pnM/Zcwjb4g33byvcJHZdFtG3ojMIy8gGu/Qq33+ecgBtE7r2F08yjtjf5uEiad - K4Yq+mzJ47+WTPYGxTcHtykTmrAAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGhSURBVDhPYyAG/AcCKJMwWLlp///ZyzbBNYA033nw9H91 - 6xTiDJk8d83/nmmL/1e1zgRr+Pb9x//Vm/b8T8mpIt4Vk2av/D95zmqQ5f+fvXjzPy2/5r+YEB8J3ti4 - 73/X5IX/T5y5+P/gsXP/w+KzSTNg4aod/7unLPrfO23h//LGvv8+QdHEawaBzokL/5c09P1Pzqv7Hxqb - +d/NO4g0A0AgIa/lf1hC4f+QtLb//gktxBsQ3fHuf0Tn6/8hzQ/+e5ed+u9Tfva/X9Xl/z6lp/+7Ze/E - b1BE+6v/kT3v/gc33PlvHT3vv2lQ33+3vH3//auv/ncFaraKmY/fgLD25//D2p7+d0zbANZsGtT737vk - 1H//yqv/nTI2/TcJ7sdvQGjLo/9Bjff+O6Vu+m8c0A02IABou2/F2f8WEdP+aztk4TcguOnef/+yS//t - ktf8N/SBBJx3yfH/dkmr/mvaJP+XkdfEb4Bf5cX/9kmrgbZ3/Vc3CwcnHvuUNf+1rBP+q5tH/Df2b8dv - gHPGlv9mIZP+a1jF/jf0qsGvmDqAgQEAkYXpGFtqYpEAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHgSURBVDhPvZHdS1pxGMfPn7IKieq63Y/RKw0aFF1ssEEv - dOVFXXUVFQ3Wlg4H2dSo7A21jnUiKiPFylwttMy9GXMNNgUrzinLrGN98zxaVgu7GOwLn5vf+X0/D8/v - MP8cbuEbJFiblzDMuDDAfcQbLYfklfSRyrejn3CirnUID0tr7peYrd5kLZHY2Tm6hudgcXjxrEF5v8Qw - 66aixQew64DHL+C9fhrskgDTAg+jnUffLA/V+B7xojNwUzjAOUkg5eQ0BuEgikAoTILbaR/ZQX6tg0jW - GUZnstPHXscpFDMCWtg/aOz3Y3h+l86vp0ETArciIK9qgiCBOr6vtPdRRMQOH8F2YB9f/LvQTQWp1MHG - CM/WPl4qgsitmkROxSiyywcTAmnf46h4NVmu86Fe/RnvjNskuIxwKGLr9zEcmwfQsGuQPelJCYRwFF9/ - huD+HoDT8wu2Tz/Q2pv4vc0jYcjVQTx/68PTtg1Cw65CVtqdEuSXVP9Fo2qDBGJ8vRAvYtN/BKtLgHlx - Dx9GncgqUqUe8q7UtK+Q4PrkS7pNy8gsUKQXVDbZETk5g27cBa15DZqxVZosldWGJWQ8fp1eUCS3xF/b - SGSX6yEr0yKruAuZhcp4uQMPHr1KL/hPYZgL78LfVeQiZg4AAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJXSURBVDhPtZJdSFNhHMYPdGE3RR/UVVcF0U0UEVQXGYWt - sNlikdii5SK2SckmS9tGas0cunRzadoW+THUprMSpUnREBqOvmdsRh8SOSPXsnY2N+eyeDrn3UaujCDo - gYcD73mf3/+Dl/ovcvZr4bihQW+LCrL8fUgez6+edgPmuqX2CIL+DkT8V+EbqUGJmANDpQKXdWoYK4uJ - k9GE2FCMtiEe6kYs2AlLkwLRyTaUSHh4MaTE2VNcKEWb4Xcew6R9NWTC/b8D2HA8ZEWj9ijcrhrQ7+sx - MaLGW9dx9Jl5kAgy0VG6Ck8NFAoO/zJSd1ttAkBfh65UiHJFHtSFuThTwIdCzINcxIVUkIU62RoCyMvO - TAd0NuswQ3dhJmBCdLwKgeeF8LYtJ/a0LoO7aREeGTNImHXWto3pAItJi+lAC6bHKhB9eRKRZwdB9y+G - vtWOKlMvzl3qglJngVxjhkRlhLCoOh3Q3KDBlM+IyIgYU4+5CN/fhI+3VpBwSvHZbwiGYhibCCJXeh45 - +eqfELO+DPSrCoQfchAeXI/QwEr4WilSmVXzTSexyeqAZ9RPwneHvNjDFyUgDdUqfB4+jZBjHejbSxGw - ZWD0GkXa/jr7HV/CTOUPQXje+OEafodsgRwcJrxr7wFkbt8Bqu5CMQIPpEx4CT71LMR4+wJ4GynImJnZ - tlMdXGE6qLcMoG/QS76st25YC+pieRF5IKktpyxmFja38j3XaxK23XHDan+SDtCXnWBeGA8i/m7k7NxC - frDbZmdOVZvPBPAnHWK2zV74m5PX/1UU9QOTNfjZ1V1+MwAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKWSURBVDhPjZJbSNNRHMf3HPRcYu+9Gb32VhAJ9RASlOBb - b2aIFop5GXPeyrmp8zLNec01HbmpqJvabjbndHl3JTmGbk7zroUXKD79N5XMFPzCjwMHPp9zzu/8ROdF - 3eChpGSc7OxBsrIcHG1fLCE4VBMT69TVz6J5P4NUekHRMexyrVOumsBqW+OjOUC/eR5tiwdJtvN80Wm4 - q3sZh+MnA9YdbNYt+vvW0esXaWqeFm409K/oNNzRGcRi3qKnZ5X2jmXaBLBVN09T4xwqlQe5fIycvKFD - wWlYbwiEQYMhSIt2gcZGLzU1s5SXT6NQjJKfP8KLZDMJz42caNhmGNa2zKPTLaB556O+bo6W9gCy1k1i - S/eJke0gqQkgL58k/pkRffvgoUDbOoVc4aauwcvb6q9UlnlQlkyh1gVJ0kKVFT4vCOWHevsvHuf5aTN7 - mPP7EIklNrS6SSRSO7LiYWRFo7wpdFPb7CVRA7phWFzaJqPAxL0n6vBqcO1yJ9FNodKF6GWKEd9yAJNl - jLT0PsRiW/jPc5tWUFkI5xgeGfOH19J6J1LNEnHxJkQZWRqKlb0sbQeZXxXeV2JBmmvnYcEGhrFDQSih - W4QEtx5UUtE8StPAARHXKxC9LhoSTu4XyojZMcXGwXeszi9EiwPoTwh2fuyH4ZQcE3MrQi8se1yJzP87 - B5IcO+mZfRSX2fAGF1B1LyLv3D3CwSmcLq9x4RXgKaGZyaUeomPU/09keqaZV4Koy/KNu8njdLkP2PsN - xk9+om4XM7MIFV1rXL6pJE9pOXukM8UWUtN6aWib4UasCXGtD61jj2brLkmKGS5FKUhI/cDAaOBswXFU - 1W6KlE7inrYTcS2Xq5EZ3H9UhUxlY2gyKMAi0R+3BHAuvd7mVQAAAABJRU5ErkJggg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALGSURBVDhPldL/T01xHMfx/hczs8VmmC/zg1i7oa6pOXVL - Jbrqlm5fbrluSqV7uynpdq/qtoh7C9Ei3eu0fBnKl6yFmSRkWF93VUZ2Q/Z0P2OuxmZe2/ntvB/nfD7v - V8Dvya2UEY+hwk2+VcZY28n+Cheph86jKWzm52t/T15VBwdtMs6ubq6+7EMe7sA5VESGnIRkOklirhN1 - XuPfkQMWGZNDprX/Mg8+PGFgdpScthIsL/JJuaRkg7mcGFMP0YYGEvQn5iN68bs2N3W9VjrGHdyc6qVv - pp8Br4eWERdJdjMK+1PW2NpYW6NGyqxkR1atHxFAsVPG/rCcmiE9jrc2nMNmah87ST3TgqZukpiK1yw9 - G8Hi06GsN6YTlVblB7LL2qlzv8EkW9h7fyuZvWHoHAZymnzHOn4Rk7UBQ3kl8dYUAqsVBJaFE6Ep9wMZ - 5jbqr8xSWF+P8qyCLXI06lor1Y0urnXdZszzjrfjHpoutBOXp2VBSQjKRJMf0Bpbsbq9HGjyEG9QE1q/ - G11TMZ03uhD5Ogcfvd8YnZrD1nCeddoINscX+IG9h1rIrHmF9vhnNNYhwnO1vnUeYWTC82t4/P1XBke+ - 4Op+RkRcLMHRBj+QUnSO1NJbJB77RIJlimjjHfaXmhiemPwxPD3nG/5Mz6CXutYetkmRBEk6PyAaJkqy - q+QBqsPjKIp6kYw62jtvMDbt+/LoF+4993K5b4Y0fQFh0k6K87P9gIhoWJzeSdTBOyzNNrNMF0uyLosT - zW7augewX+ghbV8BkartNFtiabenU2XKmY+IhqnSq9mUYSVYnYpSY0ZKLkTasYtwSUVM5DZsuo2MnVLw - 7W4CjqNZfyKiYaIkYs9iVeK2xYWJM8cog0kOW8GjgpUM24OYdEWyL2nrfOBfEUBS6HKu61ezJ2QJqtBV - /weICGTdskWErF3oGw4I+A4LpgTtu1iCBgAAAABJRU5ErkJggg== - - - - 125, 17 - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAELSURBVDhPrZDJasJQGIXzUvoO9TX0jcQuSulCLUUECwot - KtrSAbQWRDTg0CLBCY1xqmkcYo7c8ItJYy9Z+MHhLu453+IXzkbypY6/SeRriKXLiKaKZqh6Gjb4j+v4 - M7y+AF9y/yRS3UkomkbmvcaXxLMVqjsJhh/N8SE0sXP38El1J1t9Z0oOIprYiSQLVLdjGAZUbYOhopoC - z4X/tOAm8UoTO+uNjslcgzSY8wVXsTxNjug7Awt1jb68RFOa8AWXtxmaHdFWW8jTX7R7M1RbMl/APq2w - w81+VugMF6i3FZTEgXuB9XBfnSkqjRHeyl33AuvhxO8xitU+ch+SOwF7eeEK2Keb0OQcCMIe3/X1lqrb - NIsAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJYSURBVDhPvZFbSBNQHIf30ENPFmlRCEWWhD0MA0Oqh5Ck - m6KUZoWRJpS3LhiKbVPbvE53c+pKh7lN19RptTIMK4RCkQgtdZSYmgVFpZgZKnn7GptokkEP0R9+L+ec - 7zs/zhH8l8kpMSPTWriSbyJPZ0WiNDK/9XcTnawjLF7lhC6IKsh0yFKyDUQllyCoN2tYLo218j/ekiAp - JTxRRWh8oUvQ22VkcrTOmR8jFqaHDFhNKmzm7GUlYQlqQuO0BMcWI6irVDMxUr0Env1UyrQ9ieqKfKrK - cjGUZKIvzOC6UkyxPHWptMaoYOKLcQGec8D0isEeu2x+E9wsl/P9o34BbqpXOPPAWkCDRc6dqlyshiws - ehkm3VVuaNMoU4vRKUQuWZU+l7F3Rc7aAy1SbNVqZgdkMJi9NG8da/0S6EmGV4l01kZwKSYEgUGXxbe+ - fHiv5G6NiraHStehX6u/jIL2cGZag5h8FMCbSiHnTx9wCcq1Ur6+ljHYmo7NomSuXwrdcS6wM8YBnmCm - LYTJ5v2MNe5huH4HsnhvTgZ6uN6iVJ3OcJeIW2YFHU8dTXqSHIKz0HGKuWdHmHpyiPGmvYzY/Phc40N7 - zmoig7zw2+bmEugKxHQ3Z3DbXAB9GfDCUff5MaZaghl/HMBogz9DViEfjFuxK92Rxm7Bd7vn4k8U5aVS - Z8rHfi+Bdo1gIW3KFTTLV3I/cxW1aWsxpHpy7fImIg9vxt9346JAk52CRnqOPFE0kovHnQ9zJiKQowd3 - sW+3kJ1Cb3y8PNm4wYN1a9xY7z5f/d+MQPATMS7uX9kMtOAAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIvSURBVDhPrZLdS9NRGMd//0L33QRddFtTYzgXq8GvXENZ - Ngwrwl5+kWZpukwTFSvTqPkG2QqXTlqtJuGkIl/AFCkRZSpZmrmiJQ41xSaCwdfznP3yuIouogeem8P5 - fM55XqT/Es+fhUHpa11Ci3cRD93zaGoM4a5jGnW1X2C/FcD18kmUloyjsOAt8nJHcP6cHyouSQR2dQK1 - NSv4WyyvrMKU2oVDqU95qrgkeZ8scEFlxTf16u9BcGh+GbssL6DRKLAe9AiB+8EcF5SWfFWvR8dP+GNw - ATFmHwouTeGApVkInA0zXHDR9kFFRGyEhydC2CZ7kZM9huQkpxDU3w5yQdbZERWLxK9wnz+IzQY3FGUA - ZrNDCGqqP3OBcmpARf8Md/Z/wqb4Rhw+8gqJiXVCcKNyCh3tYKMEjh1/A+vRXt5tahjVTN+mlyNwN1Ks - LyHLdiG4UjaBNh/YDgDNrh9s7t9Rfm2WN5UaRjVnZvjX4f3JrTAaK4TgcuEYPI+A+85VtjhhmNKyo9KS - bkPamaIInMTgfR4YDGVCYMsbZTBQXRXmLxNE5zE6GYPvZzA6OQsl9yr2mFo4rNvtgl5fJAS0lo47WP82 - CQg+nX8T7wJzCEwv4kKxHbEGF4ObEJtwD7r4fCHIzBhidS9xeKvRgy07ZDxu64GvvQ8d3f3ofT2IvWYr - NPoGxDF4u7YeWm1OtODkiR6+nrRhtCQ0ZxoVdZsaRjXTq5QE74zLEoJ/D0laA2xoOmtG+TV7AAAAAElF - TkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIqSURBVDhPrZL7T1JxAMVZP/b/tLa2Wm21mail1YZlRjid - k6JhTApClhGmktrDWlKjK3OBDrLAMWJaY9MZZJbo0umWQIEFXRPQMB6ne788HFpbW322s93d3fM598X5 - 7xjtUxh0vId5dOaPMY14kL18O6zgrcePrWz8TMIbWMGgbQIlZy6DW31pu4Qts0ml0gjRETjdH0iGHC4Y - LONwz/hQJVITQbZSiN7qxsfPdHYzA7u8Go1jdnEZJruLLP92XWsaB5sks+4LhgvWbc5puDxeVDaocOSs - HBrtM9zps21KFJ1PSHnENZ9fzS0HwzHML4XRa3CglC+Dsqsfj0xjKGVEpNzUpof6/hAoyxs8MDqhf/4a - tyk7rt4yQtyiBb+xA+U1ChSfluLkuevo1lkhUWlRnHuMm49fIBKLk+WtJJIprMcT5E6+0uv49CUKeTuF - OmkXcweyjEB1zwzLq3d46nCDMr/E3b5hqHsGIGvXQdTcA8HFDvAaWnBUIEfRKQnOM+cqhdew/7goI1B2 - D8AfCGU3C4msbcAbXMVOcEh2UBzwxW0oqZZi1+GajKC504DpuSUw7ywPe/wtmsCcfw1jszQpW7OCY7UK - 7KsQbgqUGgqaXhN8oTjoWBqB72ksLqcwsfADw5NR9DtXSDGXQzwxKecF9ZJWyG7oMDrpJ9/2b1IgYJGo - HqKiTokywRVwmd+0qKoJB3mNOHDiAvaWC7GnrB67ubX5YkH53+BwfgHgHTGbZU7qDAAAAABJRU5ErkJg - gg== - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHXSURBVDhPrZDdS1NhAIf3z4RXXkRqEd5IoCaKROWc6YVN - XMQkMFToZjcpQaatoVuiq+UkTTrFWR/OyuWmNaGoYDLtIkHUKfOjSJxuc0/7OHObx4+bHvjxvhe/33MO - r+K/IDpn2B9hzMOQ/RtW21Q8UvVgYoPD6B3+SF5J3dGSF45pqS6ny2pndNJztGT43Q+pLsfw5G18nIw0 - yeTpmy9SPUUouMX45DjGRxZu39NzR99Ffpn6YEG/6JZmCba3txBHRnjvnMDnX2V+2Y9VEFFrm6jR3pJL - zIJLmiZwTLiwO5zxeygMfwO7LK2HMZifoarVyAU9Q2PxcpJus4XFFf/eePl3iNnFIDbXDJXV1XJB98Co - NE3QaexhYWUtMd4IR8c7uGcDPHzu5mJFhVwQe+l0BNGGaHfg24h+eSnI558BXn/dpKFFR2VVFfrWpkxJ - uiASifBrbo67nQb6Bl/x0uXFJLhpaNahVF1m8H4NoulGpiRdsBMMs/4ngMfr5YHRiOa6lqt19VxRXsBw - 8xy+x0XsfqrF0tGYkiQFsfOwtLa1c60sh++6XBZMBazZlDRrylOC3PPqY1NYcglN6Sk+tJyhvjgbVelp - +YMeR+wv8k9mUXz2RHSsUPwDd10kHqNu+GEAAAAASUVORK5CYII= - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKWSURBVDhPjZJbSNNRHMf3HPRcYu+9Gb32VhAJ9RASlOBb - b2aIFop5GXPeyrmp8zLNec01HbmpqJvabjbndHl3JTmGbk7zroUXKD79N5XMFPzCjwMHPp9zzu/8ROdF - 3eChpGSc7OxBsrIcHG1fLCE4VBMT69TVz6J5P4NUekHRMexyrVOumsBqW+OjOUC/eR5tiwdJtvN80Wm4 - q3sZh+MnA9YdbNYt+vvW0esXaWqeFm409K/oNNzRGcRi3qKnZ5X2jmXaBLBVN09T4xwqlQe5fIycvKFD - wWlYbwiEQYMhSIt2gcZGLzU1s5SXT6NQjJKfP8KLZDMJz42caNhmGNa2zKPTLaB556O+bo6W9gCy1k1i - S/eJke0gqQkgL58k/pkRffvgoUDbOoVc4aauwcvb6q9UlnlQlkyh1gVJ0kKVFT4vCOWHevsvHuf5aTN7 - mPP7EIklNrS6SSRSO7LiYWRFo7wpdFPb7CVRA7phWFzaJqPAxL0n6vBqcO1yJ9FNodKF6GWKEd9yAJNl - jLT0PsRiW/jPc5tWUFkI5xgeGfOH19J6J1LNEnHxJkQZWRqKlb0sbQeZXxXeV2JBmmvnYcEGhrFDQSih - W4QEtx5UUtE8StPAARHXKxC9LhoSTu4XyojZMcXGwXeszi9EiwPoTwh2fuyH4ZQcE3MrQi8se1yJzP87 - B5IcO+mZfRSX2fAGF1B1LyLv3D3CwSmcLq9x4RXgKaGZyaUeomPU/09keqaZV4Koy/KNu8njdLkP2PsN - xk9+om4XM7MIFV1rXL6pJE9pOXukM8UWUtN6aWib4UasCXGtD61jj2brLkmKGS5FKUhI/cDAaOBswXFU - 1W6KlE7inrYTcS2Xq5EZ3H9UhUxlY2gyKMAi0R+3BHAuvd7mVQAAAABJRU5ErkJggg== - - - - 223, 17 - - - 332, 17 - - - 25 - - \ No newline at end of file diff --git a/TestApp/Program.cs b/TestApp/Program.cs deleted file mode 100644 index 5392e95..0000000 --- a/TestApp/Program.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace TestApp -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.SetHighDpiMode(HighDpiMode.SystemAware); - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new MDIParent1()); - } - } -} diff --git a/TestApp1/App.config b/TestApp1/App.config new file mode 100644 index 0000000..cec3f99 --- /dev/null +++ b/TestApp1/App.config @@ -0,0 +1,15 @@ + + + + +
+ + + + + + en-US + + + + \ No newline at end of file diff --git a/TestApp1/MDIParent1.Designer.cs b/TestApp1/MDIParent1.Designer.cs new file mode 100644 index 0000000..112913e --- /dev/null +++ b/TestApp1/MDIParent1.Designer.cs @@ -0,0 +1,316 @@ +namespace TestApp1 +{ + partial class MDIParent1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.statusStrip = new System.Windows.Forms.StatusStrip(); + this.toolStripStatusLabel = new System.Windows.Forms.ToolStripStatusLabel(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.borderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.borderWidthToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.borderRadiusToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.borderOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.activeBorederColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.inactiveBorederColorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.captionHeightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.desktopBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageLayoutTileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageLayoutCenterToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageLayoutStretchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.imageLayoutZoomToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.removeBackgroundToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.formsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newChildFormToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.layoutMdiCascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.layoutMdiVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.layoutMdiHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.directionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.leftToRightToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.rightToLeftToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.statusStrip.SuspendLayout(); + this.menuStrip1.SuspendLayout(); + this.SuspendLayout(); + // + // statusStrip + // + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabel}); + this.statusStrip.Location = new System.Drawing.Point(0, 707); + this.statusStrip.Name = "statusStrip"; + this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); + this.statusStrip.Size = new System.Drawing.Size(1008, 22); + this.statusStrip.TabIndex = 2; + this.statusStrip.Text = "StatusStrip"; + // + // toolStripStatusLabel + // + this.toolStripStatusLabel.Name = "toolStripStatusLabel"; + this.toolStripStatusLabel.Size = new System.Drawing.Size(39, 17); + this.toolStripStatusLabel.Text = "Status"; + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.borderToolStripMenuItem, + this.desktopBackgroundToolStripMenuItem, + this.formsToolStripMenuItem, + this.directionToolStripMenuItem}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(1008, 24); + this.menuStrip1.TabIndex = 4; + this.menuStrip1.Text = "menuStrip1"; + // + // borderToolStripMenuItem + // + this.borderToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.borderWidthToolStripMenuItem, + this.borderRadiusToolStripMenuItem, + this.borderOpacityToolStripMenuItem, + this.activeBorederColorToolStripMenuItem, + this.inactiveBorederColorToolStripMenuItem, + this.captionHeightToolStripMenuItem}); + this.borderToolStripMenuItem.Name = "borderToolStripMenuItem"; + this.borderToolStripMenuItem.Size = new System.Drawing.Size(54, 20); + this.borderToolStripMenuItem.Text = "Border"; + // + // borderWidthToolStripMenuItem + // + this.borderWidthToolStripMenuItem.Name = "borderWidthToolStripMenuItem"; + this.borderWidthToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.borderWidthToolStripMenuItem.Text = "Border Width"; + this.borderWidthToolStripMenuItem.Click += new System.EventHandler(this.borderWidthToolStripMenuItem_Click); + // + // borderRadiusToolStripMenuItem + // + this.borderRadiusToolStripMenuItem.Name = "borderRadiusToolStripMenuItem"; + this.borderRadiusToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.borderRadiusToolStripMenuItem.Text = "Border Radius"; + this.borderRadiusToolStripMenuItem.Click += new System.EventHandler(this.borderRadiusToolStripMenuItem_Click); + // + // borderOpacityToolStripMenuItem + // + this.borderOpacityToolStripMenuItem.Name = "borderOpacityToolStripMenuItem"; + this.borderOpacityToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.borderOpacityToolStripMenuItem.Text = "Border Opacity"; + this.borderOpacityToolStripMenuItem.Click += new System.EventHandler(this.borderOpacityToolStripMenuItem_Click); + // + // activeBorederColorToolStripMenuItem + // + this.activeBorederColorToolStripMenuItem.Name = "activeBorederColorToolStripMenuItem"; + this.activeBorederColorToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.activeBorederColorToolStripMenuItem.Text = "Active Boreder Color"; + this.activeBorederColorToolStripMenuItem.Click += new System.EventHandler(this.activeBorederColorToolStripMenuItem_Click); + // + // inactiveBorederColorToolStripMenuItem + // + this.inactiveBorederColorToolStripMenuItem.Name = "inactiveBorederColorToolStripMenuItem"; + this.inactiveBorederColorToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.inactiveBorederColorToolStripMenuItem.Text = "Inactive Boreder Color"; + this.inactiveBorederColorToolStripMenuItem.Click += new System.EventHandler(this.inactiveBorederColorToolStripMenuItem_Click); + // + // captionHeightToolStripMenuItem + // + this.captionHeightToolStripMenuItem.Name = "captionHeightToolStripMenuItem"; + this.captionHeightToolStripMenuItem.Size = new System.Drawing.Size(191, 22); + this.captionHeightToolStripMenuItem.Text = "Caption Height"; + this.captionHeightToolStripMenuItem.Click += new System.EventHandler(this.captionHeightToolStripMenuItem_Click); + // + // desktopBackgroundToolStripMenuItem + // + this.desktopBackgroundToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.imageLayoutTileToolStripMenuItem, + this.imageLayoutCenterToolStripMenuItem, + this.imageLayoutStretchToolStripMenuItem, + this.imageLayoutZoomToolStripMenuItem, + this.removeBackgroundToolStripMenuItem}); + this.desktopBackgroundToolStripMenuItem.Name = "desktopBackgroundToolStripMenuItem"; + this.desktopBackgroundToolStripMenuItem.Size = new System.Drawing.Size(129, 20); + this.desktopBackgroundToolStripMenuItem.Text = "Desktop Background"; + // + // imageLayoutTileToolStripMenuItem + // + this.imageLayoutTileToolStripMenuItem.Name = "imageLayoutTileToolStripMenuItem"; + this.imageLayoutTileToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.imageLayoutTileToolStripMenuItem.Text = "Image Layout Tile"; + this.imageLayoutTileToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutTileToolStripMenuItem_Click); + // + // imageLayoutCenterToolStripMenuItem + // + this.imageLayoutCenterToolStripMenuItem.Name = "imageLayoutCenterToolStripMenuItem"; + this.imageLayoutCenterToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.imageLayoutCenterToolStripMenuItem.Text = "Image Layout Center"; + this.imageLayoutCenterToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutCenterToolStripMenuItem_Click); + // + // imageLayoutStretchToolStripMenuItem + // + this.imageLayoutStretchToolStripMenuItem.Name = "imageLayoutStretchToolStripMenuItem"; + this.imageLayoutStretchToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.imageLayoutStretchToolStripMenuItem.Text = "Image Layout Stretch"; + this.imageLayoutStretchToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutStretchToolStripMenuItem_Click); + // + // imageLayoutZoomToolStripMenuItem + // + this.imageLayoutZoomToolStripMenuItem.Name = "imageLayoutZoomToolStripMenuItem"; + this.imageLayoutZoomToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.imageLayoutZoomToolStripMenuItem.Text = "Image Layout Zoom"; + this.imageLayoutZoomToolStripMenuItem.Click += new System.EventHandler(this.imageLayoutZoomToolStripMenuItem_Click); + // + // removeBackgroundToolStripMenuItem + // + this.removeBackgroundToolStripMenuItem.Name = "removeBackgroundToolStripMenuItem"; + this.removeBackgroundToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.removeBackgroundToolStripMenuItem.Text = "Remove Background"; + this.removeBackgroundToolStripMenuItem.Click += new System.EventHandler(this.removeBackgroundToolStripMenuItem_Click); + // + // formsToolStripMenuItem + // + this.formsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.newFormToolStripMenuItem, + this.newChildFormToolStripMenuItem, + this.layoutMdiCascadeToolStripMenuItem, + this.layoutMdiVerticalToolStripMenuItem, + this.layoutMdiHorizontalToolStripMenuItem}); + this.formsToolStripMenuItem.Name = "formsToolStripMenuItem"; + this.formsToolStripMenuItem.Size = new System.Drawing.Size(52, 20); + this.formsToolStripMenuItem.Text = "Forms"; + // + // newFormToolStripMenuItem + // + this.newFormToolStripMenuItem.Name = "newFormToolStripMenuItem"; + this.newFormToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.newFormToolStripMenuItem.Text = "New Form"; + this.newFormToolStripMenuItem.Click += new System.EventHandler(this.newFormToolStripMenuItem_Click); + // + // newChildFormToolStripMenuItem + // + this.newChildFormToolStripMenuItem.Name = "newChildFormToolStripMenuItem"; + this.newChildFormToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.newChildFormToolStripMenuItem.Text = "New Child Form"; + this.newChildFormToolStripMenuItem.Click += new System.EventHandler(this.newChildFormToolStripMenuItem_Click); + // + // layoutMdiCascadeToolStripMenuItem + // + this.layoutMdiCascadeToolStripMenuItem.Name = "layoutMdiCascadeToolStripMenuItem"; + this.layoutMdiCascadeToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.layoutMdiCascadeToolStripMenuItem.Text = "Layout Mdi Cascade"; + this.layoutMdiCascadeToolStripMenuItem.Click += new System.EventHandler(this.CascadeToolStripMenuItem_Click); + // + // layoutMdiVerticalToolStripMenuItem + // + this.layoutMdiVerticalToolStripMenuItem.Name = "layoutMdiVerticalToolStripMenuItem"; + this.layoutMdiVerticalToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.layoutMdiVerticalToolStripMenuItem.Text = "Layout Mdi Vertical"; + this.layoutMdiVerticalToolStripMenuItem.Click += new System.EventHandler(this.TileVerticalToolStripMenuItem_Click); + // + // layoutMdiHorizontalToolStripMenuItem + // + this.layoutMdiHorizontalToolStripMenuItem.Name = "layoutMdiHorizontalToolStripMenuItem"; + this.layoutMdiHorizontalToolStripMenuItem.Size = new System.Drawing.Size(192, 22); + this.layoutMdiHorizontalToolStripMenuItem.Text = "Layout Mdi Horizontal"; + this.layoutMdiHorizontalToolStripMenuItem.Click += new System.EventHandler(this.TileHorizontalToolStripMenuItem_Click); + // + // directionToolStripMenuItem + // + this.directionToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.leftToRightToolStripMenuItem, + this.rightToLeftToolStripMenuItem}); + this.directionToolStripMenuItem.Name = "directionToolStripMenuItem"; + this.directionToolStripMenuItem.Size = new System.Drawing.Size(67, 20); + this.directionToolStripMenuItem.Text = "Direction"; + // + // leftToRightToolStripMenuItem + // + this.leftToRightToolStripMenuItem.Name = "leftToRightToolStripMenuItem"; + this.leftToRightToolStripMenuItem.Size = new System.Drawing.Size(139, 22); + this.leftToRightToolStripMenuItem.Text = "Left to Right"; + this.leftToRightToolStripMenuItem.Click += new System.EventHandler(this.leftToRightToolStripMenuItem_Click); + // + // rightToLeftToolStripMenuItem + // + this.rightToLeftToolStripMenuItem.Name = "rightToLeftToolStripMenuItem"; + this.rightToLeftToolStripMenuItem.Size = new System.Drawing.Size(139, 22); + this.rightToLeftToolStripMenuItem.Text = "Right to Left"; + this.rightToLeftToolStripMenuItem.Click += new System.EventHandler(this.rightToLeftToolStripMenuItem_Click); + // + // MDIParent1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1008, 729); + this.Controls.Add(this.statusStrip); + this.Controls.Add(this.menuStrip1); + this.IsMdiContainer = true; + this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "MDIParent1"; + this.Text = "MDIParent1"; + this.statusStrip.ResumeLayout(false); + this.statusStrip.PerformLayout(); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + #endregion + + private System.Windows.Forms.StatusStrip statusStrip; + private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel; + private System.Windows.Forms.ToolTip toolTip; + private MenuStrip menuStrip1; + private ToolStripMenuItem borderToolStripMenuItem; + private ToolStripMenuItem borderWidthToolStripMenuItem; + private ToolStripMenuItem borderRadiusToolStripMenuItem; + private ToolStripMenuItem borderOpacityToolStripMenuItem; + private ToolStripMenuItem desktopBackgroundToolStripMenuItem; + private ToolStripMenuItem formsToolStripMenuItem; + private ToolStripMenuItem directionToolStripMenuItem; + private ToolStripMenuItem activeBorederColorToolStripMenuItem; + private ToolStripMenuItem inactiveBorederColorToolStripMenuItem; + private ToolStripMenuItem captionHeightToolStripMenuItem; + private ToolStripMenuItem imageLayoutTileToolStripMenuItem; + private ToolStripMenuItem imageLayoutCenterToolStripMenuItem; + private ToolStripMenuItem imageLayoutStretchToolStripMenuItem; + private ToolStripMenuItem imageLayoutZoomToolStripMenuItem; + private ToolStripMenuItem removeBackgroundToolStripMenuItem; + private ToolStripMenuItem newFormToolStripMenuItem; + private ToolStripMenuItem newChildFormToolStripMenuItem; + private ToolStripMenuItem layoutMdiCascadeToolStripMenuItem; + private ToolStripMenuItem layoutMdiVerticalToolStripMenuItem; + private ToolStripMenuItem layoutMdiHorizontalToolStripMenuItem; + private ToolStripMenuItem leftToRightToolStripMenuItem; + private ToolStripMenuItem rightToLeftToolStripMenuItem; + } +} + + + diff --git a/TestApp1/MDIParent1.cs b/TestApp1/MDIParent1.cs new file mode 100644 index 0000000..bd91b1e --- /dev/null +++ b/TestApp1/MDIParent1.cs @@ -0,0 +1,382 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Globalization; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using SkinFramWorkCore; +using TestApp1.Properties; + +namespace TestApp1 +{ + public partial class MDIParent1 : SkinForm + { + private int childFormNumber = 0; + private TextBox txtBorders; + private Button submitButton; + private Button btnToggleMenuStrip; + private Label labelBorders; + private SkinForm frmsubmit; + private SkinForm frmChild; + + public MDIParent1() + { + InitializeComponent(); + RightToLeft = Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; + RightToLeftLayout = Thread.CurrentThread.CurrentUICulture.TextInfo.IsRightToLeft; + frmsubmit = new SkinForm { RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "Window", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterParent, AllowNcTransparency = AllowNcTransparency, Size = new Size(240, 200) }; + txtBorders = new TextBox(); + txtBorders.Location = new Point(50, 60); + txtBorders.Size = new Size(120, 23); + frmsubmit.Controls.Add(txtBorders); + submitButton = new Button(); + submitButton.Location = new Point(50, 110); + submitButton.Size = new Size(120, 30); + submitButton.Text = "Submit"; + submitButton.UseVisualStyleBackColor = true; + submitButton.Click += SubmitButton_Click; + frmsubmit.Controls.Add(submitButton); + labelBorders = new Label(); + labelBorders.AutoSize = true; + labelBorders.Location = new Point(35, 25); + labelBorders.Size = new Size(155, 15); + frmsubmit.Controls.Add(labelBorders); + frmChild = new SkinForm { MdiParent = this, RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "frmChild", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterScreen, AllowNcTransparency = AllowNcTransparency }; + + btnToggleMenuStrip = new Button { Text = "Toggle MenuStrip", Size = new Size(160, 30) }; + btnToggleMenuStrip.Click += BtnToggleMenuStrip_Click; + frmChild.Controls.Add(btnToggleMenuStrip); + Load += MDIParent1_Load; + } + + [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "")] + public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni); + + [DllImport("user32.dll", SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1401:P/Invokes should not be visible", Justification = "")] + public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); + + [Flags] + internal enum SWPFlags + { + + SWP_NOSIZE = 0x0001, + SWP_NOMOVE = 0x0002, + SWP_NOZORDER = 0x0004, + SWP_NOREDRAW = 0x0008, + SWP_NOACTIVATE = 0x0010, + SWP_FRAMECHANGED = 0x0020, + } + + private void MDIParent1_Load(object? sender, EventArgs e) + { + frmChild.Show(); + if (GetDeskTopWallpaper != null) + { + BackgroundImage = GetDeskTopWallpaper(); + BackgroundImageLayout = ImageLayout.Stretch; + } + } + private void InvalidateForm(Form form) + { + if (!form.IsDisposed && form.IsHandleCreated) + { + SetWindowPos(form.Handle, IntPtr.Zero, 0, 0, 0, 0, + (int)(SWPFlags.SWP_NOACTIVATE | SWPFlags.SWP_NOMOVE | SWPFlags.SWP_NOSIZE | + SWPFlags.SWP_NOZORDER | SWPFlags.SWP_FRAMECHANGED)); + } + } + + private void BtnToggleMenuStrip_Click(object? sender, EventArgs e) + { + if (MainMenuStrip is null) + { + MainMenuStrip = menuStrip1; + Controls.Add(menuStrip1); + } + + else + { + Controls.Remove(menuStrip1); + MainMenuStrip = null; + } + } + + + private Image? GetDeskTopWallpaper() + { + int SPI_GETDESKWALLPAPER = 0x73; + int MAX_PATH = 260; + string wallpaper = new string('\0', (int)MAX_PATH); + SystemParametersInfo(SPI_GETDESKWALLPAPER, MAX_PATH, wallpaper, 0); + + wallpaper = wallpaper.Substring(0, wallpaper.IndexOf('\0')); + return !string.IsNullOrEmpty(wallpaper) ? new Bitmap(Image.FromFile(wallpaper)) : null; + } + + + private void CascadeToolStripMenuItem_Click(object sender, EventArgs e) + { + LayoutMdi(MdiLayout.Cascade); + } + + private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e) + { + LayoutMdi(MdiLayout.TileVertical); + } + + private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e) + { + LayoutMdi(MdiLayout.TileHorizontal); + } + + private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e) + { + LayoutMdi(MdiLayout.ArrangeIcons); + } + + + + + private void rightToLeftToolStripMenuItem_Click(object sender, EventArgs e) + { + + Settings settings = Settings.Default; + if (settings.Culture == "ar-EG") return; + settings.Culture = "ar-EG"; + settings.Save(); + Application.Restart(); + } + + private void leftToRightToolStripMenuItem_Click(object sender, EventArgs e) + { + Settings settings = Settings.Default; + if (settings.Culture == "en-US") return; + settings.Culture = "en-US"; + settings.Save(); + Application.Restart(); + } + + + private void borderWidthToolStripMenuItem_Click(object sender, EventArgs e) + { + labelBorders.Text = "Insert Border Width"; + frmsubmit.ShowDialog(this); + } + + private void newFormToolStripMenuItem_Click(object sender, EventArgs e) + { + SkinForm form = new SkinForm { RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "Form1", BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, StartPosition = FormStartPosition.CenterParent, AllowNcTransparency = AllowNcTransparency, Size = new Size(1024, 768), BackgroundImage = BackgroundImage, BackgroundImageLayout = BackgroundImageLayout , ActiveCaptionColor = ActiveCaptionColor, InActiveCaptionColor = InActiveCaptionColor }; + WindowState = FormWindowState.Minimized; + form.Closing += delegate { WindowState = FormWindowState.Maximized; }; + form.Show(); + } + + private void newChildFormToolStripMenuItem_Click(object sender, EventArgs e) + { + SkinForm frmChild = new SkinForm { MdiParent = this, RightToLeft = RightToLeft, RightToLeftLayout = RightToLeftLayout, Text = "frmChild " + childFormNumber++, BorderWidth = BorderWidth, CaptionHieght = CaptionHieght, BorderRadius = BorderRadius, NcOpacity = NcOpacity, BackgroundImage = BackgroundImage, BackgroundImageLayout = BackgroundImageLayout, AllowNcTransparency = AllowNcTransparency,ActiveCaptionColor = ActiveCaptionColor,InActiveCaptionColor = InActiveCaptionColor }; + frmChild.Show(); + } + + private void imageLayoutTileToolStripMenuItem_Click(object sender, EventArgs e) + { + if (GetDeskTopWallpaper != null) + { + BackgroundImage = GetDeskTopWallpaper(); + BackgroundImageLayout = ImageLayout.Tile; + } + + + } + + private void imageLayoutCenterToolStripMenuItem_Click(object sender, EventArgs e) + { + if (GetDeskTopWallpaper != null) + { + BackgroundImage = GetDeskTopWallpaper(); + BackgroundImageLayout = ImageLayout.Center; + } + + + } + + private void imageLayoutStretchToolStripMenuItem_Click(object sender, EventArgs e) + { + if (GetDeskTopWallpaper != null) + { + BackgroundImage = GetDeskTopWallpaper(); + BackgroundImageLayout = ImageLayout.Stretch; + } + } + + private void imageLayoutZoomToolStripMenuItem_Click(object sender, EventArgs e) + { + if (GetDeskTopWallpaper != null) + { + BackgroundImage = GetDeskTopWallpaper(); + BackgroundImageLayout = ImageLayout.Zoom; + } + } + + private void removeBackgroundToolStripMenuItem_Click(object sender, EventArgs e) + { + BackgroundImage = null; + } + + private void borderRadiusToolStripMenuItem_Click(object sender, EventArgs e) + { + labelBorders.Text = "Insert Border Radius"; + frmsubmit.ShowDialog(this); + } + + private void borderOpacityToolStripMenuItem_Click(object sender, EventArgs e) + { + labelBorders.Text = "Insert Border Opacity"; + frmsubmit.ShowDialog(this); + } + private void captionHeightToolStripMenuItem_Click(object sender, EventArgs e) + { + labelBorders.Text = "Insert Caption Height"; + frmsubmit.ShowDialog(this); + } + private void SubmitButton_Click(object? sender, EventArgs e) + { + switch (labelBorders.Text) + { + case "Insert Border Width": + { + if (txtBorders.Text.Length > 0) + { + int borderWidth; + bool isnumber = int.TryParse(txtBorders.Text, out borderWidth); + if (isnumber && borderWidth > 0) + { + BorderWidth = frmChild.BorderWidth = frmsubmit.BorderWidth = borderWidth; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + ((SkinForm)child).BorderWidth = borderWidth; + InvalidateForm(child); + }); + } + } + } + + break; + + case "Insert Border Radius": + { + if (txtBorders.Text.Length > 0) + { + int borderRadius; + bool isnumber = int.TryParse(txtBorders.Text, out borderRadius); + if (isnumber && borderRadius > 0) + { + BorderRadius = frmChild.BorderRadius = frmsubmit.BorderRadius = borderRadius; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + ((SkinForm)child).BorderRadius = borderRadius; + InvalidateForm(child); + }); + } + } + } + + break; + case "Insert Border Opacity": + { + if (txtBorders.Text.Length > 0) + { + int ncOpacity; + bool isnumber = int.TryParse(txtBorders.Text, out ncOpacity); + if (isnumber && ncOpacity > 0) + { + NcOpacity = frmChild.NcOpacity = frmsubmit.NcOpacity = ncOpacity; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + ((SkinForm)child).NcOpacity = ncOpacity; + InvalidateForm(child); + }); + } + } + } + + break; + + case "Insert Caption Height": + { + if (txtBorders.Text.Length > 0) + { + int captionHieght; + bool isnumber = int.TryParse(txtBorders.Text, out captionHieght); + if (isnumber && captionHieght > 0) + { + CaptionHieght = frmChild.CaptionHieght = frmsubmit.CaptionHieght = captionHieght; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + ((SkinForm)child).CaptionHieght = captionHieght; + InvalidateForm(child); + }); + } + } + } + + break; + } + + frmsubmit.Close(); + } + + private void activeBorederColorToolStripMenuItem_Click(object sender, EventArgs e) + { + ColorDialog colorDialog = new ColorDialog(); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + ActiveCaptionColor = frmChild.ActiveCaptionColor = frmsubmit.ActiveCaptionColor = colorDialog.Color; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + + InvalidateForm(child); + }); + } + } + + private void inactiveBorederColorToolStripMenuItem_Click(object sender, EventArgs e) + { + ColorDialog colorDialog = new ColorDialog(); + if (colorDialog.ShowDialog() == DialogResult.OK) + { + InActiveCaptionColor = frmChild.InActiveCaptionColor = frmsubmit.InActiveCaptionColor = colorDialog.Color; + InvalidateForm(this); + InvalidateForm(frmChild); + InvalidateForm(frmsubmit); + MdiChildren.ToList().ForEach(child => + { + + InvalidateForm(child); + }); + } + } + } +} diff --git a/TestApp/Form1.resx b/TestApp1/MDIParent1.resx similarity index 74% rename from TestApp/Form1.resx rename to TestApp1/MDIParent1.resx index f298a7b..a3b3fc5 100644 --- a/TestApp/Form1.resx +++ b/TestApp1/MDIParent1.resx @@ -52,9 +52,21 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 223, 17 + + + 332, 17 + + + 422, 17 + + + 51 + \ No newline at end of file diff --git a/TestApp1/Program.cs b/TestApp1/Program.cs new file mode 100644 index 0000000..663ab9a --- /dev/null +++ b/TestApp1/Program.cs @@ -0,0 +1,22 @@ +using System.Globalization; + +namespace TestApp1 +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Properties.Settings settings = Properties.Settings.Default; + Thread.CurrentThread.CurrentCulture = new CultureInfo( settings.Culture); + Thread.CurrentThread.CurrentUICulture = new CultureInfo( settings.Culture); + Application.Run(new MDIParent1()); + } + } +} \ No newline at end of file diff --git a/TestApp/Properties/Resources.Designer.cs b/TestApp1/Properties/Resources.Designer.cs similarity index 93% rename from TestApp/Properties/Resources.Designer.cs rename to TestApp1/Properties/Resources.Designer.cs index 415f3ef..d3ea418 100644 --- a/TestApp/Properties/Resources.Designer.cs +++ b/TestApp1/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace TestApp.Properties { +namespace TestApp1.Properties { using System; @@ -19,7 +19,7 @@ namespace TestApp.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestApp.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TestApp1.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/TestApp/Properties/Resources.resx b/TestApp1/Properties/Resources.resx similarity index 100% rename from TestApp/Properties/Resources.resx rename to TestApp1/Properties/Resources.resx diff --git a/TestApp1/Properties/Settings.Designer.cs b/TestApp1/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d18bd7a --- /dev/null +++ b/TestApp1/Properties/Settings.Designer.cs @@ -0,0 +1,38 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace TestApp1.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("en-US")] + public string Culture { + get { + return ((string)(this["Culture"])); + } + set { + this["Culture"] = value; + } + } + } +} diff --git a/TestApp1/Properties/Settings.settings b/TestApp1/Properties/Settings.settings new file mode 100644 index 0000000..e39e9bc --- /dev/null +++ b/TestApp1/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + en-US + + + \ No newline at end of file diff --git a/TestApp/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg b/TestApp1/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg similarity index 100% rename from TestApp/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg rename to TestApp1/Resources/4475e73c885921925f61fcf123c7c8c1f93e1c0c.jpg diff --git a/TestApp/TestApp.csproj b/TestApp1/TestApp1.csproj similarity index 53% rename from TestApp/TestApp.csproj rename to TestApp1/TestApp1.csproj index 676f5c1..3a17262 100644 --- a/TestApp/TestApp.csproj +++ b/TestApp1/TestApp1.csproj @@ -1,9 +1,11 @@ - + WinExe - netcoreapp3.1 + net6.0-windows + enable true + enable @@ -16,6 +18,11 @@ True Resources.resx + + True + True + Settings.settings + @@ -25,4 +32,11 @@ + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + \ No newline at end of file