diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 150c58a4..00000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,32 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Environment (please complete the following information):**
- - .net: [e.g. 4.6.2]
- - IDE [e.g. vs2017]
- - Version [e.g. 1.0.0]
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml
new file mode 100644
index 00000000..f03073b1
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yaml
@@ -0,0 +1,96 @@
+name: Bug report
+description: File a bug report
+title: "Bug title"
+labels: []
+body:
+ - type: textarea
+ validations:
+ required: true
+ attributes:
+ label: Describe the bug
+ description: Please enter a short, clear description of the bug.
+ - type: textarea
+ validations:
+ required: true
+ attributes:
+ label: Steps to reproduce the bug
+ description: Please provide any required setup and steps to reproduce the behavior.
+ placeholder: |
+ 1. Go to '...'
+ 2. Click on '....'
+ - type: textarea
+ attributes:
+ label: Expected behavior
+ description: Please provide a description of what you expected to happen
+ - type: textarea
+ attributes:
+ label: Screenshots
+ description: If applicable, add screenshots here to help explain your problem
+ - type: dropdown
+ attributes:
+ label: NuGet package version
+ options:
+ - "HandyControl 3.4.0"
+ - "HandyControl 3.3.0"
+ - "HandyControl 3.2.0"
+ - "HandyControl 3.1.0"
+ - "HandyControl 3.0.0"
+ - "HandyControls (Custom version) 3.4.0"
+ - "HandyControls (Custom version) 3.3.11"
+ - "HandyControls (Custom version) 3.3.10"
+ - "HandyControls (Custom version) 3.3.9"
+ - "HandyControls (Custom version) 3.3.8.1"
+ - "HandyControls (Custom version) 3.3.8"
+ - "HandyControls (Custom version) 3.3.7"
+ - type: dropdown
+ attributes:
+ label: IDE
+ description: Which Visual Studio versions did you see the issue on?
+ multiple: true
+ options:
+ - "Visual Studio 2022-preview"
+ - "Visual Studio 2022"
+ - "Visual Studio 2019"
+ - "Visual Studio 2017"
+ - type: dropdown
+ attributes:
+ label: Framework type
+ description: please specify for which framework type you have encountered the issue.
+ multiple: true
+ options:
+ - ".Net 6.0"
+ - ".Net 5.0"
+ - ".Net Core 3.1"
+ - ".Net Core 3.0"
+ - ".Net Framework 4.8"
+ - ".Net Framework 4.7.2"
+ - ".Net Framework 4.7.1"
+ - ".Net Framework 4.7.0"
+ - ".Net Framework 4.6.2"
+ - ".Net Framework 4.6.1"
+ - ".Net Framework 4.6.0"
+ - ".Net Framework 4.5.2"
+ - ".Net Framework 4.5.1"
+ - ".Net Framework 4.5.0"
+ - ".Net Framework 4.0.0"
+ - type: dropdown
+ attributes:
+ label: Windows version
+ description: Which Windows versions did you see the issue on?
+ multiple: true
+ options:
+ - "Insider Build (xxxxx)"
+ - "Windows 11 (22000)"
+ - "May 2021 Update (19043)"
+ - "October 2020 Update (19042)"
+ - "May 2020 Update (19041)"
+ - "November 2019 Update (18363)"
+ - "May 2019 Update (18362)"
+ - "October 2018 Update (17763)"
+ - "April 2018 Update (17134)"
+ - "Fall Creators Update (16299)"
+ - "Creators Update (15063)"
+ - type: textarea
+ attributes:
+ label: Additional context
+ description: Enter any other applicable info here
diff --git a/README-cn.md b/README-cn.md
index c3371000..0e901601 100644
--- a/README-cn.md
+++ b/README-cn.md
@@ -143,7 +143,7 @@ HandyControl 项目已加入 [dotNET China](https://gitee.com/dotnetchina) 组
-
+
如果你的项目没有被列出,请告知我们! 😀
diff --git a/README.md b/README.md
index 7f102047..4226d573 100644
--- a/README.md
+++ b/README.md
@@ -137,7 +137,7 @@
-
+
if your project is not listed here, let us know! 😀
diff --git a/build/build.Lang.es.nuspec b/build/build.Lang.es.nuspec
new file mode 100644
index 00000000..5c1bd8c8
--- /dev/null
+++ b/build/build.Lang.es.nuspec
@@ -0,0 +1,55 @@
+
+
+
+ HandyControl.Lang.es
+ 3.3.0
+ HandyOrg
+ HandyOrg
+ HandyOrg
+ true
+ LICENSE
+ icon.png
+ https://github.com/HandyOrg/HandyControl
+ Contains some simple and commonly used WPF controls
+ Changes are detailed at https://github.com/HandyOrg/HandyControl/releases
+ Copyright © HandyOrg 2018-2021
+ WPF C# Control
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/HandyControl.sln b/src/HandyControl.sln
index 1459e713..bdeea6fc 100644
--- a/src/HandyControl.sln
+++ b/src/HandyControl.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.28729.10
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HandyControl_Net_GE45", "Net_GE45\HandyControl_Net_GE45\HandyControl_Net_GE45.csproj", "{DC966E3D-BCFF-4652-98CF-070E5494749A}"
EndProject
@@ -30,16 +30,31 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.Props = Directory.Build.Props
EndProjectSection
EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.Expression.Drawing", "Shared\Microsoft.Expression.Drawing\Microsoft.Expression.Drawing.shproj", "{E5DC7C25-6293-4660-B5FB-186496386B90}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "System.Windows.Interactivity", "Shared\System.Windows.Interactivity\System.Windows.Interactivity.shproj", "{6F0C9CFF-2269-46A7-9664-478354C582A4}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.Expression.Interactions", "Shared\Microsoft.Expression.Interactions\Microsoft.Expression.Interactions.shproj", "{3531857C-28FC-4E0F-82D9-BFBB70740E04}"
+EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Drawing\Microsoft.Expression.Drawing.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Interactions\Microsoft.Expression.Interactions.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
+ Shared\System.Windows.Interactivity\System.Windows.Interactivity.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Interactions\Microsoft.Expression.Interactions.projitems*{3531857c-28fc-4e0f-82d9-bfbb70740e04}*SharedItemsImports = 13
+ Shared\System.Windows.Interactivity\System.Windows.Interactivity.projitems*{6f0c9cff-2269-46a7-9664-478354c582a4}*SharedItemsImports = 13
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{9a7b52e6-94bb-4e7e-bb6a-7cf6761b79a7}*SharedItemsImports = 5
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{aac11083-faca-405d-9197-5c1212d65656}*SharedItemsImports = 13
Shared\Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{bbe51380-8b21-49ff-9cfc-b29447a40999}*SharedItemsImports = 13
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{c4694269-c9b8-45d5-87f8-d0088c532510}*SharedItemsImports = 13
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d8ae88f8-c36b-4d10-a7f9-22ffcfba5231}*SharedItemsImports = 5
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Drawing\Microsoft.Expression.Drawing.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Interactions\Microsoft.Expression.Interactions.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 5
+ Shared\System.Windows.Interactivity\System.Windows.Interactivity.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 5
+ Shared\Microsoft.Expression.Drawing\Microsoft.Expression.Drawing.projitems*{e5dc7c25-6293-4660-b5fb-186496386b90}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -93,6 +108,9 @@ Global
{D8AE88F8-C36B-4D10-A7F9-22FFCFBA5231} = {35E3F9C0-8924-4536-BE09-F3761FDBF066}
{D8A4748C-0500-4F63-BC47-3506658C68F7} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
{BBE51380-8B21-49FF-9CFC-B29447A40999} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
+ {E5DC7C25-6293-4660-B5FB-186496386B90} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
+ {6F0C9CFF-2269-46A7-9664-478354C582A4} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
+ {3531857C-28FC-4E0F-82D9-BFBB70740E04} = {0938270D-E9F0-489B-AF9E-5C5AD7C69897}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D4636382-1A18-4079-A3E7-054DD970F179}
diff --git a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj
index 8e3cccc3..21f318b8 100644
--- a/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj
+++ b/src/Net_40/HandyControl_Net_40/HandyControl_Net_40.csproj
@@ -83,6 +83,9 @@
+
+
+
Resources\dropper.cur
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
index 101d1183..34cd38b2 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Styles/Base/TreeViewBaseStyle.xaml
@@ -99,10 +99,10 @@
-
+
-
+
diff --git a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
index 43d0dd10..e6e99ae8 100644
--- a/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
+++ b/src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
@@ -462,6 +462,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1168,6 +1175,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
@@ -6646,109 +6831,81 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
@@ -6764,8 +6921,26 @@
+
+
+
@@ -7802,7 +7979,7 @@
-
+
@@ -7834,9 +8011,7 @@
-
-
-
+
@@ -7869,6 +8044,7 @@
+
@@ -7881,7 +8057,7 @@
-
+
@@ -7931,7 +8107,7 @@
-
+
@@ -7969,7 +8145,7 @@
-
+
@@ -7979,7 +8155,7 @@
-
+
@@ -8050,8 +8226,8 @@
-
-
+
+
@@ -8113,7 +8289,7 @@
-
+
@@ -8125,8 +8301,8 @@
-
-
+
+
@@ -8189,6 +8365,7 @@
+
@@ -8203,9 +8380,9 @@
-
+
-
+
@@ -8253,9 +8430,9 @@
-
+
-
+
@@ -8293,7 +8470,7 @@
-
+
@@ -8301,9 +8478,9 @@
-
+
-
+
@@ -8374,8 +8551,8 @@
-
-
+
+
@@ -8437,7 +8614,7 @@
-
+
@@ -8449,8 +8626,8 @@
-
-
+
+
@@ -9158,11 +9335,11 @@
-
+
-
-
+
+
@@ -9330,54 +9507,41 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -10948,6 +11078,7 @@
+
@@ -10962,9 +11093,9 @@
-
+
-
+
@@ -11012,9 +11143,9 @@
-
+
-
+
@@ -11052,7 +11183,7 @@
-
+
@@ -11060,9 +11191,9 @@
-
+
-
+
@@ -11133,8 +11264,8 @@
-
-
+
+
@@ -11196,7 +11327,7 @@
-
+
@@ -11208,8 +11339,8 @@
-
-
+
+
@@ -11675,10 +11806,10 @@
-
+
-
+
@@ -12112,7 +12243,6 @@
-
+
+
+
Resources\dropper.cur
diff --git a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
index 237b3fcf..ba9826f5 100644
--- a/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
+++ b/src/Shared/HandyControlDemo_Code/HandyControlDemo_Code.csproj
@@ -854,8 +854,8 @@
ViewModel\InteractiveDialogViewModel.cs
-
- ViewModel\ComboBoxDemoViewModel.cs
+
+ ViewModel\InputElementDemoViewModel.cs
ViewModel\AutoCompleteTextBoxDemoViewModel.cs
@@ -887,9 +887,6 @@
ViewModel\PaginationDemoViewModel.cs
-
- ViewModel\SearchBarDemoViewModel.cs
-
ViewModel\SideMenuDemoViewModel.cs
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
index 0dd38bb4..54db7684 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
@@ -15,124 +15,123 @@ using HandyControlDemo.Data;
using HandyControlDemo.Properties.Langs;
using HandyControlDemo.Tools;
-namespace HandyControlDemo
+namespace HandyControlDemo;
+
+public partial class App
{
- public partial class App
- {
#pragma warning disable IDE0052
- [SuppressMessage("ReSharper", "NotAccessedField.Local")]
- private static Mutex AppMutex;
+ [SuppressMessage("ReSharper", "NotAccessedField.Local")]
+ private static Mutex AppMutex;
#pragma warning restore IDE0052
- public App()
- {
+ public App()
+ {
#if !NET40
- var cachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache";
- if (!Directory.Exists(cachePath))
- {
- Directory.CreateDirectory(cachePath);
- }
- ProfileOptimization.SetProfileRoot(cachePath);
- ProfileOptimization.StartProfile("Profile");
-#endif
- }
-
- protected override void OnStartup(StartupEventArgs e)
+ var cachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache";
+ if (!Directory.Exists(cachePath))
{
- AppMutex = new Mutex(true, "HandyControlDemo", out var createdNew);
+ Directory.CreateDirectory(cachePath);
+ }
+ ProfileOptimization.SetProfileRoot(cachePath);
+ ProfileOptimization.StartProfile("Profile");
+#endif
+ }
- if (!createdNew)
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ AppMutex = new Mutex(true, "HandyControlDemo", out var createdNew);
+
+ if (!createdNew)
+ {
+ var current = Process.GetCurrentProcess();
+
+ foreach (var process in Process.GetProcessesByName(current.ProcessName))
{
- var current = Process.GetCurrentProcess();
-
- foreach (var process in Process.GetProcessesByName(current.ProcessName))
+ if (process.Id != current.Id)
{
- if (process.Id != current.Id)
- {
- Win32Helper.SetForegroundWindow(process.MainWindowHandle);
- break;
- }
+ Win32Helper.SetForegroundWindow(process.MainWindowHandle);
+ break;
}
- Shutdown();
}
- else
+ Shutdown();
+ }
+ else
+ {
+ var splashScreen = new SplashScreen("Resources/Img/Cover.png");
+ splashScreen.Show(true);
+
+ base.OnStartup(e);
+
+ UpdateRegistry();
+
+ ShutdownMode = ShutdownMode.OnMainWindowClose;
+ GlobalData.Init();
+ ConfigHelper.Instance.SetLang(GlobalData.Config.Lang);
+ LangProvider.Culture = new CultureInfo(GlobalData.Config.Lang);
+
+ if (GlobalData.Config.Skin != SkinType.Default)
{
- var splashScreen = new SplashScreen("Resources/Img/Cover.png");
- splashScreen.Show(true);
+ UpdateSkin(GlobalData.Config.Skin);
+ }
- base.OnStartup(e);
-
- UpdateRegistry();
-
- ShutdownMode = ShutdownMode.OnMainWindowClose;
- GlobalData.Init();
- ConfigHelper.Instance.SetLang(GlobalData.Config.Lang);
- LangProvider.Culture = new CultureInfo(GlobalData.Config.Lang);
-
- if (GlobalData.Config.Skin != SkinType.Default)
- {
- UpdateSkin(GlobalData.Config.Skin);
- }
-
- ConfigHelper.Instance.SetWindowDefaultStyle();
- ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
+ ConfigHelper.Instance.SetWindowDefaultStyle();
+ ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
#if NET40
- ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
+ ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
#else
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
#endif
- }
}
+ }
- protected override void OnExit(ExitEventArgs e)
+ protected override void OnExit(ExitEventArgs e)
+ {
+ base.OnExit(e);
+ GlobalData.Save();
+ }
+
+ internal void UpdateSkin(SkinType skin)
+ {
+ var skins0 = Resources.MergedDictionaries[0];
+ skins0.MergedDictionaries.Clear();
+ skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin));
+ skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin));
+
+ var skins1 = Resources.MergedDictionaries[1];
+ skins1.MergedDictionaries.Clear();
+ skins1.MergedDictionaries.Add(new ResourceDictionary
{
- base.OnExit(e);
- GlobalData.Save();
- }
-
- internal void UpdateSkin(SkinType skin)
+ Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
+ });
+ skins1.MergedDictionaries.Add(new ResourceDictionary
{
- var skins0 = Resources.MergedDictionaries[0];
- skins0.MergedDictionaries.Clear();
- skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin));
- skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin));
+ Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
+ });
- var skins1 = Resources.MergedDictionaries[1];
- skins1.MergedDictionaries.Clear();
- skins1.MergedDictionaries.Add(new ResourceDictionary
- {
- Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
- });
- skins1.MergedDictionaries.Add(new ResourceDictionary
- {
- Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
- });
+ Current.MainWindow?.OnApplyTemplate();
+ }
- Current.MainWindow?.OnApplyTemplate();
- }
-
- private void UpdateRegistry()
+ private void UpdateRegistry()
+ {
+ var processModule = Process.GetCurrentProcess().MainModule;
+ if (processModule != null)
{
- var processModule = Process.GetCurrentProcess().MainModule;
- if (processModule != null)
+ var registryFilePath = $"{Path.GetDirectoryName(processModule.FileName)}\\Registry.reg";
+ if (!File.Exists(registryFilePath))
{
- var registryFilePath = $"{Path.GetDirectoryName(processModule.FileName)}\\Registry.reg";
- if (!File.Exists(registryFilePath))
+ var streamResourceInfo = GetResourceStream(new Uri("pack://application:,,,/Resources/Registry.txt"));
+ if (streamResourceInfo != null)
{
- var streamResourceInfo = GetResourceStream(new Uri("pack://application:,,,/Resources/Registry.txt"));
- if (streamResourceInfo != null)
+ using var reader = new StreamReader(streamResourceInfo.Stream);
+ var registryStr = reader.ReadToEnd();
+ var newRegistryStr = registryStr.Replace("#", processModule.FileName.Replace("\\", "\\\\"));
+ File.WriteAllText(registryFilePath, newRegistryStr);
+ Process.Start(new ProcessStartInfo("cmd", $"/c {registryFilePath}")
{
- using var reader = new StreamReader(streamResourceInfo.Stream);
- var registryStr = reader.ReadToEnd();
- var newRegistryStr = registryStr.Replace("#", processModule.FileName.Replace("\\", "\\\\"));
- File.WriteAllText(registryFilePath, newRegistryStr);
- Process.Start(new ProcessStartInfo("cmd", $"/c {registryFilePath}")
- {
- UseShellExecute = false,
- CreateNoWindow = true
- });
- }
+ UseShellExecute = false,
+ CreateNoWindow = true
+ });
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/AppConfig.cs b/src/Shared/HandyControlDemo_Shared/Data/AppConfig.cs
index 5162608b..9f565c7d 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/AppConfig.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/AppConfig.cs
@@ -1,14 +1,13 @@
using System;
using HandyControl.Data;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+internal class AppConfig
{
- internal class AppConfig
- {
- public static readonly string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}AppConfig.json";
+ public static readonly string SavePath = $"{AppDomain.CurrentDomain.BaseDirectory}AppConfig.json";
- public string Lang { get; set; } = "zh-cn";
+ public string Lang { get; set; } = "zh-cn";
- public SkinType Skin { get; set; }
- }
+ public SkinType Skin { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Enum/DemoType.cs b/src/Shared/HandyControlDemo_Shared/Data/Enum/DemoType.cs
index 1bc162c7..22fe300b 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Enum/DemoType.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Enum/DemoType.cs
@@ -1,13 +1,12 @@
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public enum DemoType
{
- public enum DemoType
- {
- Type1 = 1,
- Type2,
- Type3,
- Type4,
- Type5,
- Type6
- }
+ Type1 = 1,
+ Type2,
+ Type3,
+ Type4,
+ Type5,
+ Type6
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/GlobalData.cs b/src/Shared/HandyControlDemo_Shared/Data/GlobalData.cs
index d4c8af00..dd0d4e91 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/GlobalData.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/GlobalData.cs
@@ -1,38 +1,37 @@
using System.IO;
using Newtonsoft.Json;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+internal class GlobalData
{
- internal class GlobalData
+ public static void Init()
{
- public static void Init()
+ if (File.Exists(AppConfig.SavePath))
{
- if (File.Exists(AppConfig.SavePath))
+ try
{
- try
- {
- var json = File.ReadAllText(AppConfig.SavePath);
- Config = (string.IsNullOrEmpty(json) ? new AppConfig() : JsonConvert.DeserializeObject(json)) ?? new AppConfig();
- }
- catch
- {
- Config = new AppConfig();
- }
+ var json = File.ReadAllText(AppConfig.SavePath);
+ Config = (string.IsNullOrEmpty(json) ? new AppConfig() : JsonConvert.DeserializeObject(json)) ?? new AppConfig();
}
- else
+ catch
{
Config = new AppConfig();
}
}
-
- public static void Save()
+ else
{
- var json = JsonConvert.SerializeObject(Config);
- File.WriteAllText(AppConfig.SavePath, json);
+ Config = new AppConfig();
}
-
- public static AppConfig Config { get; set; }
-
- public static bool NotifyIconIsShow { get; set; }
}
+
+ public static void Save()
+ {
+ var json = JsonConvert.SerializeObject(Config);
+ File.WriteAllText(AppConfig.SavePath, json);
+ }
+
+ public static AppConfig Config { get; set; }
+
+ public static bool NotifyIconIsShow { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
index 989304b7..6be766d0 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
@@ -1,58 +1,57 @@
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class MessageToken
{
- public class MessageToken
- {
- public static readonly string LoadShowContent = nameof(LoadShowContent);
+ public static readonly string LoadShowContent = nameof(LoadShowContent);
- public static readonly string FullSwitch = nameof(FullSwitch);
+ public static readonly string FullSwitch = nameof(FullSwitch);
- public static readonly string ContributorsView = nameof(ContributorsView);
+ public static readonly string ContributorsView = nameof(ContributorsView);
- public static readonly string ClearLeftSelected = nameof(ClearLeftSelected);
+ public static readonly string ClearLeftSelected = nameof(ClearLeftSelected);
- public static readonly string SendChatMessage = nameof(SendChatMessage);
+ public static readonly string SendChatMessage = nameof(SendChatMessage);
- public static readonly string GrowlDemoPanel = nameof(GrowlDemoPanel);
+ public static readonly string GrowlDemoPanel = nameof(GrowlDemoPanel);
- public static readonly string DialogDemoWindow = nameof(DialogDemoWindow);
+ public static readonly string DialogDemoWindow = nameof(DialogDemoWindow);
- public static readonly string MainWindow = nameof(MainWindow);
+ public static readonly string MainWindow = nameof(MainWindow);
- public static readonly string PracticalDemo = nameof(PracticalDemo);
+ public static readonly string PracticalDemo = nameof(PracticalDemo);
- public static readonly string ProjectsView = nameof(ProjectsView);
+ public static readonly string ProjectsView = nameof(ProjectsView);
- public static readonly string BlogsView = nameof(BlogsView);
+ public static readonly string BlogsView = nameof(BlogsView);
- public static readonly string WebsitesView = nameof(WebsitesView);
+ public static readonly string WebsitesView = nameof(WebsitesView);
- public static readonly string NotifyIconDemo = nameof(NotifyIconDemo);
+ public static readonly string NotifyIconDemo = nameof(NotifyIconDemo);
- public static readonly string NotifyIconContextDemo = nameof(NotifyIconContextDemo);
+ public static readonly string NotifyIconContextDemo = nameof(NotifyIconContextDemo);
- public static readonly string CommonWindow = nameof(CommonWindow);
+ public static readonly string CommonWindow = nameof(CommonWindow);
- public static readonly string BlurWindow = nameof(BlurWindow);
+ public static readonly string BlurWindow = nameof(BlurWindow);
- public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow);
+ public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow);
- public static readonly string NoNonClientAreaDragableWindow = nameof(NoNonClientAreaDragableWindow);
+ public static readonly string NoNonClientAreaDragableWindow = nameof(NoNonClientAreaDragableWindow);
- public static readonly string QQGroupView = nameof(QQGroupView);
+ public static readonly string QQGroupView = nameof(QQGroupView);
- public static readonly string GlowWindow = nameof(GlowWindow);
+ public static readonly string GlowWindow = nameof(GlowWindow);
- public static readonly string NativeCommonWindow = nameof(NativeCommonWindow);
+ public static readonly string NativeCommonWindow = nameof(NativeCommonWindow);
- public static readonly string NavigationWindow = nameof(NavigationWindow);
+ public static readonly string NavigationWindow = nameof(NavigationWindow);
- public static readonly string TouchDragMoveWindow = nameof(TouchDragMoveWindow);
+ public static readonly string TouchDragMoveWindow = nameof(TouchDragMoveWindow);
- public static readonly string DialogContainer = nameof(DialogContainer);
+ public static readonly string DialogContainer = nameof(DialogContainer);
- public static readonly string LangUpdated = nameof(LangUpdated);
+ public static readonly string LangUpdated = nameof(LangUpdated);
- public static readonly string SkinUpdated = nameof(SkinUpdated);
+ public static readonly string SkinUpdated = nameof(SkinUpdated);
- }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/AvatarModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/AvatarModel.cs
index 9168a52a..2b4db4eb 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/AvatarModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/AvatarModel.cs
@@ -1,12 +1,11 @@
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class AvatarModel
{
- public class AvatarModel
- {
- public string DisplayName { get; set; }
+ public string DisplayName { get; set; }
- public string Link { get; set; }
+ public string Link { get; set; }
- public string AvatarUri { get; set; }
- }
+ public string AvatarUri { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/CardModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/CardModel.cs
index e8867f26..0c9b7feb 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/CardModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/CardModel.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class CardModel
{
- public class CardModel
- {
- public string Header { get; set; }
+ public string Header { get; set; }
- public string Content { get; set; }
+ public string Content { get; set; }
- public string Footer { get; set; }
- }
+ public string Footer { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/ChatInfoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/ChatInfoModel.cs
index 6f77fefc..c066a908 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/ChatInfoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/ChatInfoModel.cs
@@ -1,17 +1,16 @@
using HandyControl.Data;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public struct ChatInfoModel
{
- public struct ChatInfoModel
- {
- public object Message { get; set; }
+ public object Message { get; set; }
- public string SenderId { get; set; }
+ public string SenderId { get; set; }
- public ChatRoleType Role { get; set; }
+ public ChatRoleType Role { get; set; }
- public ChatMessageType Type { get; set; }
+ public ChatMessageType Type { get; set; }
- public object Enclosure { get; set; }
- }
+ public object Enclosure { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/CoverViewDemoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/CoverViewDemoModel.cs
index 23d5b341..bda5145a 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/CoverViewDemoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/CoverViewDemoModel.cs
@@ -1,9 +1,8 @@
-namespace HandyControlDemo.Data
-{
- public class CoverViewDemoModel
- {
- public string ImgPath { get; set; }
+namespace HandyControlDemo.Data;
- public string BackgroundToken { get; set; }
- }
+public class CoverViewDemoModel
+{
+ public string ImgPath { get; set; }
+
+ public string BackgroundToken { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoDataModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoDataModel.cs
index 800a5f38..c6959889 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoDataModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoDataModel.cs
@@ -1,22 +1,21 @@
using System.Collections.Generic;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class DemoDataModel
{
- public class DemoDataModel
- {
- public int Index { get; set; }
+ public int Index { get; set; }
- public string Name { get; set; }
+ public string Name { get; set; }
- public bool IsSelected { get; set; }
+ public bool IsSelected { get; set; }
- public string Remark { get; set; }
+ public string Remark { get; set; }
- public DemoType Type { get; set; }
+ public DemoType Type { get; set; }
- public string ImgPath { get; set; }
+ public string ImgPath { get; set; }
- public List DataList { get; set; }
- }
+ public List DataList { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoInfoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoInfoModel.cs
index ad5dc2fd..0f1847db 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoInfoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoInfoModel.cs
@@ -1,38 +1,37 @@
using System.Collections.Generic;
using GalaSoft.MvvmLight;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class DemoInfoModel : ViewModelBase
{
- public class DemoInfoModel : ViewModelBase
+ public string Key { get; set; }
+
+ private string _title;
+
+ public string Title
{
- public string Key { get; set; }
-
- private string _title;
-
- public string Title
- {
- get => _title;
+ get => _title;
#if NET40
set => Set(nameof(Title), ref _title, value);
#else
- set => Set(ref _title, value);
+ set => Set(ref _title, value);
#endif
- }
+ }
- private int _selectedIndex;
+ private int _selectedIndex;
- public int SelectedIndex
- {
- get => _selectedIndex;
+ public int SelectedIndex
+ {
+ get => _selectedIndex;
#if NET40
set => Set(nameof(SelectedIndex), ref _selectedIndex, value);
#else
- set => Set(ref _selectedIndex, value);
+ set => Set(ref _selectedIndex, value);
#endif
- }
-
- public bool IsGroupEnabled { get; set; }
-
- public IList DemoItemList { get; set; }
}
+
+ public bool IsGroupEnabled { get; set; }
+
+ public IList DemoItemList { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoItemModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoItemModel.cs
index 3cbaab9c..a685b132 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/DemoItemModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/DemoItemModel.cs
@@ -1,40 +1,39 @@
using GalaSoft.MvvmLight;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class DemoItemModel : ObservableObject
{
- public class DemoItemModel : ObservableObject
+ private bool _isVisible = true;
+ private string _queriesText = string.Empty;
+
+ public string Name { get; set; }
+
+ public string GroupName { get; set; }
+
+ public string TargetCtlName { get; set; }
+
+ public string ImageName { get; set; }
+
+ public bool IsNew { get; set; }
+
+ public string QueriesText
{
- private bool _isVisible = true;
- private string _queriesText = string.Empty;
-
- public string Name { get; set; }
-
- public string GroupName { get; set; }
-
- public string TargetCtlName { get; set; }
-
- public string ImageName { get; set; }
-
- public bool IsNew { get; set; }
-
- public string QueriesText
- {
- get => _queriesText;
+ get => _queriesText;
#if NET40
- set => Set(nameof(QueriesText), ref _queriesText, value);
+ set => Set(nameof(QueriesText), ref _queriesText, value);
#else
- set => Set(ref _queriesText, value);
+ set => Set(ref _queriesText, value);
#endif
- }
+ }
- public bool IsVisible
- {
- get => _isVisible;
+ public bool IsVisible
+ {
+ get => _isVisible;
#if NET40
- set => Set(nameof(IsVisible), ref _isVisible, value);
+ set => Set(nameof(IsVisible), ref _isVisible, value);
#else
- set => Set(ref _isVisible, value);
+ set => Set(ref _isVisible, value);
#endif
- }
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs
index 6068897a..c9f6939c 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/GeometryItemModel.cs
@@ -1,13 +1,12 @@
using System.Windows.Media;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class GeometryItemModel
{
- public class GeometryItemModel
- {
- public Geometry Data { get; set; }
+ public Geometry Data { get; set; }
- public string Key { get; set; }
+ public string Key { get; set; }
- public bool Line { get; set; }
- }
+ public bool Line { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/PropertyGridDemoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/PropertyGridDemoModel.cs
index a6c48a91..073453e1 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/PropertyGridDemoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/PropertyGridDemoModel.cs
@@ -2,32 +2,31 @@
using System.Windows;
using System.Windows.Media;
-namespace HandyControlDemo.Data
+namespace HandyControlDemo.Data;
+
+public class PropertyGridDemoModel
{
- public class PropertyGridDemoModel
- {
- [Category("Category1")]
- public string String { get; set; }
+ [Category("Category1")]
+ public string String { get; set; }
- [Category("Category2")]
- public int Integer { get; set; }
+ [Category("Category2")]
+ public int Integer { get; set; }
- [Category("Category2")]
- public bool Boolean { get; set; }
+ [Category("Category2")]
+ public bool Boolean { get; set; }
- [Category("Category1")]
- public Gender Enum { get; set; }
+ [Category("Category1")]
+ public Gender Enum { get; set; }
- public HorizontalAlignment HorizontalAlignment { get; set; }
+ public HorizontalAlignment HorizontalAlignment { get; set; }
- public VerticalAlignment VerticalAlignment { get; set; }
+ public VerticalAlignment VerticalAlignment { get; set; }
- public ImageSource ImageSource { get; set; }
- }
+ public ImageSource ImageSource { get; set; }
+}
- public enum Gender
- {
- Male,
- Female
- }
+public enum Gender
+{
+ Male,
+ Female
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/StepBarDemoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/StepBarDemoModel.cs
index 317054a5..fa59a930 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/StepBarDemoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/StepBarDemoModel.cs
@@ -1,9 +1,8 @@
-namespace HandyControlDemo.Data
-{
- public class StepBarDemoModel
- {
- public string Header { get; set; }
+namespace HandyControlDemo.Data;
- public string Content { get; set; }
- }
+public class StepBarDemoModel
+{
+ public string Header { get; set; }
+
+ public string Content { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/Model/TabControlDemoModel.cs b/src/Shared/HandyControlDemo_Shared/Data/Model/TabControlDemoModel.cs
index 5f27697e..d7637cc2 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/Model/TabControlDemoModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/Model/TabControlDemoModel.cs
@@ -1,9 +1,8 @@
-namespace HandyControlDemo.Data
-{
- public class TabControlDemoModel
- {
- public string Header { get; set; }
+namespace HandyControlDemo.Data;
- public string BackgroundToken { get; set; }
- }
+public class TabControlDemoModel
+{
+ public string Header { get; set; }
+
+ public string BackgroundToken { get; set; }
}
diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
index d672b443..770a728b 100644
--- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
+++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
@@ -41,6 +41,7 @@
+
Avatar.xaml
@@ -410,7 +411,6 @@
-
@@ -421,13 +421,13 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/MainWindow.xaml.cs b/src/Shared/HandyControlDemo_Shared/MainWindow.xaml.cs
index b49f96ba..502ea268 100644
--- a/src/Shared/HandyControlDemo_Shared/MainWindow.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/MainWindow.xaml.cs
@@ -10,45 +10,44 @@ using HandyControlDemo.Tools;
using HandyControlDemo.UserControl;
using HandyControlDemo.ViewModel;
-namespace HandyControlDemo
+namespace HandyControlDemo;
+
+public partial class MainWindow
{
- public partial class MainWindow
+ public MainWindow() => InitializeComponent();
+
+ protected override void OnContentRendered(EventArgs e)
{
- public MainWindow() => InitializeComponent();
+ base.OnContentRendered(e);
- protected override void OnContentRendered(EventArgs e)
+ DataContext = ViewModelLocator.Instance.Main;
+ NonClientAreaContent = new NonClientAreaContent();
+ ControlMain.Content = new MainWindowContent();
+
+ GlobalShortcut.Init(new List
{
- base.OnContentRendered(e);
+ new(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt),
+ new(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt)
+ });
- DataContext = ViewModelLocator.Instance.Main;
- NonClientAreaContent = new NonClientAreaContent();
- ControlMain.Content = new MainWindowContent();
+ Dialog.SetToken(this, MessageToken.MainWindow);
+ WindowAttach.SetIgnoreAltF4(this, true);
- GlobalShortcut.Init(new List
- {
- new(ViewModelLocator.Instance.Main.GlobalShortcutInfoCmd, Key.I, ModifierKeys.Control | ModifierKeys.Alt),
- new(ViewModelLocator.Instance.Main.GlobalShortcutWarningCmd, Key.E, ModifierKeys.Control | ModifierKeys.Alt)
- });
+ Messenger.Default.Send(true, MessageToken.FullSwitch);
+ Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.PracticalDemo}"), MessageToken.LoadShowContent);
+ }
- Dialog.SetToken(this, MessageToken.MainWindow);
- WindowAttach.SetIgnoreAltF4(this, true);
-
- Messenger.Default.Send(true, MessageToken.FullSwitch);
- Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{MessageToken.PracticalDemo}"), MessageToken.LoadShowContent);
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ if (GlobalData.NotifyIconIsShow)
+ {
+ MessageBox.Info(Properties.Langs.Lang.AppClosingTip, Properties.Langs.Lang.Tip);
+ Hide();
+ e.Cancel = true;
}
-
- protected override void OnClosing(CancelEventArgs e)
+ else
{
- if (GlobalData.NotifyIconIsShow)
- {
- MessageBox.Info(Properties.Langs.Lang.AppClosingTip, Properties.Langs.Lang.Tip);
- Hide();
- e.Cancel = true;
- }
- else
- {
- base.OnClosing(e);
- }
+ base.OnClosing(e);
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs
index da3d7230..ca04a1bf 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/LangProvider.cs
@@ -4,2557 +4,2556 @@ using System.Windows;
using System.Windows.Data;
using HandyControl.Tools;
-namespace HandyControlDemo.Properties.Langs
+namespace HandyControlDemo.Properties.Langs;
+
+public class LangProvider : INotifyPropertyChanged
{
- public class LangProvider : INotifyPropertyChanged
+ internal static LangProvider Instance { get; } = ResourceHelper.GetResource("DemoLangs");
+
+ private static string CultureInfoStr;
+
+ public static CultureInfo Culture
{
- internal static LangProvider Instance { get; } = ResourceHelper.GetResource("DemoLangs");
-
- private static string CultureInfoStr;
-
- public static CultureInfo Culture
+ get => Lang.Culture;
+ set
{
- get => Lang.Culture;
- set
- {
- if (value == null) return;
- if (Equals(CultureInfoStr, value.EnglishName)) return;
- Lang.Culture = value;
- CultureInfoStr = value.EnglishName;
+ if (value == null) return;
+ if (Equals(CultureInfoStr, value.EnglishName)) return;
+ Lang.Culture = value;
+ CultureInfoStr = value.EnglishName;
- Instance.UpdateLangs();
- }
+ Instance.UpdateLangs();
}
-
- public static string GetLang(string key) => Lang.ResourceManager.GetString(key, Culture);
-
- public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
- BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
- {
- Source = Instance,
- Mode = BindingMode.OneWay
- });
-
- private void UpdateLangs()
- {
- OnPropertyChanged(nameof(About));
- OnPropertyChanged(nameof(AddItem));
- OnPropertyChanged(nameof(AnimationPath));
- OnPropertyChanged(nameof(AppClosingTip));
- OnPropertyChanged(nameof(Ask));
- OnPropertyChanged(nameof(AutoCompleteTextBox));
- OnPropertyChanged(nameof(Badge));
- OnPropertyChanged(nameof(BasicInfo));
- OnPropertyChanged(nameof(BasicLayout));
- OnPropertyChanged(nameof(Blink));
- OnPropertyChanged(nameof(Blog));
- OnPropertyChanged(nameof(Border));
- OnPropertyChanged(nameof(Brush));
- OnPropertyChanged(nameof(Button));
- OnPropertyChanged(nameof(ButtonCustom));
- OnPropertyChanged(nameof(ButtonGroup));
- OnPropertyChanged(nameof(Calendar));
- OnPropertyChanged(nameof(CalendarWithClock));
- OnPropertyChanged(nameof(Card));
- OnPropertyChanged(nameof(Carousel));
- OnPropertyChanged(nameof(ChangeLangAsk));
- OnPropertyChanged(nameof(ChatBubble));
- OnPropertyChanged(nameof(Chatroom));
- OnPropertyChanged(nameof(CheckBox));
- OnPropertyChanged(nameof(CheckComboBox));
- OnPropertyChanged(nameof(CirclePanel));
- OnPropertyChanged(nameof(Clear));
- OnPropertyChanged(nameof(Click2Count));
- OnPropertyChanged(nameof(Clock));
- OnPropertyChanged(nameof(ColorPicker));
- OnPropertyChanged(nameof(ColumnOffset));
- OnPropertyChanged(nameof(ColumnSpacing));
- OnPropertyChanged(nameof(ComboBox));
- OnPropertyChanged(nameof(ComingSoon));
- OnPropertyChanged(nameof(Comment));
- OnPropertyChanged(nameof(Common));
- OnPropertyChanged(nameof(CompareSlider));
- OnPropertyChanged(nameof(Complete));
- OnPropertyChanged(nameof(ContentDemoStr));
- OnPropertyChanged(nameof(Contributors));
- OnPropertyChanged(nameof(Controls));
- OnPropertyChanged(nameof(CoverFlow));
- OnPropertyChanged(nameof(CoverView));
- OnPropertyChanged(nameof(Danger));
- OnPropertyChanged(nameof(DataDisplay));
- OnPropertyChanged(nameof(DataEntry));
- OnPropertyChanged(nameof(DataGrid));
- OnPropertyChanged(nameof(DatePicker));
- OnPropertyChanged(nameof(DateTimePicker));
- OnPropertyChanged(nameof(Default));
- OnPropertyChanged(nameof(Demo));
- OnPropertyChanged(nameof(Dialog));
- OnPropertyChanged(nameof(DialogDemo));
- OnPropertyChanged(nameof(Divider));
- OnPropertyChanged(nameof(Doc_cn));
- OnPropertyChanged(nameof(Doc_en));
- OnPropertyChanged(nameof(Documentation));
- OnPropertyChanged(nameof(DragHere));
- OnPropertyChanged(nameof(Drawer));
- OnPropertyChanged(nameof(Effects));
- OnPropertyChanged(nameof(ElementGroup));
- OnPropertyChanged(nameof(Email));
- OnPropertyChanged(nameof(Empty));
- OnPropertyChanged(nameof(Error));
- OnPropertyChanged(nameof(Exit));
- OnPropertyChanged(nameof(Expander));
- OnPropertyChanged(nameof(Fatal));
- OnPropertyChanged(nameof(Feedback));
- OnPropertyChanged(nameof(FlexPanel));
- OnPropertyChanged(nameof(FlipClock));
- OnPropertyChanged(nameof(FloatingBlock));
- OnPropertyChanged(nameof(FlowDocument));
- OnPropertyChanged(nameof(FlowDocumentPageViewer));
- OnPropertyChanged(nameof(FlowDocumentReader));
- OnPropertyChanged(nameof(FlowDocumentScrollViewer));
- OnPropertyChanged(nameof(Frame));
- OnPropertyChanged(nameof(Geometry));
- OnPropertyChanged(nameof(GifImage));
- OnPropertyChanged(nameof(GotoTop));
- OnPropertyChanged(nameof(Gravatar));
- OnPropertyChanged(nameof(Grid));
- OnPropertyChanged(nameof(GroupBox));
- OnPropertyChanged(nameof(Groups));
- OnPropertyChanged(nameof(Growl));
- OnPropertyChanged(nameof(GrowlAsk));
- OnPropertyChanged(nameof(GrowlDemo));
- OnPropertyChanged(nameof(GrowlError));
- OnPropertyChanged(nameof(GrowlFatal));
- OnPropertyChanged(nameof(GrowlInfo));
- OnPropertyChanged(nameof(GrowlSuccess));
- OnPropertyChanged(nameof(GrowlWarning));
- OnPropertyChanged(nameof(HatchBrushGenerator));
- OnPropertyChanged(nameof(HoneycombPanel));
- OnPropertyChanged(nameof(HybridLayout));
- OnPropertyChanged(nameof(Ignore));
- OnPropertyChanged(nameof(ImageBlock));
- OnPropertyChanged(nameof(ImageBrowser));
- OnPropertyChanged(nameof(ImageSelector));
- OnPropertyChanged(nameof(Index));
- OnPropertyChanged(nameof(Info));
- OnPropertyChanged(nameof(Interacting));
- OnPropertyChanged(nameof(InteractiveDialog));
- OnPropertyChanged(nameof(IsNotPhone));
- OnPropertyChanged(nameof(Label));
- OnPropertyChanged(nameof(LangComment));
- OnPropertyChanged(nameof(Layout));
- OnPropertyChanged(nameof(ListBox));
- OnPropertyChanged(nameof(ListView));
- OnPropertyChanged(nameof(Loading));
- OnPropertyChanged(nameof(Magnifier));
- OnPropertyChanged(nameof(Menu));
- OnPropertyChanged(nameof(MessageBox));
- OnPropertyChanged(nameof(Misc));
- OnPropertyChanged(nameof(Morphing_Animation));
- OnPropertyChanged(nameof(Name));
- OnPropertyChanged(nameof(Navigation));
- OnPropertyChanged(nameof(NewWindow));
- OnPropertyChanged(nameof(Next));
- OnPropertyChanged(nameof(Notification));
- OnPropertyChanged(nameof(NotifyIcon));
- OnPropertyChanged(nameof(NumericUpDown));
- OnPropertyChanged(nameof(Off));
- OnPropertyChanged(nameof(Ok));
- OnPropertyChanged(nameof(On));
- OnPropertyChanged(nameof(OpenBlurWindow));
- OnPropertyChanged(nameof(OpenCommonWindow));
- OnPropertyChanged(nameof(OpenCustomContentWindow));
- OnPropertyChanged(nameof(OpenCustomMessageWindow));
- OnPropertyChanged(nameof(OpenCustomNonClientAreaWindow));
- OnPropertyChanged(nameof(OpenGlowWindow));
- OnPropertyChanged(nameof(OpenImageBrowser));
- OnPropertyChanged(nameof(OpenMessageWindow));
- OnPropertyChanged(nameof(OpenMouseFollowWindow));
- OnPropertyChanged(nameof(OpenNativeCommonWindow));
- OnPropertyChanged(nameof(OpenNavigationWindow));
- OnPropertyChanged(nameof(OpenNoNonClientAreaDragableWindow));
- OnPropertyChanged(nameof(OpenPanel));
- OnPropertyChanged(nameof(OpenSprite));
- OnPropertyChanged(nameof(OpenTouchDragMoveWindow));
- OnPropertyChanged(nameof(OutlineText));
- OnPropertyChanged(nameof(Pagination));
- OnPropertyChanged(nameof(PasswordBox));
- OnPropertyChanged(nameof(PinBox));
- OnPropertyChanged(nameof(PleaseInput));
- OnPropertyChanged(nameof(PleaseWait));
- OnPropertyChanged(nameof(PlsEnterContent));
- OnPropertyChanged(nameof(PlsEnterEmail));
- OnPropertyChanged(nameof(PlsEnterKey));
- OnPropertyChanged(nameof(Poptip));
- OnPropertyChanged(nameof(PoptipPositionStr));
- OnPropertyChanged(nameof(PracticalDemos));
- OnPropertyChanged(nameof(Prev));
- OnPropertyChanged(nameof(PreviewSlider));
- OnPropertyChanged(nameof(Primary));
- OnPropertyChanged(nameof(ProgressBar));
- OnPropertyChanged(nameof(ProgressButton));
- OnPropertyChanged(nameof(Project));
- OnPropertyChanged(nameof(PropertyGrid));
- OnPropertyChanged(nameof(PushToTalk));
- OnPropertyChanged(nameof(QQGroup));
- OnPropertyChanged(nameof(RadioButton));
- OnPropertyChanged(nameof(RangeSlider));
- OnPropertyChanged(nameof(Rate));
- OnPropertyChanged(nameof(Recommendation));
- OnPropertyChanged(nameof(Register));
- OnPropertyChanged(nameof(RelativePanel));
- OnPropertyChanged(nameof(Remark));
- OnPropertyChanged(nameof(RemoveItem));
- OnPropertyChanged(nameof(RepeatButton));
- OnPropertyChanged(nameof(Reply));
- OnPropertyChanged(nameof(Repository));
- OnPropertyChanged(nameof(ResponsiveLayout));
- OnPropertyChanged(nameof(RichTextBox));
- OnPropertyChanged(nameof(RightClickHere));
- OnPropertyChanged(nameof(RunningBlock));
- OnPropertyChanged(nameof(Screenshot));
- OnPropertyChanged(nameof(ScrollViewer));
- OnPropertyChanged(nameof(SearchBar));
- OnPropertyChanged(nameof(Second));
- OnPropertyChanged(nameof(Selected));
- OnPropertyChanged(nameof(SendNotification));
- OnPropertyChanged(nameof(Shield));
- OnPropertyChanged(nameof(ShowInCurrentWindow));
- OnPropertyChanged(nameof(ShowInMainWindow));
- OnPropertyChanged(nameof(ShowRowNumber));
- OnPropertyChanged(nameof(SideMenu));
- OnPropertyChanged(nameof(Slider));
- OnPropertyChanged(nameof(SplitButton));
- OnPropertyChanged(nameof(Sprite));
- OnPropertyChanged(nameof(StartScreenshot));
- OnPropertyChanged(nameof(StaysOpen));
- OnPropertyChanged(nameof(Step));
- OnPropertyChanged(nameof(StepBar));
- OnPropertyChanged(nameof(Styles));
- OnPropertyChanged(nameof(SubTitle));
- OnPropertyChanged(nameof(Success));
- OnPropertyChanged(nameof(TabControl));
- OnPropertyChanged(nameof(Tag));
- OnPropertyChanged(nameof(Text));
- OnPropertyChanged(nameof(TextBlock));
- OnPropertyChanged(nameof(TextBox));
- OnPropertyChanged(nameof(TextDialog));
- OnPropertyChanged(nameof(TextDialogInControl));
- OnPropertyChanged(nameof(TextDialogWithTimer));
- OnPropertyChanged(nameof(TimeBar));
- OnPropertyChanged(nameof(TimePicker));
- OnPropertyChanged(nameof(Tip));
- OnPropertyChanged(nameof(Title));
- OnPropertyChanged(nameof(TitleDemoStr1));
- OnPropertyChanged(nameof(TitleDemoStr2));
- OnPropertyChanged(nameof(TitleDemoStr3));
- OnPropertyChanged(nameof(ToggleButton));
- OnPropertyChanged(nameof(ToolBar));
- OnPropertyChanged(nameof(Tools));
- OnPropertyChanged(nameof(Transfer));
- OnPropertyChanged(nameof(TransitioningContentControl));
- OnPropertyChanged(nameof(TreeView));
- OnPropertyChanged(nameof(Try2CloseApp));
- OnPropertyChanged(nameof(Type));
- OnPropertyChanged(nameof(UniformSpacingPanel));
- OnPropertyChanged(nameof(UploadFile));
- OnPropertyChanged(nameof(UploadStr));
- OnPropertyChanged(nameof(Visibility));
- OnPropertyChanged(nameof(Vsix));
- OnPropertyChanged(nameof(Warning));
- OnPropertyChanged(nameof(WaterfallPanel));
- OnPropertyChanged(nameof(Website));
- OnPropertyChanged(nameof(Window));
- }
-
- ///
- /// 查找类似 关于 的本地化字符串。
- ///
- public string About => Lang.About;
-
- ///
- /// 查找类似 添加项 的本地化字符串。
- ///
- public string AddItem => Lang.AddItem;
-
- ///
- /// 查找类似 动画路径 的本地化字符串。
- ///
- public string AnimationPath => Lang.AnimationPath;
-
- ///
- /// 查找类似 托盘图标已打开,将隐藏窗口而不是关闭程序 的本地化字符串。
- ///
- public string AppClosingTip => Lang.AppClosingTip;
-
- ///
- /// 查找类似 询问 的本地化字符串。
- ///
- public string Ask => Lang.Ask;
-
- ///
- /// 查找类似 自动补全文本框 的本地化字符串。
- ///
- public string AutoCompleteTextBox => Lang.AutoCompleteTextBox;
-
- ///
- /// 查找类似 标记 的本地化字符串。
- ///
- public string Badge => Lang.Badge;
-
- ///
- /// 查找类似 填写基本信息 的本地化字符串。
- ///
- public string BasicInfo => Lang.BasicInfo;
-
- ///
- /// 查找类似 基础布局 的本地化字符串。
- ///
- public string BasicLayout => Lang.BasicLayout;
-
- ///
- /// 查找类似 闪烁 的本地化字符串。
- ///
- public string Blink => Lang.Blink;
-
- ///
- /// 查找类似 博客 的本地化字符串。
- ///
- public string Blog => Lang.Blog;
-
- ///
- /// 查找类似 边框 的本地化字符串。
- ///
- public string Border => Lang.Border;
-
- ///
- /// 查找类似 画刷 的本地化字符串。
- ///
- public string Brush => Lang.Brush;
-
- ///
- /// 查找类似 按钮 的本地化字符串。
- ///
- public string Button => Lang.Button;
-
- ///
- /// 查找类似 自定义按钮 的本地化字符串。
- ///
- public string ButtonCustom => Lang.ButtonCustom;
-
- ///
- /// 查找类似 按钮组 的本地化字符串。
- ///
- public string ButtonGroup => Lang.ButtonGroup;
-
- ///
- /// 查找类似 日历 的本地化字符串。
- ///
- public string Calendar => Lang.Calendar;
-
- ///
- /// 查找类似 带时钟的日历 的本地化字符串。
- ///
- public string CalendarWithClock => Lang.CalendarWithClock;
-
- ///
- /// 查找类似 卡片 的本地化字符串。
- ///
- public string Card => Lang.Card;
-
- ///
- /// 查找类似 轮播 的本地化字符串。
- ///
- public string Carousel => Lang.Carousel;
-
- ///
- /// 查找类似 是否重启以更改语言? 的本地化字符串。
- ///
- public string ChangeLangAsk => Lang.ChangeLangAsk;
-
- ///
- /// 查找类似 对话气泡 的本地化字符串。
- ///
- public string ChatBubble => Lang.ChatBubble;
-
- ///
- /// 查找类似 讨论室 的本地化字符串。
- ///
- public string Chatroom => Lang.Chatroom;
-
- ///
- /// 查找类似 复选框 的本地化字符串。
- ///
- public string CheckBox => Lang.CheckBox;
-
- ///
- /// 查找类似 多选组合框 的本地化字符串。
- ///
- public string CheckComboBox => Lang.CheckComboBox;
-
- ///
- /// 查找类似 圆形布局 的本地化字符串。
- ///
- public string CirclePanel => Lang.CirclePanel;
-
- ///
- /// 查找类似 清空 的本地化字符串。
- ///
- public string Clear => Lang.Clear;
-
- ///
- /// 查找类似 点击计数 的本地化字符串。
- ///
- public string Click2Count => Lang.Click2Count;
-
- ///
- /// 查找类似 时钟 的本地化字符串。
- ///
- public string Clock => Lang.Clock;
-
- ///
- /// 查找类似 颜色拾取器 的本地化字符串。
- ///
- public string ColorPicker => Lang.ColorPicker;
-
- ///
- /// 查找类似 分栏偏移 的本地化字符串。
- ///
- public string ColumnOffset => Lang.ColumnOffset;
-
- ///
- /// 查找类似 分栏间隔 的本地化字符串。
- ///
- public string ColumnSpacing => Lang.ColumnSpacing;
-
- ///
- /// 查找类似 组合框 的本地化字符串。
- ///
- public string ComboBox => Lang.ComboBox;
-
- ///
- /// 查找类似 敬请期待 的本地化字符串。
- ///
- public string ComingSoon => Lang.ComingSoon;
-
- ///
- /// 查找类似 评论 的本地化字符串。
- ///
- public string Comment => Lang.Comment;
-
- ///
- /// 查找类似 一般 的本地化字符串。
- ///
- public string Common => Lang.Common;
-
- ///
- /// 查找类似 对比滑块 的本地化字符串。
- ///
- public string CompareSlider => Lang.CompareSlider;
-
- ///
- /// 查找类似 完成 的本地化字符串。
- ///
- public string Complete => Lang.Complete;
-
- ///
- /// 查找类似 这是内容 的本地化字符串。
- ///
- public string ContentDemoStr => Lang.ContentDemoStr;
-
- ///
- /// 查找类似 贡献者 的本地化字符串。
- ///
- public string Contributors => Lang.Contributors;
-
- ///
- /// 查找类似 控件 的本地化字符串。
- ///
- public string Controls => Lang.Controls;
-
- ///
- /// 查找类似 封面流 的本地化字符串。
- ///
- public string CoverFlow => Lang.CoverFlow;
-
- ///
- /// 查找类似 封面视图 的本地化字符串。
- ///
- public string CoverView => Lang.CoverView;
-
- ///
- /// 查找类似 危险 的本地化字符串。
- ///
- public string Danger => Lang.Danger;
-
- ///
- /// 查找类似 数据展示 的本地化字符串。
- ///
- public string DataDisplay => Lang.DataDisplay;
-
- ///
- /// 查找类似 数据录入 的本地化字符串。
- ///
- public string DataEntry => Lang.DataEntry;
-
- ///
- /// 查找类似 数据表格 的本地化字符串。
- ///
- public string DataGrid => Lang.DataGrid;
-
- ///
- /// 查找类似 日期选择器 的本地化字符串。
- ///
- public string DatePicker => Lang.DatePicker;
-
- ///
- /// 查找类似 日期时间选择器 的本地化字符串。
- ///
- public string DateTimePicker => Lang.DateTimePicker;
-
- ///
- /// 查找类似 默认 的本地化字符串。
- ///
- public string Default => Lang.Default;
-
- ///
- /// 查找类似 示例 的本地化字符串。
- ///
- public string Demo => Lang.Demo;
-
- ///
- /// 查找类似 对话框 的本地化字符串。
- ///
- public string Dialog => Lang.Dialog;
-
- ///
- /// 查找类似 对话框示例 的本地化字符串。
- ///
- public string DialogDemo => Lang.DialogDemo;
-
- ///
- /// 查找类似 分割线 的本地化字符串。
- ///
- public string Divider => Lang.Divider;
-
- ///
- /// 查找类似 中文文档 的本地化字符串。
- ///
- public string Doc_cn => Lang.Doc_cn;
-
- ///
- /// 查找类似 英文文档 的本地化字符串。
- ///
- public string Doc_en => Lang.Doc_en;
-
- ///
- /// 查找类似 文献资料 的本地化字符串。
- ///
- public string Documentation => Lang.Documentation;
-
- ///
- /// 查找类似 在这里拖拽 的本地化字符串。
- ///
- public string DragHere => Lang.DragHere;
-
- ///
- /// 查找类似 抽屉 的本地化字符串。
- ///
- public string Drawer => Lang.Drawer;
-
- ///
- /// 查找类似 效果 的本地化字符串。
- ///
- public string Effects => Lang.Effects;
-
- ///
- /// 查找类似 元素组 的本地化字符串。
- ///
- public string ElementGroup => Lang.ElementGroup;
-
- ///
- /// 查找类似 邮箱 的本地化字符串。
- ///
- public string Email => Lang.Email;
-
- ///
- /// 查找类似 空状态 的本地化字符串。
- ///
- public string Empty => Lang.Empty;
-
- ///
- /// 查找类似 错误 的本地化字符串。
- ///
- public string Error => Lang.Error;
-
- ///
- /// 查找类似 退出 的本地化字符串。
- ///
- public string Exit => Lang.Exit;
-
- ///
- /// 查找类似 展开框 的本地化字符串。
- ///
- public string Expander => Lang.Expander;
-
- ///
- /// 查找类似 严重 的本地化字符串。
- ///
- public string Fatal => Lang.Fatal;
-
- ///
- /// 查找类似 反馈 的本地化字符串。
- ///
- public string Feedback => Lang.Feedback;
-
- ///
- /// 查找类似 弹性盒子 的本地化字符串。
- ///
- public string FlexPanel => Lang.FlexPanel;
-
- ///
- /// 查找类似 翻页时钟 的本地化字符串。
- ///
- public string FlipClock => Lang.FlipClock;
-
- ///
- /// 查找类似 漂浮块 的本地化字符串。
- ///
- public string FloatingBlock => Lang.FloatingBlock;
-
- ///
- /// 查找类似 流文档 的本地化字符串。
- ///
- public string FlowDocument => Lang.FlowDocument;
-
- ///
- /// 查找类似 流文档单页视图 的本地化字符串。
- ///
- public string FlowDocumentPageViewer => Lang.FlowDocumentPageViewer;
-
- ///
- /// 查找类似 流文档查看器 的本地化字符串。
- ///
- public string FlowDocumentReader => Lang.FlowDocumentReader;
-
- ///
- /// 查找类似 流文档滚动视图 的本地化字符串。
- ///
- public string FlowDocumentScrollViewer => Lang.FlowDocumentScrollViewer;
-
- ///
- /// 查找类似 导航框架 的本地化字符串。
- ///
- public string Frame => Lang.Frame;
-
- ///
- /// 查找类似 几何形状 的本地化字符串。
- ///
- public string Geometry => Lang.Geometry;
-
- ///
- /// 查找类似 Gif图片 的本地化字符串。
- ///
- public string GifImage => Lang.GifImage;
-
- ///
- /// 查找类似 回到顶部 的本地化字符串。
- ///
- public string GotoTop => Lang.GotoTop;
-
- ///
- /// 查找类似 头像 的本地化字符串。
- ///
- public string Gravatar => Lang.Gravatar;
-
- ///
- /// 查找类似 栅格 的本地化字符串。
- ///
- public string Grid => Lang.Grid;
-
- ///
- /// 查找类似 分组框 的本地化字符串。
- ///
- public string GroupBox => Lang.GroupBox;
-
- ///
- /// 查找类似 组数 的本地化字符串。
- ///
- public string Groups => Lang.Groups;
-
- ///
- /// 查找类似 信息通知 的本地化字符串。
- ///
- public string Growl => Lang.Growl;
-
- ///
- /// 查找类似 检测到有新版本!是否更新? 的本地化字符串。
- ///
- public string GrowlAsk => Lang.GrowlAsk;
-
- ///
- /// 查找类似 消息通知示例 的本地化字符串。
- ///
- public string GrowlDemo => Lang.GrowlDemo;
-
- ///
- /// 查找类似 连接失败,请检查网络! 的本地化字符串。
- ///
- public string GrowlError => Lang.GrowlError;
-
- ///
- /// 查找类似 程序已崩溃~~~ 的本地化字符串。
- ///
- public string GrowlFatal => Lang.GrowlFatal;
-
- ///
- /// 查找类似 今天的天气不错~~~ 的本地化字符串。
- ///
- public string GrowlInfo => Lang.GrowlInfo;
-
- ///
- /// 查找类似 文件保存成功! 的本地化字符串。
- ///
- public string GrowlSuccess => Lang.GrowlSuccess;
-
- ///
- /// 查找类似 磁盘空间快要满了! 的本地化字符串。
- ///
- public string GrowlWarning => Lang.GrowlWarning;
-
- ///
- /// 查找类似 阴影画笔生成器 的本地化字符串。
- ///
- public string HatchBrushGenerator => Lang.HatchBrushGenerator;
-
- ///
- /// 查找类似 蜂窝布局 的本地化字符串。
- ///
- public string HoneycombPanel => Lang.HoneycombPanel;
-
- ///
- /// 查找类似 混合布局 的本地化字符串。
- ///
- public string HybridLayout => Lang.HybridLayout;
-
- ///
- /// 查找类似 忽略 的本地化字符串。
- ///
- public string Ignore => Lang.Ignore;
-
- ///
- /// 查找类似 图片块 的本地化字符串。
- ///
- public string ImageBlock => Lang.ImageBlock;
-
- ///
- /// 查找类似 图片浏览器 的本地化字符串。
- ///
- public string ImageBrowser => Lang.ImageBrowser;
-
- ///
- /// 查找类似 图片选择器 的本地化字符串。
- ///
- public string ImageSelector => Lang.ImageSelector;
-
- ///
- /// 查找类似 索引 的本地化字符串。
- ///
- public string Index => Lang.Index;
-
- ///
- /// 查找类似 信息 的本地化字符串。
- ///
- public string Info => Lang.Info;
-
- ///
- /// 查找类似 交互 的本地化字符串。
- ///
- public string Interacting => Lang.Interacting;
-
- ///
- /// 查找类似 可交互对话框 的本地化字符串。
- ///
- public string InteractiveDialog => Lang.InteractiveDialog;
-
- ///
- /// 查找类似 不是手机号码 的本地化字符串。
- ///
- public string IsNotPhone => Lang.IsNotPhone;
-
- ///
- /// 查找类似 标签 的本地化字符串。
- ///
- public string Label => Lang.Label;
-
- ///
- /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
- ///
- public string LangComment => Lang.LangComment;
-
- ///
- /// 查找类似 布局 的本地化字符串。
- ///
- public string Layout => Lang.Layout;
-
- ///
- /// 查找类似 列表框 的本地化字符串。
- ///
- public string ListBox => Lang.ListBox;
-
- ///
- /// 查找类似 列表视图 的本地化字符串。
- ///
- public string ListView => Lang.ListView;
-
- ///
- /// 查找类似 加载条 的本地化字符串。
- ///
- public string Loading => Lang.Loading;
-
- ///
- /// 查找类似 放大镜 的本地化字符串。
- ///
- public string Magnifier => Lang.Magnifier;
-
- ///
- /// 查找类似 菜单 的本地化字符串。
- ///
- public string Menu => Lang.Menu;
-
- ///
- /// 查找类似 消息框 的本地化字符串。
- ///
- public string MessageBox => Lang.MessageBox;
-
- ///
- /// 查找类似 杂项 的本地化字符串。
- ///
- public string Misc => Lang.Misc;
-
- ///
- /// 查找类似 的本地化字符串。
- ///
- public string Morphing_Animation => Lang.Morphing_Animation;
-
- ///
- /// 查找类似 名称 的本地化字符串。
- ///
- public string Name => Lang.Name;
-
- ///
- /// 查找类似 导航 的本地化字符串。
- ///
- public string Navigation => Lang.Navigation;
-
- ///
- /// 查找类似 新建窗口 的本地化字符串。
- ///
- public string NewWindow => Lang.NewWindow;
-
- ///
- /// 查找类似 下一步 的本地化字符串。
- ///
- public string Next => Lang.Next;
-
- ///
- /// 查找类似 桌面通知 的本地化字符串。
- ///
- public string Notification => Lang.Notification;
-
- ///
- /// 查找类似 托盘图标 的本地化字符串。
- ///
- public string NotifyIcon => Lang.NotifyIcon;
-
- ///
- /// 查找类似 数值选择控件 的本地化字符串。
- ///
- public string NumericUpDown => Lang.NumericUpDown;
-
- ///
- /// 查找类似 关 的本地化字符串。
- ///
- public string Off => Lang.Off;
-
- ///
- /// 查找类似 确定 的本地化字符串。
- ///
- public string Ok => Lang.Ok;
-
- ///
- /// 查找类似 开 的本地化字符串。
- ///
- public string On => Lang.On;
-
- ///
- /// 查找类似 点击打开背景模糊窗口 的本地化字符串。
- ///
- public string OpenBlurWindow => Lang.OpenBlurWindow;
-
- ///
- /// 查找类似 点击打开常规窗口 的本地化字符串。
- ///
- public string OpenCommonWindow => Lang.OpenCommonWindow;
-
- ///
- /// 查找类似 点击打开自定义内容窗口 的本地化字符串。
- ///
- public string OpenCustomContentWindow => Lang.OpenCustomContentWindow;
-
- ///
- /// 查找类似 点击打开自定义消息窗口 的本地化字符串。
- ///
- public string OpenCustomMessageWindow => Lang.OpenCustomMessageWindow;
-
- ///
- /// 查找类似 点击打开自定义非客户端区域窗口 的本地化字符串。
- ///
- public string OpenCustomNonClientAreaWindow => Lang.OpenCustomNonClientAreaWindow;
-
- ///
- /// 查找类似 点击打开辉光窗口 的本地化字符串。
- ///
- public string OpenGlowWindow => Lang.OpenGlowWindow;
-
- ///
- /// 查找类似 点击打开图片浏览器 的本地化字符串。
- ///
- public string OpenImageBrowser => Lang.OpenImageBrowser;
-
- ///
- /// 查找类似 点击打开消息窗口 的本地化字符串。
- ///
- public string OpenMessageWindow => Lang.OpenMessageWindow;
-
- ///
- /// 查找类似 点击打开鼠标跟随窗口 的本地化字符串。
- ///
- public string OpenMouseFollowWindow => Lang.OpenMouseFollowWindow;
-
- ///
- /// 查找类似 点击打开原生常规窗口 的本地化字符串。
- ///
- public string OpenNativeCommonWindow => Lang.OpenNativeCommonWindow;
-
- ///
- /// 查找类似 点击打开导航窗口 的本地化字符串。
- ///
- public string OpenNavigationWindow => Lang.OpenNavigationWindow;
-
- ///
- /// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
- ///
- public string OpenNoNonClientAreaDragableWindow => Lang.OpenNoNonClientAreaDragableWindow;
-
- ///
- /// 查找类似 打开面板 的本地化字符串。
- ///
- public string OpenPanel => Lang.OpenPanel;
-
- ///
- /// 查找类似 打开精灵 的本地化字符串。
- ///
- public string OpenSprite => Lang.OpenSprite;
-
- ///
- /// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
- ///
- public string OpenTouchDragMoveWindow => Lang.OpenTouchDragMoveWindow;
-
- ///
- /// 查找类似 轮廓文本 的本地化字符串。
- ///
- public string OutlineText => Lang.OutlineText;
-
- ///
- /// 查找类似 页码条 的本地化字符串。
- ///
- public string Pagination => Lang.Pagination;
-
- ///
- /// 查找类似 密码框 的本地化字符串。
- ///
- public string PasswordBox => Lang.PasswordBox;
-
- ///
- /// 查找类似 PIN码框 的本地化字符串。
- ///
- public string PinBox => Lang.PinBox;
-
- ///
- /// 查找类似 请输入... 的本地化字符串。
- ///
- public string PleaseInput => Lang.PleaseInput;
-
- ///
- /// 查找类似 请稍后... 的本地化字符串。
- ///
- public string PleaseWait => Lang.PleaseWait;
-
- ///
- /// 查找类似 请输入内容 的本地化字符串。
- ///
- public string PlsEnterContent => Lang.PlsEnterContent;
-
- ///
- /// 查找类似 请输入邮箱 的本地化字符串。
- ///
- public string PlsEnterEmail => Lang.PlsEnterEmail;
-
- ///
- /// 查找类似 请输入关键字 的本地化字符串。
- ///
- public string PlsEnterKey => Lang.PlsEnterKey;
-
- ///
- /// 查找类似 气泡提示 的本地化字符串。
- ///
- public string Poptip => Lang.Poptip;
-
- ///
- /// 查找类似 上左;上边;上右;右上;右边;右下;下右;下边;下左;左下;左边;左上 的本地化字符串。
- ///
- public string PoptipPositionStr => Lang.PoptipPositionStr;
-
- ///
- /// 查找类似 实用例子 的本地化字符串。
- ///
- public string PracticalDemos => Lang.PracticalDemos;
-
- ///
- /// 查找类似 上一步 的本地化字符串。
- ///
- public string Prev => Lang.Prev;
-
- ///
- /// 查找类似 预览滑块 的本地化字符串。
- ///
- public string PreviewSlider => Lang.PreviewSlider;
-
- ///
- /// 查找类似 主要 的本地化字符串。
- ///
- public string Primary => Lang.Primary;
-
- ///
- /// 查找类似 进度条 的本地化字符串。
- ///
- public string ProgressBar => Lang.ProgressBar;
-
- ///
- /// 查找类似 进度按钮 的本地化字符串。
- ///
- public string ProgressButton => Lang.ProgressButton;
-
- ///
- /// 查找类似 项目 的本地化字符串。
- ///
- public string Project => Lang.Project;
-
- ///
- /// 查找类似 属性编辑器 的本地化字符串。
- ///
- public string PropertyGrid => Lang.PropertyGrid;
-
- ///
- /// 查找类似 按住说话 的本地化字符串。
- ///
- public string PushToTalk => Lang.PushToTalk;
-
- ///
- /// 查找类似 QQ群 的本地化字符串。
- ///
- public string QQGroup => Lang.QQGroup;
-
- ///
- /// 查找类似 单选按钮 的本地化字符串。
- ///
- public string RadioButton => Lang.RadioButton;
-
- ///
- /// 查找类似 范围滑块 的本地化字符串。
- ///
- public string RangeSlider => Lang.RangeSlider;
-
- ///
- /// 查找类似 评分 的本地化字符串。
- ///
- public string Rate => Lang.Rate;
-
- ///
- /// 查找类似 群友推荐 的本地化字符串。
- ///
- public string Recommendation => Lang.Recommendation;
-
- ///
- /// 查找类似 注册 的本地化字符串。
- ///
- public string Register => Lang.Register;
-
- ///
- /// 查找类似 相对布局 的本地化字符串。
- ///
- public string RelativePanel => Lang.RelativePanel;
-
- ///
- /// 查找类似 备注 的本地化字符串。
- ///
- public string Remark => Lang.Remark;
-
- ///
- /// 查找类似 删除项 的本地化字符串。
- ///
- public string RemoveItem => Lang.RemoveItem;
-
- ///
- /// 查找类似 重复按钮 的本地化字符串。
- ///
- public string RepeatButton => Lang.RepeatButton;
-
- ///
- /// 查找类似 回复 的本地化字符串。
- ///
- public string Reply => Lang.Reply;
-
- ///
- /// 查找类似 代码仓库 的本地化字符串。
- ///
- public string Repository => Lang.Repository;
-
- ///
- /// 查找类似 响应式布局 的本地化字符串。
- ///
- public string ResponsiveLayout => Lang.ResponsiveLayout;
-
- ///
- /// 查找类似 富文本框 的本地化字符串。
- ///
- public string RichTextBox => Lang.RichTextBox;
-
- ///
- /// 查找类似 在这里右击 的本地化字符串。
- ///
- public string RightClickHere => Lang.RightClickHere;
-
- ///
- /// 查找类似 滚动块 的本地化字符串。
- ///
- public string RunningBlock => Lang.RunningBlock;
-
- ///
- /// 查找类似 截图 的本地化字符串。
- ///
- public string Screenshot => Lang.Screenshot;
-
- ///
- /// 查找类似 滚动视图 的本地化字符串。
- ///
- public string ScrollViewer => Lang.ScrollViewer;
-
- ///
- /// 查找类似 搜索栏 的本地化字符串。
- ///
- public string SearchBar => Lang.SearchBar;
-
- ///
- /// 查找类似 秒 的本地化字符串。
- ///
- public string Second => Lang.Second;
-
- ///
- /// 查找类似 选中 的本地化字符串。
- ///
- public string Selected => Lang.Selected;
-
- ///
- /// 查找类似 发送通知 的本地化字符串。
- ///
- public string SendNotification => Lang.SendNotification;
-
- ///
- /// 查找类似 徽章 的本地化字符串。
- ///
- public string Shield => Lang.Shield;
-
- ///
- /// 查找类似 在当前窗口显示 的本地化字符串。
- ///
- public string ShowInCurrentWindow => Lang.ShowInCurrentWindow;
-
- ///
- /// 查找类似 在主窗口显示 的本地化字符串。
- ///
- public string ShowInMainWindow => Lang.ShowInMainWindow;
-
- ///
- /// 查找类似 显示行号 的本地化字符串。
- ///
- public string ShowRowNumber => Lang.ShowRowNumber;
-
- ///
- /// 查找类似 侧边菜单 的本地化字符串。
- ///
- public string SideMenu => Lang.SideMenu;
-
- ///
- /// 查找类似 滑块 的本地化字符串。
- ///
- public string Slider => Lang.Slider;
-
- ///
- /// 查找类似 分割按钮 的本地化字符串。
- ///
- public string SplitButton => Lang.SplitButton;
-
- ///
- /// 查找类似 精灵 的本地化字符串。
- ///
- public string Sprite => Lang.Sprite;
-
- ///
- /// 查找类似 开始截图 的本地化字符串。
- ///
- public string StartScreenshot => Lang.StartScreenshot;
-
- ///
- /// 查找类似 保持打开 的本地化字符串。
- ///
- public string StaysOpen => Lang.StaysOpen;
-
- ///
- /// 查找类似 步骤 的本地化字符串。
- ///
- public string Step => Lang.Step;
-
- ///
- /// 查找类似 步骤条 的本地化字符串。
- ///
- public string StepBar => Lang.StepBar;
-
- ///
- /// 查找类似 样式模板 的本地化字符串。
- ///
- public string Styles => Lang.Styles;
-
- ///
- /// 查找类似 子标题 的本地化字符串。
- ///
- public string SubTitle => Lang.SubTitle;
-
- ///
- /// 查找类似 成功 的本地化字符串。
- ///
- public string Success => Lang.Success;
-
- ///
- /// 查找类似 选项卡控件 的本地化字符串。
- ///
- public string TabControl => Lang.TabControl;
-
- ///
- /// 查找类似 标签 的本地化字符串。
- ///
- public string Tag => Lang.Tag;
-
- ///
- /// 查找类似 正文 的本地化字符串。
- ///
- public string Text => Lang.Text;
-
- ///
- /// 查找类似 文本块 的本地化字符串。
- ///
- public string TextBlock => Lang.TextBlock;
-
- ///
- /// 查找类似 文本框 的本地化字符串。
- ///
- public string TextBox => Lang.TextBox;
-
- ///
- /// 查找类似 文本对话框 的本地化字符串。
- ///
- public string TextDialog => Lang.TextDialog;
-
- ///
- /// 查找类似 文本对话框(控件中) 的本地化字符串。
- ///
- public string TextDialogInControl => Lang.TextDialogInControl;
-
- ///
- /// 查找类似 文本对话框,带计时器 的本地化字符串。
- ///
- public string TextDialogWithTimer => Lang.TextDialogWithTimer;
-
- ///
- /// 查找类似 时间条 的本地化字符串。
- ///
- public string TimeBar => Lang.TimeBar;
-
- ///
- /// 查找类似 时间选择器 的本地化字符串。
- ///
- public string TimePicker => Lang.TimePicker;
-
- ///
- /// 查找类似 提示 的本地化字符串。
- ///
- public string Tip => Lang.Tip;
-
- ///
- /// 查找类似 标题 的本地化字符串。
- ///
- public string Title => Lang.Title;
-
- ///
- /// 查找类似 这是标题 的本地化字符串。
- ///
- public string TitleDemoStr1 => Lang.TitleDemoStr1;
-
- ///
- /// 查找类似 此项必填 的本地化字符串。
- ///
- public string TitleDemoStr2 => Lang.TitleDemoStr2;
-
- ///
- /// 查找类似 标题在左侧 的本地化字符串。
- ///
- public string TitleDemoStr3 => Lang.TitleDemoStr3;
-
- ///
- /// 查找类似 切换按钮 的本地化字符串。
- ///
- public string ToggleButton => Lang.ToggleButton;
-
- ///
- /// 查找类似 工具条 的本地化字符串。
- ///
- public string ToolBar => Lang.ToolBar;
-
- ///
- /// 查找类似 工具 的本地化字符串。
- ///
- public string Tools => Lang.Tools;
-
- ///
- /// 查找类似 穿梭框 的本地化字符串。
- ///
- public string Transfer => Lang.Transfer;
-
- ///
- /// 查找类似 内容过渡控件 的本地化字符串。
- ///
- public string TransitioningContentControl => Lang.TransitioningContentControl;
-
- ///
- /// 查找类似 树视图 的本地化字符串。
- ///
- public string TreeView => Lang.TreeView;
-
- ///
- /// 查找类似 试试关闭程序吧? 的本地化字符串。
- ///
- public string Try2CloseApp => Lang.Try2CloseApp;
-
- ///
- /// 查找类似 类型 的本地化字符串。
- ///
- public string Type => Lang.Type;
-
- ///
- /// 查找类似 等间距布局 的本地化字符串。
- ///
- public string UniformSpacingPanel => Lang.UniformSpacingPanel;
-
- ///
- /// 查找类似 上传文件 的本地化字符串。
- ///
- public string UploadFile => Lang.UploadFile;
-
- ///
- /// 查找类似 上传;上传中 的本地化字符串。
- ///
- public string UploadStr => Lang.UploadStr;
-
- ///
- /// 查找类似 可见性 的本地化字符串。
- ///
- public string Visibility => Lang.Visibility;
-
- ///
- /// 查找类似 VS 插件 的本地化字符串。
- ///
- public string Vsix => Lang.Vsix;
-
- ///
- /// 查找类似 警告 的本地化字符串。
- ///
- public string Warning => Lang.Warning;
-
- ///
- /// 查找类似 瀑布流 的本地化字符串。
- ///
- public string WaterfallPanel => Lang.WaterfallPanel;
-
- ///
- /// 查找类似 网站 的本地化字符串。
- ///
- public string Website => Lang.Website;
-
- ///
- /// 查找类似 窗口 的本地化字符串。
- ///
- public string Window => Lang.Window;
-
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected virtual void OnPropertyChanged(string propertyName) =>
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
- public class LangKeys
+ public static string GetLang(string key) => Lang.ResourceManager.GetString(key, Culture);
+
+ public static void SetLang(DependencyObject dependencyObject, DependencyProperty dependencyProperty, string key) =>
+ BindingOperations.SetBinding(dependencyObject, dependencyProperty, new Binding(key)
+ {
+ Source = Instance,
+ Mode = BindingMode.OneWay
+ });
+
+ private void UpdateLangs()
{
- ///
- /// 查找类似 关于 的本地化字符串。
- ///
- public static string About = nameof(About);
-
- ///
- /// 查找类似 添加项 的本地化字符串。
- ///
- public static string AddItem = nameof(AddItem);
-
- ///
- /// 查找类似 动画路径 的本地化字符串。
- ///
- public static string AnimationPath = nameof(AnimationPath);
-
- ///
- /// 查找类似 托盘图标已打开,将隐藏窗口而不是关闭程序 的本地化字符串。
- ///
- public static string AppClosingTip = nameof(AppClosingTip);
-
- ///
- /// 查找类似 询问 的本地化字符串。
- ///
- public static string Ask = nameof(Ask);
-
- ///
- /// 查找类似 自动补全文本框 的本地化字符串。
- ///
- public static string AutoCompleteTextBox = nameof(AutoCompleteTextBox);
-
- ///
- /// 查找类似 标记 的本地化字符串。
- ///
- public static string Badge = nameof(Badge);
-
- ///
- /// 查找类似 填写基本信息 的本地化字符串。
- ///
- public static string BasicInfo = nameof(BasicInfo);
-
- ///
- /// 查找类似 基础布局 的本地化字符串。
- ///
- public static string BasicLayout = nameof(BasicLayout);
-
- ///
- /// 查找类似 闪烁 的本地化字符串。
- ///
- public static string Blink = nameof(Blink);
-
- ///
- /// 查找类似 博客 的本地化字符串。
- ///
- public static string Blog = nameof(Blog);
-
- ///
- /// 查找类似 边框 的本地化字符串。
- ///
- public static string Border = nameof(Border);
-
- ///
- /// 查找类似 画刷 的本地化字符串。
- ///
- public static string Brush = nameof(Brush);
-
- ///
- /// 查找类似 按钮 的本地化字符串。
- ///
- public static string Button = nameof(Button);
-
- ///
- /// 查找类似 自定义按钮 的本地化字符串。
- ///
- public static string ButtonCustom = nameof(ButtonCustom);
-
- ///
- /// 查找类似 按钮组 的本地化字符串。
- ///
- public static string ButtonGroup = nameof(ButtonGroup);
-
- ///
- /// 查找类似 日历 的本地化字符串。
- ///
- public static string Calendar = nameof(Calendar);
-
- ///
- /// 查找类似 带时钟的日历 的本地化字符串。
- ///
- public static string CalendarWithClock = nameof(CalendarWithClock);
-
- ///
- /// 查找类似 卡片 的本地化字符串。
- ///
- public static string Card = nameof(Card);
-
- ///
- /// 查找类似 轮播 的本地化字符串。
- ///
- public static string Carousel = nameof(Carousel);
-
- ///
- /// 查找类似 是否重启以更改语言? 的本地化字符串。
- ///
- public static string ChangeLangAsk = nameof(ChangeLangAsk);
-
- ///
- /// 查找类似 对话气泡 的本地化字符串。
- ///
- public static string ChatBubble = nameof(ChatBubble);
-
- ///
- /// 查找类似 讨论室 的本地化字符串。
- ///
- public static string Chatroom = nameof(Chatroom);
-
- ///
- /// 查找类似 复选框 的本地化字符串。
- ///
- public static string CheckBox = nameof(CheckBox);
-
- ///
- /// 查找类似 多选组合框 的本地化字符串。
- ///
- public static string CheckComboBox = nameof(CheckComboBox);
-
- ///
- /// 查找类似 圆形布局 的本地化字符串。
- ///
- public static string CirclePanel = nameof(CirclePanel);
-
- ///
- /// 查找类似 清空 的本地化字符串。
- ///
- public static string Clear = nameof(Clear);
-
- ///
- /// 查找类似 点击计数 的本地化字符串。
- ///
- public static string Click2Count = nameof(Click2Count);
-
- ///
- /// 查找类似 时钟 的本地化字符串。
- ///
- public static string Clock = nameof(Clock);
-
- ///
- /// 查找类似 颜色拾取器 的本地化字符串。
- ///
- public static string ColorPicker = nameof(ColorPicker);
-
- ///
- /// 查找类似 分栏偏移 的本地化字符串。
- ///
- public static string ColumnOffset = nameof(ColumnOffset);
-
- ///
- /// 查找类似 分栏间隔 的本地化字符串。
- ///
- public static string ColumnSpacing = nameof(ColumnSpacing);
-
- ///
- /// 查找类似 组合框 的本地化字符串。
- ///
- public static string ComboBox = nameof(ComboBox);
-
- ///
- /// 查找类似 敬请期待 的本地化字符串。
- ///
- public static string ComingSoon = nameof(ComingSoon);
-
- ///
- /// 查找类似 评论 的本地化字符串。
- ///
- public static string Comment = nameof(Comment);
-
- ///
- /// 查找类似 一般 的本地化字符串。
- ///
- public static string Common = nameof(Common);
-
- ///
- /// 查找类似 对比滑块 的本地化字符串。
- ///
- public static string CompareSlider = nameof(CompareSlider);
-
- ///
- /// 查找类似 完成 的本地化字符串。
- ///
- public static string Complete = nameof(Complete);
-
- ///
- /// 查找类似 这是内容 的本地化字符串。
- ///
- public static string ContentDemoStr = nameof(ContentDemoStr);
-
- ///
- /// 查找类似 贡献者 的本地化字符串。
- ///
- public static string Contributors = nameof(Contributors);
-
- ///
- /// 查找类似 控件 的本地化字符串。
- ///
- public static string Controls = nameof(Controls);
-
- ///
- /// 查找类似 封面流 的本地化字符串。
- ///
- public static string CoverFlow = nameof(CoverFlow);
-
- ///
- /// 查找类似 封面视图 的本地化字符串。
- ///
- public static string CoverView = nameof(CoverView);
-
- ///
- /// 查找类似 危险 的本地化字符串。
- ///
- public static string Danger = nameof(Danger);
-
- ///
- /// 查找类似 数据展示 的本地化字符串。
- ///
- public static string DataDisplay = nameof(DataDisplay);
-
- ///
- /// 查找类似 数据录入 的本地化字符串。
- ///
- public static string DataEntry = nameof(DataEntry);
-
- ///
- /// 查找类似 数据表格 的本地化字符串。
- ///
- public static string DataGrid = nameof(DataGrid);
-
- ///
- /// 查找类似 日期选择器 的本地化字符串。
- ///
- public static string DatePicker = nameof(DatePicker);
-
- ///
- /// 查找类似 日期时间选择器 的本地化字符串。
- ///
- public static string DateTimePicker = nameof(DateTimePicker);
-
- ///
- /// 查找类似 默认 的本地化字符串。
- ///
- public static string Default = nameof(Default);
-
- ///
- /// 查找类似 示例 的本地化字符串。
- ///
- public static string Demo = nameof(Demo);
-
- ///
- /// 查找类似 对话框 的本地化字符串。
- ///
- public static string Dialog = nameof(Dialog);
-
- ///
- /// 查找类似 对话框示例 的本地化字符串。
- ///
- public static string DialogDemo = nameof(DialogDemo);
-
- ///
- /// 查找类似 分割线 的本地化字符串。
- ///
- public static string Divider = nameof(Divider);
-
- ///
- /// 查找类似 中文文档 的本地化字符串。
- ///
- public static string Doc_cn = nameof(Doc_cn);
-
- ///
- /// 查找类似 英文文档 的本地化字符串。
- ///
- public static string Doc_en = nameof(Doc_en);
-
- ///
- /// 查找类似 文献资料 的本地化字符串。
- ///
- public static string Documentation = nameof(Documentation);
-
- ///
- /// 查找类似 在这里拖拽 的本地化字符串。
- ///
- public static string DragHere = nameof(DragHere);
-
- ///
- /// 查找类似 抽屉 的本地化字符串。
- ///
- public static string Drawer = nameof(Drawer);
-
- ///
- /// 查找类似 效果 的本地化字符串。
- ///
- public static string Effects = nameof(Effects);
-
- ///
- /// 查找类似 元素组 的本地化字符串。
- ///
- public static string ElementGroup = nameof(ElementGroup);
-
- ///
- /// 查找类似 邮箱 的本地化字符串。
- ///
- public static string Email = nameof(Email);
-
- ///
- /// 查找类似 空状态 的本地化字符串。
- ///
- public static string Empty = nameof(Empty);
-
- ///
- /// 查找类似 错误 的本地化字符串。
- ///
- public static string Error = nameof(Error);
-
- ///
- /// 查找类似 退出 的本地化字符串。
- ///
- public static string Exit = nameof(Exit);
-
- ///
- /// 查找类似 展开框 的本地化字符串。
- ///
- public static string Expander = nameof(Expander);
-
- ///
- /// 查找类似 严重 的本地化字符串。
- ///
- public static string Fatal = nameof(Fatal);
-
- ///
- /// 查找类似 反馈 的本地化字符串。
- ///
- public static string Feedback = nameof(Feedback);
-
- ///
- /// 查找类似 弹性盒子 的本地化字符串。
- ///
- public static string FlexPanel = nameof(FlexPanel);
-
- ///
- /// 查找类似 翻页时钟 的本地化字符串。
- ///
- public static string FlipClock = nameof(FlipClock);
-
- ///
- /// 查找类似 漂浮块 的本地化字符串。
- ///
- public static string FloatingBlock = nameof(FloatingBlock);
-
- ///
- /// 查找类似 流文档 的本地化字符串。
- ///
- public static string FlowDocument = nameof(FlowDocument);
-
- ///
- /// 查找类似 流文档单页视图 的本地化字符串。
- ///
- public static string FlowDocumentPageViewer = nameof(FlowDocumentPageViewer);
-
- ///
- /// 查找类似 流文档查看器 的本地化字符串。
- ///
- public static string FlowDocumentReader = nameof(FlowDocumentReader);
-
- ///
- /// 查找类似 流文档滚动视图 的本地化字符串。
- ///
- public static string FlowDocumentScrollViewer = nameof(FlowDocumentScrollViewer);
-
- ///
- /// 查找类似 导航框架 的本地化字符串。
- ///
- public static string Frame = nameof(Frame);
-
- ///
- /// 查找类似 几何形状 的本地化字符串。
- ///
- public static string Geometry = nameof(Geometry);
-
- ///
- /// 查找类似 Gif图片 的本地化字符串。
- ///
- public static string GifImage = nameof(GifImage);
-
- ///
- /// 查找类似 回到顶部 的本地化字符串。
- ///
- public static string GotoTop = nameof(GotoTop);
-
- ///
- /// 查找类似 头像 的本地化字符串。
- ///
- public static string Gravatar = nameof(Gravatar);
-
- ///
- /// 查找类似 栅格 的本地化字符串。
- ///
- public static string Grid = nameof(Grid);
-
- ///
- /// 查找类似 分组框 的本地化字符串。
- ///
- public static string GroupBox = nameof(GroupBox);
-
- ///
- /// 查找类似 组数 的本地化字符串。
- ///
- public static string Groups = nameof(Groups);
-
- ///
- /// 查找类似 信息通知 的本地化字符串。
- ///
- public static string Growl = nameof(Growl);
-
- ///
- /// 查找类似 检测到有新版本!是否更新? 的本地化字符串。
- ///
- public static string GrowlAsk = nameof(GrowlAsk);
-
- ///
- /// 查找类似 消息通知示例 的本地化字符串。
- ///
- public static string GrowlDemo = nameof(GrowlDemo);
-
- ///
- /// 查找类似 连接失败,请检查网络! 的本地化字符串。
- ///
- public static string GrowlError = nameof(GrowlError);
-
- ///
- /// 查找类似 程序已崩溃~~~ 的本地化字符串。
- ///
- public static string GrowlFatal = nameof(GrowlFatal);
-
- ///
- /// 查找类似 今天的天气不错~~~ 的本地化字符串。
- ///
- public static string GrowlInfo = nameof(GrowlInfo);
-
- ///
- /// 查找类似 文件保存成功! 的本地化字符串。
- ///
- public static string GrowlSuccess = nameof(GrowlSuccess);
-
- ///
- /// 查找类似 磁盘空间快要满了! 的本地化字符串。
- ///
- public static string GrowlWarning = nameof(GrowlWarning);
-
- ///
- /// 查找类似 阴影画笔生成器 的本地化字符串。
- ///
- public static string HatchBrushGenerator = nameof(HatchBrushGenerator);
-
- ///
- /// 查找类似 蜂窝布局 的本地化字符串。
- ///
- public static string HoneycombPanel = nameof(HoneycombPanel);
-
- ///
- /// 查找类似 混合布局 的本地化字符串。
- ///
- public static string HybridLayout = nameof(HybridLayout);
-
- ///
- /// 查找类似 忽略 的本地化字符串。
- ///
- public static string Ignore = nameof(Ignore);
-
- ///
- /// 查找类似 图片块 的本地化字符串。
- ///
- public static string ImageBlock = nameof(ImageBlock);
-
- ///
- /// 查找类似 图片浏览器 的本地化字符串。
- ///
- public static string ImageBrowser = nameof(ImageBrowser);
-
- ///
- /// 查找类似 图片选择器 的本地化字符串。
- ///
- public static string ImageSelector = nameof(ImageSelector);
-
- ///
- /// 查找类似 索引 的本地化字符串。
- ///
- public static string Index = nameof(Index);
-
- ///
- /// 查找类似 信息 的本地化字符串。
- ///
- public static string Info = nameof(Info);
-
- ///
- /// 查找类似 交互 的本地化字符串。
- ///
- public static string Interacting = nameof(Interacting);
-
- ///
- /// 查找类似 可交互对话框 的本地化字符串。
- ///
- public static string InteractiveDialog = nameof(InteractiveDialog);
-
- ///
- /// 查找类似 不是手机号码 的本地化字符串。
- ///
- public static string IsNotPhone = nameof(IsNotPhone);
-
- ///
- /// 查找类似 标签 的本地化字符串。
- ///
- public static string Label = nameof(Label);
-
- ///
- /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
- ///
- public static string LangComment = nameof(LangComment);
-
- ///
- /// 查找类似 布局 的本地化字符串。
- ///
- public static string Layout = nameof(Layout);
-
- ///
- /// 查找类似 列表框 的本地化字符串。
- ///
- public static string ListBox = nameof(ListBox);
-
- ///
- /// 查找类似 列表视图 的本地化字符串。
- ///
- public static string ListView = nameof(ListView);
-
- ///
- /// 查找类似 加载条 的本地化字符串。
- ///
- public static string Loading = nameof(Loading);
-
- ///
- /// 查找类似 放大镜 的本地化字符串。
- ///
- public static string Magnifier = nameof(Magnifier);
-
- ///
- /// 查找类似 菜单 的本地化字符串。
- ///
- public static string Menu = nameof(Menu);
-
- ///
- /// 查找类似 消息框 的本地化字符串。
- ///
- public static string MessageBox = nameof(MessageBox);
-
- ///
- /// 查找类似 杂项 的本地化字符串。
- ///
- public static string Misc = nameof(Misc);
-
- ///
- /// 查找类似 的本地化字符串。
- ///
- public static string Morphing_Animation = nameof(Morphing_Animation);
-
- ///
- /// 查找类似 名称 的本地化字符串。
- ///
- public static string Name = nameof(Name);
-
- ///
- /// 查找类似 导航 的本地化字符串。
- ///
- public static string Navigation = nameof(Navigation);
-
- ///
- /// 查找类似 新建窗口 的本地化字符串。
- ///
- public static string NewWindow = nameof(NewWindow);
-
- ///
- /// 查找类似 下一步 的本地化字符串。
- ///
- public static string Next = nameof(Next);
-
- ///
- /// 查找类似 桌面通知 的本地化字符串。
- ///
- public static string Notification = nameof(Notification);
-
- ///
- /// 查找类似 托盘图标 的本地化字符串。
- ///
- public static string NotifyIcon = nameof(NotifyIcon);
-
- ///
- /// 查找类似 数值选择控件 的本地化字符串。
- ///
- public static string NumericUpDown = nameof(NumericUpDown);
-
- ///
- /// 查找类似 关 的本地化字符串。
- ///
- public static string Off = nameof(Off);
-
- ///
- /// 查找类似 确定 的本地化字符串。
- ///
- public static string Ok = nameof(Ok);
-
- ///
- /// 查找类似 开 的本地化字符串。
- ///
- public static string On = nameof(On);
-
- ///
- /// 查找类似 点击打开背景模糊窗口 的本地化字符串。
- ///
- public static string OpenBlurWindow = nameof(OpenBlurWindow);
-
- ///
- /// 查找类似 点击打开常规窗口 的本地化字符串。
- ///
- public static string OpenCommonWindow = nameof(OpenCommonWindow);
-
- ///
- /// 查找类似 点击打开自定义内容窗口 的本地化字符串。
- ///
- public static string OpenCustomContentWindow = nameof(OpenCustomContentWindow);
-
- ///
- /// 查找类似 点击打开自定义消息窗口 的本地化字符串。
- ///
- public static string OpenCustomMessageWindow = nameof(OpenCustomMessageWindow);
-
- ///
- /// 查找类似 点击打开自定义非客户端区域窗口 的本地化字符串。
- ///
- public static string OpenCustomNonClientAreaWindow = nameof(OpenCustomNonClientAreaWindow);
-
- ///
- /// 查找类似 点击打开辉光窗口 的本地化字符串。
- ///
- public static string OpenGlowWindow = nameof(OpenGlowWindow);
-
- ///
- /// 查找类似 点击打开图片浏览器 的本地化字符串。
- ///
- public static string OpenImageBrowser = nameof(OpenImageBrowser);
-
- ///
- /// 查找类似 点击打开消息窗口 的本地化字符串。
- ///
- public static string OpenMessageWindow = nameof(OpenMessageWindow);
-
- ///
- /// 查找类似 点击打开鼠标跟随窗口 的本地化字符串。
- ///
- public static string OpenMouseFollowWindow = nameof(OpenMouseFollowWindow);
-
- ///
- /// 查找类似 点击打开原生常规窗口 的本地化字符串。
- ///
- public static string OpenNativeCommonWindow = nameof(OpenNativeCommonWindow);
-
- ///
- /// 查找类似 点击打开导航窗口 的本地化字符串。
- ///
- public static string OpenNavigationWindow = nameof(OpenNavigationWindow);
-
- ///
- /// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
- ///
- public static string OpenNoNonClientAreaDragableWindow = nameof(OpenNoNonClientAreaDragableWindow);
-
- ///
- /// 查找类似 打开面板 的本地化字符串。
- ///
- public static string OpenPanel = nameof(OpenPanel);
-
- ///
- /// 查找类似 打开精灵 的本地化字符串。
- ///
- public static string OpenSprite = nameof(OpenSprite);
-
- ///
- /// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
- ///
- public static string OpenTouchDragMoveWindow = nameof(OpenTouchDragMoveWindow);
-
- ///
- /// 查找类似 轮廓文本 的本地化字符串。
- ///
- public static string OutlineText = nameof(OutlineText);
-
- ///
- /// 查找类似 页码条 的本地化字符串。
- ///
- public static string Pagination = nameof(Pagination);
-
- ///
- /// 查找类似 密码框 的本地化字符串。
- ///
- public static string PasswordBox = nameof(PasswordBox);
-
- ///
- /// 查找类似 PIN码框 的本地化字符串。
- ///
- public static string PinBox = nameof(PinBox);
-
- ///
- /// 查找类似 请输入... 的本地化字符串。
- ///
- public static string PleaseInput = nameof(PleaseInput);
-
- ///
- /// 查找类似 请稍后... 的本地化字符串。
- ///
- public static string PleaseWait = nameof(PleaseWait);
-
- ///
- /// 查找类似 请输入内容 的本地化字符串。
- ///
- public static string PlsEnterContent = nameof(PlsEnterContent);
-
- ///
- /// 查找类似 请输入邮箱 的本地化字符串。
- ///
- public static string PlsEnterEmail = nameof(PlsEnterEmail);
-
- ///
- /// 查找类似 请输入关键字 的本地化字符串。
- ///
- public static string PlsEnterKey = nameof(PlsEnterKey);
-
- ///
- /// 查找类似 气泡提示 的本地化字符串。
- ///
- public static string Poptip = nameof(Poptip);
-
- ///
- /// 查找类似 上左;上边;上右;右上;右边;右下;下右;下边;下左;左下;左边;左上 的本地化字符串。
- ///
- public static string PoptipPositionStr = nameof(PoptipPositionStr);
-
- ///
- /// 查找类似 实用例子 的本地化字符串。
- ///
- public static string PracticalDemos = nameof(PracticalDemos);
-
- ///
- /// 查找类似 上一步 的本地化字符串。
- ///
- public static string Prev = nameof(Prev);
-
- ///
- /// 查找类似 预览滑块 的本地化字符串。
- ///
- public static string PreviewSlider = nameof(PreviewSlider);
-
- ///
- /// 查找类似 主要 的本地化字符串。
- ///
- public static string Primary = nameof(Primary);
-
- ///
- /// 查找类似 进度条 的本地化字符串。
- ///
- public static string ProgressBar = nameof(ProgressBar);
-
- ///
- /// 查找类似 进度按钮 的本地化字符串。
- ///
- public static string ProgressButton = nameof(ProgressButton);
-
- ///
- /// 查找类似 项目 的本地化字符串。
- ///
- public static string Project = nameof(Project);
-
- ///
- /// 查找类似 属性编辑器 的本地化字符串。
- ///
- public static string PropertyGrid = nameof(PropertyGrid);
-
- ///
- /// 查找类似 按住说话 的本地化字符串。
- ///
- public static string PushToTalk = nameof(PushToTalk);
-
- ///
- /// 查找类似 QQ群 的本地化字符串。
- ///
- public static string QQGroup = nameof(QQGroup);
-
- ///
- /// 查找类似 单选按钮 的本地化字符串。
- ///
- public static string RadioButton = nameof(RadioButton);
-
- ///
- /// 查找类似 范围滑块 的本地化字符串。
- ///
- public static string RangeSlider = nameof(RangeSlider);
-
- ///
- /// 查找类似 评分 的本地化字符串。
- ///
- public static string Rate = nameof(Rate);
-
- ///
- /// 查找类似 群友推荐 的本地化字符串。
- ///
- public static string Recommendation = nameof(Recommendation);
-
- ///
- /// 查找类似 注册 的本地化字符串。
- ///
- public static string Register = nameof(Register);
-
- ///
- /// 查找类似 相对布局 的本地化字符串。
- ///
- public static string RelativePanel = nameof(RelativePanel);
-
- ///
- /// 查找类似 备注 的本地化字符串。
- ///
- public static string Remark = nameof(Remark);
-
- ///
- /// 查找类似 删除项 的本地化字符串。
- ///
- public static string RemoveItem = nameof(RemoveItem);
-
- ///
- /// 查找类似 重复按钮 的本地化字符串。
- ///
- public static string RepeatButton = nameof(RepeatButton);
-
- ///
- /// 查找类似 回复 的本地化字符串。
- ///
- public static string Reply = nameof(Reply);
-
- ///
- /// 查找类似 代码仓库 的本地化字符串。
- ///
- public static string Repository = nameof(Repository);
-
- ///
- /// 查找类似 响应式布局 的本地化字符串。
- ///
- public static string ResponsiveLayout = nameof(ResponsiveLayout);
-
- ///
- /// 查找类似 富文本框 的本地化字符串。
- ///
- public static string RichTextBox = nameof(RichTextBox);
-
- ///
- /// 查找类似 在这里右击 的本地化字符串。
- ///
- public static string RightClickHere = nameof(RightClickHere);
-
- ///
- /// 查找类似 滚动块 的本地化字符串。
- ///
- public static string RunningBlock = nameof(RunningBlock);
-
- ///
- /// 查找类似 截图 的本地化字符串。
- ///
- public static string Screenshot = nameof(Screenshot);
-
- ///
- /// 查找类似 滚动视图 的本地化字符串。
- ///
- public static string ScrollViewer = nameof(ScrollViewer);
-
- ///
- /// 查找类似 搜索栏 的本地化字符串。
- ///
- public static string SearchBar = nameof(SearchBar);
-
- ///
- /// 查找类似 秒 的本地化字符串。
- ///
- public static string Second = nameof(Second);
-
- ///
- /// 查找类似 选中 的本地化字符串。
- ///
- public static string Selected = nameof(Selected);
-
- ///
- /// 查找类似 发送通知 的本地化字符串。
- ///
- public static string SendNotification = nameof(SendNotification);
-
- ///
- /// 查找类似 徽章 的本地化字符串。
- ///
- public static string Shield = nameof(Shield);
-
- ///
- /// 查找类似 在当前窗口显示 的本地化字符串。
- ///
- public static string ShowInCurrentWindow = nameof(ShowInCurrentWindow);
-
- ///
- /// 查找类似 在主窗口显示 的本地化字符串。
- ///
- public static string ShowInMainWindow = nameof(ShowInMainWindow);
-
- ///
- /// 查找类似 显示行号 的本地化字符串。
- ///
- public static string ShowRowNumber = nameof(ShowRowNumber);
-
- ///
- /// 查找类似 侧边菜单 的本地化字符串。
- ///
- public static string SideMenu = nameof(SideMenu);
-
- ///
- /// 查找类似 滑块 的本地化字符串。
- ///
- public static string Slider = nameof(Slider);
-
- ///
- /// 查找类似 分割按钮 的本地化字符串。
- ///
- public static string SplitButton = nameof(SplitButton);
-
- ///
- /// 查找类似 精灵 的本地化字符串。
- ///
- public static string Sprite = nameof(Sprite);
-
- ///
- /// 查找类似 开始截图 的本地化字符串。
- ///
- public static string StartScreenshot = nameof(StartScreenshot);
-
- ///
- /// 查找类似 保持打开 的本地化字符串。
- ///
- public static string StaysOpen = nameof(StaysOpen);
-
- ///
- /// 查找类似 步骤 的本地化字符串。
- ///
- public static string Step = nameof(Step);
-
- ///
- /// 查找类似 步骤条 的本地化字符串。
- ///
- public static string StepBar = nameof(StepBar);
-
- ///
- /// 查找类似 样式模板 的本地化字符串。
- ///
- public static string Styles = nameof(Styles);
-
- ///
- /// 查找类似 子标题 的本地化字符串。
- ///
- public static string SubTitle = nameof(SubTitle);
-
- ///
- /// 查找类似 成功 的本地化字符串。
- ///
- public static string Success = nameof(Success);
-
- ///
- /// 查找类似 选项卡控件 的本地化字符串。
- ///
- public static string TabControl = nameof(TabControl);
-
- ///
- /// 查找类似 标签 的本地化字符串。
- ///
- public static string Tag = nameof(Tag);
-
- ///
- /// 查找类似 正文 的本地化字符串。
- ///
- public static string Text = nameof(Text);
-
- ///
- /// 查找类似 文本块 的本地化字符串。
- ///
- public static string TextBlock = nameof(TextBlock);
-
- ///
- /// 查找类似 文本框 的本地化字符串。
- ///
- public static string TextBox = nameof(TextBox);
-
- ///
- /// 查找类似 文本对话框 的本地化字符串。
- ///
- public static string TextDialog = nameof(TextDialog);
-
- ///
- /// 查找类似 文本对话框(控件中) 的本地化字符串。
- ///
- public static string TextDialogInControl = nameof(TextDialogInControl);
-
- ///
- /// 查找类似 文本对话框,带计时器 的本地化字符串。
- ///
- public static string TextDialogWithTimer = nameof(TextDialogWithTimer);
-
- ///
- /// 查找类似 时间条 的本地化字符串。
- ///
- public static string TimeBar = nameof(TimeBar);
-
- ///
- /// 查找类似 时间选择器 的本地化字符串。
- ///
- public static string TimePicker = nameof(TimePicker);
-
- ///
- /// 查找类似 提示 的本地化字符串。
- ///
- public static string Tip = nameof(Tip);
-
- ///
- /// 查找类似 标题 的本地化字符串。
- ///
- public static string Title = nameof(Title);
-
- ///
- /// 查找类似 这是标题 的本地化字符串。
- ///
- public static string TitleDemoStr1 = nameof(TitleDemoStr1);
-
- ///
- /// 查找类似 此项必填 的本地化字符串。
- ///
- public static string TitleDemoStr2 = nameof(TitleDemoStr2);
-
- ///
- /// 查找类似 标题在左侧 的本地化字符串。
- ///
- public static string TitleDemoStr3 = nameof(TitleDemoStr3);
-
- ///
- /// 查找类似 切换按钮 的本地化字符串。
- ///
- public static string ToggleButton = nameof(ToggleButton);
-
- ///
- /// 查找类似 工具条 的本地化字符串。
- ///
- public static string ToolBar = nameof(ToolBar);
-
- ///
- /// 查找类似 工具 的本地化字符串。
- ///
- public static string Tools = nameof(Tools);
-
- ///
- /// 查找类似 穿梭框 的本地化字符串。
- ///
- public static string Transfer = nameof(Transfer);
-
- ///
- /// 查找类似 内容过渡控件 的本地化字符串。
- ///
- public static string TransitioningContentControl = nameof(TransitioningContentControl);
-
- ///
- /// 查找类似 树视图 的本地化字符串。
- ///
- public static string TreeView = nameof(TreeView);
-
- ///
- /// 查找类似 试试关闭程序吧? 的本地化字符串。
- ///
- public static string Try2CloseApp = nameof(Try2CloseApp);
-
- ///
- /// 查找类似 类型 的本地化字符串。
- ///
- public static string Type = nameof(Type);
-
- ///
- /// 查找类似 等间距布局 的本地化字符串。
- ///
- public static string UniformSpacingPanel = nameof(UniformSpacingPanel);
-
- ///
- /// 查找类似 上传文件 的本地化字符串。
- ///
- public static string UploadFile = nameof(UploadFile);
-
- ///
- /// 查找类似 上传;上传中 的本地化字符串。
- ///
- public static string UploadStr = nameof(UploadStr);
-
- ///
- /// 查找类似 可见性 的本地化字符串。
- ///
- public static string Visibility = nameof(Visibility);
-
- ///
- /// 查找类似 VS 插件 的本地化字符串。
- ///
- public static string Vsix = nameof(Vsix);
-
- ///
- /// 查找类似 警告 的本地化字符串。
- ///
- public static string Warning = nameof(Warning);
-
- ///
- /// 查找类似 瀑布流 的本地化字符串。
- ///
- public static string WaterfallPanel = nameof(WaterfallPanel);
-
- ///
- /// 查找类似 网站 的本地化字符串。
- ///
- public static string Website = nameof(Website);
-
- ///
- /// 查找类似 窗口 的本地化字符串。
- ///
- public static string Window = nameof(Window);
-
+ OnPropertyChanged(nameof(About));
+ OnPropertyChanged(nameof(AddItem));
+ OnPropertyChanged(nameof(AnimationPath));
+ OnPropertyChanged(nameof(AppClosingTip));
+ OnPropertyChanged(nameof(Ask));
+ OnPropertyChanged(nameof(AutoCompleteTextBox));
+ OnPropertyChanged(nameof(Badge));
+ OnPropertyChanged(nameof(BasicInfo));
+ OnPropertyChanged(nameof(BasicLayout));
+ OnPropertyChanged(nameof(Blink));
+ OnPropertyChanged(nameof(Blog));
+ OnPropertyChanged(nameof(Border));
+ OnPropertyChanged(nameof(Brush));
+ OnPropertyChanged(nameof(Button));
+ OnPropertyChanged(nameof(ButtonCustom));
+ OnPropertyChanged(nameof(ButtonGroup));
+ OnPropertyChanged(nameof(Calendar));
+ OnPropertyChanged(nameof(CalendarWithClock));
+ OnPropertyChanged(nameof(Card));
+ OnPropertyChanged(nameof(Carousel));
+ OnPropertyChanged(nameof(ChangeLangAsk));
+ OnPropertyChanged(nameof(ChatBubble));
+ OnPropertyChanged(nameof(Chatroom));
+ OnPropertyChanged(nameof(CheckBox));
+ OnPropertyChanged(nameof(CheckComboBox));
+ OnPropertyChanged(nameof(CirclePanel));
+ OnPropertyChanged(nameof(Clear));
+ OnPropertyChanged(nameof(Click2Count));
+ OnPropertyChanged(nameof(Clock));
+ OnPropertyChanged(nameof(ColorPicker));
+ OnPropertyChanged(nameof(ColumnOffset));
+ OnPropertyChanged(nameof(ColumnSpacing));
+ OnPropertyChanged(nameof(ComboBox));
+ OnPropertyChanged(nameof(ComingSoon));
+ OnPropertyChanged(nameof(Comment));
+ OnPropertyChanged(nameof(Common));
+ OnPropertyChanged(nameof(CompareSlider));
+ OnPropertyChanged(nameof(Complete));
+ OnPropertyChanged(nameof(ContentDemoStr));
+ OnPropertyChanged(nameof(Contributors));
+ OnPropertyChanged(nameof(Controls));
+ OnPropertyChanged(nameof(CoverFlow));
+ OnPropertyChanged(nameof(CoverView));
+ OnPropertyChanged(nameof(Danger));
+ OnPropertyChanged(nameof(DataDisplay));
+ OnPropertyChanged(nameof(DataEntry));
+ OnPropertyChanged(nameof(DataGrid));
+ OnPropertyChanged(nameof(DatePicker));
+ OnPropertyChanged(nameof(DateTimePicker));
+ OnPropertyChanged(nameof(Default));
+ OnPropertyChanged(nameof(Demo));
+ OnPropertyChanged(nameof(Dialog));
+ OnPropertyChanged(nameof(DialogDemo));
+ OnPropertyChanged(nameof(Divider));
+ OnPropertyChanged(nameof(Doc_cn));
+ OnPropertyChanged(nameof(Doc_en));
+ OnPropertyChanged(nameof(Documentation));
+ OnPropertyChanged(nameof(DragHere));
+ OnPropertyChanged(nameof(Drawer));
+ OnPropertyChanged(nameof(Effects));
+ OnPropertyChanged(nameof(ElementGroup));
+ OnPropertyChanged(nameof(Email));
+ OnPropertyChanged(nameof(Empty));
+ OnPropertyChanged(nameof(Error));
+ OnPropertyChanged(nameof(Exit));
+ OnPropertyChanged(nameof(Expander));
+ OnPropertyChanged(nameof(Fatal));
+ OnPropertyChanged(nameof(Feedback));
+ OnPropertyChanged(nameof(FlexPanel));
+ OnPropertyChanged(nameof(FlipClock));
+ OnPropertyChanged(nameof(FloatingBlock));
+ OnPropertyChanged(nameof(FlowDocument));
+ OnPropertyChanged(nameof(FlowDocumentPageViewer));
+ OnPropertyChanged(nameof(FlowDocumentReader));
+ OnPropertyChanged(nameof(FlowDocumentScrollViewer));
+ OnPropertyChanged(nameof(Frame));
+ OnPropertyChanged(nameof(Geometry));
+ OnPropertyChanged(nameof(GifImage));
+ OnPropertyChanged(nameof(GotoTop));
+ OnPropertyChanged(nameof(Gravatar));
+ OnPropertyChanged(nameof(Grid));
+ OnPropertyChanged(nameof(GroupBox));
+ OnPropertyChanged(nameof(Groups));
+ OnPropertyChanged(nameof(Growl));
+ OnPropertyChanged(nameof(GrowlAsk));
+ OnPropertyChanged(nameof(GrowlDemo));
+ OnPropertyChanged(nameof(GrowlError));
+ OnPropertyChanged(nameof(GrowlFatal));
+ OnPropertyChanged(nameof(GrowlInfo));
+ OnPropertyChanged(nameof(GrowlSuccess));
+ OnPropertyChanged(nameof(GrowlWarning));
+ OnPropertyChanged(nameof(HatchBrushGenerator));
+ OnPropertyChanged(nameof(HoneycombPanel));
+ OnPropertyChanged(nameof(HybridLayout));
+ OnPropertyChanged(nameof(Ignore));
+ OnPropertyChanged(nameof(ImageBlock));
+ OnPropertyChanged(nameof(ImageBrowser));
+ OnPropertyChanged(nameof(ImageSelector));
+ OnPropertyChanged(nameof(Index));
+ OnPropertyChanged(nameof(Info));
+ OnPropertyChanged(nameof(Interacting));
+ OnPropertyChanged(nameof(InteractiveDialog));
+ OnPropertyChanged(nameof(IsNotPhone));
+ OnPropertyChanged(nameof(Label));
+ OnPropertyChanged(nameof(LangComment));
+ OnPropertyChanged(nameof(Layout));
+ OnPropertyChanged(nameof(ListBox));
+ OnPropertyChanged(nameof(ListView));
+ OnPropertyChanged(nameof(Loading));
+ OnPropertyChanged(nameof(Magnifier));
+ OnPropertyChanged(nameof(Menu));
+ OnPropertyChanged(nameof(MessageBox));
+ OnPropertyChanged(nameof(Misc));
+ OnPropertyChanged(nameof(Morphing_Animation));
+ OnPropertyChanged(nameof(Name));
+ OnPropertyChanged(nameof(Navigation));
+ OnPropertyChanged(nameof(NewWindow));
+ OnPropertyChanged(nameof(Next));
+ OnPropertyChanged(nameof(Notification));
+ OnPropertyChanged(nameof(NotifyIcon));
+ OnPropertyChanged(nameof(NumericUpDown));
+ OnPropertyChanged(nameof(Off));
+ OnPropertyChanged(nameof(Ok));
+ OnPropertyChanged(nameof(On));
+ OnPropertyChanged(nameof(OpenBlurWindow));
+ OnPropertyChanged(nameof(OpenCommonWindow));
+ OnPropertyChanged(nameof(OpenCustomContentWindow));
+ OnPropertyChanged(nameof(OpenCustomMessageWindow));
+ OnPropertyChanged(nameof(OpenCustomNonClientAreaWindow));
+ OnPropertyChanged(nameof(OpenGlowWindow));
+ OnPropertyChanged(nameof(OpenImageBrowser));
+ OnPropertyChanged(nameof(OpenMessageWindow));
+ OnPropertyChanged(nameof(OpenMouseFollowWindow));
+ OnPropertyChanged(nameof(OpenNativeCommonWindow));
+ OnPropertyChanged(nameof(OpenNavigationWindow));
+ OnPropertyChanged(nameof(OpenNoNonClientAreaDragableWindow));
+ OnPropertyChanged(nameof(OpenPanel));
+ OnPropertyChanged(nameof(OpenSprite));
+ OnPropertyChanged(nameof(OpenTouchDragMoveWindow));
+ OnPropertyChanged(nameof(OutlineText));
+ OnPropertyChanged(nameof(Pagination));
+ OnPropertyChanged(nameof(PasswordBox));
+ OnPropertyChanged(nameof(PinBox));
+ OnPropertyChanged(nameof(PleaseInput));
+ OnPropertyChanged(nameof(PleaseWait));
+ OnPropertyChanged(nameof(PlsEnterContent));
+ OnPropertyChanged(nameof(PlsEnterEmail));
+ OnPropertyChanged(nameof(PlsEnterKey));
+ OnPropertyChanged(nameof(Poptip));
+ OnPropertyChanged(nameof(PoptipPositionStr));
+ OnPropertyChanged(nameof(PracticalDemos));
+ OnPropertyChanged(nameof(Prev));
+ OnPropertyChanged(nameof(PreviewSlider));
+ OnPropertyChanged(nameof(Primary));
+ OnPropertyChanged(nameof(ProgressBar));
+ OnPropertyChanged(nameof(ProgressButton));
+ OnPropertyChanged(nameof(Project));
+ OnPropertyChanged(nameof(PropertyGrid));
+ OnPropertyChanged(nameof(PushToTalk));
+ OnPropertyChanged(nameof(QQGroup));
+ OnPropertyChanged(nameof(RadioButton));
+ OnPropertyChanged(nameof(RangeSlider));
+ OnPropertyChanged(nameof(Rate));
+ OnPropertyChanged(nameof(Recommendation));
+ OnPropertyChanged(nameof(Register));
+ OnPropertyChanged(nameof(RelativePanel));
+ OnPropertyChanged(nameof(Remark));
+ OnPropertyChanged(nameof(RemoveItem));
+ OnPropertyChanged(nameof(RepeatButton));
+ OnPropertyChanged(nameof(Reply));
+ OnPropertyChanged(nameof(Repository));
+ OnPropertyChanged(nameof(ResponsiveLayout));
+ OnPropertyChanged(nameof(RichTextBox));
+ OnPropertyChanged(nameof(RightClickHere));
+ OnPropertyChanged(nameof(RunningBlock));
+ OnPropertyChanged(nameof(Screenshot));
+ OnPropertyChanged(nameof(ScrollViewer));
+ OnPropertyChanged(nameof(SearchBar));
+ OnPropertyChanged(nameof(Second));
+ OnPropertyChanged(nameof(Selected));
+ OnPropertyChanged(nameof(SendNotification));
+ OnPropertyChanged(nameof(Shield));
+ OnPropertyChanged(nameof(ShowInCurrentWindow));
+ OnPropertyChanged(nameof(ShowInMainWindow));
+ OnPropertyChanged(nameof(ShowRowNumber));
+ OnPropertyChanged(nameof(SideMenu));
+ OnPropertyChanged(nameof(Slider));
+ OnPropertyChanged(nameof(SplitButton));
+ OnPropertyChanged(nameof(Sprite));
+ OnPropertyChanged(nameof(StartScreenshot));
+ OnPropertyChanged(nameof(StaysOpen));
+ OnPropertyChanged(nameof(Step));
+ OnPropertyChanged(nameof(StepBar));
+ OnPropertyChanged(nameof(Styles));
+ OnPropertyChanged(nameof(SubTitle));
+ OnPropertyChanged(nameof(Success));
+ OnPropertyChanged(nameof(TabControl));
+ OnPropertyChanged(nameof(Tag));
+ OnPropertyChanged(nameof(Text));
+ OnPropertyChanged(nameof(TextBlock));
+ OnPropertyChanged(nameof(TextBox));
+ OnPropertyChanged(nameof(TextDialog));
+ OnPropertyChanged(nameof(TextDialogInControl));
+ OnPropertyChanged(nameof(TextDialogWithTimer));
+ OnPropertyChanged(nameof(TimeBar));
+ OnPropertyChanged(nameof(TimePicker));
+ OnPropertyChanged(nameof(Tip));
+ OnPropertyChanged(nameof(Title));
+ OnPropertyChanged(nameof(TitleDemoStr1));
+ OnPropertyChanged(nameof(TitleDemoStr2));
+ OnPropertyChanged(nameof(TitleDemoStr3));
+ OnPropertyChanged(nameof(ToggleButton));
+ OnPropertyChanged(nameof(ToolBar));
+ OnPropertyChanged(nameof(Tools));
+ OnPropertyChanged(nameof(Transfer));
+ OnPropertyChanged(nameof(TransitioningContentControl));
+ OnPropertyChanged(nameof(TreeView));
+ OnPropertyChanged(nameof(Try2CloseApp));
+ OnPropertyChanged(nameof(Type));
+ OnPropertyChanged(nameof(UniformSpacingPanel));
+ OnPropertyChanged(nameof(UploadFile));
+ OnPropertyChanged(nameof(UploadStr));
+ OnPropertyChanged(nameof(Visibility));
+ OnPropertyChanged(nameof(Vsix));
+ OnPropertyChanged(nameof(Warning));
+ OnPropertyChanged(nameof(WaterfallPanel));
+ OnPropertyChanged(nameof(Website));
+ OnPropertyChanged(nameof(Window));
}
+
+ ///
+ /// 查找类似 关于 的本地化字符串。
+ ///
+ public string About => Lang.About;
+
+ ///
+ /// 查找类似 添加项 的本地化字符串。
+ ///
+ public string AddItem => Lang.AddItem;
+
+ ///
+ /// 查找类似 动画路径 的本地化字符串。
+ ///
+ public string AnimationPath => Lang.AnimationPath;
+
+ ///
+ /// 查找类似 托盘图标已打开,将隐藏窗口而不是关闭程序 的本地化字符串。
+ ///
+ public string AppClosingTip => Lang.AppClosingTip;
+
+ ///
+ /// 查找类似 询问 的本地化字符串。
+ ///
+ public string Ask => Lang.Ask;
+
+ ///
+ /// 查找类似 自动补全文本框 的本地化字符串。
+ ///
+ public string AutoCompleteTextBox => Lang.AutoCompleteTextBox;
+
+ ///
+ /// 查找类似 标记 的本地化字符串。
+ ///
+ public string Badge => Lang.Badge;
+
+ ///
+ /// 查找类似 填写基本信息 的本地化字符串。
+ ///
+ public string BasicInfo => Lang.BasicInfo;
+
+ ///
+ /// 查找类似 基础布局 的本地化字符串。
+ ///
+ public string BasicLayout => Lang.BasicLayout;
+
+ ///
+ /// 查找类似 闪烁 的本地化字符串。
+ ///
+ public string Blink => Lang.Blink;
+
+ ///
+ /// 查找类似 博客 的本地化字符串。
+ ///
+ public string Blog => Lang.Blog;
+
+ ///
+ /// 查找类似 边框 的本地化字符串。
+ ///
+ public string Border => Lang.Border;
+
+ ///
+ /// 查找类似 画刷 的本地化字符串。
+ ///
+ public string Brush => Lang.Brush;
+
+ ///
+ /// 查找类似 按钮 的本地化字符串。
+ ///
+ public string Button => Lang.Button;
+
+ ///
+ /// 查找类似 自定义按钮 的本地化字符串。
+ ///
+ public string ButtonCustom => Lang.ButtonCustom;
+
+ ///
+ /// 查找类似 按钮组 的本地化字符串。
+ ///
+ public string ButtonGroup => Lang.ButtonGroup;
+
+ ///
+ /// 查找类似 日历 的本地化字符串。
+ ///
+ public string Calendar => Lang.Calendar;
+
+ ///
+ /// 查找类似 带时钟的日历 的本地化字符串。
+ ///
+ public string CalendarWithClock => Lang.CalendarWithClock;
+
+ ///
+ /// 查找类似 卡片 的本地化字符串。
+ ///
+ public string Card => Lang.Card;
+
+ ///
+ /// 查找类似 轮播 的本地化字符串。
+ ///
+ public string Carousel => Lang.Carousel;
+
+ ///
+ /// 查找类似 是否重启以更改语言? 的本地化字符串。
+ ///
+ public string ChangeLangAsk => Lang.ChangeLangAsk;
+
+ ///
+ /// 查找类似 对话气泡 的本地化字符串。
+ ///
+ public string ChatBubble => Lang.ChatBubble;
+
+ ///
+ /// 查找类似 讨论室 的本地化字符串。
+ ///
+ public string Chatroom => Lang.Chatroom;
+
+ ///
+ /// 查找类似 复选框 的本地化字符串。
+ ///
+ public string CheckBox => Lang.CheckBox;
+
+ ///
+ /// 查找类似 多选组合框 的本地化字符串。
+ ///
+ public string CheckComboBox => Lang.CheckComboBox;
+
+ ///
+ /// 查找类似 圆形布局 的本地化字符串。
+ ///
+ public string CirclePanel => Lang.CirclePanel;
+
+ ///
+ /// 查找类似 清空 的本地化字符串。
+ ///
+ public string Clear => Lang.Clear;
+
+ ///
+ /// 查找类似 点击计数 的本地化字符串。
+ ///
+ public string Click2Count => Lang.Click2Count;
+
+ ///
+ /// 查找类似 时钟 的本地化字符串。
+ ///
+ public string Clock => Lang.Clock;
+
+ ///
+ /// 查找类似 颜色拾取器 的本地化字符串。
+ ///
+ public string ColorPicker => Lang.ColorPicker;
+
+ ///
+ /// 查找类似 分栏偏移 的本地化字符串。
+ ///
+ public string ColumnOffset => Lang.ColumnOffset;
+
+ ///
+ /// 查找类似 分栏间隔 的本地化字符串。
+ ///
+ public string ColumnSpacing => Lang.ColumnSpacing;
+
+ ///
+ /// 查找类似 组合框 的本地化字符串。
+ ///
+ public string ComboBox => Lang.ComboBox;
+
+ ///
+ /// 查找类似 敬请期待 的本地化字符串。
+ ///
+ public string ComingSoon => Lang.ComingSoon;
+
+ ///
+ /// 查找类似 评论 的本地化字符串。
+ ///
+ public string Comment => Lang.Comment;
+
+ ///
+ /// 查找类似 一般 的本地化字符串。
+ ///
+ public string Common => Lang.Common;
+
+ ///
+ /// 查找类似 对比滑块 的本地化字符串。
+ ///
+ public string CompareSlider => Lang.CompareSlider;
+
+ ///
+ /// 查找类似 完成 的本地化字符串。
+ ///
+ public string Complete => Lang.Complete;
+
+ ///
+ /// 查找类似 这是内容 的本地化字符串。
+ ///
+ public string ContentDemoStr => Lang.ContentDemoStr;
+
+ ///
+ /// 查找类似 贡献者 的本地化字符串。
+ ///
+ public string Contributors => Lang.Contributors;
+
+ ///
+ /// 查找类似 控件 的本地化字符串。
+ ///
+ public string Controls => Lang.Controls;
+
+ ///
+ /// 查找类似 封面流 的本地化字符串。
+ ///
+ public string CoverFlow => Lang.CoverFlow;
+
+ ///
+ /// 查找类似 封面视图 的本地化字符串。
+ ///
+ public string CoverView => Lang.CoverView;
+
+ ///
+ /// 查找类似 危险 的本地化字符串。
+ ///
+ public string Danger => Lang.Danger;
+
+ ///
+ /// 查找类似 数据展示 的本地化字符串。
+ ///
+ public string DataDisplay => Lang.DataDisplay;
+
+ ///
+ /// 查找类似 数据录入 的本地化字符串。
+ ///
+ public string DataEntry => Lang.DataEntry;
+
+ ///
+ /// 查找类似 数据表格 的本地化字符串。
+ ///
+ public string DataGrid => Lang.DataGrid;
+
+ ///
+ /// 查找类似 日期选择器 的本地化字符串。
+ ///
+ public string DatePicker => Lang.DatePicker;
+
+ ///
+ /// 查找类似 日期时间选择器 的本地化字符串。
+ ///
+ public string DateTimePicker => Lang.DateTimePicker;
+
+ ///
+ /// 查找类似 默认 的本地化字符串。
+ ///
+ public string Default => Lang.Default;
+
+ ///
+ /// 查找类似 示例 的本地化字符串。
+ ///
+ public string Demo => Lang.Demo;
+
+ ///
+ /// 查找类似 对话框 的本地化字符串。
+ ///
+ public string Dialog => Lang.Dialog;
+
+ ///
+ /// 查找类似 对话框示例 的本地化字符串。
+ ///
+ public string DialogDemo => Lang.DialogDemo;
+
+ ///
+ /// 查找类似 分割线 的本地化字符串。
+ ///
+ public string Divider => Lang.Divider;
+
+ ///
+ /// 查找类似 中文文档 的本地化字符串。
+ ///
+ public string Doc_cn => Lang.Doc_cn;
+
+ ///
+ /// 查找类似 英文文档 的本地化字符串。
+ ///
+ public string Doc_en => Lang.Doc_en;
+
+ ///
+ /// 查找类似 文献资料 的本地化字符串。
+ ///
+ public string Documentation => Lang.Documentation;
+
+ ///
+ /// 查找类似 在这里拖拽 的本地化字符串。
+ ///
+ public string DragHere => Lang.DragHere;
+
+ ///
+ /// 查找类似 抽屉 的本地化字符串。
+ ///
+ public string Drawer => Lang.Drawer;
+
+ ///
+ /// 查找类似 效果 的本地化字符串。
+ ///
+ public string Effects => Lang.Effects;
+
+ ///
+ /// 查找类似 元素组 的本地化字符串。
+ ///
+ public string ElementGroup => Lang.ElementGroup;
+
+ ///
+ /// 查找类似 邮箱 的本地化字符串。
+ ///
+ public string Email => Lang.Email;
+
+ ///
+ /// 查找类似 空状态 的本地化字符串。
+ ///
+ public string Empty => Lang.Empty;
+
+ ///
+ /// 查找类似 错误 的本地化字符串。
+ ///
+ public string Error => Lang.Error;
+
+ ///
+ /// 查找类似 退出 的本地化字符串。
+ ///
+ public string Exit => Lang.Exit;
+
+ ///
+ /// 查找类似 展开框 的本地化字符串。
+ ///
+ public string Expander => Lang.Expander;
+
+ ///
+ /// 查找类似 严重 的本地化字符串。
+ ///
+ public string Fatal => Lang.Fatal;
+
+ ///
+ /// 查找类似 反馈 的本地化字符串。
+ ///
+ public string Feedback => Lang.Feedback;
+
+ ///
+ /// 查找类似 弹性盒子 的本地化字符串。
+ ///
+ public string FlexPanel => Lang.FlexPanel;
+
+ ///
+ /// 查找类似 翻页时钟 的本地化字符串。
+ ///
+ public string FlipClock => Lang.FlipClock;
+
+ ///
+ /// 查找类似 漂浮块 的本地化字符串。
+ ///
+ public string FloatingBlock => Lang.FloatingBlock;
+
+ ///
+ /// 查找类似 流文档 的本地化字符串。
+ ///
+ public string FlowDocument => Lang.FlowDocument;
+
+ ///
+ /// 查找类似 流文档单页视图 的本地化字符串。
+ ///
+ public string FlowDocumentPageViewer => Lang.FlowDocumentPageViewer;
+
+ ///
+ /// 查找类似 流文档查看器 的本地化字符串。
+ ///
+ public string FlowDocumentReader => Lang.FlowDocumentReader;
+
+ ///
+ /// 查找类似 流文档滚动视图 的本地化字符串。
+ ///
+ public string FlowDocumentScrollViewer => Lang.FlowDocumentScrollViewer;
+
+ ///
+ /// 查找类似 导航框架 的本地化字符串。
+ ///
+ public string Frame => Lang.Frame;
+
+ ///
+ /// 查找类似 几何形状 的本地化字符串。
+ ///
+ public string Geometry => Lang.Geometry;
+
+ ///
+ /// 查找类似 Gif图片 的本地化字符串。
+ ///
+ public string GifImage => Lang.GifImage;
+
+ ///
+ /// 查找类似 回到顶部 的本地化字符串。
+ ///
+ public string GotoTop => Lang.GotoTop;
+
+ ///
+ /// 查找类似 头像 的本地化字符串。
+ ///
+ public string Gravatar => Lang.Gravatar;
+
+ ///
+ /// 查找类似 栅格 的本地化字符串。
+ ///
+ public string Grid => Lang.Grid;
+
+ ///
+ /// 查找类似 分组框 的本地化字符串。
+ ///
+ public string GroupBox => Lang.GroupBox;
+
+ ///
+ /// 查找类似 组数 的本地化字符串。
+ ///
+ public string Groups => Lang.Groups;
+
+ ///
+ /// 查找类似 信息通知 的本地化字符串。
+ ///
+ public string Growl => Lang.Growl;
+
+ ///
+ /// 查找类似 检测到有新版本!是否更新? 的本地化字符串。
+ ///
+ public string GrowlAsk => Lang.GrowlAsk;
+
+ ///
+ /// 查找类似 消息通知示例 的本地化字符串。
+ ///
+ public string GrowlDemo => Lang.GrowlDemo;
+
+ ///
+ /// 查找类似 连接失败,请检查网络! 的本地化字符串。
+ ///
+ public string GrowlError => Lang.GrowlError;
+
+ ///
+ /// 查找类似 程序已崩溃~~~ 的本地化字符串。
+ ///
+ public string GrowlFatal => Lang.GrowlFatal;
+
+ ///
+ /// 查找类似 今天的天气不错~~~ 的本地化字符串。
+ ///
+ public string GrowlInfo => Lang.GrowlInfo;
+
+ ///
+ /// 查找类似 文件保存成功! 的本地化字符串。
+ ///
+ public string GrowlSuccess => Lang.GrowlSuccess;
+
+ ///
+ /// 查找类似 磁盘空间快要满了! 的本地化字符串。
+ ///
+ public string GrowlWarning => Lang.GrowlWarning;
+
+ ///
+ /// 查找类似 阴影画笔生成器 的本地化字符串。
+ ///
+ public string HatchBrushGenerator => Lang.HatchBrushGenerator;
+
+ ///
+ /// 查找类似 蜂窝布局 的本地化字符串。
+ ///
+ public string HoneycombPanel => Lang.HoneycombPanel;
+
+ ///
+ /// 查找类似 混合布局 的本地化字符串。
+ ///
+ public string HybridLayout => Lang.HybridLayout;
+
+ ///
+ /// 查找类似 忽略 的本地化字符串。
+ ///
+ public string Ignore => Lang.Ignore;
+
+ ///
+ /// 查找类似 图片块 的本地化字符串。
+ ///
+ public string ImageBlock => Lang.ImageBlock;
+
+ ///
+ /// 查找类似 图片浏览器 的本地化字符串。
+ ///
+ public string ImageBrowser => Lang.ImageBrowser;
+
+ ///
+ /// 查找类似 图片选择器 的本地化字符串。
+ ///
+ public string ImageSelector => Lang.ImageSelector;
+
+ ///
+ /// 查找类似 索引 的本地化字符串。
+ ///
+ public string Index => Lang.Index;
+
+ ///
+ /// 查找类似 信息 的本地化字符串。
+ ///
+ public string Info => Lang.Info;
+
+ ///
+ /// 查找类似 交互 的本地化字符串。
+ ///
+ public string Interacting => Lang.Interacting;
+
+ ///
+ /// 查找类似 可交互对话框 的本地化字符串。
+ ///
+ public string InteractiveDialog => Lang.InteractiveDialog;
+
+ ///
+ /// 查找类似 不是手机号码 的本地化字符串。
+ ///
+ public string IsNotPhone => Lang.IsNotPhone;
+
+ ///
+ /// 查找类似 标签 的本地化字符串。
+ ///
+ public string Label => Lang.Label;
+
+ ///
+ /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
+ ///
+ public string LangComment => Lang.LangComment;
+
+ ///
+ /// 查找类似 布局 的本地化字符串。
+ ///
+ public string Layout => Lang.Layout;
+
+ ///
+ /// 查找类似 列表框 的本地化字符串。
+ ///
+ public string ListBox => Lang.ListBox;
+
+ ///
+ /// 查找类似 列表视图 的本地化字符串。
+ ///
+ public string ListView => Lang.ListView;
+
+ ///
+ /// 查找类似 加载条 的本地化字符串。
+ ///
+ public string Loading => Lang.Loading;
+
+ ///
+ /// 查找类似 放大镜 的本地化字符串。
+ ///
+ public string Magnifier => Lang.Magnifier;
+
+ ///
+ /// 查找类似 菜单 的本地化字符串。
+ ///
+ public string Menu => Lang.Menu;
+
+ ///
+ /// 查找类似 消息框 的本地化字符串。
+ ///
+ public string MessageBox => Lang.MessageBox;
+
+ ///
+ /// 查找类似 杂项 的本地化字符串。
+ ///
+ public string Misc => Lang.Misc;
+
+ ///
+ /// 查找类似 的本地化字符串。
+ ///
+ public string Morphing_Animation => Lang.Morphing_Animation;
+
+ ///
+ /// 查找类似 名称 的本地化字符串。
+ ///
+ public string Name => Lang.Name;
+
+ ///
+ /// 查找类似 导航 的本地化字符串。
+ ///
+ public string Navigation => Lang.Navigation;
+
+ ///
+ /// 查找类似 新建窗口 的本地化字符串。
+ ///
+ public string NewWindow => Lang.NewWindow;
+
+ ///
+ /// 查找类似 下一步 的本地化字符串。
+ ///
+ public string Next => Lang.Next;
+
+ ///
+ /// 查找类似 桌面通知 的本地化字符串。
+ ///
+ public string Notification => Lang.Notification;
+
+ ///
+ /// 查找类似 托盘图标 的本地化字符串。
+ ///
+ public string NotifyIcon => Lang.NotifyIcon;
+
+ ///
+ /// 查找类似 数值选择控件 的本地化字符串。
+ ///
+ public string NumericUpDown => Lang.NumericUpDown;
+
+ ///
+ /// 查找类似 关 的本地化字符串。
+ ///
+ public string Off => Lang.Off;
+
+ ///
+ /// 查找类似 确定 的本地化字符串。
+ ///
+ public string Ok => Lang.Ok;
+
+ ///
+ /// 查找类似 开 的本地化字符串。
+ ///
+ public string On => Lang.On;
+
+ ///
+ /// 查找类似 点击打开背景模糊窗口 的本地化字符串。
+ ///
+ public string OpenBlurWindow => Lang.OpenBlurWindow;
+
+ ///
+ /// 查找类似 点击打开常规窗口 的本地化字符串。
+ ///
+ public string OpenCommonWindow => Lang.OpenCommonWindow;
+
+ ///
+ /// 查找类似 点击打开自定义内容窗口 的本地化字符串。
+ ///
+ public string OpenCustomContentWindow => Lang.OpenCustomContentWindow;
+
+ ///
+ /// 查找类似 点击打开自定义消息窗口 的本地化字符串。
+ ///
+ public string OpenCustomMessageWindow => Lang.OpenCustomMessageWindow;
+
+ ///
+ /// 查找类似 点击打开自定义非客户端区域窗口 的本地化字符串。
+ ///
+ public string OpenCustomNonClientAreaWindow => Lang.OpenCustomNonClientAreaWindow;
+
+ ///
+ /// 查找类似 点击打开辉光窗口 的本地化字符串。
+ ///
+ public string OpenGlowWindow => Lang.OpenGlowWindow;
+
+ ///
+ /// 查找类似 点击打开图片浏览器 的本地化字符串。
+ ///
+ public string OpenImageBrowser => Lang.OpenImageBrowser;
+
+ ///
+ /// 查找类似 点击打开消息窗口 的本地化字符串。
+ ///
+ public string OpenMessageWindow => Lang.OpenMessageWindow;
+
+ ///
+ /// 查找类似 点击打开鼠标跟随窗口 的本地化字符串。
+ ///
+ public string OpenMouseFollowWindow => Lang.OpenMouseFollowWindow;
+
+ ///
+ /// 查找类似 点击打开原生常规窗口 的本地化字符串。
+ ///
+ public string OpenNativeCommonWindow => Lang.OpenNativeCommonWindow;
+
+ ///
+ /// 查找类似 点击打开导航窗口 的本地化字符串。
+ ///
+ public string OpenNavigationWindow => Lang.OpenNavigationWindow;
+
+ ///
+ /// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
+ ///
+ public string OpenNoNonClientAreaDragableWindow => Lang.OpenNoNonClientAreaDragableWindow;
+
+ ///
+ /// 查找类似 打开面板 的本地化字符串。
+ ///
+ public string OpenPanel => Lang.OpenPanel;
+
+ ///
+ /// 查找类似 打开精灵 的本地化字符串。
+ ///
+ public string OpenSprite => Lang.OpenSprite;
+
+ ///
+ /// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
+ ///
+ public string OpenTouchDragMoveWindow => Lang.OpenTouchDragMoveWindow;
+
+ ///
+ /// 查找类似 轮廓文本 的本地化字符串。
+ ///
+ public string OutlineText => Lang.OutlineText;
+
+ ///
+ /// 查找类似 页码条 的本地化字符串。
+ ///
+ public string Pagination => Lang.Pagination;
+
+ ///
+ /// 查找类似 密码框 的本地化字符串。
+ ///
+ public string PasswordBox => Lang.PasswordBox;
+
+ ///
+ /// 查找类似 PIN码框 的本地化字符串。
+ ///
+ public string PinBox => Lang.PinBox;
+
+ ///
+ /// 查找类似 请输入... 的本地化字符串。
+ ///
+ public string PleaseInput => Lang.PleaseInput;
+
+ ///
+ /// 查找类似 请稍后... 的本地化字符串。
+ ///
+ public string PleaseWait => Lang.PleaseWait;
+
+ ///
+ /// 查找类似 请输入内容 的本地化字符串。
+ ///
+ public string PlsEnterContent => Lang.PlsEnterContent;
+
+ ///
+ /// 查找类似 请输入邮箱 的本地化字符串。
+ ///
+ public string PlsEnterEmail => Lang.PlsEnterEmail;
+
+ ///
+ /// 查找类似 请输入关键字 的本地化字符串。
+ ///
+ public string PlsEnterKey => Lang.PlsEnterKey;
+
+ ///
+ /// 查找类似 气泡提示 的本地化字符串。
+ ///
+ public string Poptip => Lang.Poptip;
+
+ ///
+ /// 查找类似 上左;上边;上右;右上;右边;右下;下右;下边;下左;左下;左边;左上 的本地化字符串。
+ ///
+ public string PoptipPositionStr => Lang.PoptipPositionStr;
+
+ ///
+ /// 查找类似 实用例子 的本地化字符串。
+ ///
+ public string PracticalDemos => Lang.PracticalDemos;
+
+ ///
+ /// 查找类似 上一步 的本地化字符串。
+ ///
+ public string Prev => Lang.Prev;
+
+ ///
+ /// 查找类似 预览滑块 的本地化字符串。
+ ///
+ public string PreviewSlider => Lang.PreviewSlider;
+
+ ///
+ /// 查找类似 主要 的本地化字符串。
+ ///
+ public string Primary => Lang.Primary;
+
+ ///
+ /// 查找类似 进度条 的本地化字符串。
+ ///
+ public string ProgressBar => Lang.ProgressBar;
+
+ ///
+ /// 查找类似 进度按钮 的本地化字符串。
+ ///
+ public string ProgressButton => Lang.ProgressButton;
+
+ ///
+ /// 查找类似 项目 的本地化字符串。
+ ///
+ public string Project => Lang.Project;
+
+ ///
+ /// 查找类似 属性编辑器 的本地化字符串。
+ ///
+ public string PropertyGrid => Lang.PropertyGrid;
+
+ ///
+ /// 查找类似 按住说话 的本地化字符串。
+ ///
+ public string PushToTalk => Lang.PushToTalk;
+
+ ///
+ /// 查找类似 QQ群 的本地化字符串。
+ ///
+ public string QQGroup => Lang.QQGroup;
+
+ ///
+ /// 查找类似 单选按钮 的本地化字符串。
+ ///
+ public string RadioButton => Lang.RadioButton;
+
+ ///
+ /// 查找类似 范围滑块 的本地化字符串。
+ ///
+ public string RangeSlider => Lang.RangeSlider;
+
+ ///
+ /// 查找类似 评分 的本地化字符串。
+ ///
+ public string Rate => Lang.Rate;
+
+ ///
+ /// 查找类似 群友推荐 的本地化字符串。
+ ///
+ public string Recommendation => Lang.Recommendation;
+
+ ///
+ /// 查找类似 注册 的本地化字符串。
+ ///
+ public string Register => Lang.Register;
+
+ ///
+ /// 查找类似 相对布局 的本地化字符串。
+ ///
+ public string RelativePanel => Lang.RelativePanel;
+
+ ///
+ /// 查找类似 备注 的本地化字符串。
+ ///
+ public string Remark => Lang.Remark;
+
+ ///
+ /// 查找类似 删除项 的本地化字符串。
+ ///
+ public string RemoveItem => Lang.RemoveItem;
+
+ ///
+ /// 查找类似 重复按钮 的本地化字符串。
+ ///
+ public string RepeatButton => Lang.RepeatButton;
+
+ ///
+ /// 查找类似 回复 的本地化字符串。
+ ///
+ public string Reply => Lang.Reply;
+
+ ///
+ /// 查找类似 代码仓库 的本地化字符串。
+ ///
+ public string Repository => Lang.Repository;
+
+ ///
+ /// 查找类似 响应式布局 的本地化字符串。
+ ///
+ public string ResponsiveLayout => Lang.ResponsiveLayout;
+
+ ///
+ /// 查找类似 富文本框 的本地化字符串。
+ ///
+ public string RichTextBox => Lang.RichTextBox;
+
+ ///
+ /// 查找类似 在这里右击 的本地化字符串。
+ ///
+ public string RightClickHere => Lang.RightClickHere;
+
+ ///
+ /// 查找类似 滚动块 的本地化字符串。
+ ///
+ public string RunningBlock => Lang.RunningBlock;
+
+ ///
+ /// 查找类似 截图 的本地化字符串。
+ ///
+ public string Screenshot => Lang.Screenshot;
+
+ ///
+ /// 查找类似 滚动视图 的本地化字符串。
+ ///
+ public string ScrollViewer => Lang.ScrollViewer;
+
+ ///
+ /// 查找类似 搜索栏 的本地化字符串。
+ ///
+ public string SearchBar => Lang.SearchBar;
+
+ ///
+ /// 查找类似 秒 的本地化字符串。
+ ///
+ public string Second => Lang.Second;
+
+ ///
+ /// 查找类似 选中 的本地化字符串。
+ ///
+ public string Selected => Lang.Selected;
+
+ ///
+ /// 查找类似 发送通知 的本地化字符串。
+ ///
+ public string SendNotification => Lang.SendNotification;
+
+ ///
+ /// 查找类似 徽章 的本地化字符串。
+ ///
+ public string Shield => Lang.Shield;
+
+ ///
+ /// 查找类似 在当前窗口显示 的本地化字符串。
+ ///
+ public string ShowInCurrentWindow => Lang.ShowInCurrentWindow;
+
+ ///
+ /// 查找类似 在主窗口显示 的本地化字符串。
+ ///
+ public string ShowInMainWindow => Lang.ShowInMainWindow;
+
+ ///
+ /// 查找类似 显示行号 的本地化字符串。
+ ///
+ public string ShowRowNumber => Lang.ShowRowNumber;
+
+ ///
+ /// 查找类似 侧边菜单 的本地化字符串。
+ ///
+ public string SideMenu => Lang.SideMenu;
+
+ ///
+ /// 查找类似 滑块 的本地化字符串。
+ ///
+ public string Slider => Lang.Slider;
+
+ ///
+ /// 查找类似 分割按钮 的本地化字符串。
+ ///
+ public string SplitButton => Lang.SplitButton;
+
+ ///
+ /// 查找类似 精灵 的本地化字符串。
+ ///
+ public string Sprite => Lang.Sprite;
+
+ ///
+ /// 查找类似 开始截图 的本地化字符串。
+ ///
+ public string StartScreenshot => Lang.StartScreenshot;
+
+ ///
+ /// 查找类似 保持打开 的本地化字符串。
+ ///
+ public string StaysOpen => Lang.StaysOpen;
+
+ ///
+ /// 查找类似 步骤 的本地化字符串。
+ ///
+ public string Step => Lang.Step;
+
+ ///
+ /// 查找类似 步骤条 的本地化字符串。
+ ///
+ public string StepBar => Lang.StepBar;
+
+ ///
+ /// 查找类似 样式模板 的本地化字符串。
+ ///
+ public string Styles => Lang.Styles;
+
+ ///
+ /// 查找类似 子标题 的本地化字符串。
+ ///
+ public string SubTitle => Lang.SubTitle;
+
+ ///
+ /// 查找类似 成功 的本地化字符串。
+ ///
+ public string Success => Lang.Success;
+
+ ///
+ /// 查找类似 选项卡控件 的本地化字符串。
+ ///
+ public string TabControl => Lang.TabControl;
+
+ ///
+ /// 查找类似 标签 的本地化字符串。
+ ///
+ public string Tag => Lang.Tag;
+
+ ///
+ /// 查找类似 正文 的本地化字符串。
+ ///
+ public string Text => Lang.Text;
+
+ ///
+ /// 查找类似 文本块 的本地化字符串。
+ ///
+ public string TextBlock => Lang.TextBlock;
+
+ ///
+ /// 查找类似 文本框 的本地化字符串。
+ ///
+ public string TextBox => Lang.TextBox;
+
+ ///
+ /// 查找类似 文本对话框 的本地化字符串。
+ ///
+ public string TextDialog => Lang.TextDialog;
+
+ ///
+ /// 查找类似 文本对话框(控件中) 的本地化字符串。
+ ///
+ public string TextDialogInControl => Lang.TextDialogInControl;
+
+ ///
+ /// 查找类似 文本对话框,带计时器 的本地化字符串。
+ ///
+ public string TextDialogWithTimer => Lang.TextDialogWithTimer;
+
+ ///
+ /// 查找类似 时间条 的本地化字符串。
+ ///
+ public string TimeBar => Lang.TimeBar;
+
+ ///
+ /// 查找类似 时间选择器 的本地化字符串。
+ ///
+ public string TimePicker => Lang.TimePicker;
+
+ ///
+ /// 查找类似 提示 的本地化字符串。
+ ///
+ public string Tip => Lang.Tip;
+
+ ///
+ /// 查找类似 标题 的本地化字符串。
+ ///
+ public string Title => Lang.Title;
+
+ ///
+ /// 查找类似 这是标题 的本地化字符串。
+ ///
+ public string TitleDemoStr1 => Lang.TitleDemoStr1;
+
+ ///
+ /// 查找类似 此项必填 的本地化字符串。
+ ///
+ public string TitleDemoStr2 => Lang.TitleDemoStr2;
+
+ ///
+ /// 查找类似 标题在左侧 的本地化字符串。
+ ///
+ public string TitleDemoStr3 => Lang.TitleDemoStr3;
+
+ ///
+ /// 查找类似 切换按钮 的本地化字符串。
+ ///
+ public string ToggleButton => Lang.ToggleButton;
+
+ ///
+ /// 查找类似 工具条 的本地化字符串。
+ ///
+ public string ToolBar => Lang.ToolBar;
+
+ ///
+ /// 查找类似 工具 的本地化字符串。
+ ///
+ public string Tools => Lang.Tools;
+
+ ///
+ /// 查找类似 穿梭框 的本地化字符串。
+ ///
+ public string Transfer => Lang.Transfer;
+
+ ///
+ /// 查找类似 内容过渡控件 的本地化字符串。
+ ///
+ public string TransitioningContentControl => Lang.TransitioningContentControl;
+
+ ///
+ /// 查找类似 树视图 的本地化字符串。
+ ///
+ public string TreeView => Lang.TreeView;
+
+ ///
+ /// 查找类似 试试关闭程序吧? 的本地化字符串。
+ ///
+ public string Try2CloseApp => Lang.Try2CloseApp;
+
+ ///
+ /// 查找类似 类型 的本地化字符串。
+ ///
+ public string Type => Lang.Type;
+
+ ///
+ /// 查找类似 等间距布局 的本地化字符串。
+ ///
+ public string UniformSpacingPanel => Lang.UniformSpacingPanel;
+
+ ///
+ /// 查找类似 上传文件 的本地化字符串。
+ ///
+ public string UploadFile => Lang.UploadFile;
+
+ ///
+ /// 查找类似 上传;上传中 的本地化字符串。
+ ///
+ public string UploadStr => Lang.UploadStr;
+
+ ///
+ /// 查找类似 可见性 的本地化字符串。
+ ///
+ public string Visibility => Lang.Visibility;
+
+ ///
+ /// 查找类似 VS 插件 的本地化字符串。
+ ///
+ public string Vsix => Lang.Vsix;
+
+ ///
+ /// 查找类似 警告 的本地化字符串。
+ ///
+ public string Warning => Lang.Warning;
+
+ ///
+ /// 查找类似 瀑布流 的本地化字符串。
+ ///
+ public string WaterfallPanel => Lang.WaterfallPanel;
+
+ ///
+ /// 查找类似 网站 的本地化字符串。
+ ///
+ public string Website => Lang.Website;
+
+ ///
+ /// 查找类似 窗口 的本地化字符串。
+ ///
+ public string Window => Lang.Window;
+
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ protected virtual void OnPropertyChanged(string propertyName) =>
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+}
+
+public class LangKeys
+{
+ ///
+ /// 查找类似 关于 的本地化字符串。
+ ///
+ public static string About = nameof(About);
+
+ ///
+ /// 查找类似 添加项 的本地化字符串。
+ ///
+ public static string AddItem = nameof(AddItem);
+
+ ///
+ /// 查找类似 动画路径 的本地化字符串。
+ ///
+ public static string AnimationPath = nameof(AnimationPath);
+
+ ///
+ /// 查找类似 托盘图标已打开,将隐藏窗口而不是关闭程序 的本地化字符串。
+ ///
+ public static string AppClosingTip = nameof(AppClosingTip);
+
+ ///
+ /// 查找类似 询问 的本地化字符串。
+ ///
+ public static string Ask = nameof(Ask);
+
+ ///
+ /// 查找类似 自动补全文本框 的本地化字符串。
+ ///
+ public static string AutoCompleteTextBox = nameof(AutoCompleteTextBox);
+
+ ///
+ /// 查找类似 标记 的本地化字符串。
+ ///
+ public static string Badge = nameof(Badge);
+
+ ///
+ /// 查找类似 填写基本信息 的本地化字符串。
+ ///
+ public static string BasicInfo = nameof(BasicInfo);
+
+ ///
+ /// 查找类似 基础布局 的本地化字符串。
+ ///
+ public static string BasicLayout = nameof(BasicLayout);
+
+ ///
+ /// 查找类似 闪烁 的本地化字符串。
+ ///
+ public static string Blink = nameof(Blink);
+
+ ///
+ /// 查找类似 博客 的本地化字符串。
+ ///
+ public static string Blog = nameof(Blog);
+
+ ///
+ /// 查找类似 边框 的本地化字符串。
+ ///
+ public static string Border = nameof(Border);
+
+ ///
+ /// 查找类似 画刷 的本地化字符串。
+ ///
+ public static string Brush = nameof(Brush);
+
+ ///
+ /// 查找类似 按钮 的本地化字符串。
+ ///
+ public static string Button = nameof(Button);
+
+ ///
+ /// 查找类似 自定义按钮 的本地化字符串。
+ ///
+ public static string ButtonCustom = nameof(ButtonCustom);
+
+ ///
+ /// 查找类似 按钮组 的本地化字符串。
+ ///
+ public static string ButtonGroup = nameof(ButtonGroup);
+
+ ///
+ /// 查找类似 日历 的本地化字符串。
+ ///
+ public static string Calendar = nameof(Calendar);
+
+ ///
+ /// 查找类似 带时钟的日历 的本地化字符串。
+ ///
+ public static string CalendarWithClock = nameof(CalendarWithClock);
+
+ ///
+ /// 查找类似 卡片 的本地化字符串。
+ ///
+ public static string Card = nameof(Card);
+
+ ///
+ /// 查找类似 轮播 的本地化字符串。
+ ///
+ public static string Carousel = nameof(Carousel);
+
+ ///
+ /// 查找类似 是否重启以更改语言? 的本地化字符串。
+ ///
+ public static string ChangeLangAsk = nameof(ChangeLangAsk);
+
+ ///
+ /// 查找类似 对话气泡 的本地化字符串。
+ ///
+ public static string ChatBubble = nameof(ChatBubble);
+
+ ///
+ /// 查找类似 讨论室 的本地化字符串。
+ ///
+ public static string Chatroom = nameof(Chatroom);
+
+ ///
+ /// 查找类似 复选框 的本地化字符串。
+ ///
+ public static string CheckBox = nameof(CheckBox);
+
+ ///
+ /// 查找类似 多选组合框 的本地化字符串。
+ ///
+ public static string CheckComboBox = nameof(CheckComboBox);
+
+ ///
+ /// 查找类似 圆形布局 的本地化字符串。
+ ///
+ public static string CirclePanel = nameof(CirclePanel);
+
+ ///
+ /// 查找类似 清空 的本地化字符串。
+ ///
+ public static string Clear = nameof(Clear);
+
+ ///
+ /// 查找类似 点击计数 的本地化字符串。
+ ///
+ public static string Click2Count = nameof(Click2Count);
+
+ ///
+ /// 查找类似 时钟 的本地化字符串。
+ ///
+ public static string Clock = nameof(Clock);
+
+ ///
+ /// 查找类似 颜色拾取器 的本地化字符串。
+ ///
+ public static string ColorPicker = nameof(ColorPicker);
+
+ ///
+ /// 查找类似 分栏偏移 的本地化字符串。
+ ///
+ public static string ColumnOffset = nameof(ColumnOffset);
+
+ ///
+ /// 查找类似 分栏间隔 的本地化字符串。
+ ///
+ public static string ColumnSpacing = nameof(ColumnSpacing);
+
+ ///
+ /// 查找类似 组合框 的本地化字符串。
+ ///
+ public static string ComboBox = nameof(ComboBox);
+
+ ///
+ /// 查找类似 敬请期待 的本地化字符串。
+ ///
+ public static string ComingSoon = nameof(ComingSoon);
+
+ ///
+ /// 查找类似 评论 的本地化字符串。
+ ///
+ public static string Comment = nameof(Comment);
+
+ ///
+ /// 查找类似 一般 的本地化字符串。
+ ///
+ public static string Common = nameof(Common);
+
+ ///
+ /// 查找类似 对比滑块 的本地化字符串。
+ ///
+ public static string CompareSlider = nameof(CompareSlider);
+
+ ///
+ /// 查找类似 完成 的本地化字符串。
+ ///
+ public static string Complete = nameof(Complete);
+
+ ///
+ /// 查找类似 这是内容 的本地化字符串。
+ ///
+ public static string ContentDemoStr = nameof(ContentDemoStr);
+
+ ///
+ /// 查找类似 贡献者 的本地化字符串。
+ ///
+ public static string Contributors = nameof(Contributors);
+
+ ///
+ /// 查找类似 控件 的本地化字符串。
+ ///
+ public static string Controls = nameof(Controls);
+
+ ///
+ /// 查找类似 封面流 的本地化字符串。
+ ///
+ public static string CoverFlow = nameof(CoverFlow);
+
+ ///
+ /// 查找类似 封面视图 的本地化字符串。
+ ///
+ public static string CoverView = nameof(CoverView);
+
+ ///
+ /// 查找类似 危险 的本地化字符串。
+ ///
+ public static string Danger = nameof(Danger);
+
+ ///
+ /// 查找类似 数据展示 的本地化字符串。
+ ///
+ public static string DataDisplay = nameof(DataDisplay);
+
+ ///
+ /// 查找类似 数据录入 的本地化字符串。
+ ///
+ public static string DataEntry = nameof(DataEntry);
+
+ ///
+ /// 查找类似 数据表格 的本地化字符串。
+ ///
+ public static string DataGrid = nameof(DataGrid);
+
+ ///
+ /// 查找类似 日期选择器 的本地化字符串。
+ ///
+ public static string DatePicker = nameof(DatePicker);
+
+ ///
+ /// 查找类似 日期时间选择器 的本地化字符串。
+ ///
+ public static string DateTimePicker = nameof(DateTimePicker);
+
+ ///
+ /// 查找类似 默认 的本地化字符串。
+ ///
+ public static string Default = nameof(Default);
+
+ ///
+ /// 查找类似 示例 的本地化字符串。
+ ///
+ public static string Demo = nameof(Demo);
+
+ ///
+ /// 查找类似 对话框 的本地化字符串。
+ ///
+ public static string Dialog = nameof(Dialog);
+
+ ///
+ /// 查找类似 对话框示例 的本地化字符串。
+ ///
+ public static string DialogDemo = nameof(DialogDemo);
+
+ ///
+ /// 查找类似 分割线 的本地化字符串。
+ ///
+ public static string Divider = nameof(Divider);
+
+ ///
+ /// 查找类似 中文文档 的本地化字符串。
+ ///
+ public static string Doc_cn = nameof(Doc_cn);
+
+ ///
+ /// 查找类似 英文文档 的本地化字符串。
+ ///
+ public static string Doc_en = nameof(Doc_en);
+
+ ///
+ /// 查找类似 文献资料 的本地化字符串。
+ ///
+ public static string Documentation = nameof(Documentation);
+
+ ///
+ /// 查找类似 在这里拖拽 的本地化字符串。
+ ///
+ public static string DragHere = nameof(DragHere);
+
+ ///
+ /// 查找类似 抽屉 的本地化字符串。
+ ///
+ public static string Drawer = nameof(Drawer);
+
+ ///
+ /// 查找类似 效果 的本地化字符串。
+ ///
+ public static string Effects = nameof(Effects);
+
+ ///
+ /// 查找类似 元素组 的本地化字符串。
+ ///
+ public static string ElementGroup = nameof(ElementGroup);
+
+ ///
+ /// 查找类似 邮箱 的本地化字符串。
+ ///
+ public static string Email = nameof(Email);
+
+ ///
+ /// 查找类似 空状态 的本地化字符串。
+ ///
+ public static string Empty = nameof(Empty);
+
+ ///
+ /// 查找类似 错误 的本地化字符串。
+ ///
+ public static string Error = nameof(Error);
+
+ ///
+ /// 查找类似 退出 的本地化字符串。
+ ///
+ public static string Exit = nameof(Exit);
+
+ ///
+ /// 查找类似 展开框 的本地化字符串。
+ ///
+ public static string Expander = nameof(Expander);
+
+ ///
+ /// 查找类似 严重 的本地化字符串。
+ ///
+ public static string Fatal = nameof(Fatal);
+
+ ///
+ /// 查找类似 反馈 的本地化字符串。
+ ///
+ public static string Feedback = nameof(Feedback);
+
+ ///
+ /// 查找类似 弹性盒子 的本地化字符串。
+ ///
+ public static string FlexPanel = nameof(FlexPanel);
+
+ ///
+ /// 查找类似 翻页时钟 的本地化字符串。
+ ///
+ public static string FlipClock = nameof(FlipClock);
+
+ ///
+ /// 查找类似 漂浮块 的本地化字符串。
+ ///
+ public static string FloatingBlock = nameof(FloatingBlock);
+
+ ///
+ /// 查找类似 流文档 的本地化字符串。
+ ///
+ public static string FlowDocument = nameof(FlowDocument);
+
+ ///
+ /// 查找类似 流文档单页视图 的本地化字符串。
+ ///
+ public static string FlowDocumentPageViewer = nameof(FlowDocumentPageViewer);
+
+ ///
+ /// 查找类似 流文档查看器 的本地化字符串。
+ ///
+ public static string FlowDocumentReader = nameof(FlowDocumentReader);
+
+ ///
+ /// 查找类似 流文档滚动视图 的本地化字符串。
+ ///
+ public static string FlowDocumentScrollViewer = nameof(FlowDocumentScrollViewer);
+
+ ///
+ /// 查找类似 导航框架 的本地化字符串。
+ ///
+ public static string Frame = nameof(Frame);
+
+ ///
+ /// 查找类似 几何形状 的本地化字符串。
+ ///
+ public static string Geometry = nameof(Geometry);
+
+ ///
+ /// 查找类似 Gif图片 的本地化字符串。
+ ///
+ public static string GifImage = nameof(GifImage);
+
+ ///
+ /// 查找类似 回到顶部 的本地化字符串。
+ ///
+ public static string GotoTop = nameof(GotoTop);
+
+ ///
+ /// 查找类似 头像 的本地化字符串。
+ ///
+ public static string Gravatar = nameof(Gravatar);
+
+ ///
+ /// 查找类似 栅格 的本地化字符串。
+ ///
+ public static string Grid = nameof(Grid);
+
+ ///
+ /// 查找类似 分组框 的本地化字符串。
+ ///
+ public static string GroupBox = nameof(GroupBox);
+
+ ///
+ /// 查找类似 组数 的本地化字符串。
+ ///
+ public static string Groups = nameof(Groups);
+
+ ///
+ /// 查找类似 信息通知 的本地化字符串。
+ ///
+ public static string Growl = nameof(Growl);
+
+ ///
+ /// 查找类似 检测到有新版本!是否更新? 的本地化字符串。
+ ///
+ public static string GrowlAsk = nameof(GrowlAsk);
+
+ ///
+ /// 查找类似 消息通知示例 的本地化字符串。
+ ///
+ public static string GrowlDemo = nameof(GrowlDemo);
+
+ ///
+ /// 查找类似 连接失败,请检查网络! 的本地化字符串。
+ ///
+ public static string GrowlError = nameof(GrowlError);
+
+ ///
+ /// 查找类似 程序已崩溃~~~ 的本地化字符串。
+ ///
+ public static string GrowlFatal = nameof(GrowlFatal);
+
+ ///
+ /// 查找类似 今天的天气不错~~~ 的本地化字符串。
+ ///
+ public static string GrowlInfo = nameof(GrowlInfo);
+
+ ///
+ /// 查找类似 文件保存成功! 的本地化字符串。
+ ///
+ public static string GrowlSuccess = nameof(GrowlSuccess);
+
+ ///
+ /// 查找类似 磁盘空间快要满了! 的本地化字符串。
+ ///
+ public static string GrowlWarning = nameof(GrowlWarning);
+
+ ///
+ /// 查找类似 阴影画笔生成器 的本地化字符串。
+ ///
+ public static string HatchBrushGenerator = nameof(HatchBrushGenerator);
+
+ ///
+ /// 查找类似 蜂窝布局 的本地化字符串。
+ ///
+ public static string HoneycombPanel = nameof(HoneycombPanel);
+
+ ///
+ /// 查找类似 混合布局 的本地化字符串。
+ ///
+ public static string HybridLayout = nameof(HybridLayout);
+
+ ///
+ /// 查找类似 忽略 的本地化字符串。
+ ///
+ public static string Ignore = nameof(Ignore);
+
+ ///
+ /// 查找类似 图片块 的本地化字符串。
+ ///
+ public static string ImageBlock = nameof(ImageBlock);
+
+ ///
+ /// 查找类似 图片浏览器 的本地化字符串。
+ ///
+ public static string ImageBrowser = nameof(ImageBrowser);
+
+ ///
+ /// 查找类似 图片选择器 的本地化字符串。
+ ///
+ public static string ImageSelector = nameof(ImageSelector);
+
+ ///
+ /// 查找类似 索引 的本地化字符串。
+ ///
+ public static string Index = nameof(Index);
+
+ ///
+ /// 查找类似 信息 的本地化字符串。
+ ///
+ public static string Info = nameof(Info);
+
+ ///
+ /// 查找类似 交互 的本地化字符串。
+ ///
+ public static string Interacting = nameof(Interacting);
+
+ ///
+ /// 查找类似 可交互对话框 的本地化字符串。
+ ///
+ public static string InteractiveDialog = nameof(InteractiveDialog);
+
+ ///
+ /// 查找类似 不是手机号码 的本地化字符串。
+ ///
+ public static string IsNotPhone = nameof(IsNotPhone);
+
+ ///
+ /// 查找类似 标签 的本地化字符串。
+ ///
+ public static string Label = nameof(Label);
+
+ ///
+ /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
+ ///
+ public static string LangComment = nameof(LangComment);
+
+ ///
+ /// 查找类似 布局 的本地化字符串。
+ ///
+ public static string Layout = nameof(Layout);
+
+ ///
+ /// 查找类似 列表框 的本地化字符串。
+ ///
+ public static string ListBox = nameof(ListBox);
+
+ ///
+ /// 查找类似 列表视图 的本地化字符串。
+ ///
+ public static string ListView = nameof(ListView);
+
+ ///
+ /// 查找类似 加载条 的本地化字符串。
+ ///
+ public static string Loading = nameof(Loading);
+
+ ///
+ /// 查找类似 放大镜 的本地化字符串。
+ ///
+ public static string Magnifier = nameof(Magnifier);
+
+ ///
+ /// 查找类似 菜单 的本地化字符串。
+ ///
+ public static string Menu = nameof(Menu);
+
+ ///
+ /// 查找类似 消息框 的本地化字符串。
+ ///
+ public static string MessageBox = nameof(MessageBox);
+
+ ///
+ /// 查找类似 杂项 的本地化字符串。
+ ///
+ public static string Misc = nameof(Misc);
+
+ ///
+ /// 查找类似 的本地化字符串。
+ ///
+ public static string Morphing_Animation = nameof(Morphing_Animation);
+
+ ///
+ /// 查找类似 名称 的本地化字符串。
+ ///
+ public static string Name = nameof(Name);
+
+ ///
+ /// 查找类似 导航 的本地化字符串。
+ ///
+ public static string Navigation = nameof(Navigation);
+
+ ///
+ /// 查找类似 新建窗口 的本地化字符串。
+ ///
+ public static string NewWindow = nameof(NewWindow);
+
+ ///
+ /// 查找类似 下一步 的本地化字符串。
+ ///
+ public static string Next = nameof(Next);
+
+ ///
+ /// 查找类似 桌面通知 的本地化字符串。
+ ///
+ public static string Notification = nameof(Notification);
+
+ ///
+ /// 查找类似 托盘图标 的本地化字符串。
+ ///
+ public static string NotifyIcon = nameof(NotifyIcon);
+
+ ///
+ /// 查找类似 数值选择控件 的本地化字符串。
+ ///
+ public static string NumericUpDown = nameof(NumericUpDown);
+
+ ///
+ /// 查找类似 关 的本地化字符串。
+ ///
+ public static string Off = nameof(Off);
+
+ ///
+ /// 查找类似 确定 的本地化字符串。
+ ///
+ public static string Ok = nameof(Ok);
+
+ ///
+ /// 查找类似 开 的本地化字符串。
+ ///
+ public static string On = nameof(On);
+
+ ///
+ /// 查找类似 点击打开背景模糊窗口 的本地化字符串。
+ ///
+ public static string OpenBlurWindow = nameof(OpenBlurWindow);
+
+ ///
+ /// 查找类似 点击打开常规窗口 的本地化字符串。
+ ///
+ public static string OpenCommonWindow = nameof(OpenCommonWindow);
+
+ ///
+ /// 查找类似 点击打开自定义内容窗口 的本地化字符串。
+ ///
+ public static string OpenCustomContentWindow = nameof(OpenCustomContentWindow);
+
+ ///
+ /// 查找类似 点击打开自定义消息窗口 的本地化字符串。
+ ///
+ public static string OpenCustomMessageWindow = nameof(OpenCustomMessageWindow);
+
+ ///
+ /// 查找类似 点击打开自定义非客户端区域窗口 的本地化字符串。
+ ///
+ public static string OpenCustomNonClientAreaWindow = nameof(OpenCustomNonClientAreaWindow);
+
+ ///
+ /// 查找类似 点击打开辉光窗口 的本地化字符串。
+ ///
+ public static string OpenGlowWindow = nameof(OpenGlowWindow);
+
+ ///
+ /// 查找类似 点击打开图片浏览器 的本地化字符串。
+ ///
+ public static string OpenImageBrowser = nameof(OpenImageBrowser);
+
+ ///
+ /// 查找类似 点击打开消息窗口 的本地化字符串。
+ ///
+ public static string OpenMessageWindow = nameof(OpenMessageWindow);
+
+ ///
+ /// 查找类似 点击打开鼠标跟随窗口 的本地化字符串。
+ ///
+ public static string OpenMouseFollowWindow = nameof(OpenMouseFollowWindow);
+
+ ///
+ /// 查找类似 点击打开原生常规窗口 的本地化字符串。
+ ///
+ public static string OpenNativeCommonWindow = nameof(OpenNativeCommonWindow);
+
+ ///
+ /// 查找类似 点击打开导航窗口 的本地化字符串。
+ ///
+ public static string OpenNavigationWindow = nameof(OpenNavigationWindow);
+
+ ///
+ /// 查找类似 打开无非客户端区域可拖拽窗口 的本地化字符串。
+ ///
+ public static string OpenNoNonClientAreaDragableWindow = nameof(OpenNoNonClientAreaDragableWindow);
+
+ ///
+ /// 查找类似 打开面板 的本地化字符串。
+ ///
+ public static string OpenPanel = nameof(OpenPanel);
+
+ ///
+ /// 查找类似 打开精灵 的本地化字符串。
+ ///
+ public static string OpenSprite = nameof(OpenSprite);
+
+ ///
+ /// 查找类似 点击打开触摸拖动窗口 的本地化字符串。
+ ///
+ public static string OpenTouchDragMoveWindow = nameof(OpenTouchDragMoveWindow);
+
+ ///
+ /// 查找类似 轮廓文本 的本地化字符串。
+ ///
+ public static string OutlineText = nameof(OutlineText);
+
+ ///
+ /// 查找类似 页码条 的本地化字符串。
+ ///
+ public static string Pagination = nameof(Pagination);
+
+ ///
+ /// 查找类似 密码框 的本地化字符串。
+ ///
+ public static string PasswordBox = nameof(PasswordBox);
+
+ ///
+ /// 查找类似 PIN码框 的本地化字符串。
+ ///
+ public static string PinBox = nameof(PinBox);
+
+ ///
+ /// 查找类似 请输入... 的本地化字符串。
+ ///
+ public static string PleaseInput = nameof(PleaseInput);
+
+ ///
+ /// 查找类似 请稍后... 的本地化字符串。
+ ///
+ public static string PleaseWait = nameof(PleaseWait);
+
+ ///
+ /// 查找类似 请输入内容 的本地化字符串。
+ ///
+ public static string PlsEnterContent = nameof(PlsEnterContent);
+
+ ///
+ /// 查找类似 请输入邮箱 的本地化字符串。
+ ///
+ public static string PlsEnterEmail = nameof(PlsEnterEmail);
+
+ ///
+ /// 查找类似 请输入关键字 的本地化字符串。
+ ///
+ public static string PlsEnterKey = nameof(PlsEnterKey);
+
+ ///
+ /// 查找类似 气泡提示 的本地化字符串。
+ ///
+ public static string Poptip = nameof(Poptip);
+
+ ///
+ /// 查找类似 上左;上边;上右;右上;右边;右下;下右;下边;下左;左下;左边;左上 的本地化字符串。
+ ///
+ public static string PoptipPositionStr = nameof(PoptipPositionStr);
+
+ ///
+ /// 查找类似 实用例子 的本地化字符串。
+ ///
+ public static string PracticalDemos = nameof(PracticalDemos);
+
+ ///
+ /// 查找类似 上一步 的本地化字符串。
+ ///
+ public static string Prev = nameof(Prev);
+
+ ///
+ /// 查找类似 预览滑块 的本地化字符串。
+ ///
+ public static string PreviewSlider = nameof(PreviewSlider);
+
+ ///
+ /// 查找类似 主要 的本地化字符串。
+ ///
+ public static string Primary = nameof(Primary);
+
+ ///
+ /// 查找类似 进度条 的本地化字符串。
+ ///
+ public static string ProgressBar = nameof(ProgressBar);
+
+ ///
+ /// 查找类似 进度按钮 的本地化字符串。
+ ///
+ public static string ProgressButton = nameof(ProgressButton);
+
+ ///
+ /// 查找类似 项目 的本地化字符串。
+ ///
+ public static string Project = nameof(Project);
+
+ ///
+ /// 查找类似 属性编辑器 的本地化字符串。
+ ///
+ public static string PropertyGrid = nameof(PropertyGrid);
+
+ ///
+ /// 查找类似 按住说话 的本地化字符串。
+ ///
+ public static string PushToTalk = nameof(PushToTalk);
+
+ ///
+ /// 查找类似 QQ群 的本地化字符串。
+ ///
+ public static string QQGroup = nameof(QQGroup);
+
+ ///
+ /// 查找类似 单选按钮 的本地化字符串。
+ ///
+ public static string RadioButton = nameof(RadioButton);
+
+ ///
+ /// 查找类似 范围滑块 的本地化字符串。
+ ///
+ public static string RangeSlider = nameof(RangeSlider);
+
+ ///
+ /// 查找类似 评分 的本地化字符串。
+ ///
+ public static string Rate = nameof(Rate);
+
+ ///
+ /// 查找类似 群友推荐 的本地化字符串。
+ ///
+ public static string Recommendation = nameof(Recommendation);
+
+ ///
+ /// 查找类似 注册 的本地化字符串。
+ ///
+ public static string Register = nameof(Register);
+
+ ///
+ /// 查找类似 相对布局 的本地化字符串。
+ ///
+ public static string RelativePanel = nameof(RelativePanel);
+
+ ///
+ /// 查找类似 备注 的本地化字符串。
+ ///
+ public static string Remark = nameof(Remark);
+
+ ///
+ /// 查找类似 删除项 的本地化字符串。
+ ///
+ public static string RemoveItem = nameof(RemoveItem);
+
+ ///
+ /// 查找类似 重复按钮 的本地化字符串。
+ ///
+ public static string RepeatButton = nameof(RepeatButton);
+
+ ///
+ /// 查找类似 回复 的本地化字符串。
+ ///
+ public static string Reply = nameof(Reply);
+
+ ///
+ /// 查找类似 代码仓库 的本地化字符串。
+ ///
+ public static string Repository = nameof(Repository);
+
+ ///
+ /// 查找类似 响应式布局 的本地化字符串。
+ ///
+ public static string ResponsiveLayout = nameof(ResponsiveLayout);
+
+ ///
+ /// 查找类似 富文本框 的本地化字符串。
+ ///
+ public static string RichTextBox = nameof(RichTextBox);
+
+ ///
+ /// 查找类似 在这里右击 的本地化字符串。
+ ///
+ public static string RightClickHere = nameof(RightClickHere);
+
+ ///
+ /// 查找类似 滚动块 的本地化字符串。
+ ///
+ public static string RunningBlock = nameof(RunningBlock);
+
+ ///
+ /// 查找类似 截图 的本地化字符串。
+ ///
+ public static string Screenshot = nameof(Screenshot);
+
+ ///
+ /// 查找类似 滚动视图 的本地化字符串。
+ ///
+ public static string ScrollViewer = nameof(ScrollViewer);
+
+ ///
+ /// 查找类似 搜索栏 的本地化字符串。
+ ///
+ public static string SearchBar = nameof(SearchBar);
+
+ ///
+ /// 查找类似 秒 的本地化字符串。
+ ///
+ public static string Second = nameof(Second);
+
+ ///
+ /// 查找类似 选中 的本地化字符串。
+ ///
+ public static string Selected = nameof(Selected);
+
+ ///
+ /// 查找类似 发送通知 的本地化字符串。
+ ///
+ public static string SendNotification = nameof(SendNotification);
+
+ ///
+ /// 查找类似 徽章 的本地化字符串。
+ ///
+ public static string Shield = nameof(Shield);
+
+ ///
+ /// 查找类似 在当前窗口显示 的本地化字符串。
+ ///
+ public static string ShowInCurrentWindow = nameof(ShowInCurrentWindow);
+
+ ///
+ /// 查找类似 在主窗口显示 的本地化字符串。
+ ///
+ public static string ShowInMainWindow = nameof(ShowInMainWindow);
+
+ ///
+ /// 查找类似 显示行号 的本地化字符串。
+ ///
+ public static string ShowRowNumber = nameof(ShowRowNumber);
+
+ ///
+ /// 查找类似 侧边菜单 的本地化字符串。
+ ///
+ public static string SideMenu = nameof(SideMenu);
+
+ ///
+ /// 查找类似 滑块 的本地化字符串。
+ ///
+ public static string Slider = nameof(Slider);
+
+ ///
+ /// 查找类似 分割按钮 的本地化字符串。
+ ///
+ public static string SplitButton = nameof(SplitButton);
+
+ ///
+ /// 查找类似 精灵 的本地化字符串。
+ ///
+ public static string Sprite = nameof(Sprite);
+
+ ///
+ /// 查找类似 开始截图 的本地化字符串。
+ ///
+ public static string StartScreenshot = nameof(StartScreenshot);
+
+ ///
+ /// 查找类似 保持打开 的本地化字符串。
+ ///
+ public static string StaysOpen = nameof(StaysOpen);
+
+ ///
+ /// 查找类似 步骤 的本地化字符串。
+ ///
+ public static string Step = nameof(Step);
+
+ ///
+ /// 查找类似 步骤条 的本地化字符串。
+ ///
+ public static string StepBar = nameof(StepBar);
+
+ ///
+ /// 查找类似 样式模板 的本地化字符串。
+ ///
+ public static string Styles = nameof(Styles);
+
+ ///
+ /// 查找类似 子标题 的本地化字符串。
+ ///
+ public static string SubTitle = nameof(SubTitle);
+
+ ///
+ /// 查找类似 成功 的本地化字符串。
+ ///
+ public static string Success = nameof(Success);
+
+ ///
+ /// 查找类似 选项卡控件 的本地化字符串。
+ ///
+ public static string TabControl = nameof(TabControl);
+
+ ///
+ /// 查找类似 标签 的本地化字符串。
+ ///
+ public static string Tag = nameof(Tag);
+
+ ///
+ /// 查找类似 正文 的本地化字符串。
+ ///
+ public static string Text = nameof(Text);
+
+ ///
+ /// 查找类似 文本块 的本地化字符串。
+ ///
+ public static string TextBlock = nameof(TextBlock);
+
+ ///
+ /// 查找类似 文本框 的本地化字符串。
+ ///
+ public static string TextBox = nameof(TextBox);
+
+ ///
+ /// 查找类似 文本对话框 的本地化字符串。
+ ///
+ public static string TextDialog = nameof(TextDialog);
+
+ ///
+ /// 查找类似 文本对话框(控件中) 的本地化字符串。
+ ///
+ public static string TextDialogInControl = nameof(TextDialogInControl);
+
+ ///
+ /// 查找类似 文本对话框,带计时器 的本地化字符串。
+ ///
+ public static string TextDialogWithTimer = nameof(TextDialogWithTimer);
+
+ ///
+ /// 查找类似 时间条 的本地化字符串。
+ ///
+ public static string TimeBar = nameof(TimeBar);
+
+ ///
+ /// 查找类似 时间选择器 的本地化字符串。
+ ///
+ public static string TimePicker = nameof(TimePicker);
+
+ ///
+ /// 查找类似 提示 的本地化字符串。
+ ///
+ public static string Tip = nameof(Tip);
+
+ ///
+ /// 查找类似 标题 的本地化字符串。
+ ///
+ public static string Title = nameof(Title);
+
+ ///
+ /// 查找类似 这是标题 的本地化字符串。
+ ///
+ public static string TitleDemoStr1 = nameof(TitleDemoStr1);
+
+ ///
+ /// 查找类似 此项必填 的本地化字符串。
+ ///
+ public static string TitleDemoStr2 = nameof(TitleDemoStr2);
+
+ ///
+ /// 查找类似 标题在左侧 的本地化字符串。
+ ///
+ public static string TitleDemoStr3 = nameof(TitleDemoStr3);
+
+ ///
+ /// 查找类似 切换按钮 的本地化字符串。
+ ///
+ public static string ToggleButton = nameof(ToggleButton);
+
+ ///
+ /// 查找类似 工具条 的本地化字符串。
+ ///
+ public static string ToolBar = nameof(ToolBar);
+
+ ///
+ /// 查找类似 工具 的本地化字符串。
+ ///
+ public static string Tools = nameof(Tools);
+
+ ///
+ /// 查找类似 穿梭框 的本地化字符串。
+ ///
+ public static string Transfer = nameof(Transfer);
+
+ ///
+ /// 查找类似 内容过渡控件 的本地化字符串。
+ ///
+ public static string TransitioningContentControl = nameof(TransitioningContentControl);
+
+ ///
+ /// 查找类似 树视图 的本地化字符串。
+ ///
+ public static string TreeView = nameof(TreeView);
+
+ ///
+ /// 查找类似 试试关闭程序吧? 的本地化字符串。
+ ///
+ public static string Try2CloseApp = nameof(Try2CloseApp);
+
+ ///
+ /// 查找类似 类型 的本地化字符串。
+ ///
+ public static string Type = nameof(Type);
+
+ ///
+ /// 查找类似 等间距布局 的本地化字符串。
+ ///
+ public static string UniformSpacingPanel = nameof(UniformSpacingPanel);
+
+ ///
+ /// 查找类似 上传文件 的本地化字符串。
+ ///
+ public static string UploadFile = nameof(UploadFile);
+
+ ///
+ /// 查找类似 上传;上传中 的本地化字符串。
+ ///
+ public static string UploadStr = nameof(UploadStr);
+
+ ///
+ /// 查找类似 可见性 的本地化字符串。
+ ///
+ public static string Visibility = nameof(Visibility);
+
+ ///
+ /// 查找类似 VS 插件 的本地化字符串。
+ ///
+ public static string Vsix = nameof(Vsix);
+
+ ///
+ /// 查找类似 警告 的本地化字符串。
+ ///
+ public static string Warning = nameof(Warning);
+
+ ///
+ /// 查找类似 瀑布流 的本地化字符串。
+ ///
+ public static string WaterfallPanel = nameof(WaterfallPanel);
+
+ ///
+ /// 查找类似 网站 的本地化字符串。
+ ///
+ public static string Website = nameof(Website);
+
+ ///
+ /// 查找类似 窗口 的本地化字符串。
+ ///
+ public static string Window = nameof(Window);
+
}
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/DemoTheme.cs b/src/Shared/HandyControlDemo_Shared/Resources/DemoTheme.cs
index cbade368..b9294fc4 100644
--- a/src/Shared/HandyControlDemo_Shared/Resources/DemoTheme.cs
+++ b/src/Shared/HandyControlDemo_Shared/Resources/DemoTheme.cs
@@ -4,16 +4,15 @@ using HandyControl.Data;
using HandyControl.Themes;
using HandyControl.Tools;
-namespace HandyControlDemo.Resources
-{
- public class DemoTheme : Theme
- {
- public override ResourceDictionary GetSkin(SkinType skinType) =>
- ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
+namespace HandyControlDemo.Resources;
- public override ResourceDictionary GetTheme() => new()
- {
- Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
- };
- }
+public class DemoTheme : Theme
+{
+ public override ResourceDictionary GetSkin(SkinType skinType) =>
+ ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skinType);
+
+ public override ResourceDictionary GetTheme() => new()
+ {
+ Source = new Uri("pack://application:,,,/HandyControlDemo;component/Resources/Themes/Theme.xaml")
+ };
}
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
index ff888595..e6cf4862 100644
--- a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
+++ b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
@@ -42,7 +42,6 @@
@@ -79,8 +78,10 @@
@@ -176,7 +177,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/Service/Data/DataService.cs b/src/Shared/HandyControlDemo_Shared/Service/Data/DataService.cs
index dd79df82..e4424361 100644
--- a/src/Shared/HandyControlDemo_Shared/Service/Data/DataService.cs
+++ b/src/Shared/HandyControlDemo_Shared/Service/Data/DataService.cs
@@ -12,443 +12,430 @@ using HandyControlDemo.Properties.Langs;
using HandyControlDemo.Tools.Converter;
using Newtonsoft.Json;
-namespace HandyControlDemo.Service
+namespace HandyControlDemo.Service;
+
+public class DataService
{
- public class DataService
+ internal ObservableCollection GetTabControlDemoDataList()
{
- internal ObservableCollection GetTabControlDemoDataList()
+ return new()
{
- return new()
+ new TabControlDemoModel
{
- new TabControlDemoModel
- {
- Header = "Success",
- BackgroundToken = ResourceToken.SuccessBrush
- },
- new TabControlDemoModel
- {
- Header = "Primary",
- BackgroundToken = ResourceToken.PrimaryBrush
- },
- new TabControlDemoModel
- {
- Header = "Warning",
- BackgroundToken = ResourceToken.WarningBrush
- },
- new TabControlDemoModel
- {
- Header = "Danger",
- BackgroundToken = ResourceToken.DangerBrush
- },
- new TabControlDemoModel
- {
- Header = "Info",
- BackgroundToken = ResourceToken.InfoBrush
- }
- };
- }
-
- internal List GetDemoDataList()
- {
- var list = new List();
- for (var i = 1; i <= 20; i++)
+ Header = "Success",
+ BackgroundToken = ResourceToken.SuccessBrush
+ },
+ new TabControlDemoModel
{
- var dataList = new List();
- for (var j = 0; j < 3; j++)
- {
- dataList.Add(new DemoDataModel
- {
- Index = j,
- IsSelected = j % 2 == 0,
- Name = $"SubName{j}",
- Type = (DemoType) j
- });
- }
- var model = new DemoDataModel
- {
- Index = i,
- IsSelected = i % 2 == 0,
- Name = $"Name{i}",
- Type = (DemoType) (i % 6 + 1),
- DataList = dataList,
- ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{i % 6 + 1}.png",
- Remark = new string(i.ToString()[0], 10)
- };
- list.Add(model);
+ Header = "Primary",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new TabControlDemoModel
+ {
+ Header = "Warning",
+ BackgroundToken = ResourceToken.WarningBrush
+ },
+ new TabControlDemoModel
+ {
+ Header = "Danger",
+ BackgroundToken = ResourceToken.DangerBrush
+ },
+ new TabControlDemoModel
+ {
+ Header = "Info",
+ BackgroundToken = ResourceToken.InfoBrush
}
+ };
+ }
- return list;
- }
-
- internal List GetDemoDataList(int count)
+ internal List GetDemoDataList()
+ {
+ var list = new List();
+ for (var i = 1; i <= 20; i++)
{
- var list = new List();
- for (var i = 1; i <= count; i++)
+ var dataList = new List();
+ for (var j = 0; j < 3; j++)
{
- var index = i % 6 + 1;
- var model = new DemoDataModel
+ dataList.Add(new DemoDataModel
{
- Index = i,
- IsSelected = i % 2 == 0,
- Name = $"Name{i}",
- Type = (DemoType) index,
- ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{index}.png",
- Remark = new string(i.ToString()[0], 10)
- };
- list.Add(model);
- }
-
- return list;
- }
-
- internal List GetComboBoxDemoDataList()
- {
- var converter = new StringRepeatConverter();
- var list = new List();
- for (var i = 1; i <= 9; i++)
- {
- list.Add($"{converter.Convert(Lang.Text, null, i, CultureInfo.CurrentCulture)}{i}");
- }
-
- return list;
- }
-
- internal List GetContributorDataList()
- {
- var client = new WebClient();
- client.Headers.Add("User-Agent", "request");
- var list = new List();
- try
- {
- var json = client.DownloadString(new Uri("https://api.github.com/repos/nabian/handycontrol/contributors"));
- var objList = JsonConvert.DeserializeObject>(json);
- list.AddRange(objList.Select(item => new AvatarModel
- {
- DisplayName = item.login,
- AvatarUri = item.avatar_url,
- Link = item.html_url
- }));
- }
- catch (Exception e)
- {
- HandyControl.Controls.MessageBox.Error(e.Message, Lang.Error);
- }
-
- return list;
- }
-
- internal List GetBlogDataList()
- {
- return new()
- {
- new AvatarModel
- {
- DisplayName = "林德熙",
- AvatarUri = "https://avatars3.githubusercontent.com/u/16054566?s=400&v=4",
- Link = "https://blog.lindexi.com/"
- },
- new AvatarModel
- {
- DisplayName = "吕毅",
- AvatarUri = "https://avatars2.githubusercontent.com/u/9959623?s=400&v=4",
- Link = "https://blog.walterlv.com/"
- },
- new AvatarModel
- {
- DisplayName = "DinoChan",
- AvatarUri = "https://avatars1.githubusercontent.com/u/6076257?s=400&v=4",
- Link = "https://www.cnblogs.com/dino623/"
- },
- new AvatarModel
- {
- DisplayName = "noctwolf",
- AvatarUri = "https://avatars3.githubusercontent.com/u/21022467?s=400&v=4",
- Link = "https://www.cnblogs.com/noctwolf/"
- },
- new AvatarModel
- {
- DisplayName = "关关长语",
- AvatarUri = "https://avatars3.githubusercontent.com/u/25916858?s=400&v=4",
- Link = "https://blog.csdn.net/qq_28806349/category_11213909.html"
- }
- };
- }
-
- internal List GetProjectDataList()
- {
- return new()
- {
- new AvatarModel
- {
- DisplayName = "phpEnv",
- AvatarUri = "https://cdn.phpenv.cn:444/logo.png",
- Link = "https://www.phpenv.cn/"
- },
- new AvatarModel
- {
- DisplayName = "AutumnBox",
- AvatarUri = "https://raw.githubusercontent.com/zsh2401/AutumnBox/master/src/AutumnBox.GUI/Resources/Images/icon.png",
- Link = "https://github.com/zsh2401/AutumnBox"
- },
- new AvatarModel
- {
- DisplayName = "quicker",
- AvatarUri = "https://files.getquicker.net/_sitefiles/quicker_round_128.png",
- Link = "https://getquicker.net"
- }
- };
- }
-
- internal List GetWebsiteDataList()
- {
- return new()
- {
- new AvatarModel
- {
- DisplayName = "Dotnet9",
- AvatarUri = "https://pic.cnblogs.com/avatar/1663243/20191124121029.png",
- Link = "https://dotnet9.com/"
- }
- };
- }
-
- internal ObservableCollection GetCardDataList()
- {
- return new()
- {
- new CardModel
- {
- Header = "Atomic",
- Content = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
- Footer = "Stive Morgan"
- },
- new CardModel
- {
- Header = "Zinderlong",
- Content = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
- Footer = "Zonderling"
- },
- new CardModel
- {
- Header = "Busy Doin' Nothin'",
- Content = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
- Footer = "Ace Wilder"
- },
- new CardModel
- {
- Header = "Wrong",
- Content = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
- Footer = "Blaxy Girls"
- },
- new CardModel
- {
- Header = "The Lights",
- Content = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
- Footer = "Panda Eyes"
- },
- new CardModel
- {
- Header = "EA7-50-Cent Disco",
- Content = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
- Footer = "еяхат музыка"
- },
- new CardModel
- {
- Header = "Monsters",
- Content = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
- Footer = "Different Heaven"
- },
- new CardModel
- {
- Header = "Gangsta Walk",
- Content = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
- Footer = "Illusionize"
- },
- new CardModel
- {
- Header = "Won't Back Down",
- Content = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
- Footer = "Boehm / Benjamin Francis Leftwich"
- },
- new CardModel
- {
- Header = "Katchi",
- Content = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
- Footer = "Ofenbach / Nick Waterhouse"
- }
- };
- }
-
- internal CardModel GetCardData()
- {
- return new()
- {
- Content = $"/HandyControlDemo;component/Resources/Img/Album/{DateTime.Now.Second % 10 + 1}.jpg"
- };
- }
-
- internal List GetStepBarDemoDataList()
- {
- return new()
- {
- new StepBarDemoModel
- {
- Header = LangKeys.Step,
- Content = LangKeys.Register
- },
- new StepBarDemoModel
- {
- Header = LangKeys.Step,
- Content = LangKeys.BasicInfo
- },
- new StepBarDemoModel
- {
- Header = LangKeys.Step,
- Content = LangKeys.UploadFile
- },
- new StepBarDemoModel
- {
- Header = LangKeys.Step,
- Content = LangKeys.Complete
- }
- };
- }
-
- internal ObservableCollection GetCoverViewDemoDataList()
- {
- return new()
- {
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
- BackgroundToken = ResourceToken.SuccessBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
- BackgroundToken = ResourceToken.PrimaryBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
- BackgroundToken = ResourceToken.WarningBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
- BackgroundToken = ResourceToken.DangerBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
- BackgroundToken = ResourceToken.SuccessBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
- BackgroundToken = ResourceToken.PrimaryBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
- BackgroundToken = ResourceToken.InfoBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
- BackgroundToken = ResourceToken.WarningBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
- BackgroundToken = ResourceToken.PrimaryBrush
- },
- new CoverViewDemoModel
- {
- ImgPath = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
- BackgroundToken = ResourceToken.DangerBrush
- }
- };
- }
-
- internal List GetDemoInfo()
- {
- var infoList = new List();
-
- var stream = Application.GetResourceStream(new Uri("Data/DemoInfo.json", UriKind.Relative))?.Stream;
- if (stream == null) return infoList;
-
- string jsonStr;
- using (var reader = new StreamReader(stream))
- {
- jsonStr = reader.ReadToEnd();
- }
-
- var jsonObj = JsonConvert.DeserializeObject(jsonStr);
- foreach (var item in jsonObj)
- {
- var titleKey = (string) item.title;
- var title = titleKey;
- List list = Convert2DemoItemList(item.demoItemList);
-
- var demoInfoModel = new DemoInfoModel
- {
- Key = titleKey,
- Title = title,
- DemoItemList = list,
- SelectedIndex = (int) item.selectedIndex,
- IsGroupEnabled = (bool) item.group
- };
-
- infoList.Add(demoInfoModel);
- }
-
- return infoList;
- }
-
- private List Convert2DemoItemList(dynamic list)
- {
- var resultList = new List();
-
- foreach (var item in list)
- {
- var name = (string) item[0];
- string targetCtlName = item[1];
- string imageName = item[2];
- var isNew = !string.IsNullOrEmpty((string) item[3]);
- var groupName = (string) item[4];
- if (string.IsNullOrEmpty(groupName))
- {
- groupName = "Misc";
- }
-
- resultList.Add(new DemoItemModel
- {
- Name = name,
- TargetCtlName = targetCtlName,
- ImageName = $"../../Resources/Img/LeftMainContent/{imageName}.png",
- IsNew = isNew,
- GroupName = groupName
+ Index = j,
+ IsSelected = j % 2 == 0,
+ Name = $"SubName{j}",
+ Type = (DemoType) j
});
}
-
- return resultList;
+ var model = new DemoDataModel
+ {
+ Index = i,
+ IsSelected = i % 2 == 0,
+ Name = $"Name{i}",
+ Type = (DemoType) (i % 6 + 1),
+ DataList = dataList,
+ ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{i % 6 + 1}.png",
+ Remark = new string(i.ToString()[0], 10)
+ };
+ list.Add(model);
}
- public string GetDemoUrl(DemoInfoModel demoInfo, DemoItemModel demoItem)
+ return list;
+ }
+
+ internal List GetDemoDataList(int count)
+ {
+ var list = new List();
+ for (var i = 1; i <= count; i++)
{
- var key = demoInfo.Key switch
+ var index = i % 6 + 1;
+ var model = new DemoDataModel
{
- "Styles" => "native_controls",
- "Controls" => "extend_controls",
- "Tools" => "tools",
- _ => string.Empty
+ Index = i,
+ IsSelected = i % 2 == 0,
+ Name = $"Name{i}",
+ Type = (DemoType) index,
+ ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{index}.png",
+ Remark = new string(i.ToString()[0], 10)
+ };
+ list.Add(model);
+ }
+
+ return list;
+ }
+
+ internal List GetContributorDataList()
+ {
+ var client = new WebClient();
+ client.Headers.Add("User-Agent", "request");
+ var list = new List();
+ try
+ {
+ var json = client.DownloadString(new Uri("https://api.github.com/repos/nabian/handycontrol/contributors"));
+ var objList = JsonConvert.DeserializeObject>(json);
+ list.AddRange(objList.Select(item => new AvatarModel
+ {
+ DisplayName = item.login,
+ AvatarUri = item.avatar_url,
+ Link = item.html_url
+ }));
+ }
+ catch (Exception e)
+ {
+ HandyControl.Controls.MessageBox.Error(e.Message, Lang.Error);
+ }
+
+ return list;
+ }
+
+ internal List GetBlogDataList()
+ {
+ return new()
+ {
+ new AvatarModel
+ {
+ DisplayName = "林德熙",
+ AvatarUri = "https://avatars3.githubusercontent.com/u/16054566?s=400&v=4",
+ Link = "https://blog.lindexi.com/"
+ },
+ new AvatarModel
+ {
+ DisplayName = "吕毅",
+ AvatarUri = "https://avatars2.githubusercontent.com/u/9959623?s=400&v=4",
+ Link = "https://blog.walterlv.com/"
+ },
+ new AvatarModel
+ {
+ DisplayName = "DinoChan",
+ AvatarUri = "https://avatars1.githubusercontent.com/u/6076257?s=400&v=4",
+ Link = "https://www.cnblogs.com/dino623/"
+ },
+ new AvatarModel
+ {
+ DisplayName = "noctwolf",
+ AvatarUri = "https://avatars3.githubusercontent.com/u/21022467?s=400&v=4",
+ Link = "https://www.cnblogs.com/noctwolf/"
+ },
+ new AvatarModel
+ {
+ DisplayName = "关关长语",
+ AvatarUri = "https://avatars3.githubusercontent.com/u/25916858?s=400&v=4",
+ Link = "https://blog.csdn.net/qq_28806349/category_11213909.html"
+ }
+ };
+ }
+
+ internal List GetProjectDataList()
+ {
+ return new()
+ {
+ new AvatarModel
+ {
+ DisplayName = "phpEnv",
+ AvatarUri = "https://cdn.phpenv.cn:444/logo.png",
+ Link = "https://www.phpenv.cn/"
+ },
+ new AvatarModel
+ {
+ DisplayName = "AutumnBox",
+ AvatarUri = "https://raw.githubusercontent.com/zsh2401/AutumnBox/master/src/AutumnBox.GUI/Resources/Images/icon.png",
+ Link = "https://github.com/zsh2401/AutumnBox"
+ },
+ new AvatarModel
+ {
+ DisplayName = "quicker",
+ AvatarUri = "https://files.getquicker.net/_sitefiles/quicker_round_128.png",
+ Link = "https://getquicker.net"
+ }
+ };
+ }
+
+ internal List GetWebsiteDataList()
+ {
+ return new()
+ {
+ new AvatarModel
+ {
+ DisplayName = "Dotnet9",
+ AvatarUri = "https://pic.cnblogs.com/avatar/1663243/20191124121029.png",
+ Link = "https://dotnet9.com/"
+ }
+ };
+ }
+
+ internal ObservableCollection GetCardDataList()
+ {
+ return new()
+ {
+ new CardModel
+ {
+ Header = "Atomic",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
+ Footer = "Stive Morgan"
+ },
+ new CardModel
+ {
+ Header = "Zinderlong",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
+ Footer = "Zonderling"
+ },
+ new CardModel
+ {
+ Header = "Busy Doin' Nothin'",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
+ Footer = "Ace Wilder"
+ },
+ new CardModel
+ {
+ Header = "Wrong",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
+ Footer = "Blaxy Girls"
+ },
+ new CardModel
+ {
+ Header = "The Lights",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
+ Footer = "Panda Eyes"
+ },
+ new CardModel
+ {
+ Header = "EA7-50-Cent Disco",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
+ Footer = "еяхат музыка"
+ },
+ new CardModel
+ {
+ Header = "Monsters",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
+ Footer = "Different Heaven"
+ },
+ new CardModel
+ {
+ Header = "Gangsta Walk",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
+ Footer = "Illusionize"
+ },
+ new CardModel
+ {
+ Header = "Won't Back Down",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
+ Footer = "Boehm / Benjamin Francis Leftwich"
+ },
+ new CardModel
+ {
+ Header = "Katchi",
+ Content = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
+ Footer = "Ofenbach / Nick Waterhouse"
+ }
+ };
+ }
+
+ internal CardModel GetCardData()
+ {
+ return new()
+ {
+ Content = $"/HandyControlDemo;component/Resources/Img/Album/{DateTime.Now.Second % 10 + 1}.jpg"
+ };
+ }
+
+ internal List GetStepBarDemoDataList()
+ {
+ return new()
+ {
+ new StepBarDemoModel
+ {
+ Header = LangKeys.Step,
+ Content = LangKeys.Register
+ },
+ new StepBarDemoModel
+ {
+ Header = LangKeys.Step,
+ Content = LangKeys.BasicInfo
+ },
+ new StepBarDemoModel
+ {
+ Header = LangKeys.Step,
+ Content = LangKeys.UploadFile
+ },
+ new StepBarDemoModel
+ {
+ Header = LangKeys.Step,
+ Content = LangKeys.Complete
+ }
+ };
+ }
+
+ internal ObservableCollection GetCoverViewDemoDataList()
+ {
+ return new()
+ {
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
+ BackgroundToken = ResourceToken.SuccessBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
+ BackgroundToken = ResourceToken.WarningBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
+ BackgroundToken = ResourceToken.DangerBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
+ BackgroundToken = ResourceToken.SuccessBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
+ BackgroundToken = ResourceToken.InfoBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
+ BackgroundToken = ResourceToken.WarningBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
+ BackgroundToken = ResourceToken.DangerBrush
+ }
+ };
+ }
+
+ internal List GetDemoInfo()
+ {
+ var infoList = new List();
+
+ var stream = Application.GetResourceStream(new Uri("Data/DemoInfo.json", UriKind.Relative))?.Stream;
+ if (stream == null) return infoList;
+
+ string jsonStr;
+ using (var reader = new StreamReader(stream))
+ {
+ jsonStr = reader.ReadToEnd();
+ }
+
+ var jsonObj = JsonConvert.DeserializeObject(jsonStr);
+ foreach (var item in jsonObj)
+ {
+ var titleKey = (string) item.title;
+ var title = titleKey;
+ List list = Convert2DemoItemList(item.demoItemList);
+
+ var demoInfoModel = new DemoInfoModel
+ {
+ Key = titleKey,
+ Title = title,
+ DemoItemList = list,
+ SelectedIndex = (int) item.selectedIndex,
+ IsGroupEnabled = (bool) item.group
};
- var domainName = LangProvider.Culture == null || LangProvider.Culture.Name.ToLower() == "zh-cn"
- ? "handyorg"
- : "ghost1372";
- return $"https://{domainName}.github.io/handycontrol/{key}/{demoItem.Name[0].ToString().ToLower()}{demoItem.Name.Substring(1)}";
+ infoList.Add(demoInfoModel);
}
+
+ return infoList;
+ }
+
+ private List Convert2DemoItemList(dynamic list)
+ {
+ var resultList = new List();
+
+ foreach (var item in list)
+ {
+ var name = (string) item[0];
+ string targetCtlName = item[1];
+ string imageName = item[2];
+ var isNew = !string.IsNullOrEmpty((string) item[3]);
+ var groupName = (string) item[4];
+ if (string.IsNullOrEmpty(groupName))
+ {
+ groupName = "Misc";
+ }
+
+ resultList.Add(new DemoItemModel
+ {
+ Name = name,
+ TargetCtlName = targetCtlName,
+ ImageName = $"../../Resources/Img/LeftMainContent/{imageName}.png",
+ IsNew = isNew,
+ GroupName = groupName
+ });
+ }
+
+ return resultList;
+ }
+
+ public string GetDemoUrl(DemoInfoModel demoInfo, DemoItemModel demoItem)
+ {
+ var key = demoInfo.Key switch
+ {
+ "Styles" => "native_controls",
+ "Controls" => "extend_controls",
+ "Tools" => "tools",
+ _ => string.Empty
+ };
+
+ var domainName = LangProvider.Culture == null || LangProvider.Culture.Name.ToLower() == "zh-cn"
+ ? "handyorg"
+ : "ghost1372";
+ return $"https://{domainName}.github.io/handycontrol/{key}/{demoItem.Name[0].ToString().ToLower()}{demoItem.Name.Substring(1)}";
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs b/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs
index 978efe48..10fd810a 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Converter/HatchBrushConverter.cs
@@ -5,29 +5,28 @@ using System.Windows.Media;
using HandyControl.Data;
using HandyControl.Tools;
-namespace HandyControlDemo.Tools.Converter
+namespace HandyControlDemo.Tools.Converter;
+
+public class HatchBrushConverter : IValueConverter
{
- public class HatchBrushConverter : IValueConverter
+ private readonly HatchBrushGenerator _brushGenerator;
+
+ public HatchBrushConverter()
{
- private readonly HatchBrushGenerator _brushGenerator;
+ _brushGenerator = new HatchBrushGenerator();
+ }
- public HatchBrushConverter()
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is HatchStyle style)
{
- _brushGenerator = new HatchBrushGenerator();
+ return _brushGenerator.GetHatchBrush(style, ResourceHelper.GetResource(ResourceToken.DarkPrimaryColor), Colors.Transparent);
}
+ return Brushes.Transparent;
+ }
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is HatchStyle style)
- {
- return _brushGenerator.GetHatchBrush(style, ResourceHelper.GetResource(ResourceToken.DarkPrimaryColor), Colors.Transparent);
- }
- return Brushes.Transparent;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Converter/String2BrushConverter.cs b/src/Shared/HandyControlDemo_Shared/Tools/Converter/String2BrushConverter.cs
index a6a66284..346a8cd5 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Converter/String2BrushConverter.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Converter/String2BrushConverter.cs
@@ -4,18 +4,17 @@ using System.Windows.Data;
using System.Windows.Media;
using HandyControl.Tools;
-namespace HandyControlDemo.Tools.Converter
-{
- public class String2BrushConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value is string str ? ResourceHelper.GetResource(str) : default;
- }
+namespace HandyControlDemo.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class String2BrushConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value is string str ? ResourceHelper.GetResource(str) : default;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Converter/StringRepeatConverter.cs b/src/Shared/HandyControlDemo_Shared/Tools/Converter/StringRepeatConverter.cs
index 77ed023f..4144619c 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Converter/StringRepeatConverter.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Converter/StringRepeatConverter.cs
@@ -3,43 +3,42 @@ using System.Globalization;
using System.Text;
using System.Windows.Data;
-namespace HandyControlDemo.Tools.Converter
+namespace HandyControlDemo.Tools.Converter;
+
+public class StringRepeatConverter : IValueConverter
{
- public class StringRepeatConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ if (value is string strValue)
{
- if (value is string strValue)
+ var builder = new StringBuilder();
+ int num;
+ if (parameter is string numStr)
{
- var builder = new StringBuilder();
- int num;
- if (parameter is string numStr)
- {
- if (!int.TryParse(numStr, out num))
- {
- return strValue;
- }
- }
- else if (parameter is int intValue)
- {
- num = intValue;
- }
- else
+ if (!int.TryParse(numStr, out num))
{
return strValue;
}
- for (var i = 0; i < num; i++)
- {
- builder.Append(strValue);
- }
- return builder.ToString();
}
- return string.Empty;
+ else if (parameter is int intValue)
+ {
+ num = intValue;
+ }
+ else
+ {
+ return strValue;
+ }
+ for (var i = 0; i < num; i++)
+ {
+ builder.Append(strValue);
+ }
+ return builder.ToString();
}
+ return string.Empty;
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Extension/LangExtension.cs b/src/Shared/HandyControlDemo_Shared/Tools/Extension/LangExtension.cs
index 00f8d96d..e3080f9d 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Extension/LangExtension.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Extension/LangExtension.cs
@@ -1,12 +1,11 @@
using HandyControlDemo.Properties.Langs;
-namespace HandyControlDemo.Tools.Extension
+namespace HandyControlDemo.Tools.Extension;
+
+public class LangExtension : HandyControl.Tools.Extension.LangExtension
{
- public class LangExtension : HandyControl.Tools.Extension.LangExtension
+ public LangExtension()
{
- public LangExtension()
- {
- Source = LangProvider.Instance;
- }
+ Source = LangProvider.Instance;
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Helper/AssemblyHelper.cs b/src/Shared/HandyControlDemo_Shared/Tools/Helper/AssemblyHelper.cs
index b3921178..8e831fac 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Helper/AssemblyHelper.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Helper/AssemblyHelper.cs
@@ -1,37 +1,36 @@
using System;
using System.Collections.Generic;
-namespace HandyControlDemo.Tools
+namespace HandyControlDemo.Tools;
+
+internal class AssemblyHelper
{
- internal class AssemblyHelper
+ private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name;
+
+ private static readonly Dictionary CacheDic = new();
+
+ public static void Register(string name, object instance) => CacheDic[name] = instance;
+
+ public static object ResolveByKey(string key)
{
- private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name;
-
- private static readonly Dictionary CacheDic = new();
-
- public static void Register(string name, object instance) => CacheDic[name] = instance;
-
- public static object ResolveByKey(string key)
+ if (CacheDic.TryGetValue(key, out var value))
{
- if (CacheDic.TryGetValue(key, out var value))
- {
- return value;
- }
-
- return null;
+ return value;
}
- public static object CreateInternalInstance(string className)
+ return null;
+ }
+
+ public static object CreateInternalInstance(string className)
+ {
+ try
{
- try
- {
- var type = Type.GetType($"{NameSpaceStr}.{className}");
- return type == null ? null : Activator.CreateInstance(type);
- }
- catch
- {
- return null;
- }
+ var type = Type.GetType($"{NameSpaceStr}.{className}");
+ return type == null ? null : Activator.CreateInstance(type);
+ }
+ catch
+ {
+ return null;
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Helper/VersionHelper.cs b/src/Shared/HandyControlDemo_Shared/Tools/Helper/VersionHelper.cs
index 84bbed1c..062e601c 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Helper/VersionHelper.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Helper/VersionHelper.cs
@@ -1,15 +1,15 @@
using System.Diagnostics;
using System.Reflection;
-namespace HandyControlDemo.Tools
+namespace HandyControlDemo.Tools;
+
+internal class VersionHelper
{
- internal class VersionHelper
+ internal static string GetVersion()
{
- internal static string GetVersion()
- {
- var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
+ var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location);
#if NET40
- var netVersion = "NET 40";
+ var netVersion = "NET 40";
#elif NET45
var netVersion = "NET 45";
#elif NET451
@@ -35,14 +35,13 @@ namespace HandyControlDemo.Tools
#elif NET6_0
var netVersion = "NET 60";
#elif NETCOREAPP3_0
- var netVersion = "CORE 30";
+ var netVersion = "CORE 30";
#elif NETCOREAPP3_1
var netVersion = "CORE 31";
#endif
- return $"v {versionInfo.FileVersion} {netVersion}";
- }
-
- internal static string GetCopyright() =>
- FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).LegalCopyright;
+ return $"v {versionInfo.FileVersion} {netVersion}";
}
+
+ internal static string GetCopyright() =>
+ FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).LegalCopyright;
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs b/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
index c8929ae9..cc1ac22f 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/Helper/Win32Helper.cs
@@ -1,14 +1,13 @@
using System;
using System.Runtime.InteropServices;
-namespace HandyControlDemo.Tools
-{
- internal class Win32Helper
- {
- [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
+namespace HandyControlDemo.Tools;
- [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
- public static extern int MciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
- }
+internal class Win32Helper
+{
+ [DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
+ public static extern bool SetForegroundWindow(IntPtr hWnd);
+
+ [DllImport("winmm.dll", EntryPoint = "mciSendString", CharSet = CharSet.Auto)]
+ public static extern int MciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/HighlightingProvider.cs b/src/Shared/HandyControlDemo_Shared/Tools/HighlightingProvider.cs
index 48770e36..078ea8de 100644
--- a/src/Shared/HandyControlDemo_Shared/Tools/HighlightingProvider.cs
+++ b/src/Shared/HandyControlDemo_Shared/Tools/HighlightingProvider.cs
@@ -6,75 +6,74 @@ using HandyControl.Data;
using ICSharpCode.AvalonEdit.Highlighting;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
-namespace HandyControlDemo.Tools
+namespace HandyControlDemo.Tools;
+
+internal class HighlightingProvider
{
- internal class HighlightingProvider
+ public static HighlightingProvider Default = new Lazy(() => new HighlightingProvider()).Value;
+
+ protected static readonly Lazy DefaultDefinition = new(() => HighlightingManager.Instance.GetDefinition("C#"));
+
+ private static readonly Dictionary Providers = new();
+
+ protected Dictionary> Definition;
+
+ public static void Register(SkinType skinType, HighlightingProvider provider)
{
- public static HighlightingProvider Default = new Lazy(() => new HighlightingProvider()).Value;
-
- protected static readonly Lazy DefaultDefinition = new(() => HighlightingManager.Instance.GetDefinition("C#"));
-
- private static readonly Dictionary Providers = new();
-
- protected Dictionary> Definition;
-
- public static void Register(SkinType skinType, HighlightingProvider provider)
- {
- Providers[skinType] = provider ?? throw new ArgumentNullException(nameof(provider));
- provider.InitDefinitions();
- }
-
- public static IHighlightingDefinition GetDefinition(SkinType skinType, string name)
- {
- if (Providers.TryGetValue(skinType, out var provider))
- {
- return provider.GetDefinition(name);
- }
-
- return DefaultDefinition.Value;
- }
-
- protected static IHighlightingDefinition LoadDefinition(string xshdName)
- {
- var streamResourceInfo = Application.GetResourceStream(new Uri($"pack://application:,,,/Resources/xshd/{xshdName}.xshd"));
- if (streamResourceInfo == null)
- {
- return DefaultDefinition.Value;
- }
-
- using var reader = new XmlTextReader(streamResourceInfo.Stream);
- return HighlightingLoader.Load(reader, HighlightingManager.Instance);
- }
-
- protected virtual IHighlightingDefinition GetDefinition(string name)
- {
- if (Definition.TryGetValue(name, out var definition))
- {
- return definition.Value;
- }
-
- return DefaultDefinition.Value;
- }
-
- protected virtual void InitDefinitions()
- {
- Definition = new Dictionary>
- {
- ["XML"] = new(() => HighlightingManager.Instance.GetDefinition("XML")),
- ["C#"] = new(() => DefaultDefinition.Value)
- };
- }
+ Providers[skinType] = provider ?? throw new ArgumentNullException(nameof(provider));
+ provider.InitDefinitions();
}
- internal class HighlightingProviderDark : HighlightingProvider
+ public static IHighlightingDefinition GetDefinition(SkinType skinType, string name)
{
- protected override void InitDefinitions()
+ if (Providers.TryGetValue(skinType, out var provider))
{
- Definition = new Dictionary>
- {
- ["XML"] = new(() => LoadDefinition("XML-Dark")),
- ["C#"] = new(() => LoadDefinition("CSharp-Dark")),
- };
+ return provider.GetDefinition(name);
}
+
+ return DefaultDefinition.Value;
+ }
+
+ protected static IHighlightingDefinition LoadDefinition(string xshdName)
+ {
+ var streamResourceInfo = Application.GetResourceStream(new Uri($"pack://application:,,,/Resources/xshd/{xshdName}.xshd"));
+ if (streamResourceInfo == null)
+ {
+ return DefaultDefinition.Value;
+ }
+
+ using var reader = new XmlTextReader(streamResourceInfo.Stream);
+ return HighlightingLoader.Load(reader, HighlightingManager.Instance);
+ }
+
+ protected virtual IHighlightingDefinition GetDefinition(string name)
+ {
+ if (Definition.TryGetValue(name, out var definition))
+ {
+ return definition.Value;
+ }
+
+ return DefaultDefinition.Value;
+ }
+
+ protected virtual void InitDefinitions()
+ {
+ Definition = new Dictionary>
+ {
+ ["XML"] = new(() => HighlightingManager.Instance.GetDefinition("XML")),
+ ["C#"] = new(() => DefaultDefinition.Value)
+ };
+ }
+}
+
+internal class HighlightingProviderDark : HighlightingProvider
+{
+ protected override void InitDefinitions()
+ {
+ Definition = new Dictionary>
+ {
+ ["XML"] = new(() => LoadDefinition("XML-Dark")),
+ ["C#"] = new(() => LoadDefinition("CSharp-Dark")),
+ };
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/Tools/ValidationRule/NumericUpDownDemoRule.cs b/src/Shared/HandyControlDemo_Shared/Tools/ValidationRule/NumericUpDownDemoRule.cs
new file mode 100644
index 00000000..91235fe2
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/Tools/ValidationRule/NumericUpDownDemoRule.cs
@@ -0,0 +1,19 @@
+using System.Globalization;
+using System.Windows.Controls;
+
+namespace HandyControlDemo.Tools;
+
+public class NumericUpDownDemoRule : ValidationRule
+{
+ public override ValidationResult Validate(object value, CultureInfo cultureInfo)
+ {
+ if (value is not double doubleValue)
+ {
+ return new ValidationResult(false, HandyControl.Properties.Langs.Lang.FormatError);
+ }
+
+ return doubleValue % 2 > double.Epsilon
+ ? new ValidationResult(false, Properties.Langs.Lang.Error)
+ : ValidationResult.ValidResult;
+ }
+}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml.cs
index 3ee1da1e..1a3502da 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml.cs
@@ -1,40 +1,39 @@
using System.Windows;
using System.Windows.Media.Imaging;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class Avatar
{
- public partial class Avatar
+ public Avatar()
{
- public Avatar()
- {
- InitializeComponent();
- }
+ InitializeComponent();
+ }
- public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
- "Source", typeof(BitmapFrame), typeof(Avatar), new PropertyMetadata(default(BitmapFrame)));
+ public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
+ "Source", typeof(BitmapFrame), typeof(Avatar), new PropertyMetadata(default(BitmapFrame)));
- public BitmapFrame Source
- {
- get => (BitmapFrame) GetValue(SourceProperty);
- set => SetValue(SourceProperty, value);
- }
+ public BitmapFrame Source
+ {
+ get => (BitmapFrame) GetValue(SourceProperty);
+ set => SetValue(SourceProperty, value);
+ }
- public static readonly DependencyProperty UserNameProperty = DependencyProperty.Register(
- "DisplayName", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
+ public static readonly DependencyProperty UserNameProperty = DependencyProperty.Register(
+ "DisplayName", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
- public string DisplayName
- {
- get => (string) GetValue(UserNameProperty);
- set => SetValue(UserNameProperty, value);
- }
+ public string DisplayName
+ {
+ get => (string) GetValue(UserNameProperty);
+ set => SetValue(UserNameProperty, value);
+ }
- public static readonly DependencyProperty LinkProperty = DependencyProperty.Register(
- "Link", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
+ public static readonly DependencyProperty LinkProperty = DependencyProperty.Register(
+ "Link", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
- public string Link
- {
- get => (string) GetValue(LinkProperty);
- set => SetValue(LinkProperty, value);
- }
+ public string Link
+ {
+ get => (string) GetValue(LinkProperty);
+ set => SetValue(LinkProperty, value);
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/ChatBox.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/ChatBox.xaml.cs
index 86df6eef..9645bed6 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/ChatBox.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/ChatBox.xaml.cs
@@ -1,22 +1,21 @@
using System.Windows.Controls;
using HandyControl.Tools;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ChatBox
{
- public partial class ChatBox
+ private ScrollViewer _scrollViewer;
+
+ public ChatBox()
{
- private ScrollViewer _scrollViewer;
+ InitializeComponent();
+ ListBoxChat.ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged;
+ }
- public ChatBox()
- {
- InitializeComponent();
- ListBoxChat.ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged;
- }
-
- private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
- {
- _scrollViewer ??= VisualHelper.GetChild(ListBoxChat);
- _scrollViewer?.ScrollToBottom();
- }
+ private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
+ {
+ _scrollViewer ??= VisualHelper.GetChild(ListBoxChat);
+ _scrollViewer?.ScrollToBottom();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs
index ae6da16c..6849200c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/GeometryItem.xaml.cs
@@ -1,19 +1,18 @@
using System.Windows;
using HandyControlDemo.Data;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class GeometryItem
{
- public partial class GeometryItem
+ public GeometryItem() => InitializeComponent();
+
+ public static readonly DependencyProperty InfoProperty = DependencyProperty.Register(
+ "Info", typeof(GeometryItemModel), typeof(GeometryItem), new PropertyMetadata(default(GeometryItemModel)));
+
+ public GeometryItemModel Info
{
- public GeometryItem() => InitializeComponent();
-
- public static readonly DependencyProperty InfoProperty = DependencyProperty.Register(
- "Info", typeof(GeometryItemModel), typeof(GeometryItem), new PropertyMetadata(default(GeometryItemModel)));
-
- public GeometryItemModel Info
- {
- get => (GeometryItemModel) GetValue(InfoProperty);
- set => SetValue(InfoProperty, value);
- }
+ get => (GeometryItemModel) GetValue(InfoProperty);
+ set => SetValue(InfoProperty, value);
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/IFull.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/IFull.cs
index 8d7e9aa4..f11afea5 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/IFull.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/IFull.cs
@@ -1,7 +1,6 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+internal interface IFull
{
- internal interface IFull
- {
- }
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/InteractiveDialog.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/InteractiveDialog.xaml.cs
index 393fa350..7ac4c7a4 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/InteractiveDialog.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/InteractiveDialog.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class InteractiveDialog
{
- public partial class InteractiveDialog
+ public InteractiveDialog()
{
- public InteractiveDialog()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialog.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialog.xaml.cs
index 5977cf29..6a38b274 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialog.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialog.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TextDialog
{
- public partial class TextDialog
+ public TextDialog()
{
- public TextDialog()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialogWithTimer.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialogWithTimer.xaml.cs
index 73765ea6..9db2627b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialogWithTimer.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/TextDialogWithTimer.xaml.cs
@@ -2,23 +2,22 @@
using System.Windows.Controls.Primitives;
using HandyControl.Tools;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TextDialogWithTimer
{
- public partial class TextDialogWithTimer
+ public TextDialogWithTimer()
{
- public TextDialogWithTimer()
- {
- InitializeComponent();
+ InitializeComponent();
- var animation = AnimationHelper.CreateAnimation(100, 5000);
- animation.EasingFunction = null;
- animation.Completed += Animation_Completed;
- ProgressBarTimer.BeginAnimation(RangeBase.ValueProperty, animation);
- }
+ var animation = AnimationHelper.CreateAnimation(100, 5000);
+ animation.EasingFunction = null;
+ animation.Completed += Animation_Completed;
+ ProgressBarTimer.BeginAnimation(RangeBase.ValueProperty, animation);
+ }
- private void Animation_Completed(object sender, EventArgs e)
- {
- ButtonClose.Command.Execute(null);
- }
+ private void Animation_Completed(object sender, EventArgs e)
+ {
+ ButtonClose.Command.Execute(null);
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AnimationPathDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AnimationPathDemoCtl.xaml.cs
index e24baa6e..ed36b01c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AnimationPathDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AnimationPathDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class AnimationPathDemoCtl
{
- public partial class AnimationPathDemoCtl
+ public AnimationPathDemoCtl()
{
- public AnimationPathDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AutoCompleteTextBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AutoCompleteTextBoxDemoCtl.xaml.cs
index 1baf6628..277f839c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AutoCompleteTextBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/AutoCompleteTextBoxDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class AutoCompleteTextBoxDemoCtl
{
- public partial class AutoCompleteTextBoxDemoCtl
+ public AutoCompleteTextBoxDemoCtl()
{
- public AutoCompleteTextBoxDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml
index 8d363fcb..806ae926 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml
@@ -7,25 +7,25 @@
Background="{DynamicResource RegionBrush}"
DataContext="{Binding BadgeDemo, Source={StaticResource Locator}}">
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml.cs
index 7c745584..1093cda5 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/BadgeDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class BadgeDemoCtl
{
- public partial class BadgeDemoCtl
+ public BadgeDemoCtl()
{
- public BadgeDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml
index d5ff5fc5..56a1dfe7 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml
@@ -6,67 +6,69 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml.cs
index eb922b4c..5fd591be 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ButtonGroupDemoCtl.xaml.cs
@@ -1,40 +1,39 @@
using System.Windows;
using System.Windows.Media.Imaging;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ButtonGroupDemoCtl
{
- public partial class ButtonGroupDemoCtl
+ public ButtonGroupDemoCtl()
{
- public ButtonGroupDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
+ }
- public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
- "Source", typeof(BitmapFrame), typeof(Avatar), new PropertyMetadata(default(BitmapFrame)));
+ public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
+ "Source", typeof(BitmapFrame), typeof(Avatar), new PropertyMetadata(default(BitmapFrame)));
- public BitmapFrame Source
- {
- get => (BitmapFrame) GetValue(SourceProperty);
- set => SetValue(SourceProperty, value);
- }
+ public BitmapFrame Source
+ {
+ get => (BitmapFrame) GetValue(SourceProperty);
+ set => SetValue(SourceProperty, value);
+ }
- public static readonly DependencyProperty UserNameProperty = DependencyProperty.Register(
- "DisplayName", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
+ public static readonly DependencyProperty UserNameProperty = DependencyProperty.Register(
+ "DisplayName", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
- public string DisplayName
- {
- get => (string) GetValue(UserNameProperty);
- set => SetValue(UserNameProperty, value);
- }
+ public string DisplayName
+ {
+ get => (string) GetValue(UserNameProperty);
+ set => SetValue(UserNameProperty, value);
+ }
- public static readonly DependencyProperty LinkProperty = DependencyProperty.Register(
- "Link", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
+ public static readonly DependencyProperty LinkProperty = DependencyProperty.Register(
+ "Link", typeof(string), typeof(Avatar), new PropertyMetadata(default(string)));
- public string Link
- {
- get => (string) GetValue(LinkProperty);
- set => SetValue(LinkProperty, value);
- }
+ public string Link
+ {
+ get => (string) GetValue(LinkProperty);
+ set => SetValue(LinkProperty, value);
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CalendarWithClockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CalendarWithClockDemoCtl.xaml.cs
index ec65eb73..7ad76d4b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CalendarWithClockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CalendarWithClockDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CalendarWithClockDemoCtl
{
- public partial class CalendarWithClockDemoCtl
+ public CalendarWithClockDemoCtl()
{
- public CalendarWithClockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml
index d446a17f..9a966eb3 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml
@@ -6,7 +6,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:data="clr-namespace:HandyControlDemo.Data">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml.cs
index bff18126..8d1c52da 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CardDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CardDemoCtl
{
- public partial class CardDemoCtl
+ public CardDemoCtl()
{
- public CardDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml
index 889109ad..f9ccfd6f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml
@@ -4,7 +4,7 @@
Background="{DynamicResource RegionBrush}"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml.cs
index 51545d68..d0a44b92 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CarouselDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CarouselDemoCtl
{
- public partial class CarouselDemoCtl
+ public CarouselDemoCtl()
{
- public CarouselDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml
index b7e9da26..0e58a4f0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml
@@ -5,17 +5,19 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml.cs
index 6c68a1de..d2084f0d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ChatBubbleDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ChatBubbleDemoCtl
{
- public partial class ChatBubbleDemoCtl
+ public ChatBubbleDemoCtl()
{
- public ChatBubbleDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
index 6eb0f4a6..79e3ea2e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml
@@ -1,13 +1,13 @@
-
+
@@ -50,6 +50,6 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml.cs
index 44bbec67..40ac094e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CheckComboBoxDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CheckComboBoxDemoCtl
{
- public partial class CheckComboBoxDemoCtl
+ public CheckComboBoxDemoCtl()
{
- public CheckComboBoxDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CirclePanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CirclePanelDemoCtl.xaml.cs
index 62bee1d5..44fe0902 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CirclePanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CirclePanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CirclePanelDemoCtl
{
- public partial class CirclePanelDemoCtl
+ public CirclePanelDemoCtl()
{
- public CirclePanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml
index bc1a0bfb..45f5cb92 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml
@@ -4,9 +4,11 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml.cs
index 2603a663..fdb30a1e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ClockDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ClockDemoCtl
{
- public partial class ClockDemoCtl
+ public ClockDemoCtl()
{
- public ClockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ColorPickerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ColorPickerDemoCtl.xaml.cs
index 16863a27..e0ffbc82 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ColorPickerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ColorPickerDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ColorPickerDemoCtl
{
- public partial class ColorPickerDemoCtl
+ public ColorPickerDemoCtl()
{
- public ColorPickerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml
index 8a972e79..2b6d7aae 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml
@@ -1,13 +1,13 @@
-
+
@@ -40,6 +40,6 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml.cs
index 95f82acf..17100254 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ComboBoxDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ComboBoxDemoCtl
{
- public partial class ComboBoxDemoCtl
+ public ComboBoxDemoCtl()
{
- public ComboBoxDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml
index c77e8e3c..50168652 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml
@@ -4,7 +4,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml.cs
index 4ae9ffa1..2e1681b2 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CompareSliderDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CompareSliderDemoCtl
{
- public partial class CompareSliderDemoCtl
+ public CompareSliderDemoCtl()
{
- public CompareSliderDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml
index 742adf40..f67804dd 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml
@@ -4,6 +4,8 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
index b482538a..2d997aba 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
@@ -1,28 +1,27 @@
using System;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CoverFlowDemoCtl
{
- public partial class CoverFlowDemoCtl
+ public CoverFlowDemoCtl()
{
- public CoverFlowDemoCtl()
+ InitializeComponent();
+
+ CoverFlowMain.AddRange(new[]
{
- InitializeComponent();
+ new Uri(@"pack://application:,,,/Resources/Img/Album/1.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/2.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/3.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/4.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/5.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/6.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/7.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/8.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/9.jpg"),
+ new Uri(@"pack://application:,,,/Resources/Img/Album/10.jpg")
+ });
- CoverFlowMain.AddRange(new[]
- {
- new Uri(@"pack://application:,,,/Resources/Img/Album/1.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/2.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/3.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/4.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/5.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/6.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/7.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/8.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/9.jpg"),
- new Uri(@"pack://application:,,,/Resources/Img/Album/10.jpg")
- });
-
- CoverFlowMain.PageIndex = 2;
- }
+ CoverFlowMain.PageIndex = 2;
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml
index cc3ff299..7bf7739d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml
@@ -7,19 +7,21 @@
DataContext="{Binding CoverView,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml.cs
index 32f1adf9..b0533530 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverViewDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class CoverViewDemoCtl
{
- public partial class CoverViewDemoCtl
+ public CoverViewDemoCtl()
{
- public CoverViewDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml
index 040ab4ad..b7dd79c6 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml
@@ -7,16 +7,29 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml.cs
index a7f7a755..22370b5a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DatePickerDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class DatePickerDemoCtl
{
- public partial class DatePickerDemoCtl
+ public DatePickerDemoCtl()
{
- public DatePickerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml
index 661f1e1d..0f14ce55 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml
@@ -6,27 +6,49 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml.cs
index 2ddac486..4516e027 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DateTimePickerDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class DateTimePickerDemoCtl
{
- public partial class DateTimePickerDemoCtl
+ public DateTimePickerDemoCtl()
{
- public DateTimePickerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml.cs
index a67e46c5..a0ca5ee2 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class DialogDemoCtl
{
- public partial class DialogDemoCtl
+ public DialogDemoCtl()
{
- public DialogDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
index 3bb2853a..62c81bf1 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml
@@ -6,39 +6,41 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml.cs
index 7cd8f16f..a729a1ef 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DividerDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class DividerDemoCtl
{
- public partial class DividerDemoCtl
+ public DividerDemoCtl()
{
- public DividerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DrawerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DrawerDemoCtl.xaml.cs
index 81259d96..d5035402 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DrawerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DrawerDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class DrawerDemoCtl
{
- public partial class DrawerDemoCtl
+ public DrawerDemoCtl()
{
- public DrawerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml
index bea3e62a..a14d51db 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml
@@ -6,8 +6,20 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -15,11 +27,20 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml.cs
index e18109c3..bfffd2f8 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ElementGroupDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ElementGroupDemoCtl
{
- public partial class ElementGroupDemoCtl
+ public ElementGroupDemoCtl()
{
- public ElementGroupDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml
index c55f1b4c..183f0232 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml
@@ -12,7 +12,7 @@
-
+
@@ -45,6 +45,6 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml.cs
index d9089da2..edbf80f8 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlexPanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class FlexPanelDemoCtl : IFull
{
- public partial class FlexPanelDemoCtl : IFull
+ public FlexPanelDemoCtl()
{
- public FlexPanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml
index 8e2f08b2..e2240307 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml
@@ -4,6 +4,8 @@
Background="{DynamicResource RegionBrush}"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml.cs
index 01474c10..1bf77c65 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FlipClockDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class FlipClockDemoCtl
{
- public partial class FlipClockDemoCtl
+ public FlipClockDemoCtl()
{
- public FlipClockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FloatingBlockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FloatingBlockDemoCtl.xaml.cs
index f7cbc776..91e2b19f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FloatingBlockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/FloatingBlockDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class FloatingBlockDemoCtl
{
- public partial class FloatingBlockDemoCtl
+ public FloatingBlockDemoCtl()
{
- public FloatingBlockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GifImageDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GifImageDemoCtl.xaml.cs
index 315e0296..ced84c6b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GifImageDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GifImageDemoCtl.xaml.cs
@@ -1,17 +1,16 @@
using System;
-namespace HandyControlDemo.UserControl
-{
- public partial class GifImageDemoCtl : IDisposable
- {
- public GifImageDemoCtl()
- {
- InitializeComponent();
- }
+namespace HandyControlDemo.UserControl;
- public void Dispose()
- {
- GifImageMain.Dispose();
- }
+public partial class GifImageDemoCtl : IDisposable
+{
+ public GifImageDemoCtl()
+ {
+ InitializeComponent();
+ }
+
+ public void Dispose()
+ {
+ GifImageMain.Dispose();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml
index 6ab499a8..055f8d70 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml
@@ -4,7 +4,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml.cs
index 3626a1df..6a7916f2 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GotoTopDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class GotoTopDemoCtl
{
- public partial class GotoTopDemoCtl
+ public GotoTopDemoCtl()
{
- public GotoTopDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml
index 98ecc600..4b5c9ffc 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml
@@ -4,24 +4,26 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml.cs
index 3a27748e..3361fe1c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GravatarDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class GravatarDemoCtl
{
- public partial class GravatarDemoCtl
+ public GravatarDemoCtl()
{
- public GravatarDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
index 29eb161a..1ab2917f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
@@ -6,7 +6,7 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
+
@@ -154,5 +154,5 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml.cs
index f8443e4e..1581bf0b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class GridDemoCtl : IFull
{
- public partial class GridDemoCtl : IFull
+ public GridDemoCtl()
{
- public GridDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GrowlDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GrowlDemoCtl.xaml.cs
index c3474865..7862f170 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GrowlDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/GrowlDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class GrowlDemoCtl
{
- public partial class GrowlDemoCtl
+ public GrowlDemoCtl()
{
- public GrowlDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/HoneycombPanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/HoneycombPanelDemoCtl.xaml.cs
index 13c4d23e..4c2f3f59 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/HoneycombPanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/HoneycombPanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class HoneycombPanelDemoCtl
{
- public partial class HoneycombPanelDemoCtl
+ public HoneycombPanelDemoCtl()
{
- public HoneycombPanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml
index 75ee0588..bf300da0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml
@@ -4,17 +4,19 @@
Background="{DynamicResource RegionBrush}"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml.cs
index abf2962a..3f949fa5 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBlockDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ImageBlockDemoCtl
{
- public partial class ImageBlockDemoCtl
+ public ImageBlockDemoCtl()
{
- public ImageBlockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
index be1672ce..f39b909f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml
@@ -8,7 +8,7 @@
xmlns:hc="https://handyorg.github.io/handycontrol">
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
index da51a2c1..f7699802 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageBrowserDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ImageBrowserDemoCtl
{
- public partial class ImageBrowserDemoCtl
+ public ImageBrowserDemoCtl()
{
- public ImageBrowserDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml
index a08ee288..15d5be6b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml
@@ -4,13 +4,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml.cs
index b71a7746..a631ecf6 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ImageSelectorDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ImageSelectorDemoCtl
{
- public partial class ImageSelectorDemoCtl
+ public ImageSelectorDemoCtl()
{
- public ImageSelectorDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/LoadingDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/LoadingDemoCtl.xaml.cs
index 005ed41a..f0db3031 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/LoadingDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/LoadingDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class LoadingDemoCtl
{
- public partial class LoadingDemoCtl
+ public LoadingDemoCtl()
{
- public LoadingDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml
index 4851dca1..ba0c5059 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml
@@ -4,14 +4,16 @@
Background="{DynamicResource RegionBrush}"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml.cs
index a09d3502..be76bdbc 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/MagnifierDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class MagnifierDemoCtl
{
- public partial class MagnifierDemoCtl
+ public MagnifierDemoCtl()
{
- public MagnifierDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotificationDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotificationDemoCtl.xaml.cs
index 4a86ef88..1aaed8c8 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotificationDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotificationDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class NotificationDemoCtl
{
- public partial class NotificationDemoCtl
+ public NotificationDemoCtl()
{
- public NotificationDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml.cs
index 402408dd..bcf9032f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NotifyIconDemoCtl.xaml.cs
@@ -2,20 +2,19 @@
using HandyControlDemo.Tools;
using HandyControlDemo.ViewModel;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class NotifyIconDemoCtl
{
- public partial class NotifyIconDemoCtl
+ public NotifyIconDemoCtl()
{
- public NotifyIconDemoCtl()
- {
- InitializeComponent();
+ InitializeComponent();
- AssemblyHelper.Register(nameof(NotifyIconDemoCtl), this);
- Unloaded += NotifyIconDemoCtl_Unloaded;
- }
-
- private void NotifyIconDemoCtl_Unloaded(object sender, RoutedEventArgs e) => ViewModelLocator.Instance.NotifyIconDemo.Cleanup();
-
- private void ButtonPush_OnClick(object sender, RoutedEventArgs e) => NotifyIconContextContent.CloseContextControl();
+ AssemblyHelper.Register(nameof(NotifyIconDemoCtl), this);
+ Unloaded += NotifyIconDemoCtl_Unloaded;
}
+
+ private void NotifyIconDemoCtl_Unloaded(object sender, RoutedEventArgs e) => ViewModelLocator.Instance.NotifyIconDemo.Cleanup();
+
+ private void ButtonPush_OnClick(object sender, RoutedEventArgs e) => NotifyIconContextContent.CloseContextControl();
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml
index e09deb85..5ddf70dd 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml
@@ -4,29 +4,69 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
- Background="{DynamicResource RegionBrush}">
+ xmlns:tools="clr-namespace:HandyControlDemo.Tools"
+ Background="{DynamicResource RegionBrush}"
+ DataContext="{Binding InputElementDemo, Source={StaticResource Locator}}">
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
index 3fb6ea48..611e7385 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/NumericUpDownDemoCtl.xaml.cs
@@ -1,19 +1,9 @@
-using HandyControl.Data;
+namespace HandyControlDemo.UserControl;
-
-namespace HandyControlDemo.UserControl
+public partial class NumericUpDownDemoCtl
{
- public partial class NumericUpDownDemoCtl
+ public NumericUpDownDemoCtl()
{
- public NumericUpDownDemoCtl()
- {
- InitializeComponent();
-
- NumericUpDownCustomVerify.VerifyFunc = str => double.TryParse(str, out var v)
- ? v % 2 < 1e-06
- ? OperationResult.Failed(Properties.Langs.Lang.Error)
- : OperationResult.Success()
- : OperationResult.Failed(Properties.Langs.Lang.Error);
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml
index 1d93bf32..d8ba610b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml
@@ -6,14 +6,16 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml.cs
index 1e637136..123b0241 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/OutlineTextDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class OutlineTextDemoCtl
{
- public partial class OutlineTextDemoCtl
+ public OutlineTextDemoCtl()
{
- public OutlineTextDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml
index 2bf36b55..d5c3ba2b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml
@@ -19,7 +19,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml.cs
index 054499d8..4e9c8607 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PaginationDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class PaginationDemoCtl
{
- public partial class PaginationDemoCtl
+ public PaginationDemoCtl()
{
- public PaginationDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml
index 1d2a0bd5..0059b3cc 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml
@@ -6,29 +6,31 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml.cs
index 8e750253..3697d19f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PasswordBoxDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class PasswordBoxDemoCtl
{
- public partial class PasswordBoxDemoCtl
+ public PasswordBoxDemoCtl()
{
- public PasswordBoxDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PinBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PinBoxDemoCtl.xaml.cs
index 02c0ca3a..17b3a149 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PinBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PinBoxDemoCtl.xaml.cs
@@ -1,21 +1,20 @@
using System.Windows;
using HandyControl.Controls;
-namespace HandyControlDemo.UserControl
-{
- public partial class PinBoxDemoCtl
- {
- public PinBoxDemoCtl()
- {
- InitializeComponent();
- }
+namespace HandyControlDemo.UserControl;
- private void PinBox_OnCompleted(object sender, RoutedEventArgs e)
+public partial class PinBoxDemoCtl
+{
+ public PinBoxDemoCtl()
+ {
+ InitializeComponent();
+ }
+
+ private void PinBox_OnCompleted(object sender, RoutedEventArgs e)
+ {
+ if (e.OriginalSource is PinBox pinBox)
{
- if (e.OriginalSource is PinBox pinBox)
- {
- Growl.Info(pinBox.Password);
- }
+ Growl.Info(pinBox.Password);
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
index 0f9947ce..ab9e5ff0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml
@@ -10,14 +10,12 @@
@@ -35,12 +33,12 @@
-
-
-
+
+
@@ -62,17 +60,17 @@
-
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml.cs
index 8daa08f5..beb08430 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PoptipDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class PoptipDemoCtl
{
- public partial class PoptipDemoCtl
+ public PoptipDemoCtl()
{
- public PoptipDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PreviewSliderDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PreviewSliderDemoCtl.xaml.cs
index 9869b2ca..0313ee00 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PreviewSliderDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PreviewSliderDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class PreviewSliderDemoCtl
{
- public partial class PreviewSliderDemoCtl
+ public PreviewSliderDemoCtl()
{
- public PreviewSliderDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressBarDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressBarDemoCtl.xaml.cs
index eb096c94..a6af0224 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressBarDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressBarDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ProgressBarDemoCtl
{
- public partial class ProgressBarDemoCtl
+ public ProgressBarDemoCtl()
{
- public ProgressBarDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml
index 00aae1f9..32a3b95d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml
@@ -5,23 +5,25 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs
index f44f7110..5ff7442c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs
@@ -2,64 +2,63 @@
using System.Windows;
using System.Windows.Threading;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ProgressButtonDemoCtl
{
- public partial class ProgressButtonDemoCtl
+ public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register(
+ "Progress", typeof(int), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(int)));
+
+ public int Progress
{
- public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register(
- "Progress", typeof(int), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(int)));
+ get => (int) GetValue(ProgressProperty);
+ set => SetValue(ProgressProperty, value);
+ }
- public int Progress
+ public static readonly DependencyProperty IsUploadingProperty = DependencyProperty.Register(
+ "IsUploading", typeof(bool), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(bool)));
+
+ public bool IsUploading
+ {
+ get => (bool) GetValue(IsUploadingProperty);
+ set => SetValue(IsUploadingProperty, value);
+ }
+
+ private readonly DispatcherTimer _timer;
+
+ public ProgressButtonDemoCtl()
+ {
+ InitializeComponent();
+
+ DataContext = this;
+
+ _timer = new DispatcherTimer
{
- get => (int) GetValue(ProgressProperty);
- set => SetValue(ProgressProperty, value);
+ Interval = TimeSpan.FromMilliseconds(200)
+ };
+ _timer.Tick += Timer_Tick;
+ }
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ Progress++;
+ if (Progress == 100)
+ {
+ Progress = 0;
+ _timer.Stop();
+ IsUploading = false;
}
+ }
- public static readonly DependencyProperty IsUploadingProperty = DependencyProperty.Register(
- "IsUploading", typeof(bool), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(bool)));
-
- public bool IsUploading
+ private void ButtonProgress_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (_timer.IsEnabled)
{
- get => (bool) GetValue(IsUploadingProperty);
- set => SetValue(IsUploadingProperty, value);
+ _timer.Stop();
}
-
- private readonly DispatcherTimer _timer;
-
- public ProgressButtonDemoCtl()
+ else
{
- InitializeComponent();
-
- DataContext = this;
-
- _timer = new DispatcherTimer
- {
- Interval = TimeSpan.FromMilliseconds(200)
- };
- _timer.Tick += Timer_Tick;
- }
-
- private void Timer_Tick(object sender, EventArgs e)
- {
- Progress++;
- if (Progress == 100)
- {
- Progress = 0;
- _timer.Stop();
- IsUploading = false;
- }
- }
-
- private void ButtonProgress_OnClick(object sender, RoutedEventArgs e)
- {
- if (_timer.IsEnabled)
- {
- _timer.Stop();
- }
- else
- {
- _timer.Start();
- }
+ _timer.Start();
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PropertyGridDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PropertyGridDemoCtl.xaml.cs
index 54d15322..bcdda5fb 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PropertyGridDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/PropertyGridDemoCtl.xaml.cs
@@ -1,31 +1,30 @@
using System.Windows;
using HandyControlDemo.Data;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class PropertyGridDemoCtl
{
- public partial class PropertyGridDemoCtl
+ public PropertyGridDemoCtl()
{
- public PropertyGridDemoCtl()
+ InitializeComponent();
+
+ DemoModel = new PropertyGridDemoModel
{
- InitializeComponent();
+ String = "TestString",
+ Enum = Gender.Female,
+ Boolean = true,
+ Integer = 98,
+ VerticalAlignment = VerticalAlignment.Stretch
+ };
+ }
- DemoModel = new PropertyGridDemoModel
- {
- String = "TestString",
- Enum = Gender.Female,
- Boolean = true,
- Integer = 98,
- VerticalAlignment = VerticalAlignment.Stretch
- };
- }
+ public static readonly DependencyProperty DemoModelProperty = DependencyProperty.Register(
+ "DemoModel", typeof(PropertyGridDemoModel), typeof(PropertyGridDemoCtl), new PropertyMetadata(default(PropertyGridDemoModel)));
- public static readonly DependencyProperty DemoModelProperty = DependencyProperty.Register(
- "DemoModel", typeof(PropertyGridDemoModel), typeof(PropertyGridDemoCtl), new PropertyMetadata(default(PropertyGridDemoModel)));
-
- public PropertyGridDemoModel DemoModel
- {
- get => (PropertyGridDemoModel) GetValue(DemoModelProperty);
- set => SetValue(DemoModelProperty, value);
- }
+ public PropertyGridDemoModel DemoModel
+ {
+ get => (PropertyGridDemoModel) GetValue(DemoModelProperty);
+ set => SetValue(DemoModelProperty, value);
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml
index 8f4f3b99..3cc98cd0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml
@@ -4,19 +4,21 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml.cs
index cf953706..8b918850 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RangeSliderDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class RangeSliderDemoCtl
{
- public partial class RangeSliderDemoCtl
+ public RangeSliderDemoCtl()
{
- public RangeSliderDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RateDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RateDemoCtl.xaml.cs
index 5f5c2bb6..f14957e7 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RateDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RateDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class RateDemoCtl
{
- public partial class RateDemoCtl
+ public RateDemoCtl()
{
- public RateDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml
index 87ca8eca..0e049bd1 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml
@@ -4,58 +4,60 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs
index 747c9b57..cf514cbb 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RelativePanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class RelativePanelDemoCtl
{
- public partial class RelativePanelDemoCtl
+ public RelativePanelDemoCtl()
{
- public RelativePanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml
index 74fc67f7..be53f250 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml
@@ -6,31 +6,33 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml.cs
index a115d149..4365c90f 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/RunningBlockDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class RunningBlockDemoCtl
{
- public partial class RunningBlockDemoCtl
+ public RunningBlockDemoCtl()
{
- public RunningBlockDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs
index 7f237020..7d605777 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScreenshotDemoCtl.xaml.cs
@@ -5,29 +5,28 @@ using System.Windows.Media;
using HandyControl.Controls;
using HandyControl.Data;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ScreenshotDemoCtl : IDisposable
{
- public partial class ScreenshotDemoCtl : IDisposable
+ public ScreenshotDemoCtl()
{
- public ScreenshotDemoCtl()
- {
- InitializeComponent();
- Screenshot.Snapped += Screenshot_Snapped;
- }
-
- private void Screenshot_Snapped(object sender, FunctionEventArgs e)
- {
- new HandyControl.Controls.Window
- {
- Content = new Image
- {
- Source = e.Info,
- Stretch = Stretch.None
- },
- WindowStartupLocation = WindowStartupLocation.CenterScreen
- }.ShowDialog();
- }
-
- public void Dispose() => Screenshot.Snapped -= Screenshot_Snapped;
+ InitializeComponent();
+ Screenshot.Snapped += Screenshot_Snapped;
}
+
+ private void Screenshot_Snapped(object sender, FunctionEventArgs e)
+ {
+ new HandyControl.Controls.Window
+ {
+ Content = new Image
+ {
+ Source = e.Info,
+ Stretch = Stretch.None
+ },
+ WindowStartupLocation = WindowStartupLocation.CenterScreen
+ }.ShowDialog();
+ }
+
+ public void Dispose() => Screenshot.Snapped -= Screenshot_Snapped;
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml
index 08918f62..50371526 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml
@@ -5,7 +5,7 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}"
- Width="550"
+ MaxWidth="550"
Height="600">
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml.cs
index 56df29a7..0f8fc047 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ScrollViewerDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ScrollViewerDemoCtl
{
- public partial class ScrollViewerDemoCtl
+ public ScrollViewerDemoCtl()
{
- public ScrollViewerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml
index e1038cfe..7930304c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml
@@ -4,28 +4,64 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
- DataContext="{Binding SearchBarDemo,Source={StaticResource Locator}}"
+ DataContext="{Binding InputElementDemo, Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml.cs
index 0375fd53..a36f374e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SearchBarDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class SearchBarDemoCtl
{
- public partial class SearchBarDemoCtl
+ public SearchBarDemoCtl()
{
- public SearchBarDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ShieldDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ShieldDemoCtl.xaml.cs
index 6cfbc669..345bae9e 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ShieldDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/ShieldDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ShieldDemoCtl
{
- public partial class ShieldDemoCtl
+ public ShieldDemoCtl()
{
- public ShieldDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml.cs
index 021ff249..e00177ff 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SideMenuDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class SideMenuDemoCtl
{
- public partial class SideMenuDemoCtl
+ public SideMenuDemoCtl()
{
- public SideMenuDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SplitButtonDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SplitButtonDemoCtl.xaml.cs
index 6c369070..62646b8b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SplitButtonDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SplitButtonDemoCtl.xaml.cs
@@ -1,17 +1,16 @@
using System.Windows;
-namespace HandyControlDemo.UserControl
-{
- public partial class SplitButtonDemoCtl
- {
- public SplitButtonDemoCtl()
- {
- InitializeComponent();
- }
+namespace HandyControlDemo.UserControl;
- private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
- {
- MessageBox.Show("123");
- }
+public partial class SplitButtonDemoCtl
+{
+ public SplitButtonDemoCtl()
+ {
+ InitializeComponent();
+ }
+
+ private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show("123");
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml.cs
index fa59e94e..a5fcf899 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class SpriteDemoCtl
{
- public partial class SpriteDemoCtl
+ public SpriteDemoCtl()
{
- public SpriteDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml.cs
index 991bab9b..7adeb054 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class StepBarDemoCtl
{
- public partial class StepBarDemoCtl
+ public StepBarDemoCtl()
{
- public StepBarDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
index 98f7378d..78c93a18 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml
@@ -5,7 +5,7 @@
DataContext="{Binding TabControlDemo,Source={StaticResource Locator}}"
xmlns:hc="https://handyorg.github.io/handycontrol">
-
+
@@ -14,9 +14,13 @@
-
-
-
+
+
+
+
+
+
+
@@ -39,13 +43,7 @@
-
-
-
-
-
-
-
+
@@ -68,7 +66,7 @@
-
+
@@ -80,7 +78,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml.cs
index 7df67fc8..1cb6625a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TabControlDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TabControlDemoCtl
{
- public partial class TabControlDemoCtl
+ public TabControlDemoCtl()
{
- public TabControlDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml
index d1744bb2..4c8b5bf5 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml
@@ -14,32 +14,34 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml.cs
index aaeb7890..f48d959a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TagDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TagDemoCtl
{
- public partial class TagDemoCtl
+ public TagDemoCtl()
{
- public TagDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml
index f9cef692..c3d97fee 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml
@@ -4,27 +4,46 @@
Background="{DynamicResource RegionBrush}"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
- xmlns:hc="https://handyorg.github.io/handycontrol">
+ xmlns:hc="https://handyorg.github.io/handycontrol"
+ DataContext="{Binding InputElementDemo, Source={StaticResource Locator}}">
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml.cs
index f68246b0..1eedb806 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TextBoxDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TextBoxDemoCtl
{
- public partial class TextBoxDemoCtl
+ public TextBoxDemoCtl()
{
- public TextBoxDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimeBarDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimeBarDemoCtl.xaml.cs
index 03270e26..46686525 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimeBarDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimeBarDemoCtl.xaml.cs
@@ -1,20 +1,19 @@
using System;
using HandyControl.Data;
-namespace HandyControlDemo.UserControl
-{
- public partial class TimeBarDemoCtl
- {
- public TimeBarDemoCtl()
- {
- InitializeComponent();
+namespace HandyControlDemo.UserControl;
- for (int i = 0; i < 10; i++)
- {
- var hour = 6 * i;
- TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(hour), DateTime.Today.AddHours(hour + 1)));
- TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(-hour), DateTime.Today.AddHours(-hour + 1)));
- }
+public partial class TimeBarDemoCtl
+{
+ public TimeBarDemoCtl()
+ {
+ InitializeComponent();
+
+ for (int i = 0; i < 10; i++)
+ {
+ var hour = 6 * i;
+ TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(hour), DateTime.Today.AddHours(hour + 1)));
+ TimeBarDemo.Hotspots.Add(new DateTimeRange(DateTime.Today.AddHours(-hour), DateTime.Today.AddHours(-hour + 1)));
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml
index c9cf2352..c430c1f4 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml
@@ -6,31 +6,57 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml.cs
index 9c4fcf0f..6ae08ea0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TimePickerDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TimePickerDemoCtl
{
- public partial class TimePickerDemoCtl
+ public TimePickerDemoCtl()
{
- public TimePickerDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransferDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransferDemoCtl.xaml.cs
index 4fba3b92..00b3c4c7 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransferDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransferDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TransferDemoCtl
{
- public partial class TransferDemoCtl
+ public TransferDemoCtl()
{
- public TransferDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml
index b7d76fec..c20c2c2d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml
@@ -2,52 +2,52 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
- Background="{DynamicResource RegionBrush}"
- Width="720"
- Height="500">
-
+ Background="{DynamicResource RegionBrush}">
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml.cs
index 92a140ce..0a0a909a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/TransitioningContentControlDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class TransitioningContentControlDemoCtl
{
- public partial class TransitioningContentControlDemoCtl
+ public TransitioningContentControlDemoCtl()
{
- public TransitioningContentControlDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml
index 6287df75..28f53324 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml
@@ -6,34 +6,36 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml.cs
index 781aa558..eaf7dc8c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/UniformSpacingPanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class UniformSpacingPanelDemoCtl
{
- public partial class UniformSpacingPanelDemoCtl
+ public UniformSpacingPanelDemoCtl()
{
- public UniformSpacingPanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml
index 37218e9a..4e1a662c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml
@@ -12,7 +12,7 @@
-
+
@@ -32,7 +32,7 @@
-
+
@@ -51,7 +51,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml.cs
index 3e9c2468..3fd985c0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WaterfallPanelDemoCtl.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class WaterfallPanelDemoCtl
{
- public partial class WaterfallPanelDemoCtl
+ public WaterfallPanelDemoCtl()
{
- public WaterfallPanelDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
index cbbe9643..7ec91422 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml
@@ -8,16 +8,18 @@
DataContext="{Binding WindowDemo,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml.cs
index dccc1d0f..64cf4855 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/WindowDemoCtl.xaml.cs
@@ -4,61 +4,60 @@ using HandyControl.Data;
using HandyControl.Tools;
using MessageBox = HandyControl.Controls.MessageBox;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class WindowDemoCtl
{
- public partial class WindowDemoCtl
+ public WindowDemoCtl()
{
- public WindowDemoCtl()
- {
- InitializeComponent();
- }
+ InitializeComponent();
+ }
- private void ButtonMessage_OnClick(object sender, RoutedEventArgs e)
- {
- MessageBox.Show(Properties.Langs.Lang.GrowlAsk, Properties.Langs.Lang.Title, MessageBoxButton.YesNo, MessageBoxImage.Question);
- }
+ private void ButtonMessage_OnClick(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show(Properties.Langs.Lang.GrowlAsk, Properties.Langs.Lang.Title, MessageBoxButton.YesNo, MessageBoxImage.Question);
+ }
- private void ButtonCustomMessage_OnClick(object sender, RoutedEventArgs e)
+ private void ButtonCustomMessage_OnClick(object sender, RoutedEventArgs e)
+ {
+ MessageBox.Show(new MessageBoxInfo
{
- MessageBox.Show(new MessageBoxInfo
- {
- Message = Properties.Langs.Lang.GrowlAsk,
- Caption = Properties.Langs.Lang.Title,
- Button = MessageBoxButton.YesNo,
- IconBrushKey = ResourceToken.AccentBrush,
- IconKey = ResourceToken.AskGeometry,
- StyleKey = "MessageBoxCustom"
- });
- }
+ Message = Properties.Langs.Lang.GrowlAsk,
+ Caption = Properties.Langs.Lang.Title,
+ Button = MessageBoxButton.YesNo,
+ IconBrushKey = ResourceToken.AccentBrush,
+ IconKey = ResourceToken.AskGeometry,
+ StyleKey = "MessageBoxCustom"
+ });
+ }
- private void ButtonMouseFollow_OnClick(object sender, RoutedEventArgs e)
+ private void ButtonMouseFollow_OnClick(object sender, RoutedEventArgs e)
+ {
+ var picker = SingleOpenHelper.CreateControl();
+ var window = new PopupWindow
{
- var picker = SingleOpenHelper.CreateControl();
- var window = new PopupWindow
- {
- PopupElement = picker
- };
- picker.SelectedColorChanged += delegate { window.Close(); };
- picker.Canceled += delegate { window.Close(); };
- window.Show(ButtonMouseFollow, false);
- }
+ PopupElement = picker
+ };
+ picker.SelectedColorChanged += delegate { window.Close(); };
+ picker.Canceled += delegate { window.Close(); };
+ window.Show(ButtonMouseFollow, false);
+ }
- private void ButtonCustomContent_OnClick(object sender, RoutedEventArgs e)
+ private void ButtonCustomContent_OnClick(object sender, RoutedEventArgs e)
+ {
+ var picker = SingleOpenHelper.CreateControl();
+ var window = new PopupWindow
{
- var picker = SingleOpenHelper.CreateControl();
- var window = new PopupWindow
- {
- PopupElement = picker,
- WindowStartupLocation = WindowStartupLocation.CenterScreen,
- AllowsTransparency = true,
- WindowStyle = WindowStyle.None,
- MinWidth = 0,
- MinHeight = 0,
- Title = Properties.Langs.Lang.ColorPicker
- };
- picker.SelectedColorChanged += delegate { window.Close(); };
- picker.Canceled += delegate { window.Close(); };
- window.Show();
- }
+ PopupElement = picker,
+ WindowStartupLocation = WindowStartupLocation.CenterScreen,
+ AllowsTransparency = true,
+ WindowStyle = WindowStyle.None,
+ MinWidth = 0,
+ MinHeight = 0,
+ Title = Properties.Langs.Lang.ColorPicker
+ };
+ picker.SelectedColorChanged += delegate { window.Close(); };
+ picker.Canceled += delegate { window.Close(); };
+ window.Show();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppNotification.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppNotification.xaml.cs
index ffc76c31..63ebcf0a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppNotification.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppNotification.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class AppNotification
{
- public partial class AppNotification
+ public AppNotification()
{
- public AppNotification()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs
index b0cba5f3..f9db9155 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class AppSprite
{
- public partial class AppSprite
+ public AppSprite()
{
- public AppSprite()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml.cs
index 8c69a7c4..2f40d7e4 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml.cs
@@ -1,10 +1,9 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class BlogsView
{
- public partial class BlogsView
+ public BlogsView()
{
- public BlogsView()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml.cs
index 3f213c1d..50b71a3c 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml.cs
@@ -1,11 +1,10 @@
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+public partial class ContributorsView
{
- public partial class ContributorsView
+ public ContributorsView()
{
- public ContributorsView()
- {
- InitializeComponent();
- }
+ InitializeComponent();
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
index 52fe0e9a..8f038e1d 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml
@@ -45,7 +45,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
index 224a8ae3..ad2c645b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/LeftMainContent.xaml.cs
@@ -11,112 +11,111 @@ using HandyControlDemo.Data;
using HandyControlDemo.ViewModel;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+///
+/// 左侧主内容
+///
+public partial class LeftMainContent
{
- ///
- /// 左侧主内容
- ///
- public partial class LeftMainContent
+ private string _searchKey;
+
+ public LeftMainContent()
{
- private string _searchKey;
+ InitializeComponent();
+ }
- public LeftMainContent()
+ private void TabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (e.AddedItems.Count == 0) return;
+ if (e.AddedItems[0] is DemoInfoModel demoInfo)
{
- InitializeComponent();
- }
+ ViewModelLocator.Instance.Main.DemoInfoCurrent = demoInfo;
+ var selectedIndex = demoInfo.SelectedIndex;
+ demoInfo.SelectedIndex = -1;
+ demoInfo.SelectedIndex = selectedIndex;
- private void TabControl_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (e.AddedItems.Count == 0) return;
- if (e.AddedItems[0] is DemoInfoModel demoInfo)
- {
- ViewModelLocator.Instance.Main.DemoInfoCurrent = demoInfo;
- var selectedIndex = demoInfo.SelectedIndex;
- demoInfo.SelectedIndex = -1;
- demoInfo.SelectedIndex = selectedIndex;
-
- FilterItems();
- GroupItems(sender as TabControl, demoInfo);
- }
- }
-
- private void ButtonAscending_OnClick(object sender, RoutedEventArgs e)
- {
- if (sender is ToggleButton button && button.Tag is ItemsControl itemsControl)
- {
- if (button.IsChecked == true)
- {
- itemsControl.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
- }
- else
- {
- itemsControl.Items.SortDescriptions.Clear();
- }
- }
- }
-
- private void SearchBar_OnSearchStarted(object sender, FunctionEventArgs e)
- {
- _searchKey = e.Info;
FilterItems();
+ GroupItems(sender as TabControl, demoInfo);
}
+ }
- private void FilterItems()
+ private void ButtonAscending_OnClick(object sender, RoutedEventArgs e)
+ {
+ if (sender is ToggleButton button && button.Tag is ItemsControl itemsControl)
{
- if (string.IsNullOrEmpty(_searchKey))
+ if (button.IsChecked == true)
{
- foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
- {
- item.IsVisible = true;
- item.QueriesText = string.Empty;
- }
+ itemsControl.Items.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
}
else
{
- var key = _searchKey.ToLower();
- foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
+ itemsControl.Items.SortDescriptions.Clear();
+ }
+ }
+ }
+
+ private void SearchBar_OnSearchStarted(object sender, FunctionEventArgs e)
+ {
+ _searchKey = e.Info;
+ FilterItems();
+ }
+
+ private void FilterItems()
+ {
+ if (string.IsNullOrEmpty(_searchKey))
+ {
+ foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
+ {
+ item.IsVisible = true;
+ item.QueriesText = string.Empty;
+ }
+ }
+ else
+ {
+ var key = _searchKey.ToLower();
+ foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
+ {
+ if (item.Name.ToLower().Contains(key))
{
- if (item.Name.ToLower().Contains(key))
- {
- item.IsVisible = true;
- item.QueriesText = _searchKey;
- }
- else if (item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(key))
+ item.IsVisible = true;
+ item.QueriesText = _searchKey;
+ }
+ else if (item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(key))
+ {
+ item.IsVisible = true;
+ item.QueriesText = _searchKey;
+ }
+ else
+ {
+ var name = Properties.Langs.LangProvider.GetLang(item.Name);
+ if (!string.IsNullOrEmpty(name) && name.ToLower().Contains(key))
{
item.IsVisible = true;
item.QueriesText = _searchKey;
}
else
{
- var name = Properties.Langs.LangProvider.GetLang(item.Name);
- if (!string.IsNullOrEmpty(name) && name.ToLower().Contains(key))
- {
- item.IsVisible = true;
- item.QueriesText = _searchKey;
- }
- else
- {
- item.IsVisible = false;
- item.QueriesText = string.Empty;
- }
+ item.IsVisible = false;
+ item.QueriesText = string.Empty;
}
}
}
}
+ }
- private void GroupItems(TabControl tabControl, DemoInfoModel demoInfo)
+ private void GroupItems(TabControl tabControl, DemoInfoModel demoInfo)
+ {
+ var listBox = VisualHelper.GetChild(tabControl);
+ if (listBox == null) return;
+ listBox.Items.GroupDescriptions?.Clear();
+
+ if (demoInfo.IsGroupEnabled)
{
- var listBox = VisualHelper.GetChild(tabControl);
- if (listBox == null) return;
- listBox.Items.GroupDescriptions?.Clear();
-
- if (demoInfo.IsGroupEnabled)
+ Dispatcher.BeginInvoke(new Action(() =>
{
- Dispatcher.BeginInvoke(new Action(() =>
- {
- listBox.Items.GroupDescriptions?.Add(new PropertyGroupDescription("GroupName"));
- }), DispatcherPriority.Background);
- }
+ listBox.Items.GroupDescriptions?.Add(new PropertyGroupDescription("GroupName"));
+ }), DispatcherPriority.Background);
}
}
}
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml.cs
index 173ed9b6..6b489f06 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/MainContent.xaml.cs
@@ -11,173 +11,172 @@ using HandyControlDemo.ViewModel;
using ICSharpCode.AvalonEdit;
-namespace HandyControlDemo.UserControl
+namespace HandyControlDemo.UserControl;
+
+///
+/// 主内容
+///
+public partial class MainContent
{
- ///
- /// 主内容
- ///
- public partial class MainContent
+ private bool _isFull;
+
+ private string _currentDemoKey;
+
+ private bool _drawerCodeUsed;
+
+ private Dictionary _textEditor;
+
+ public MainContent()
{
- private bool _isFull;
+ InitializeComponent();
- private string _currentDemoKey;
+ Messenger.Default.Register(this, MessageToken.FullSwitch, FullSwitch);
+ Messenger.Default.Register(this, MessageToken.SkinUpdated, SkinUpdated);
+ }
- private bool _drawerCodeUsed;
-
- private Dictionary _textEditor;
-
- public MainContent()
+ private void FullSwitch(bool isFull)
+ {
+ if (_isFull == isFull)
{
- InitializeComponent();
-
- Messenger.Default.Register(this, MessageToken.FullSwitch, FullSwitch);
- Messenger.Default.Register(this, MessageToken.SkinUpdated, SkinUpdated);
+ return;
}
- private void FullSwitch(bool isFull)
+ _isFull = isFull;
+
+ if (_isFull)
{
- if (_isFull == isFull)
- {
- return;
- }
-
- _isFull = isFull;
-
- if (_isFull)
- {
- BorderRootEffect.Show();
- BorderEffect.Collapse();
- BorderTitle.Collapse();
- GridMain.HorizontalAlignment = HorizontalAlignment.Stretch;
- GridMain.VerticalAlignment = VerticalAlignment.Stretch;
- PresenterMain.Margin = new Thickness();
- BorderRoot.CornerRadius = new CornerRadius(10);
- BorderRoot.Style = ResourceHelper.GetResource
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CoverViewBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CoverViewBaseStyle.xaml
index 5458edbf..442852af 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/CoverViewBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/CoverViewBaseStyle.xaml
@@ -29,7 +29,7 @@
-
+
@@ -62,13 +62,11 @@
-
-
-
+
-
\ No newline at end of file
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DatePickerBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DatePickerBaseStyle.xaml
index 4d93d623..09d0028f 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DatePickerBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DatePickerBaseStyle.xaml
@@ -32,6 +32,7 @@
+
@@ -44,7 +45,7 @@
-
+
@@ -95,7 +96,7 @@
-
+
@@ -134,7 +135,7 @@
-
+
@@ -144,7 +145,7 @@
-
+
@@ -217,8 +218,8 @@
-
-
+
+
@@ -281,7 +282,7 @@
-
+
@@ -293,8 +294,8 @@
-
-
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DateTimePickerBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DateTimePickerBaseStyle.xaml
index e58bacc1..81e51d02 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/DateTimePickerBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/DateTimePickerBaseStyle.xaml
@@ -8,6 +8,7 @@
+
@@ -22,9 +23,9 @@
-
+
-
+
@@ -73,9 +74,9 @@
-
+
-
+
@@ -114,7 +115,7 @@
-
+
@@ -122,9 +123,9 @@
-
+
-
+
@@ -197,8 +198,8 @@
-
-
+
+
@@ -261,7 +262,7 @@
-
+
@@ -273,8 +274,8 @@
-
-
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ElementGroupBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ElementGroupBaseStyle.xaml
new file mode 100644
index 00000000..f37c92cb
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ElementGroupBaseStyle.xaml
@@ -0,0 +1,39 @@
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ItemsPanelTemplate.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ItemsPanelTemplate.xaml
new file mode 100644
index 00000000..bada6f89
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ItemsPanelTemplate.xaml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
index 139c6332..d29dc02c 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ListBoxBaseStyle.xaml
@@ -73,11 +73,11 @@
-
+
-
-
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
index 036616d5..8f76a90a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/NumericUpDownBaseStyle.xaml
@@ -4,54 +4,41 @@
xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:system="clr-namespace:System;assembly=mscorlib">
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
@@ -134,110 +127,82 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/StepBarBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/StepBarBaseStyle.xaml
index ff623ef1..cf59fb07 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/StepBarBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/StepBarBaseStyle.xaml
@@ -66,14 +66,6 @@
-
-
-
-
-
-
-
-
@@ -105,23 +97,23 @@
-
+
-
+
-
+
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
index 3a772bee..cac7e07a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
@@ -15,48 +15,37 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
\ No newline at end of file
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ToggleButtonBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
index 399f4141..4ccfa31a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ToggleButtonBaseStyle.xaml
@@ -4,6 +4,7 @@
xmlns:system="clr-namespace:System;assembly=mscorlib">
+
+
-
-
@@ -93,13 +103,13 @@
@@ -151,6 +162,7 @@
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Carousel.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Carousel.xaml
index 9f5856cb..a8d595f4 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Carousel.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Carousel.xaml
@@ -68,7 +68,6 @@
-
@@ -88,89 +87,4 @@
-
-
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/DatePicker.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/DatePicker.xaml
index aa4f381b..6ba057c7 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/DatePicker.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/DatePicker.xaml
@@ -4,8 +4,27 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/DateTimePicker.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/DateTimePicker.xaml
index 35391c24..4f46907b 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/DateTimePicker.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/DateTimePicker.xaml
@@ -4,8 +4,27 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/ElementGroup.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/ElementGroup.xaml
new file mode 100644
index 00000000..feb31095
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/ElementGroup.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/ImageViewer.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/ImageViewer.xaml
index 26c85bde..9e3199f8 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/ImageViewer.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/ImageViewer.xaml
@@ -6,8 +6,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/NumericUpDown.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/NumericUpDown.xaml
index 06f9b8fa..6f97ba2c 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/NumericUpDown.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/NumericUpDown.xaml
@@ -4,8 +4,29 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/PropertyGrid.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/PropertyGrid.xaml
index 7906c69d..91dcc0b3 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/PropertyGrid.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/PropertyGrid.xaml
@@ -67,10 +67,6 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
@@ -93,14 +103,15 @@
-
+
@@ -213,7 +231,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/SearchBar.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/SearchBar.xaml
index 9edf609f..e4b97bc9 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/SearchBar.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/SearchBar.xaml
@@ -4,8 +4,29 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TextBox.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TextBox.xaml
index d0cb5f86..3d4b22d0 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/TextBox.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/TextBox.xaml
@@ -8,7 +8,7 @@
@@ -16,8 +16,9 @@
@@ -25,8 +26,9 @@
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TimePicker.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TimePicker.xaml
index 801d2ac9..204d49a3 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/TimePicker.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/TimePicker.xaml
@@ -4,8 +4,27 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/ToggleButton.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/ToggleButton.xaml
index d5e3e627..4319e86f 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/ToggleButton.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/ToggleButton.xaml
@@ -6,7 +6,6 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1168,6 +1175,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
@@ -6729,109 +6914,81 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
@@ -6847,8 +7004,26 @@
+
+
+
@@ -7920,7 +8097,7 @@
-
+
@@ -7952,9 +8129,7 @@
-
-
-
+
@@ -7987,6 +8162,7 @@
+
@@ -7999,7 +8175,7 @@
-
+
@@ -8049,7 +8225,7 @@
-
+
@@ -8087,7 +8263,7 @@
-
+
@@ -8097,7 +8273,7 @@
-
+
@@ -8168,8 +8344,8 @@
-
-
+
+
@@ -8231,7 +8407,7 @@
-
+
@@ -8243,8 +8419,8 @@
-
-
+
+
@@ -8307,6 +8483,7 @@
+
@@ -8321,9 +8498,9 @@
-
+
-
+
@@ -8371,9 +8548,9 @@
-
+
-
+
@@ -8411,7 +8588,7 @@
-
+
@@ -8419,9 +8596,9 @@
-
+
-
+
@@ -8492,8 +8669,8 @@
-
-
+
+
@@ -8555,7 +8732,7 @@
-
+
@@ -8567,8 +8744,8 @@
-
-
+
+
@@ -9276,11 +9453,11 @@
-
+
-
-
+
+
@@ -9448,54 +9625,41 @@
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
-
-
-
-
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -11066,6 +11196,7 @@
+
@@ -11080,9 +11211,9 @@
-
+
-
+
@@ -11130,9 +11261,9 @@
-
+
-
+
@@ -11170,7 +11301,7 @@
-
+
@@ -11178,9 +11309,9 @@
-
+
-
+
@@ -11251,8 +11382,8 @@
-
-
+
+
@@ -11314,7 +11445,7 @@
-
+
@@ -11326,8 +11457,8 @@
-
-
+
+
@@ -11794,10 +11925,10 @@
-
+
-
+
@@ -12245,7 +12376,6 @@
-
@@ -12581,14 +12711,52 @@
+
+
+
+
+
+
+
+
@@ -12664,8 +12832,6 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Theme_40.txt b/src/Shared/HandyControl_Shared/Themes/Theme_40.txt
index d1158b1a..80e81bb0 100644
--- a/src/Shared/HandyControl_Shared/Themes/Theme_40.txt
+++ b/src/Shared/HandyControl_Shared/Themes/Theme_40.txt
@@ -37,9 +37,11 @@ Styles\Base\RepeatButtonBaseStyle.xaml
Styles\Base\ToggleBlockBaseStyle.xaml
Styles\Base\GroupBoxBaseStyle.xaml
Styles\Base\ButtonGroupBaseStyle.xaml
+Styles\Base\ElementGroupBaseStyle.xaml
Styles\Base\ProgressBarBaseStyle.xaml
Styles\Base\CheckBoxBaseStyle.xaml
Styles\Base\RadioButtonBaseStyle.xaml
+Styles\Base\ItemsPanelTemplate.xaml
# --------------------------------------
Styles\Button.xaml
Styles\TextBlock.xaml
@@ -138,6 +140,7 @@ Styles\DateTimePicker.xaml
Styles\Dialog.xaml
Styles\Divider.xaml
Styles\Drawer.xaml
+Styles\ElementGroup.xaml
Styles\Empty.xaml
Styles\Expander.xaml
Styles\FlipClock.xaml
diff --git a/src/Shared/HandyControl_Shared/Themes/Theme_GE45.txt b/src/Shared/HandyControl_Shared/Themes/Theme_GE45.txt
index e42ae089..0020c54a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Theme_GE45.txt
+++ b/src/Shared/HandyControl_Shared/Themes/Theme_GE45.txt
@@ -37,9 +37,11 @@ Styles\Base\RepeatButtonBaseStyle.xaml
Styles\Base\ToggleBlockBaseStyle.xaml
Styles\Base\GroupBoxBaseStyle.xaml
Styles\Base\ButtonGroupBaseStyle.xaml
+Styles\Base\ElementGroupBaseStyle.xaml
Styles\Base\ProgressBarBaseStyle.xaml
Styles\Base\CheckBoxBaseStyle.xaml
Styles\Base\RadioButtonBaseStyle.xaml
+Styles\Base\ItemsPanelTemplate.xaml
# --------------------------------------
Styles\Button.xaml
Styles\TextBlock.xaml
@@ -138,6 +140,7 @@ Styles\DateTimePicker.xaml
Styles\Dialog.xaml
Styles\Divider.xaml
Styles\Drawer.xaml
+Styles\ElementGroup.xaml
Styles\Empty.xaml
Styles\Expander.xaml
Styles\FlipClock.xaml
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2BooleanReConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2BooleanReConverter.cs
index 2c551e59..1af3fdf5 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2BooleanReConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2BooleanReConverter.cs
@@ -2,26 +2,25 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Boolean2BooleanReConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is bool boolValue)
- {
- return !boolValue;
- }
- return value;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+public class Boolean2BooleanReConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is bool boolValue)
{
- if (value is bool boolValue)
- {
- return !boolValue;
- }
- return value;
+ return !boolValue;
}
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is bool boolValue)
+ {
+ return !boolValue;
+ }
+ return value;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2StrConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2StrConverter.cs
index 08754c0c..3177a8cb 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2StrConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2StrConverter.cs
@@ -2,31 +2,30 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class Boolean2StringConverter : IValueConverter
{
- public class Boolean2StringConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ if (value is bool boolValue)
{
- if (value is bool boolValue)
+ if (parameter is string str)
{
- if (parameter is string str)
+ var arr = str.Split(';');
+ if (arr.Length > 1)
{
- var arr = str.Split(';');
- if (arr.Length > 1)
- {
- return boolValue ? arr[1] : arr[0];
- }
- return "";
+ return boolValue ? arr[1] : arr[0];
}
return "";
}
return "";
}
+ return "";
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2VisibilityReConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2VisibilityReConverter.cs
index 6c0efe81..b94627f8 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2VisibilityReConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Boolean2VisibilityReConverter.cs
@@ -3,18 +3,17 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Boolean2VisibilityReConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value != null && (bool) value ? Visibility.Collapsed : Visibility.Visible;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class Boolean2VisibilityReConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value != null && (bool) value ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2BooleanConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2BooleanConverter.cs
index b154e6be..89c83351 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2BooleanConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2BooleanConverter.cs
@@ -5,36 +5,35 @@ using System.Linq;
using System.Windows.Data;
using HandyControl.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class BooleanArr2BooleanConverter : IMultiValueConverter
{
- public class BooleanArr2BooleanConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ if (values == null)
{
- if (values == null)
+ return ValueBoxes.FalseBox;
+ }
+
+ var arr = new List();
+ foreach (var item in values)
+ {
+ if (item is bool boolValue)
+ {
+ arr.Add(boolValue);
+ }
+ else
{
return ValueBoxes.FalseBox;
}
-
- var arr = new List();
- foreach (var item in values)
- {
- if (item is bool boolValue)
- {
- arr.Add(boolValue);
- }
- else
- {
- return ValueBoxes.FalseBox;
- }
- }
-
- return ValueBoxes.BooleanBox(arr.All(item => item));
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return ValueBoxes.BooleanBox(arr.All(item => item));
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs
index fb17a66c..19714766 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs
@@ -5,35 +5,34 @@ using System.Linq;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class BooleanArr2VisibilityConverter : IMultiValueConverter
{
- public class BooleanArr2VisibilityConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ if (values == null)
{
- if (values == null)
+ return Visibility.Collapsed;
+ }
+
+ var arr = new List();
+ foreach (var item in values)
+ {
+ if (item is bool boolValue)
+ {
+ arr.Add(boolValue);
+ }
+ else
{
return Visibility.Collapsed;
}
-
- var arr = new List();
- foreach (var item in values)
- {
- if (item is bool boolValue)
- {
- arr.Add(boolValue);
- }
- else
- {
- return Visibility.Collapsed;
- }
- }
- return arr.All(item => item) ? Visibility.Visible : Visibility.Collapsed;
}
+ return arr.All(item => item) ? Visibility.Visible : Visibility.Collapsed;
+ }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularClipConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularClipConverter.cs
index a47acf92..8eb83de5 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularClipConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularClipConverter.cs
@@ -6,31 +6,30 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class BorderCircularClipConverter : IMultiValueConverter
{
- public class BorderCircularClipConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ if (values.Length == 3 && values[0] is double width && values[1] is double height && values[2] is CornerRadius radius)
{
- if (values.Length == 3 && values[0] is double width && values[1] is double height && values[2] is CornerRadius radius)
+ if (width < double.Epsilon || height < double.Epsilon)
{
- if (width < double.Epsilon || height < double.Epsilon)
- {
- return Geometry.Empty;
- }
-
- var clip = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft);
- clip.Freeze();
-
- return clip;
+ return Geometry.Empty;
}
- return DependencyProperty.UnsetValue;
+ var clip = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft);
+ clip.Freeze();
+
+ return clip;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return DependencyProperty.UnsetValue;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularConverter.cs
index 13ec9abb..2d556de2 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/BorderCircularConverter.cs
@@ -3,29 +3,28 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class BorderCircularConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values.Length == 2 && values[0] is double width && values[1] is double height)
- {
- if (width < double.Epsilon || height < double.Epsilon)
- {
- return new CornerRadius();
- }
+namespace HandyControl.Tools.Converter;
- var min = Math.Min(width, height);
- return new CornerRadius(min / 2);
+public class BorderCircularConverter : IMultiValueConverter
+{
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2 && values[0] is double width && values[1] is double height)
+ {
+ if (width < double.Epsilon || height < double.Epsilon)
+ {
+ return new CornerRadius();
}
- return DependencyProperty.UnsetValue;
+ var min = Math.Min(width, height);
+ return new CornerRadius(min / 2);
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return DependencyProperty.UnsetValue;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs
index f5361168..a27fab6a 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs
@@ -4,47 +4,46 @@ using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class BorderClipConverter : IMultiValueConverter
{
- public class BorderClipConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ if (values.Length == 3 && values[0] is double width && values[1] is double height && values[2] is CornerRadius radius)
{
- if (values.Length == 3 && values[0] is double width && values[1] is double height && values[2] is CornerRadius radius)
+ if (width < double.Epsilon || height < double.Epsilon)
{
- if (width < double.Epsilon || height < double.Epsilon)
- {
- return Geometry.Empty;
- }
-
- var clip = new PathGeometry
- {
- Figures = new PathFigureCollection
- {
- new(new Point(radius.TopLeft, 0), new PathSegment[]
- {
- new LineSegment(new Point(width - radius.TopRight, 0), false),
- new ArcSegment(new Point(width, radius.TopRight), new Size(radius.TopRight, radius.TopRight), 90, false, SweepDirection.Clockwise, false),
- new LineSegment(new Point(width, height - radius.BottomRight), false),
- new ArcSegment(new Point(width - radius.BottomRight, height), new Size(radius.BottomRight, radius.BottomRight), 90, false, SweepDirection.Clockwise, false),
- new LineSegment(new Point(radius.BottomLeft, height), false),
- new ArcSegment(new Point(0, height - radius.BottomLeft), new Size(radius.BottomLeft, radius.BottomLeft), 90, false, SweepDirection.Clockwise, false),
- new LineSegment(new Point(0, radius.TopLeft), false),
- new ArcSegment(new Point(radius.TopLeft, 0), new Size(radius.TopLeft, radius.TopLeft), 90, false, SweepDirection.Clockwise, false),
- }, false)
- }
- };
- clip.Freeze();
-
- return clip;
+ return Geometry.Empty;
}
- return DependencyProperty.UnsetValue;
+ var clip = new PathGeometry
+ {
+ Figures = new PathFigureCollection
+ {
+ new(new Point(radius.TopLeft, 0), new PathSegment[]
+ {
+ new LineSegment(new Point(width - radius.TopRight, 0), false),
+ new ArcSegment(new Point(width, radius.TopRight), new Size(radius.TopRight, radius.TopRight), 90, false, SweepDirection.Clockwise, false),
+ new LineSegment(new Point(width, height - radius.BottomRight), false),
+ new ArcSegment(new Point(width - radius.BottomRight, height), new Size(radius.BottomRight, radius.BottomRight), 90, false, SweepDirection.Clockwise, false),
+ new LineSegment(new Point(radius.BottomLeft, height), false),
+ new ArcSegment(new Point(0, height - radius.BottomLeft), new Size(radius.BottomLeft, radius.BottomLeft), 90, false, SweepDirection.Clockwise, false),
+ new LineSegment(new Point(0, radius.TopLeft), false),
+ new ArcSegment(new Point(radius.TopLeft, 0), new Size(radius.TopLeft, radius.TopLeft), 90, false, SweepDirection.Clockwise, false),
+ }, false)
+ }
+ };
+ clip.Freeze();
+
+ return clip;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return DependencyProperty.UnsetValue;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs
index 5411a8bc..7c054342 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/ColLayoutConverter.cs
@@ -6,130 +6,129 @@ using System.Security;
using System.Text;
using HandyControl.Tools.Extension;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class ColLayoutConverter : TypeConverter
{
- public class ColLayoutConverter : TypeConverter
+ public override bool CanConvertFrom(ITypeDescriptorContext typeDescriptorContext, Type sourceType)
{
- public override bool CanConvertFrom(ITypeDescriptorContext typeDescriptorContext, Type sourceType)
+ switch (Type.GetTypeCode(sourceType))
{
- switch (Type.GetTypeCode(sourceType))
- {
- case TypeCode.Int16:
- case TypeCode.UInt16:
- case TypeCode.Int32:
- case TypeCode.UInt32:
- case TypeCode.Int64:
- case TypeCode.UInt64:
- case TypeCode.Single:
- case TypeCode.Double:
- case TypeCode.Decimal:
- case TypeCode.String:
- return true;
- default:
- return false;
- }
- }
-
- public override bool CanConvertTo(ITypeDescriptorContext typeDescriptorContext, Type destinationType) =>
- destinationType == typeof(InstanceDescriptor) || destinationType == typeof(string);
-
- public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object source)
- {
- if (source == null) throw GetConvertFromException(null);
-
- return source switch
- {
- string s => FromString(s, cultureInfo),
- double d => new ColLayout((int) d),
- _ => new ColLayout(Convert.ToInt32(source, cultureInfo))
- };
- }
-
- [SecurityCritical]
- public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
- {
- if (value == null) throw new ArgumentNullException(nameof(value));
-
- if (destinationType == null) throw new ArgumentNullException(nameof(destinationType));
-
- if (!(value is ColLayout th)) throw new ArgumentException("UnexpectedParameterType");
-
- if (destinationType == typeof(string)) return ToString(th, cultureInfo);
- if (destinationType == typeof(InstanceDescriptor))
- {
- var ci = typeof(ColLayout).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) });
- return new InstanceDescriptor(ci, new object[] { th.Xs, th.Sm, th.Md, th.Lg, th.Xl, th.Xxl });
- }
-
- throw new ArgumentException("CannotConvertType");
- }
-
- private static string ToString(ColLayout th, CultureInfo cultureInfo)
- {
- var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
-
- // Initial capacity [128] is an estimate based on a sum of:
- // 72 = 6x double (twelve digits is generous for the range of values likely)
- // 4 = 4x separator characters
- var sb = new StringBuilder(128);
-
- sb.Append(th.Xs.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(th.Sm.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(th.Md.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(th.Lg.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(th.Xl.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(th.Xxl.ToString(cultureInfo));
- return th.ToString();
- }
-
- private static ColLayout FromString(string s, CultureInfo cultureInfo)
- {
- var th = new TokenizerHelper(s, cultureInfo);
- var lengths = new int[6];
- var i = 0;
-
- while (th.NextToken())
- {
- if (i >= 6)
- {
- i = 7; // Set i to a bad value.
- break;
- }
-
- lengths[i] = th.GetCurrentToken().Value();
- i++;
- }
-
- return i switch
- {
- 1 => new ColLayout(lengths[0]),
- 2 => new ColLayout { Xs = lengths[0], Sm = lengths[1] },
- 3 => new ColLayout { Xs = lengths[0], Sm = lengths[1], Md = lengths[2] },
- 4 => new ColLayout { Xs = lengths[0], Sm = lengths[1], Md = lengths[2], Lg = lengths[3] },
- 5 => new ColLayout
- {
- Xs = lengths[0],
- Sm = lengths[1],
- Md = lengths[2],
- Lg = lengths[3],
- Xl = lengths[4]
- },
- 6 => new ColLayout
- {
- Xs = lengths[0],
- Sm = lengths[1],
- Md = lengths[2],
- Lg = lengths[3],
- Xl = lengths[4],
- Xxl = lengths[5]
- },
- _ => throw new FormatException("InvalidStringColLayout")
- };
+ case TypeCode.Int16:
+ case TypeCode.UInt16:
+ case TypeCode.Int32:
+ case TypeCode.UInt32:
+ case TypeCode.Int64:
+ case TypeCode.UInt64:
+ case TypeCode.Single:
+ case TypeCode.Double:
+ case TypeCode.Decimal:
+ case TypeCode.String:
+ return true;
+ default:
+ return false;
}
}
+
+ public override bool CanConvertTo(ITypeDescriptorContext typeDescriptorContext, Type destinationType) =>
+ destinationType == typeof(InstanceDescriptor) || destinationType == typeof(string);
+
+ public override object ConvertFrom(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object source)
+ {
+ if (source == null) throw GetConvertFromException(null);
+
+ return source switch
+ {
+ string s => FromString(s, cultureInfo),
+ double d => new ColLayout((int) d),
+ _ => new ColLayout(Convert.ToInt32(source, cultureInfo))
+ };
+ }
+
+ [SecurityCritical]
+ public override object ConvertTo(ITypeDescriptorContext typeDescriptorContext, CultureInfo cultureInfo, object value, Type destinationType)
+ {
+ if (value == null) throw new ArgumentNullException(nameof(value));
+
+ if (destinationType == null) throw new ArgumentNullException(nameof(destinationType));
+
+ if (!(value is ColLayout th)) throw new ArgumentException("UnexpectedParameterType");
+
+ if (destinationType == typeof(string)) return ToString(th, cultureInfo);
+ if (destinationType == typeof(InstanceDescriptor))
+ {
+ var ci = typeof(ColLayout).GetConstructor(new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) });
+ return new InstanceDescriptor(ci, new object[] { th.Xs, th.Sm, th.Md, th.Lg, th.Xl, th.Xxl });
+ }
+
+ throw new ArgumentException("CannotConvertType");
+ }
+
+ private static string ToString(ColLayout th, CultureInfo cultureInfo)
+ {
+ var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
+
+ // Initial capacity [128] is an estimate based on a sum of:
+ // 72 = 6x double (twelve digits is generous for the range of values likely)
+ // 4 = 4x separator characters
+ var sb = new StringBuilder(128);
+
+ sb.Append(th.Xs.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(th.Sm.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(th.Md.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(th.Lg.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(th.Xl.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(th.Xxl.ToString(cultureInfo));
+ return th.ToString();
+ }
+
+ private static ColLayout FromString(string s, CultureInfo cultureInfo)
+ {
+ var th = new TokenizerHelper(s, cultureInfo);
+ var lengths = new int[6];
+ var i = 0;
+
+ while (th.NextToken())
+ {
+ if (i >= 6)
+ {
+ i = 7; // Set i to a bad value.
+ break;
+ }
+
+ lengths[i] = th.GetCurrentToken().Value();
+ i++;
+ }
+
+ return i switch
+ {
+ 1 => new ColLayout(lengths[0]),
+ 2 => new ColLayout { Xs = lengths[0], Sm = lengths[1] },
+ 3 => new ColLayout { Xs = lengths[0], Sm = lengths[1], Md = lengths[2] },
+ 4 => new ColLayout { Xs = lengths[0], Sm = lengths[1], Md = lengths[2], Lg = lengths[3] },
+ 5 => new ColLayout
+ {
+ Xs = lengths[0],
+ Sm = lengths[1],
+ Md = lengths[2],
+ Lg = lengths[3],
+ Xl = lengths[4]
+ },
+ 6 => new ColLayout
+ {
+ Xs = lengths[0],
+ Sm = lengths[1],
+ Md = lengths[2],
+ Lg = lengths[3],
+ Xl = lengths[4],
+ Xxl = lengths[5]
+ },
+ _ => throw new FormatException("InvalidStringColLayout")
+ };
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Color2ChannelAConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Color2ChannelAConverter.cs
index 2402f1d8..e4c3828d 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Color2ChannelAConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Color2ChannelAConverter.cs
@@ -3,37 +3,36 @@ using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
-namespace HandyControl.Tools.Converter
-{
- public class Color2ChannelAConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is SolidColorBrush brush)
- {
- return brush.Color.A;
- }
- return 0;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+public class Color2ChannelAConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is SolidColorBrush brush)
{
- if (value is string str)
+ return brush.Color.A;
+ }
+ return 0;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is string str)
+ {
+ try
{
- try
+ if (ColorConverter.ConvertFromString(str) is Color color)
{
- if (ColorConverter.ConvertFromString(str) is Color color)
- {
- return new SolidColorBrush(color);
- }
- }
- catch
- {
- return parameter;
+ return new SolidColorBrush(color);
}
+ }
+ catch
+ {
return parameter;
}
return parameter;
}
+ return parameter;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Color2HexStrConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Color2HexStrConverter.cs
index 5bf18280..b58392e6 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Color2HexStrConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Color2HexStrConverter.cs
@@ -3,38 +3,37 @@ using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
-namespace HandyControl.Tools.Converter
-{
- public class Color2HexStringConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is SolidColorBrush brush)
- {
- var color = brush.Color;
- return color.A < 255 ? $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}" : $"#{color.R:X2}{color.G:X2}{color.B:X2}";
- }
- return "";
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+public class Color2HexStringConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is SolidColorBrush brush)
{
- if (value is string str)
+ var color = brush.Color;
+ return color.A < 255 ? $"#{color.A:X2}{color.R:X2}{color.G:X2}{color.B:X2}" : $"#{color.R:X2}{color.G:X2}{color.B:X2}";
+ }
+ return "";
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is string str)
+ {
+ try
{
- try
+ if (ColorConverter.ConvertFromString(str) is Color color)
{
- if (ColorConverter.ConvertFromString(str) is Color color)
- {
- return new SolidColorBrush(color);
- }
- }
- catch
- {
- return new SolidColorBrush(default);
+ return new SolidColorBrush(color);
}
+ }
+ catch
+ {
return new SolidColorBrush(default);
}
return new SolidColorBrush(default);
}
+ return new SolidColorBrush(default);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/CornerRadiusSplitConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/CornerRadiusSplitConverter.cs
index 449db208..6923ee18 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/CornerRadiusSplitConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/CornerRadiusSplitConverter.cs
@@ -3,32 +3,31 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class CornerRadiusSplitConverter : IValueConverter
{
- public class CornerRadiusSplitConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ if (value is CornerRadius cornerRadius)
{
- if (value is CornerRadius cornerRadius)
+ if (parameter is string str)
{
- if (parameter is string str)
- {
- var arr = str.Split(',');
- if (arr.Length != 4) return cornerRadius;
+ var arr = str.Split(',');
+ if (arr.Length != 4) return cornerRadius;
- return new CornerRadius(
- arr[0].Equals("1") ? cornerRadius.TopLeft : 0,
- arr[1].Equals("1") ? cornerRadius.TopRight : 0,
- arr[2].Equals("1") ? cornerRadius.BottomRight : 0,
- arr[3].Equals("1") ? cornerRadius.BottomLeft : 0);
- }
+ return new CornerRadius(
+ arr[0].Equals("1") ? cornerRadius.TopLeft : 0,
+ arr[1].Equals("1") ? cornerRadius.TopRight : 0,
+ arr[2].Equals("1") ? cornerRadius.BottomRight : 0,
+ arr[3].Equals("1") ? cornerRadius.BottomLeft : 0);
}
- return value;
}
+ return value;
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/DataGridSelectAllButtonVisibilityConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/DataGridSelectAllButtonVisibilityConverter.cs
index 2b0d5b57..ea0514a0 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/DataGridSelectAllButtonVisibilityConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/DataGridSelectAllButtonVisibilityConverter.cs
@@ -4,46 +4,43 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class DataGridSelectAllButtonVisibilityConverter : IMultiValueConverter
{
- public class DataGridSelectAllButtonVisibilityConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ if (values == null)
{
- if (values == null)
- {
- return Visibility.Collapsed;
- }
+ return Visibility.Collapsed;
+ }
- if (values.Length != 2)
- {
- return Visibility.Collapsed;
- }
+ if (values.Length != 2)
+ {
+ return Visibility.Collapsed;
+ }
- if (values[0] is DataGridHeadersVisibility headersVisibility)
+ if (values[0] is DataGridHeadersVisibility headersVisibility)
+ {
+ if (values[1] is bool showButton)
{
- if (values[1] is bool showButton)
+ if (headersVisibility == DataGridHeadersVisibility.All)
{
- if (headersVisibility == DataGridHeadersVisibility.All)
- {
- return showButton ? Visibility.Visible : Visibility.Collapsed;
- }
-
- return Visibility.Collapsed;
+ return showButton ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Collapsed;
}
- else if (values[0] is bool showButton)
- {
- if (values[1] is DataGridHeadersVisibility visibility)
- {
- if (visibility == DataGridHeadersVisibility.All)
- {
- return showButton ? Visibility.Visible : Visibility.Collapsed;
- }
- return Visibility.Collapsed;
+ return Visibility.Collapsed;
+ }
+ else if (values[0] is bool showButton)
+ {
+ if (values[1] is DataGridHeadersVisibility visibility)
+ {
+ if (visibility == DataGridHeadersVisibility.All)
+ {
+ return showButton ? Visibility.Visible : Visibility.Collapsed;
}
return Visibility.Collapsed;
@@ -52,9 +49,11 @@ namespace HandyControl.Tools.Converter
return Visibility.Collapsed;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return Visibility.Collapsed;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Double2GridLengthConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Double2GridLengthConverter.cs
index b0098f4b..62538ead 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Double2GridLengthConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Double2GridLengthConverter.cs
@@ -3,27 +3,26 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class Double2GridLengthConverter : IValueConverter
{
- public class Double2GridLengthConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ if (value is double doubleValue)
{
- if (value is double doubleValue)
+ if (double.IsNaN(doubleValue) || double.IsInfinity(doubleValue))
{
- if (double.IsNaN(doubleValue) || double.IsInfinity(doubleValue))
- {
- return new GridLength(1.0, GridUnitType.Star);
- }
- return new GridLength(doubleValue);
+ return new GridLength(1.0, GridUnitType.Star);
}
-
- return new GridLength(0);
+ return new GridLength(doubleValue);
}
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return new GridLength(0);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/DoubleMinConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/DoubleMinConverter.cs
index 75fb1add..713af864 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/DoubleMinConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/DoubleMinConverter.cs
@@ -3,29 +3,28 @@ using System.Globalization;
using System.Windows.Data;
using HandyControl.Tools.Extension;
-namespace HandyControl.Tools.Converter
-{
- public class DoubleMinConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is double doubleValue)
- {
- if (parameter is string str)
- {
- var minValue = str.Value();
- return doubleValue < minValue ? minValue : doubleValue;
- }
+namespace HandyControl.Tools.Converter;
- return doubleValue < .0 ? .0 : doubleValue;
+public class DoubleMinConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value is double doubleValue)
+ {
+ if (parameter is string str)
+ {
+ var minValue = str.Value();
+ return doubleValue < minValue ? minValue : doubleValue;
}
- return .0;
+ return doubleValue < .0 ? .0 : doubleValue;
}
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return .0;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Int2StrConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Int2StrConverter.cs
index bb71ee23..e90d8051 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Int2StrConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Int2StrConverter.cs
@@ -2,37 +2,36 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Int2StringConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value != null)
- {
- if (int.TryParse(value.ToString(), out var intValue))
- {
- if (parameter is string str)
- {
- var arr = str.Split(';');
- if (arr.Length > intValue)
- {
- return arr[intValue];
- }
+namespace HandyControl.Tools.Converter;
- return intValue;
+public class Int2StringConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value != null)
+ {
+ if (int.TryParse(value.ToString(), out var intValue))
+ {
+ if (parameter is string str)
+ {
+ var arr = str.Split(';');
+ if (arr.Length > intValue)
+ {
+ return arr[intValue];
}
return intValue;
}
+
+ return intValue;
}
-
- return value;
}
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return value;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Long2FileSizeConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Long2FileSizeConverter.cs
index f8fb3cf5..315b7bd7 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Long2FileSizeConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Long2FileSizeConverter.cs
@@ -2,51 +2,50 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Long2FileSizeConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value == null) return Properties.Langs.Lang.UnknownSize;
- if (value is long intValue)
- {
- if (intValue < 0)
- {
- return Properties.Langs.Lang.UnknownSize;
- }
- if (intValue < 1024)
- {
- return $"{intValue} B";
- }
- if (intValue < 1048576)
- {
- return $"{intValue / 1024.0:0.00} KB";
- }
- if (intValue < 1073741824)
- {
- return $"{intValue / 1048576.0:0.00} MB";
- }
- if (intValue < 1099511627776)
- {
- return $"{intValue / 1073741824.0:0.00} GB";
- }
- if (intValue < 1125899906842624)
- {
- return $"{intValue / 1099511627776.0:0.00} TB";
- }
- if (intValue < 1152921504606847000)
- {
- return $"{intValue / 1125899906842624.0:0.00} PB";
- }
- return Properties.Langs.Lang.TooLarge;
- }
- return Properties.Langs.Lang.Unknown;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+public class Long2FileSizeConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (value == null) return Properties.Langs.Lang.UnknownSize;
+ if (value is long intValue)
{
- throw new NotSupportedException();
+ if (intValue < 0)
+ {
+ return Properties.Langs.Lang.UnknownSize;
+ }
+ if (intValue < 1024)
+ {
+ return $"{intValue} B";
+ }
+ if (intValue < 1048576)
+ {
+ return $"{intValue / 1024.0:0.00} KB";
+ }
+ if (intValue < 1073741824)
+ {
+ return $"{intValue / 1048576.0:0.00} MB";
+ }
+ if (intValue < 1099511627776)
+ {
+ return $"{intValue / 1073741824.0:0.00} GB";
+ }
+ if (intValue < 1125899906842624)
+ {
+ return $"{intValue / 1099511627776.0:0.00} TB";
+ }
+ if (intValue < 1152921504606847000)
+ {
+ return $"{intValue / 1125899906842624.0:0.00} PB";
+ }
+ return Properties.Langs.Lang.TooLarge;
}
+ return Properties.Langs.Lang.Unknown;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Number2PercentageConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Number2PercentageConverter.cs
index 785e618e..d4fe7b4b 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Number2PercentageConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Number2PercentageConverter.cs
@@ -4,33 +4,32 @@ using System.Windows.Data;
using HandyControl.Expression.Drawing;
using HandyControl.Tools.Extension;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class Number2PercentageConverter : IMultiValueConverter
{
- public class Number2PercentageConverter : IMultiValueConverter
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values == null || values.Length != 2) return .0;
+ if (values == null || values.Length != 2) return .0;
- var obj1 = values[0];
- var obj2 = values[1];
+ var obj1 = values[0];
+ var obj2 = values[1];
- if (obj1 == null || obj2 == null) return .0;
+ if (obj1 == null || obj2 == null) return .0;
- var str1 = values[0].ToString();
- var str2 = values[1].ToString();
+ var str1 = values[0].ToString();
+ var str2 = values[1].ToString();
- var v1 = str1.Value();
- var v2 = str2.Value();
+ var v1 = str1.Value();
+ var v2 = str2.Value();
- if (MathHelper.IsVerySmall(v2)) return 100.0;
+ if (MathHelper.IsVerySmall(v2)) return 100.0;
- return v1 / v2 * 100;
- }
+ return v1 / v2 * 100;
+ }
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Object2BooleanConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Object2BooleanConverter.cs
index d160d5f1..892ce2c3 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Object2BooleanConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Object2BooleanConverter.cs
@@ -2,15 +2,14 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Object2BooleanConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => !(value is null);
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class Object2BooleanConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => !(value is null);
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Object2StringConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Object2StringConverter.cs
index 7db10f32..88be78cb 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Object2StringConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Object2StringConverter.cs
@@ -2,15 +2,14 @@
using System.Globalization;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Object2StringConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value?.ToString();
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class Object2StringConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => value?.ToString();
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityConverter.cs
index 3a753049..d8432dbe 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityConverter.cs
@@ -3,18 +3,17 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Object2VisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value == null ? Visibility.Collapsed : Visibility.Visible;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class Object2VisibilityConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value == null ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs
index b1d5f3a2..9b4205e6 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/Object2VisibilityReConverter.cs
@@ -3,18 +3,17 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class Object2VisibilityReConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value == null ? Visibility.Visible : Visibility.Collapsed;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+public class Object2VisibilityReConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value == null ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/RectangleCircularConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/RectangleCircularConverter.cs
index 5e2e818d..af08f6f0 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/RectangleCircularConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/RectangleCircularConverter.cs
@@ -3,29 +3,28 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class RectangleCircularConverter : IMultiValueConverter
- {
- public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
- {
- if (values.Length == 2 && values[0] is double width && values[1] is double height)
- {
- if (width < double.Epsilon || height < double.Epsilon)
- {
- return .0;
- }
+namespace HandyControl.Tools.Converter;
- var min = Math.Min(width, height);
- return min / 2;
+public class RectangleCircularConverter : IMultiValueConverter
+{
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values.Length == 2 && values[0] is double width && values[1] is double height)
+ {
+ if (width < double.Epsilon || height < double.Epsilon)
+ {
+ return .0;
}
- return DependencyProperty.UnsetValue;
+ var min = Math.Min(width, height);
+ return min / 2;
}
- public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ return DependencyProperty.UnsetValue;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityConverter.cs
index 6a8fba25..e8fe4310 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityConverter.cs
@@ -3,18 +3,17 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class String2VisibilityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return string.IsNullOrEmpty((string) value) ? Visibility.Collapsed : Visibility.Visible;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value != null && (Visibility) value == Visibility.Collapsed;
- }
+public class String2VisibilityConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return string.IsNullOrEmpty((string) value) ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value != null && (Visibility) value == Visibility.Collapsed;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityReConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityReConverter.cs
index 42fb8816..cc9fddbb 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityReConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/String2VisibilityReConverter.cs
@@ -3,18 +3,17 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
-{
- public class String2VisibilityReConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return string.IsNullOrEmpty((string) value) ? Visibility.Visible : Visibility.Collapsed;
- }
+namespace HandyControl.Tools.Converter;
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value != null && (Visibility) value == Visibility.Collapsed;
- }
+public class String2VisibilityReConverter : IValueConverter
+{
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return string.IsNullOrEmpty((string) value) ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value != null && (Visibility) value == Visibility.Collapsed;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/ThicknessSplitConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/ThicknessSplitConverter.cs
index a1dbc5c0..89433e05 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/ThicknessSplitConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/ThicknessSplitConverter.cs
@@ -3,32 +3,31 @@ using System.Globalization;
using System.Windows;
using System.Windows.Data;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class ThicknessSplitConverter : IValueConverter
{
- public class ThicknessSplitConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ if (value is Thickness thickness)
{
- if (value is Thickness thickness)
+ if (parameter is string str)
{
- if (parameter is string str)
- {
- var arr = str.Split(',');
- if (arr.Length != 4) return thickness;
+ var arr = str.Split(',');
+ if (arr.Length != 4) return thickness;
- return new Thickness(
- arr[0].Equals("1") ? thickness.Left : 0,
- arr[1].Equals("1") ? thickness.Top : 0,
- arr[2].Equals("1") ? thickness.Right : 0,
- arr[3].Equals("1") ? thickness.Bottom : 0);
- }
+ return new Thickness(
+ arr[0].Equals("1") ? thickness.Left : 0,
+ arr[1].Equals("1") ? thickness.Top : 0,
+ arr[2].Equals("1") ? thickness.Right : 0,
+ arr[3].Equals("1") ? thickness.Bottom : 0);
}
- return value;
}
+ return value;
+ }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
index cc379701..5a6f7bb5 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
@@ -4,25 +4,24 @@ using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
-namespace HandyControl.Tools.Converter
+namespace HandyControl.Tools.Converter;
+
+public class TreeViewItemMarginConverter : IValueConverter
{
- public class TreeViewItemMarginConverter : IValueConverter
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
- public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ var left = 0.0;
+ UIElement element = value as TreeViewItem;
+ while (element != null && element.GetType() != typeof(TreeView))
{
- var left = 0.0;
- UIElement element = value as TreeViewItem;
- while (element != null && element.GetType() != typeof(TreeView))
- {
- element = (UIElement) VisualTreeHelper.GetParent(element);
- if (element is TreeViewItem)
- left += 19.0;
- }
- return new Thickness(left, 0, 0, 0);
- }
- public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
- {
- throw new NotSupportedException();
+ element = (UIElement) VisualTreeHelper.GetParent(element);
+ if (element is TreeViewItem)
+ left += 19.0;
}
+ return new Thickness(left, 0, 0, 0);
+ }
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
+ {
+ throw new NotSupportedException();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs b/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
index 08bc0915..37f67cea 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
@@ -6,122 +6,121 @@ using System.Windows.Markup;
using HandyControl.Data;
using HandyControl.Tools.Converter;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+[TypeConverter(typeof(ColLayoutConverter))]
+public class ColLayout : MarkupExtension
{
- [TypeConverter(typeof(ColLayoutConverter))]
- public class ColLayout : MarkupExtension
+ public static readonly int ColMaxCellCount = 24;
+
+ public static readonly int HalfColMaxCellCount = 12;
+
+ public static readonly int XsMaxWidth = 768;
+
+ public static readonly int SmMaxWidth = 992;
+
+ public static readonly int MdMaxWidth = 1200;
+
+ public static readonly int LgMaxWidth = 1920;
+
+ public static readonly int XlMaxWidth = 2560;
+
+ public int Xs { get; set; } = 24;
+
+ public int Sm { get; set; } = 12;
+
+ public int Md { get; set; } = 8;
+
+ public int Lg { get; set; } = 6;
+
+ public int Xl { get; set; } = 4;
+
+ public int Xxl { get; set; } = 2;
+
+ public ColLayout()
{
- public static readonly int ColMaxCellCount = 24;
- public static readonly int HalfColMaxCellCount = 12;
+ }
- public static readonly int XsMaxWidth = 768;
+ public ColLayout(int uniformWidth)
+ {
+ Xs = uniformWidth;
+ Sm = uniformWidth;
+ Md = uniformWidth;
+ Lg = uniformWidth;
+ Xl = uniformWidth;
+ Xxl = uniformWidth;
+ }
- public static readonly int SmMaxWidth = 992;
+ public ColLayout(int xs, int sm, int md, int lg, int xl, int xxl)
+ {
+ Xs = xs;
+ Sm = sm;
+ Md = md;
+ Lg = lg;
+ Xl = xl;
+ Xxl = xxl;
+ }
- public static readonly int MdMaxWidth = 1200;
-
- public static readonly int LgMaxWidth = 1920;
-
- public static readonly int XlMaxWidth = 2560;
-
- public int Xs { get; set; } = 24;
-
- public int Sm { get; set; } = 12;
-
- public int Md { get; set; } = 8;
-
- public int Lg { get; set; } = 6;
-
- public int Xl { get; set; } = 4;
-
- public int Xxl { get; set; } = 2;
-
- public ColLayout()
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ return new ColLayout
{
+ Xs = Xs,
+ Sm = Sm,
+ Md = Md,
+ Lg = Lg,
+ Xl = Xl,
+ Xxl = Xxl
+ };
+ }
- }
-
- public ColLayout(int uniformWidth)
+ public static ColLayoutStatus GetLayoutStatus(double width)
+ {
+ if (width < MdMaxWidth)
{
- Xs = uniformWidth;
- Sm = uniformWidth;
- Md = uniformWidth;
- Lg = uniformWidth;
- Xl = uniformWidth;
- Xxl = uniformWidth;
- }
-
- public ColLayout(int xs, int sm, int md, int lg, int xl, int xxl)
- {
- Xs = xs;
- Sm = sm;
- Md = md;
- Lg = lg;
- Xl = xl;
- Xxl = xxl;
- }
-
- public override object ProvideValue(IServiceProvider serviceProvider)
- {
- return new ColLayout
+ if (width < SmMaxWidth)
{
- Xs = Xs,
- Sm = Sm,
- Md = Md,
- Lg = Lg,
- Xl = Xl,
- Xxl = Xxl
- };
- }
-
- public static ColLayoutStatus GetLayoutStatus(double width)
- {
- if (width < MdMaxWidth)
- {
- if (width < SmMaxWidth)
+ if (width < XsMaxWidth)
{
- if (width < XsMaxWidth)
- {
- return ColLayoutStatus.Xs;
- }
- return ColLayoutStatus.Sm;
+ return ColLayoutStatus.Xs;
}
- return ColLayoutStatus.Md;
+ return ColLayoutStatus.Sm;
}
- if (width < XlMaxWidth)
- {
- if (width < LgMaxWidth)
- {
- return ColLayoutStatus.Lg;
- }
- return ColLayoutStatus.Xl;
- }
- return ColLayoutStatus.Xxl;
+ return ColLayoutStatus.Md;
}
-
- public override string ToString()
+ if (width < XlMaxWidth)
{
- var cultureInfo = CultureInfo.CurrentCulture;
- var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
-
- // Initial capacity [128] is an estimate based on a sum of:
- // 72 = 6x double (twelve digits is generous for the range of values likely)
- // 4 = 4x separator characters
- var sb = new StringBuilder(128);
-
- sb.Append(Xs.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(Sm.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(Md.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(Lg.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(Xl.ToString(cultureInfo));
- sb.Append(listSeparator);
- sb.Append(Xxl.ToString(cultureInfo));
- return sb.ToString();
+ if (width < LgMaxWidth)
+ {
+ return ColLayoutStatus.Lg;
+ }
+ return ColLayoutStatus.Xl;
}
+ return ColLayoutStatus.Xxl;
+ }
+
+ public override string ToString()
+ {
+ var cultureInfo = CultureInfo.CurrentCulture;
+ var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
+
+ // Initial capacity [128] is an estimate based on a sum of:
+ // 72 = 6x double (twelve digits is generous for the range of values likely)
+ // 4 = 4x separator characters
+ var sb = new StringBuilder(128);
+
+ sb.Append(Xs.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(Sm.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(Md.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(Lg.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(Xl.ToString(cultureInfo));
+ sb.Append(listSeparator);
+ sb.Append(Xxl.ToString(cultureInfo));
+ return sb.ToString();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/ColorExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/ColorExtension.cs
index 95ac893f..10a6deef 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/ColorExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/ColorExtension.cs
@@ -2,32 +2,31 @@
using System.Windows.Media;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+///
+/// 颜色扩展类
+///
+public static class ColorExtension
{
///
- /// 颜色扩展类
+ /// 将颜色转换为10进制表示(rgb顺序颠倒)
///
- public static class ColorExtension
+ ///
+ ///
+ public static int ToInt32(this Color color) => color.R << 16 | color.G << 8 | color.B;
+
+ ///
+ /// 将颜色转换为10进制表示(rgb顺序颠倒)
+ ///
+ ///
+ ///
+ public static int ToInt32Reverse(this Color color) => color.R | color.G << 8 | color.B << 18;
+
+ internal static List ToList(this Color color) => new()
{
- ///
- /// 将颜色转换为10进制表示(rgb顺序颠倒)
- ///
- ///
- ///
- public static int ToInt32(this Color color) => color.R << 16 | color.G << 8 | color.B;
-
- ///
- /// 将颜色转换为10进制表示(rgb顺序颠倒)
- ///
- ///
- ///
- public static int ToInt32Reverse(this Color color) => color.R | color.G << 8 | color.B << 18;
-
- internal static List ToList(this Color color) => new()
- {
- color.R,
- color.G,
- color.B
- };
- }
+ color.R,
+ color.G,
+ color.B
+ };
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs
index 779d25bf..4ed89210 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs
@@ -1,18 +1,17 @@
using System.Windows;
using System.Windows.Media;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public static class DependencyObjectExtension
{
- public static class DependencyObjectExtension
+ public static DependencyObject GetVisualOrLogicalParent(this DependencyObject sourceElement)
{
- public static DependencyObject GetVisualOrLogicalParent(this DependencyObject sourceElement)
+ return sourceElement switch
{
- return sourceElement switch
- {
- null => null,
- Visual _ => (VisualTreeHelper.GetParent(sourceElement) ?? LogicalTreeHelper.GetParent(sourceElement)),
- _ => LogicalTreeHelper.GetParent(sourceElement)
- };
- }
+ null => null,
+ Visual _ => (VisualTreeHelper.GetParent(sourceElement) ?? LogicalTreeHelper.GetParent(sourceElement)),
+ _ => LogicalTreeHelper.GetParent(sourceElement)
+ };
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/DialogExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/DialogExtension.cs
index aae15918..b3e23049 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/DialogExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/DialogExtension.cs
@@ -3,76 +3,75 @@ using System.Threading.Tasks;
using System.Windows;
using HandyControl.Controls;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public interface IDialogResultable
{
- public interface IDialogResultable
- {
- T Result { get; set; }
+ T Result { get; set; }
- Action CloseAction { get; set; }
- }
+ Action CloseAction { get; set; }
+}
- public static class DialogExtension
+public static class DialogExtension
+{
+ public static Task GetResultAsync(this Dialog dialog)
{
- public static Task GetResultAsync(this Dialog dialog)
+ var tcs = new TaskCompletionSource();
+
+ try
{
- var tcs = new TaskCompletionSource();
+ if (dialog.IsClosed)
+ {
+ SetResult();
+ }
+ else
+ {
+ dialog.Unloaded += OnUnloaded;
+ dialog.GetViewModel>().CloseAction = dialog.Close;
+ }
+ }
+ catch (Exception e)
+ {
+ tcs.TrySetException(e);
+ }
+ return tcs.Task;
+
+ // ReSharper disable once ImplicitlyCapturedClosure
+ void OnUnloaded(object sender, RoutedEventArgs args)
+ {
+ dialog.Unloaded -= OnUnloaded;
+ SetResult();
+ }
+
+ void SetResult()
+ {
try
{
- if (dialog.IsClosed)
- {
- SetResult();
- }
- else
- {
- dialog.Unloaded += OnUnloaded;
- dialog.GetViewModel>().CloseAction = dialog.Close;
- }
+ tcs.TrySetResult(dialog.GetViewModel>().Result);
}
catch (Exception e)
{
tcs.TrySetException(e);
}
-
- return tcs.Task;
-
- // ReSharper disable once ImplicitlyCapturedClosure
- void OnUnloaded(object sender, RoutedEventArgs args)
- {
- dialog.Unloaded -= OnUnloaded;
- SetResult();
- }
-
- void SetResult()
- {
- try
- {
- tcs.TrySetResult(dialog.GetViewModel>().Result);
- }
- catch (Exception e)
- {
- tcs.TrySetException(e);
- }
- }
- }
-
- public static Dialog Initialize(this Dialog dialog, Action configure)
- {
- configure?.Invoke(dialog.GetViewModel());
-
- return dialog;
- }
-
- public static TViewModel GetViewModel(this Dialog dialog)
- {
- if (!(dialog.Content is FrameworkElement frameworkElement))
- throw new InvalidOperationException("The dialog is not a derived class of the FrameworkElement. ");
-
- if (!(frameworkElement.DataContext is TViewModel viewModel))
- throw new InvalidOperationException($"The view model of the dialog is not the {typeof(TViewModel)} type or its derived class. ");
-
- return viewModel;
}
}
+
+ public static Dialog Initialize(this Dialog dialog, Action configure)
+ {
+ configure?.Invoke(dialog.GetViewModel());
+
+ return dialog;
+ }
+
+ public static TViewModel GetViewModel(this Dialog dialog)
+ {
+ if (!(dialog.Content is FrameworkElement frameworkElement))
+ throw new InvalidOperationException("The dialog is not a derived class of the FrameworkElement. ");
+
+ if (!(frameworkElement.DataContext is TViewModel viewModel))
+ throw new InvalidOperationException($"The view model of the dialog is not the {typeof(TViewModel)} type or its derived class. ");
+
+ return viewModel;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
index 631001ad..2748ac4e 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
@@ -2,30 +2,29 @@
using System.Collections.Generic;
using System.Linq;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public static class EnumerableExtension
{
- public static class EnumerableExtension
+ public static IEnumerable Do(this IEnumerable source, Action predicate)
{
- public static IEnumerable Do(this IEnumerable source, Action predicate)
+ var enumerable = source as IList ?? source.ToList();
+ foreach (var item in enumerable)
{
- var enumerable = source as IList ?? source.ToList();
- foreach (var item in enumerable)
- {
- predicate.Invoke(item);
- }
-
- return enumerable;
+ predicate.Invoke(item);
}
- public static IEnumerable DoWithIndex(this IEnumerable source, Action predicate)
- {
- var enumerable = source as IList ?? source.ToList();
- for (var i = 0; i < enumerable.Count; i++)
- {
- predicate.Invoke(enumerable[i], i);
- }
+ return enumerable;
+ }
- return enumerable;
+ public static IEnumerable DoWithIndex(this IEnumerable source, Action predicate)
+ {
+ var enumerable = source as IList ?? source.ToList();
+ for (var i = 0; i < enumerable.Count; i++)
+ {
+ predicate.Invoke(enumerable[i], i);
}
+
+ return enumerable;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs
index 28b26358..f8b42fb9 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/FrameworkElementExtension.cs
@@ -1,58 +1,57 @@
using System.Windows;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public static class FrameworkElementExtension
{
- public static class FrameworkElementExtension
+
+ public static double GetValidWidth(this FrameworkElement element)
{
-
- public static double GetValidWidth(this FrameworkElement element)
+ if (!double.IsNaN(element.Width))
{
- if (!double.IsNaN(element.Width))
+ if (element.Width > 0)
{
- if (element.Width > 0)
- {
- return element.Width;
- }
+ return element.Width;
}
- else
+ }
+ else
+ {
+ if (element.ActualWidth > 0)
{
- if (element.ActualWidth > 0)
- {
- return element.ActualWidth;
- }
-
- if (element.DesiredSize.Width > 0)
- {
- return element.DesiredSize.Width;
- }
+ return element.ActualWidth;
}
- return 0;
+ if (element.DesiredSize.Width > 0)
+ {
+ return element.DesiredSize.Width;
+ }
}
- public static double GetValidHeight(this FrameworkElement element)
+ return 0;
+ }
+
+ public static double GetValidHeight(this FrameworkElement element)
+ {
+ if (!double.IsNaN(element.Height))
{
- if (!double.IsNaN(element.Height))
+ if (element.Height > 0)
{
- if (element.Height > 0)
- {
- return element.Height;
- }
+ return element.Height;
}
- else
- {
- if (element.ActualHeight > 0)
- {
- return element.ActualHeight;
- }
-
- if (element.DesiredSize.Height > 0)
- {
- return element.DesiredSize.Height;
- }
- }
-
- return 0;
}
+ else
+ {
+ if (element.ActualHeight > 0)
+ {
+ return element.ActualHeight;
+ }
+
+ if (element.DesiredSize.Height > 0)
+ {
+ return element.DesiredSize.Height;
+ }
+ }
+
+ return 0;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/GeometryExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/GeometryExtension.cs
index f7b4ad68..80cec295 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/GeometryExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/GeometryExtension.cs
@@ -3,48 +3,47 @@ using System.Windows;
using System.Windows.Media;
using HandyControl.Expression.Drawing;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public static class GeometryExtension
{
- public static class GeometryExtension
+ ///
+ /// 获取路径总长度
+ ///
+ ///
+ ///
+ public static double GetTotalLength(this Geometry geometry)
{
- ///
- /// 获取路径总长度
- ///
- ///
- ///
- public static double GetTotalLength(this Geometry geometry)
- {
- if (geometry == null) return 0;
+ if (geometry == null) return 0;
- var pathGeometry = PathGeometry.CreateFromGeometry(geometry);
- pathGeometry.GetPointAtFractionLength(1e-4, out var point, out _);
- var length = (pathGeometry.Figures[0].StartPoint - point).Length * 1e+4;
+ var pathGeometry = PathGeometry.CreateFromGeometry(geometry);
+ pathGeometry.GetPointAtFractionLength(1e-4, out var point, out _);
+ var length = (pathGeometry.Figures[0].StartPoint - point).Length * 1e+4;
- return length;
- }
+ return length;
+ }
- ///
- /// 获取路径总长度
- ///
- ///
- ///
- ///
- ///
- public static double GetTotalLength(this Geometry geometry, Size size, double strokeThickness = 1)
- {
- if (geometry == null) return 0;
+ ///
+ /// 获取路径总长度
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static double GetTotalLength(this Geometry geometry, Size size, double strokeThickness = 1)
+ {
+ if (geometry == null) return 0;
- if (MathHelper.IsVerySmall(size.Width) || MathHelper.IsVerySmall(size.Height)) return 0;
+ if (MathHelper.IsVerySmall(size.Width) || MathHelper.IsVerySmall(size.Height)) return 0;
- var length = GetTotalLength(geometry);
- var sw = geometry.Bounds.Width / size.Width;
- var sh = geometry.Bounds.Height / size.Height;
- var min = Math.Min(sw, sh);
+ var length = GetTotalLength(geometry);
+ var sw = geometry.Bounds.Width / size.Width;
+ var sh = geometry.Bounds.Height / size.Height;
+ var min = Math.Min(sw, sh);
- if (MathHelper.IsVerySmall(min) || MathHelper.IsVerySmall(strokeThickness)) return 0;
+ if (MathHelper.IsVerySmall(min) || MathHelper.IsVerySmall(strokeThickness)) return 0;
- length /= min;
- return length / strokeThickness;
- }
+ length /= min;
+ return length / strokeThickness;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/LangExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/LangExtension.cs
index 6cbca4b4..d585f0ce 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/LangExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/LangExtension.cs
@@ -4,148 +4,147 @@ using System.Windows.Data;
using System.Windows.Markup;
using HandyControl.Properties.Langs;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public class LangExtension : MarkupExtension
{
- public class LangExtension : MarkupExtension
+ private readonly DependencyObject _proxy;
+
+ public LangExtension()
{
- private readonly DependencyObject _proxy;
+ _proxy = new DependencyObject();
+ Source = LangProvider.Instance;
+ }
- public LangExtension()
+ public LangExtension(string key) : this()
+ {
+ Key = key;
+ }
+
+ public static readonly DependencyProperty KeyProperty = DependencyProperty.RegisterAttached(
+ "Key", typeof(object), typeof(LangExtension), new PropertyMetadata(default));
+
+ public object Key
+ {
+ get => _proxy.GetValue(KeyProperty);
+ set => _proxy.SetValue(KeyProperty, value);
+ }
+
+ private static readonly DependencyProperty TargetPropertyProperty = DependencyProperty.RegisterAttached(
+ "TargetProperty", typeof(DependencyProperty), typeof(LangExtension), new PropertyMetadata(default(DependencyProperty)));
+
+ private static void SetTargetProperty(DependencyObject element, DependencyProperty value)
+ => element.SetValue(TargetPropertyProperty, value);
+
+ private static DependencyProperty GetTargetProperty(DependencyObject element)
+ => (DependencyProperty) element.GetValue(TargetPropertyProperty);
+
+ public BindingMode Mode { get; set; }
+
+ public IValueConverter Converter { get; set; }
+
+ public object ConverterParameter { get; set; }
+
+ public object Source { get; set; }
+
+ public override object ProvideValue(IServiceProvider serviceProvider)
+ {
+ if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget)) return this;
+ if (provideValueTarget.TargetObject.GetType().FullName == "System.Windows.SharedDp") return this;
+ if (!(provideValueTarget.TargetObject is DependencyObject targetObject)) return this;
+ if (!(provideValueTarget.TargetProperty is DependencyProperty targetProperty)) return this;
+
+ switch (Key)
{
- _proxy = new DependencyObject();
- Source = LangProvider.Instance;
- }
-
- public LangExtension(string key) : this()
- {
- Key = key;
- }
-
- public static readonly DependencyProperty KeyProperty = DependencyProperty.RegisterAttached(
- "Key", typeof(object), typeof(LangExtension), new PropertyMetadata(default));
-
- public object Key
- {
- get => _proxy.GetValue(KeyProperty);
- set => _proxy.SetValue(KeyProperty, value);
- }
-
- private static readonly DependencyProperty TargetPropertyProperty = DependencyProperty.RegisterAttached(
- "TargetProperty", typeof(DependencyProperty), typeof(LangExtension), new PropertyMetadata(default(DependencyProperty)));
-
- private static void SetTargetProperty(DependencyObject element, DependencyProperty value)
- => element.SetValue(TargetPropertyProperty, value);
-
- private static DependencyProperty GetTargetProperty(DependencyObject element)
- => (DependencyProperty) element.GetValue(TargetPropertyProperty);
-
- public BindingMode Mode { get; set; }
-
- public IValueConverter Converter { get; set; }
-
- public object ConverterParameter { get; set; }
-
- public object Source { get; set; }
-
- public override object ProvideValue(IServiceProvider serviceProvider)
- {
- if (!(serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget provideValueTarget)) return this;
- if (provideValueTarget.TargetObject.GetType().FullName == "System.Windows.SharedDp") return this;
- if (!(provideValueTarget.TargetObject is DependencyObject targetObject)) return this;
- if (!(provideValueTarget.TargetProperty is DependencyProperty targetProperty)) return this;
-
- switch (Key)
- {
- case string key:
+ case string key:
+ {
+ var binding = CreateLangBinding(key);
+ BindingOperations.SetBinding(targetObject, targetProperty, binding);
+ return binding.ProvideValue(serviceProvider);
+ }
+ case Binding keyBinding when targetObject is FrameworkElement element:
+ {
+ if (element.DataContext != null)
{
- var binding = CreateLangBinding(key);
- BindingOperations.SetBinding(targetObject, targetProperty, binding);
+ var binding = SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
return binding.ProvideValue(serviceProvider);
}
- case Binding keyBinding when targetObject is FrameworkElement element:
+
+ SetTargetProperty(element, targetProperty);
+ element.DataContextChanged += LangExtension_DataContextChanged;
+
+ break;
+ }
+ case Binding keyBinding when targetObject is FrameworkContentElement element:
+ {
+ if (element.DataContext != null)
{
- if (element.DataContext != null)
- {
- var binding = SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
- return binding.ProvideValue(serviceProvider);
- }
-
- SetTargetProperty(element, targetProperty);
- element.DataContextChanged += LangExtension_DataContextChanged;
-
- break;
+ var binding = SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
+ return binding.ProvideValue(serviceProvider);
}
- case Binding keyBinding when targetObject is FrameworkContentElement element:
- {
- if (element.DataContext != null)
- {
- var binding = SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
- return binding.ProvideValue(serviceProvider);
- }
- SetTargetProperty(element, targetProperty);
- element.DataContextChanged += LangExtension_DataContextChanged;
+ SetTargetProperty(element, targetProperty);
+ element.DataContextChanged += LangExtension_DataContextChanged;
- break;
- }
- }
-
- return string.Empty;
+ break;
+ }
}
- private void LangExtension_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- switch (sender)
- {
- case FrameworkElement element:
- {
- element.DataContextChanged -= LangExtension_DataContextChanged;
- if (!(Key is Binding keyBinding)) return;
-
- var targetProperty = GetTargetProperty(element);
- SetTargetProperty(element, null);
- SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
- break;
- }
- case FrameworkContentElement element:
- {
- element.DataContextChanged -= LangExtension_DataContextChanged;
- if (!(Key is Binding keyBinding)) return;
-
- var targetProperty = GetTargetProperty(element);
- SetTargetProperty(element, null);
- SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
- break;
- }
- }
- }
-
- private BindingBase SetLangBinding(DependencyObject targetObject, DependencyProperty targetProperty, PropertyPath path, object dataContext)
- {
- if (targetProperty == null) return null;
-
- BindingOperations.SetBinding(targetObject, targetProperty, new Binding
- {
- Path = path,
- Source = dataContext,
- Mode = BindingMode.OneWay
- });
-
- var key = targetObject.GetValue(targetProperty) as string;
- if (string.IsNullOrEmpty(key)) return null;
-
- var binding = CreateLangBinding(key);
- BindingOperations.SetBinding(targetObject, targetProperty, binding);
- return binding;
- }
-
- private BindingBase CreateLangBinding(string key) => new Binding(key)
- {
- Converter = Converter,
- ConverterParameter = ConverterParameter,
- UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
- Source = Source,
- Mode = BindingMode.OneWay
- };
+ return string.Empty;
}
+
+ private void LangExtension_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ switch (sender)
+ {
+ case FrameworkElement element:
+ {
+ element.DataContextChanged -= LangExtension_DataContextChanged;
+ if (!(Key is Binding keyBinding)) return;
+
+ var targetProperty = GetTargetProperty(element);
+ SetTargetProperty(element, null);
+ SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
+ break;
+ }
+ case FrameworkContentElement element:
+ {
+ element.DataContextChanged -= LangExtension_DataContextChanged;
+ if (!(Key is Binding keyBinding)) return;
+
+ var targetProperty = GetTargetProperty(element);
+ SetTargetProperty(element, null);
+ SetLangBinding(element, targetProperty, keyBinding.Path, element.DataContext);
+ break;
+ }
+ }
+ }
+
+ private BindingBase SetLangBinding(DependencyObject targetObject, DependencyProperty targetProperty, PropertyPath path, object dataContext)
+ {
+ if (targetProperty == null) return null;
+
+ BindingOperations.SetBinding(targetObject, targetProperty, new Binding
+ {
+ Path = path,
+ Source = dataContext,
+ Mode = BindingMode.OneWay
+ });
+
+ var key = targetObject.GetValue(targetProperty) as string;
+ if (string.IsNullOrEmpty(key)) return null;
+
+ var binding = CreateLangBinding(key);
+ BindingOperations.SetBinding(targetObject, targetProperty, binding);
+ return binding;
+ }
+
+ private BindingBase CreateLangBinding(string key) => new Binding(key)
+ {
+ Converter = Converter,
+ ConverterParameter = ConverterParameter,
+ UpdateSourceTrigger = UpdateSourceTrigger.Explicit,
+ Source = Source,
+ Mode = BindingMode.OneWay
+ };
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/StringExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/StringExtension.cs
index 9ecf53bf..ad844163 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/StringExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/StringExtension.cs
@@ -1,32 +1,31 @@
using System;
using System.ComponentModel;
-namespace HandyControl.Tools.Extension
-{
- public static class StringExtension
- {
- public static T Value(this string input)
- {
- try
- {
- return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(input);
- }
- catch
- {
- return default;
- }
- }
+namespace HandyControl.Tools.Extension;
- public static object Value(this string input, Type type)
+public static class StringExtension
+{
+ public static T Value(this string input)
+ {
+ try
{
- try
- {
- return TypeDescriptor.GetConverter(type).ConvertFromString(input);
- }
- catch
- {
- return null;
- }
+ return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(input);
+ }
+ catch
+ {
+ return default;
+ }
+ }
+
+ public static object Value(this string input, Type type)
+ {
+ try
+ {
+ return TypeDescriptor.GetConverter(type).ConvertFromString(input);
+ }
+ catch
+ {
+ return null;
}
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
index 2784b127..0f816e58 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
@@ -1,33 +1,32 @@
using System.Windows;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+// ReSharper disable once InconsistentNaming
+public static class UIElementExtension
{
- // ReSharper disable once InconsistentNaming
- public static class UIElementExtension
- {
- ///
- /// 显示元素
- ///
- ///
- public static void Show(this UIElement element) => element.Visibility = Visibility.Visible;
+ ///
+ /// 显示元素
+ ///
+ ///
+ public static void Show(this UIElement element) => element.Visibility = Visibility.Visible;
- ///
- /// 显示元素
- ///
- ///
- ///
- public static void Show(this UIElement element, bool show) => element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
+ ///
+ /// 显示元素
+ ///
+ ///
+ ///
+ public static void Show(this UIElement element, bool show) => element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
- ///
- /// 不现实元素,但保留空间
- ///
- ///
- public static void Hide(this UIElement element) => element.Visibility = Visibility.Hidden;
+ ///
+ /// 不现实元素,但保留空间
+ ///
+ ///
+ public static void Hide(this UIElement element) => element.Visibility = Visibility.Hidden;
- ///
- /// 不显示元素,且不保留空间
- ///
- ///
- public static void Collapse(this UIElement element) => element.Visibility = Visibility.Collapsed;
- }
+ ///
+ /// 不显示元素,且不保留空间
+ ///
+ ///
+ public static void Collapse(this UIElement element) => element.Visibility = Visibility.Collapsed;
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/ValueExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/ValueExtension.cs
index 7d5ae5f1..4ffe4aba 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/ValueExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/ValueExtension.cs
@@ -1,23 +1,22 @@
using System.Windows;
using HandyControl.Expression.Drawing;
-namespace HandyControl.Tools.Extension
+namespace HandyControl.Tools.Extension;
+
+public static class ValueExtension
{
- public static class ValueExtension
- {
- public static Thickness Add(this Thickness a, Thickness b) => new(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom);
+ public static Thickness Add(this Thickness a, Thickness b) => new(a.Left + b.Left, a.Top + b.Top, a.Right + b.Right, a.Bottom + b.Bottom);
- public static bool IsZero(this Thickness thickness) =>
- MathHelper.IsZero(thickness.Left)
- && MathHelper.IsZero(thickness.Top)
- && MathHelper.IsZero(thickness.Right)
- && MathHelper.IsZero(thickness.Bottom);
+ public static bool IsZero(this Thickness thickness) =>
+ MathHelper.IsZero(thickness.Left)
+ && MathHelper.IsZero(thickness.Top)
+ && MathHelper.IsZero(thickness.Right)
+ && MathHelper.IsZero(thickness.Bottom);
- public static bool IsUniform(this Thickness thickness) =>
- MathHelper.AreClose(thickness.Left, thickness.Top)
- && MathHelper.AreClose(thickness.Left, thickness.Right)
- && MathHelper.AreClose(thickness.Left, thickness.Bottom);
+ public static bool IsUniform(this Thickness thickness) =>
+ MathHelper.AreClose(thickness.Left, thickness.Top)
+ && MathHelper.AreClose(thickness.Left, thickness.Right)
+ && MathHelper.AreClose(thickness.Left, thickness.Bottom);
- public static bool IsNaN(this double value) => double.IsNaN(value);
- }
+ public static bool IsNaN(this double value) => double.IsNaN(value);
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Generator/ComparerGenerator.cs b/src/Shared/HandyControl_Shared/Tools/Generator/ComparerGenerator.cs
index e02a258b..4f61f348 100644
--- a/src/Shared/HandyControl_Shared/Tools/Generator/ComparerGenerator.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Generator/ComparerGenerator.cs
@@ -3,33 +3,32 @@ using System.Collections.Generic;
using HandyControl.Collections;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class ComparerGenerator
{
- public class ComparerGenerator
+ private static readonly Dictionary TypeCodeDic = new()
{
- private static readonly Dictionary TypeCodeDic = new()
- {
- [typeof(DateTimeRange)] = ComparerTypeCode.DateTimeRange,
- };
+ [typeof(DateTimeRange)] = ComparerTypeCode.DateTimeRange,
+ };
- public static IComparer GetComparer()
+ public static IComparer GetComparer()
+ {
+ if (TypeCodeDic.TryGetValue(typeof(T), out var comparerType))
{
- if (TypeCodeDic.TryGetValue(typeof(T), out var comparerType))
+ if (comparerType == ComparerTypeCode.DateTimeRange)
{
- if (comparerType == ComparerTypeCode.DateTimeRange)
- {
- return (IComparer) new DateTimeRangeComparer();
- }
-
- return null;
+ return (IComparer) new DateTimeRangeComparer();
}
return null;
}
- private enum ComparerTypeCode
- {
- DateTimeRange
- }
+ return null;
+ }
+
+ private enum ComparerTypeCode
+ {
+ DateTimeRange
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs b/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs
index 361ce4c0..f591629b 100644
--- a/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Generator/DateTimeRangeComparer.cs
@@ -1,15 +1,14 @@
using System.Collections.Generic;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class DateTimeRangeComparer : IComparer
{
- public class DateTimeRangeComparer : IComparer
+ public int Compare(DateTimeRange x, DateTimeRange y)
{
- public int Compare(DateTimeRange x, DateTimeRange y)
- {
- if (x.Start > y.Start && x.End > y.End) return 1;
- if (x.Start < y.Start && x.End < y.End) return -1;
- return 0;
- }
+ if (x.Start > y.Start && x.End > y.End) return 1;
+ if (x.Start < y.Start && x.End < y.End) return -1;
+ return 0;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs b/src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs
index d647c3f7..4f845e2e 100644
--- a/src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Generator/GithubGravatarGenerator.cs
@@ -7,114 +7,113 @@ using System.Windows.Media;
using System.Windows.Shapes;
using HandyControl.Controls;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class GithubGravatarGenerator : IGravatarGenerator
{
- public class GithubGravatarGenerator : IGravatarGenerator
+ private const int RenderDataMaxLength = 15;
+
+ public object GetGravatar(string id)
{
- private const int RenderDataMaxLength = 15;
+ var hashcode = GetHashCode(id);
+ var renderData = GetRenderData(hashcode);
+ var renderBrush = GetRenderBrush(hashcode);
+ var geometryGroup = new GeometryGroup();
- public object GetGravatar(string id)
+ void AddRec(int i, int j, bool hidden = false)
{
- var hashcode = GetHashCode(id);
- var renderData = GetRenderData(hashcode);
- var renderBrush = GetRenderBrush(hashcode);
- var geometryGroup = new GeometryGroup();
-
- void AddRec(int i, int j, bool hidden = false)
- {
- var rec = new RectangleGeometry(new Rect(new Point(i, j), hidden ? new Size() : new Size(1, 1)));
- geometryGroup.Children.Add(rec);
- }
-
- var index = 0;
- for (var i = 0; i < 2; i++)
- {
- for (var j = 0; j < 5; j++, index++)
- {
- AddRec(i, j, renderData[index] == 0);
- }
- }
+ var rec = new RectangleGeometry(new Rect(new Point(i, j), hidden ? new Size() : new Size(1, 1)));
+ geometryGroup.Children.Add(rec);
+ }
+ var index = 0;
+ for (var i = 0; i < 2; i++)
+ {
for (var j = 0; j < 5; j++, index++)
{
- AddRec(2, j, renderData[index] == 0);
+ AddRec(i, j, renderData[index] == 0);
}
+ }
+ for (var j = 0; j < 5; j++, index++)
+ {
+ AddRec(2, j, renderData[index] == 0);
+ }
+
+ index -= 10;
+ for (var i = 3; i < 5; i++)
+ {
+ for (var j = 0; j < 5; j++, index++)
+ {
+ AddRec(i, j, renderData[index] == 0);
+ }
index -= 10;
- for (var i = 3; i < 5; i++)
- {
- for (var j = 0; j < 5; j++, index++)
- {
- AddRec(i, j, renderData[index] == 0);
- }
- index -= 10;
- }
-
- var path = new Path
- {
- Data = geometryGroup,
- Fill = renderBrush,
- VerticalAlignment = VerticalAlignment.Top,
- Stretch = Stretch.Uniform
- };
-
- RenderOptions.SetEdgeMode(path, EdgeMode.Aliased);
-
- return path;
}
- private string GetHashCode(string id)
+ var path = new Path
{
- var md5 = MD5.Create();
- var bytes = Encoding.ASCII.GetBytes(id);
- var hash = md5.ComputeHash(bytes);
- var stringBuilder = new StringBuilder();
- foreach (var item in hash)
- {
- stringBuilder.Append(item.ToString("X2"));
- }
- return stringBuilder.ToString();
- }
+ Data = geometryGroup,
+ Fill = renderBrush,
+ VerticalAlignment = VerticalAlignment.Top,
+ Stretch = Stretch.Uniform
+ };
- private int[] GetRenderData(string hashcode)
+ RenderOptions.SetEdgeMode(path, EdgeMode.Aliased);
+
+ return path;
+ }
+
+ private string GetHashCode(string id)
+ {
+ var md5 = MD5.Create();
+ var bytes = Encoding.ASCII.GetBytes(id);
+ var hash = md5.ComputeHash(bytes);
+ var stringBuilder = new StringBuilder();
+ foreach (var item in hash)
{
- var arr = new int[RenderDataMaxLength];
- for (var i = 0; i < RenderDataMaxLength; i++)
- {
- var c = hashcode[i];
- var v = (int) c;
- arr[i] = v % 2;
- }
-
- return arr;
+ stringBuilder.Append(item.ToString("X2"));
}
+ return stringBuilder.ToString();
+ }
- private Brush GetRenderBrush(string hashcode)
+ private int[] GetRenderData(string hashcode)
+ {
+ var arr = new int[RenderDataMaxLength];
+ for (var i = 0; i < RenderDataMaxLength; i++)
{
- var v = (double) int.Parse(hashcode.Substring(hashcode.Length - 7), NumberStyles.HexNumber);
- var scale = v / 0xfffffff;
- var color = Hsl2Rgb(scale);
- return new SolidColorBrush(color);
+ var c = hashcode[i];
+ var v = (int) c;
+ arr[i] = v % 2;
}
- //adapted from https://github.com/stewartlord/identicon.js/blob/4fad7cafec1b7a4d896015e084e861625ef5d64f/identicon.js#L110
- private Color Hsl2Rgb(double h, double s = 0.7, double b = 0.5)
+ return arr;
+ }
+
+ private Brush GetRenderBrush(string hashcode)
+ {
+ var v = (double) int.Parse(hashcode.Substring(hashcode.Length - 7), NumberStyles.HexNumber);
+ var scale = v / 0xfffffff;
+ var color = Hsl2Rgb(scale);
+ return new SolidColorBrush(color);
+ }
+
+ //adapted from https://github.com/stewartlord/identicon.js/blob/4fad7cafec1b7a4d896015e084e861625ef5d64f/identicon.js#L110
+ private Color Hsl2Rgb(double h, double s = 0.7, double b = 0.5)
+ {
+ h *= 6;
+ var arr = new[]
{
- h *= 6;
- var arr = new[]
- {
- b += s *= b < .5 ? b : 1 - b,
- b - h % 1 * s * 2,
- b -= s *= 2,
- b,
- b + h % 1 * s,
- b + s
- };
+ b += s *= b < .5 ? b : 1 - b,
+ b - h % 1 * s * 2,
+ b -= s *= 2,
+ b,
+ b + h % 1 * s,
+ b + s
+ };
- var hValue = (int) Math.Floor(h);
+ var hValue = (int) Math.Floor(h);
- return Color.FromRgb((byte) (arr[hValue % 6] * 255), (byte) (arr[(hValue | 16) % 6] * 255),
- (byte) (arr[(hValue | 8) % 6] * 255));
- }
+ return Color.FromRgb((byte) (arr[hValue % 6] * 255), (byte) (arr[(hValue | 16) % 6] * 255),
+ (byte) (arr[(hValue | 8) % 6] * 255));
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs b/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs
index 1ad76fa2..9f00f085 100644
--- a/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs
@@ -3,115 +3,114 @@ using System.Windows;
using System.Windows.Media;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class HatchBrushGenerator
{
- public class HatchBrushGenerator
+ private static readonly byte[][] HatchBrushes =
{
- private static readonly byte[][] HatchBrushes =
+ new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00}, // Horizontal
+ new byte[] {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, // Vertical
+ new byte[] {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, // ForwardDiagonal
+ new byte[] {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, // BackwardDiagonal
+ new byte[] {0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08}, // Cross
+ new byte[] {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81}, // DiagonalCross
+ new byte[] {0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80}, // Percent05
+ new byte[] {0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88}, // Percent10
+ new byte[] {0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc}, // Percent20
+ new byte[] {0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc}, // Percent25
+ new byte[] {0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc}, // Percent30
+ new byte[] {0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc}, // Percent40
+ new byte[] {0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc}, // Percent50
+ new byte[] {0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee}, // Percent60
+ new byte[] {0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff}, // Percent70
+ new byte[] {0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff}, // Percent75
+ new byte[] {0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff}, // Percent80
+ new byte[] {0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff}, // Percent90
+ new byte[] {0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88}, // LightDownwardDiagonal
+ new byte[] {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11}, // LightUpwardDiagonal
+ new byte[] {0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc}, // DarkDownwardDiagonal
+ new byte[] {0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99}, // DarkUpwardDiagonal
+ new byte[] {0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0}, // WideDownwardDiagonal
+ new byte[] {0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1}, // WideUpwardDiagonal
+ new byte[] {0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, // LightVertical
+ new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff}, // LightHorizontal
+ new byte[] {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, // NarrowVertical
+ new byte[] {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff}, // NarrowHorizontal
+ new byte[] {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc}, // DarkVertical
+ new byte[] {0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff}, // DarkHorizontal
+ new byte[] {0x11, 0x22, 0x44, 0x88, 0x00, 0x00, 0x00, 0x00}, // DashedDownwardDiagonal
+ new byte[] {0x88, 0x44, 0x22, 0x11, 0x00, 0x00, 0x00, 0x00}, // DashedUpwardDiagonal
+ new byte[] {0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00}, // DashedHorizontal
+ new byte[] {0x01, 0x01, 0x01, 0x01, 0x10, 0x10, 0x10, 0x10}, // DashedVertical
+ new byte[] {0x01, 0x08, 0x80, 0x10, 0x02, 0x40, 0x04, 0x20}, // SmallConfetti
+ new byte[] {0x03, 0x63, 0x6c, 0x0c, 0xc0, 0xc6, 0x36, 0x30}, // LargeConfetti
+ new byte[] {0x03, 0x84, 0x48, 0x30, 0x03, 0x84, 0x48, 0x30}, // ZigZag
+ new byte[] {0x30, 0x49, 0x06, 0x00, 0x30, 0x49, 0x06, 0x00}, // Wave
+ new byte[] {0x81, 0x42, 0x24, 0x18, 0x08, 0x04, 0x02, 0x01}, // DiagonalBrick
+ new byte[] {0xff, 0x01, 0x01, 0x01, 0xff, 0x10, 0x10, 0x10}, // HorizontalBrick
+ new byte[] {0x11, 0x82, 0x44, 0xa8, 0x11, 0xa2, 0x44, 0x2a}, // Weave
+ new byte[] {0x55, 0xaa, 0x55, 0xaa, 0x0f, 0x0f, 0x0f, 0x0f}, // Plaid
+ new byte[] {0x02, 0x01, 0x02, 0x00, 0x10, 0x20, 0x10, 0x00}, // Divot
+ new byte[] {0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00}, // DottedGrid
+ new byte[] {0x11, 0x00, 0x04, 0x00, 0x11, 0x00, 0x40, 0x00}, // DottedDiamond
+ new byte[] {0x03, 0x0c, 0x10, 0x20, 0x20, 0x30, 0x48, 0x84}, // Shingle
+ new byte[] {0xff, 0x33, 0xff, 0xcc, 0xff, 0x33, 0xff, 0xcc}, // Trellis
+ new byte[] {0xee, 0x19, 0x1f, 0x1f, 0xee, 0x91, 0xf1, 0xf1}, // Sphere
+ new byte[] {0xff, 0x11, 0x11, 0x11, 0xff, 0x11, 0x11, 0x11}, // SmallGrid
+ new byte[] {0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc}, // SmallCheckerBoard
+ new byte[] {0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0}, // LargeCheckerBoard
+ new byte[] {0x01, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82}, // OutlinedDiamond
+ new byte[] {0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00} // SolidDiamond
+ };
+
+ public Brush GetHatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
+ {
+ var hatchData = GetHatchData(hatchStyle);
+
+ var foreGeometryGroup = new GeometryGroup();
+
+ for (var y = 0; y < 8; y++)
{
- new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00}, // Horizontal
- new byte[] {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08}, // Vertical
- new byte[] {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}, // ForwardDiagonal
- new byte[] {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}, // BackwardDiagonal
- new byte[] {0x08, 0x08, 0x08, 0xff, 0x08, 0x08, 0x08, 0x08}, // Cross
- new byte[] {0x81, 0x42, 0x24, 0x18, 0x18, 0x24, 0x42, 0x81}, // DiagonalCross
- new byte[] {0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80}, // Percent05
- new byte[] {0x00, 0x02, 0x00, 0x88, 0x00, 0x20, 0x00, 0x88}, // Percent10
- new byte[] {0x00, 0x22, 0x00, 0xcc, 0x00, 0x22, 0x00, 0xcc}, // Percent20
- new byte[] {0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc, 0x00, 0xcc}, // Percent25
- new byte[] {0x00, 0xcc, 0x04, 0xcc, 0x00, 0xcc, 0x40, 0xcc}, // Percent30
- new byte[] {0x44, 0xcc, 0x22, 0xcc, 0x44, 0xcc, 0x22, 0xcc}, // Percent40
- new byte[] {0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc, 0x55, 0xcc}, // Percent50
- new byte[] {0x55, 0xcd, 0x55, 0xee, 0x55, 0xdc, 0x55, 0xee}, // Percent60
- new byte[] {0x55, 0xdd, 0x55, 0xff, 0x55, 0xdd, 0x55, 0xff}, // Percent70
- new byte[] {0x55, 0xff, 0x55, 0xff, 0x55, 0xff, 0x55, 0xff}, // Percent75
- new byte[] {0x55, 0xff, 0x59, 0xff, 0x55, 0xff, 0x99, 0xff}, // Percent80
- new byte[] {0x77, 0xff, 0xdd, 0xff, 0x77, 0xff, 0xfd, 0xff}, // Percent90
- new byte[] {0x11, 0x22, 0x44, 0x88, 0x11, 0x22, 0x44, 0x88}, // LightDownwardDiagonal
- new byte[] {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11}, // LightUpwardDiagonal
- new byte[] {0x99, 0x33, 0x66, 0xcc, 0x99, 0x33, 0x66, 0xcc}, // DarkDownwardDiagonal
- new byte[] {0xcc, 0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99}, // DarkUpwardDiagonal
- new byte[] {0xc1, 0x83, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0}, // WideDownwardDiagonal
- new byte[] {0xe0, 0x70, 0x38, 0x1c, 0x0e, 0x07, 0x83, 0xc1}, // WideUpwardDiagonal
- new byte[] {0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88}, // LightVertical
- new byte[] {0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff}, // LightHorizontal
- new byte[] {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, // NarrowVertical
- new byte[] {0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff}, // NarrowHorizontal
- new byte[] {0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc}, // DarkVertical
- new byte[] {0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff}, // DarkHorizontal
- new byte[] {0x11, 0x22, 0x44, 0x88, 0x00, 0x00, 0x00, 0x00}, // DashedDownwardDiagonal
- new byte[] {0x88, 0x44, 0x22, 0x11, 0x00, 0x00, 0x00, 0x00}, // DashedUpwardDiagonal
- new byte[] {0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00}, // DashedHorizontal
- new byte[] {0x01, 0x01, 0x01, 0x01, 0x10, 0x10, 0x10, 0x10}, // DashedVertical
- new byte[] {0x01, 0x08, 0x80, 0x10, 0x02, 0x40, 0x04, 0x20}, // SmallConfetti
- new byte[] {0x03, 0x63, 0x6c, 0x0c, 0xc0, 0xc6, 0x36, 0x30}, // LargeConfetti
- new byte[] {0x03, 0x84, 0x48, 0x30, 0x03, 0x84, 0x48, 0x30}, // ZigZag
- new byte[] {0x30, 0x49, 0x06, 0x00, 0x30, 0x49, 0x06, 0x00}, // Wave
- new byte[] {0x81, 0x42, 0x24, 0x18, 0x08, 0x04, 0x02, 0x01}, // DiagonalBrick
- new byte[] {0xff, 0x01, 0x01, 0x01, 0xff, 0x10, 0x10, 0x10}, // HorizontalBrick
- new byte[] {0x11, 0x82, 0x44, 0xa8, 0x11, 0xa2, 0x44, 0x2a}, // Weave
- new byte[] {0x55, 0xaa, 0x55, 0xaa, 0x0f, 0x0f, 0x0f, 0x0f}, // Plaid
- new byte[] {0x02, 0x01, 0x02, 0x00, 0x10, 0x20, 0x10, 0x00}, // Divot
- new byte[] {0x55, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00}, // DottedGrid
- new byte[] {0x11, 0x00, 0x04, 0x00, 0x11, 0x00, 0x40, 0x00}, // DottedDiamond
- new byte[] {0x03, 0x0c, 0x10, 0x20, 0x20, 0x30, 0x48, 0x84}, // Shingle
- new byte[] {0xff, 0x33, 0xff, 0xcc, 0xff, 0x33, 0xff, 0xcc}, // Trellis
- new byte[] {0xee, 0x19, 0x1f, 0x1f, 0xee, 0x91, 0xf1, 0xf1}, // Sphere
- new byte[] {0xff, 0x11, 0x11, 0x11, 0xff, 0x11, 0x11, 0x11}, // SmallGrid
- new byte[] {0x33, 0x33, 0xcc, 0xcc, 0x33, 0x33, 0xcc, 0xcc}, // SmallCheckerBoard
- new byte[] {0x0f, 0x0f, 0x0f, 0x0f, 0xf0, 0xf0, 0xf0, 0xf0}, // LargeCheckerBoard
- new byte[] {0x01, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82}, // OutlinedDiamond
- new byte[] {0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00} // SolidDiamond
- };
-
- public Brush GetHatchBrush(HatchStyle hatchStyle, Color foreColor, Color backColor)
- {
- var hatchData = GetHatchData(hatchStyle);
-
- var foreGeometryGroup = new GeometryGroup();
-
- for (var y = 0; y < 8; y++)
+ for (var x = 0; x < 8; x++)
{
- for (var x = 0; x < 8; x++)
+ if ((hatchData[y] & (0x80 >> x)) > 0)
{
- if ((hatchData[y] & (0x80 >> x)) > 0)
+ foreGeometryGroup.Children.Add(new RectangleGeometry(new Rect(x, y, 1, 1)));
+ }
+ }
+ }
+
+ var drawingBrush = new DrawingBrush
+ {
+ Viewport = new Rect(0, 0, 8, 8),
+ ViewportUnits = BrushMappingMode.Absolute,
+ Stretch = Stretch.None,
+ TileMode = TileMode.Tile,
+ Drawing = new DrawingGroup
+ {
+ Children =
+ {
+ new GeometryDrawing
{
- foreGeometryGroup.Children.Add(new RectangleGeometry(new Rect(x, y, 1, 1)));
+ Brush = new SolidColorBrush(backColor),
+ Geometry = new RectangleGeometry(new Rect(0, 0, 8, 8))
+ },
+ new GeometryDrawing
+ {
+ Brush = new SolidColorBrush(foreColor),
+ Geometry = foreGeometryGroup
}
}
}
+ };
+ RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);
- var drawingBrush = new DrawingBrush
- {
- Viewport = new Rect(0, 0, 8, 8),
- ViewportUnits = BrushMappingMode.Absolute,
- Stretch = Stretch.None,
- TileMode = TileMode.Tile,
- Drawing = new DrawingGroup
- {
- Children =
- {
- new GeometryDrawing
- {
- Brush = new SolidColorBrush(backColor),
- Geometry = new RectangleGeometry(new Rect(0, 0, 8, 8))
- },
- new GeometryDrawing
- {
- Brush = new SolidColorBrush(foreColor),
- Geometry = foreGeometryGroup
- }
- }
- }
- };
- RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);
-
- return drawingBrush;
- }
-
- private byte[] GetHatchData(HatchStyle hatchStyle) =>
- hatchStyle < HatchStyle.Horizontal || hatchStyle > HatchStyle.SolidDiamond
- ? throw new ArgumentOutOfRangeException(nameof(hatchStyle))
- : HatchBrushes[(int) hatchStyle];
+ return drawingBrush;
}
+
+ private byte[] GetHatchData(HatchStyle hatchStyle) =>
+ hatchStyle < HatchStyle.Horizontal || hatchStyle > HatchStyle.SolidDiamond
+ ? throw new ArgumentOutOfRangeException(nameof(hatchStyle))
+ : HatchBrushes[(int) hatchStyle];
}
diff --git a/src/Shared/HandyControl_Shared/Tools/GifImageAnimator.cs b/src/Shared/HandyControl_Shared/Tools/GifImageAnimator.cs
index 97c1ce5a..b2c5b678 100644
--- a/src/Shared/HandyControl_Shared/Tools/GifImageAnimator.cs
+++ b/src/Shared/HandyControl_Shared/Tools/GifImageAnimator.cs
@@ -6,270 +6,269 @@ using System.Threading;
using HandyControl.Controls;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+internal class ImageAnimator
{
- internal class ImageAnimator
+ private static List ImageInfoList;
+
+ private static readonly ReaderWriterLock RwImgListLock = new();
+
+ private static Thread AnimationThread;
+
+ private static bool AnyFrameDirty;
+
+ [ThreadStatic]
+ private static int ThreadWriterLockWaitCount;
+
+ public static bool CanAnimate(GifImage image)
{
- private static List ImageInfoList;
-
- private static readonly ReaderWriterLock RwImgListLock = new();
-
- private static Thread AnimationThread;
-
- private static bool AnyFrameDirty;
-
- [ThreadStatic]
- private static int ThreadWriterLockWaitCount;
-
- public static bool CanAnimate(GifImage image)
+ if (image == null)
{
- if (image == null)
- {
- return false;
- }
-
- lock (image)
- {
- var dimensions = image.FrameDimensionsList;
-
- if (dimensions.Select(guid => new GifFrameDimension(guid)).Contains(GifFrameDimension.Time))
- {
- return image.GetFrameCount(GifFrameDimension.Time) > 1;
- }
- }
-
return false;
}
- public static void Animate(GifImage image, EventHandler onFrameChangedHandler)
+ lock (image)
{
- if (image == null)
+ var dimensions = image.FrameDimensionsList;
+
+ if (dimensions.Select(guid => new GifFrameDimension(guid)).Contains(GifFrameDimension.Time))
{
- return;
- }
-
- GifImageInfo imageInfo;
-
- // See comment in the class header about locking the image ref.
- lock (image)
- {
- // could we avoid creating an ImageInfo object if FrameCount == 1 ?
- imageInfo = new GifImageInfo(image);
- }
-
- // If the image is already animating, stop animating it
- StopAnimate(image, onFrameChangedHandler);
-
- // Acquire a writer lock to modify the image info list. If the thread has a reader lock we need to upgrade
- // it to a writer lock; acquiring a reader lock in this case would block the thread on itself.
- // If the thread already has a writer lock its ref count will be incremented w/o placing the request in the
- // writer queue. See ReaderWriterLock.AcquireWriterLock method in the MSDN.
-
- var readerLockHeld = RwImgListLock.IsReaderLockHeld;
- var lockDowngradeCookie = new LockCookie();
-
- ThreadWriterLockWaitCount++;
-
- try
- {
- if (readerLockHeld)
- {
- lockDowngradeCookie = RwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
- }
- else
- {
- RwImgListLock.AcquireWriterLock(Timeout.Infinite);
- }
- }
- finally
- {
- ThreadWriterLockWaitCount--;
- }
-
- try
- {
- if (imageInfo.Animated)
- {
- // Construct the image array
- //
- ImageInfoList ??= new List();
-
- // Add the new image
- //
- imageInfo.FrameChangedHandler = onFrameChangedHandler;
- ImageInfoList.Add(imageInfo);
-
- // Construct a new timer thread if we haven't already
- //
- if (AnimationThread == null)
- {
- AnimationThread = new Thread(AnimateImages50Ms)
- {
- Name = nameof(ImageAnimator),
- IsBackground = true
- };
- AnimationThread.Start();
- }
- }
- }
- finally
- {
- if (readerLockHeld)
- {
- RwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
- }
- else
- {
- RwImgListLock.ReleaseWriterLock();
- }
+ return image.GetFrameCount(GifFrameDimension.Time) > 1;
}
}
- public static void StopAnimate(GifImage image, EventHandler onFrameChangedHandler)
+ return false;
+ }
+
+ public static void Animate(GifImage image, EventHandler onFrameChangedHandler)
+ {
+ if (image == null)
{
- // Make sure we have a list of images
- if (image == null || ImageInfoList == null)
+ return;
+ }
+
+ GifImageInfo imageInfo;
+
+ // See comment in the class header about locking the image ref.
+ lock (image)
+ {
+ // could we avoid creating an ImageInfo object if FrameCount == 1 ?
+ imageInfo = new GifImageInfo(image);
+ }
+
+ // If the image is already animating, stop animating it
+ StopAnimate(image, onFrameChangedHandler);
+
+ // Acquire a writer lock to modify the image info list. If the thread has a reader lock we need to upgrade
+ // it to a writer lock; acquiring a reader lock in this case would block the thread on itself.
+ // If the thread already has a writer lock its ref count will be incremented w/o placing the request in the
+ // writer queue. See ReaderWriterLock.AcquireWriterLock method in the MSDN.
+
+ var readerLockHeld = RwImgListLock.IsReaderLockHeld;
+ var lockDowngradeCookie = new LockCookie();
+
+ ThreadWriterLockWaitCount++;
+
+ try
+ {
+ if (readerLockHeld)
{
- return;
+ lockDowngradeCookie = RwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
}
-
- // Acquire a writer lock to modify the image info list - See comments on Animate() about this locking.
-
- var readerLockHeld = RwImgListLock.IsReaderLockHeld;
- var lockDowngradeCookie = new LockCookie();
-
- ThreadWriterLockWaitCount++;
-
- try
+ else
{
- if (readerLockHeld)
- {
- lockDowngradeCookie = RwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
- }
- else
- {
- RwImgListLock.AcquireWriterLock(Timeout.Infinite);
- }
- }
- finally
- {
- ThreadWriterLockWaitCount--;
+ RwImgListLock.AcquireWriterLock(Timeout.Infinite);
}
+ }
+ finally
+ {
+ ThreadWriterLockWaitCount--;
+ }
- try
+ try
+ {
+ if (imageInfo.Animated)
{
- // Find the corresponding reference and remove it
- for (var i = 0; i < ImageInfoList.Count; i++)
+ // Construct the image array
+ //
+ ImageInfoList ??= new List();
+
+ // Add the new image
+ //
+ imageInfo.FrameChangedHandler = onFrameChangedHandler;
+ ImageInfoList.Add(imageInfo);
+
+ // Construct a new timer thread if we haven't already
+ //
+ if (AnimationThread == null)
{
- var imageInfo = ImageInfoList[i];
-
- if (Equals(image, imageInfo.Image))
+ AnimationThread = new Thread(AnimateImages50Ms)
{
- if (onFrameChangedHandler == imageInfo.FrameChangedHandler || onFrameChangedHandler != null && onFrameChangedHandler.Equals(imageInfo.FrameChangedHandler))
- {
- ImageInfoList.Remove(imageInfo);
- }
- break;
- }
- }
-
- if (!ImageInfoList.Any())
- {
- AnimationThread?.Join();
- AnimationThread = null;
- }
- }
- finally
- {
- if (readerLockHeld)
- {
- RwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
- }
- else
- {
- RwImgListLock.ReleaseWriterLock();
+ Name = nameof(ImageAnimator),
+ IsBackground = true
+ };
+ AnimationThread.Start();
}
}
}
-
- public static void UpdateFrames()
+ finally
{
- if (!AnyFrameDirty || ImageInfoList == null)
+ if (readerLockHeld)
{
- return;
+ RwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
}
- if (ThreadWriterLockWaitCount > 0)
+ else
{
- // Cannot acquire reader lock at this time, frames update will be missed.
- return;
+ RwImgListLock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ public static void StopAnimate(GifImage image, EventHandler onFrameChangedHandler)
+ {
+ // Make sure we have a list of images
+ if (image == null || ImageInfoList == null)
+ {
+ return;
+ }
+
+ // Acquire a writer lock to modify the image info list - See comments on Animate() about this locking.
+
+ var readerLockHeld = RwImgListLock.IsReaderLockHeld;
+ var lockDowngradeCookie = new LockCookie();
+
+ ThreadWriterLockWaitCount++;
+
+ try
+ {
+ if (readerLockHeld)
+ {
+ lockDowngradeCookie = RwImgListLock.UpgradeToWriterLock(Timeout.Infinite);
+ }
+ else
+ {
+ RwImgListLock.AcquireWriterLock(Timeout.Infinite);
+ }
+ }
+ finally
+ {
+ ThreadWriterLockWaitCount--;
+ }
+
+ try
+ {
+ // Find the corresponding reference and remove it
+ for (var i = 0; i < ImageInfoList.Count; i++)
+ {
+ var imageInfo = ImageInfoList[i];
+
+ if (Equals(image, imageInfo.Image))
+ {
+ if (onFrameChangedHandler == imageInfo.FrameChangedHandler || onFrameChangedHandler != null && onFrameChangedHandler.Equals(imageInfo.FrameChangedHandler))
+ {
+ ImageInfoList.Remove(imageInfo);
+ }
+ break;
+ }
}
+ if (!ImageInfoList.Any())
+ {
+ AnimationThread?.Join();
+ AnimationThread = null;
+ }
+ }
+ finally
+ {
+ if (readerLockHeld)
+ {
+ RwImgListLock.DowngradeFromWriterLock(ref lockDowngradeCookie);
+ }
+ else
+ {
+ RwImgListLock.ReleaseWriterLock();
+ }
+ }
+ }
+
+ public static void UpdateFrames()
+ {
+ if (!AnyFrameDirty || ImageInfoList == null)
+ {
+ return;
+ }
+ if (ThreadWriterLockWaitCount > 0)
+ {
+ // Cannot acquire reader lock at this time, frames update will be missed.
+ return;
+ }
+
+ RwImgListLock.AcquireReaderLock(Timeout.Infinite);
+
+ try
+ {
+ foreach (var imageInfo in ImageInfoList)
+ {
+ // See comment in the class header about locking the image ref.
+ lock (imageInfo.Image)
+ {
+ imageInfo.UpdateFrame();
+ }
+ }
+ AnyFrameDirty = false;
+ }
+ finally
+ {
+ RwImgListLock.ReleaseReaderLock();
+ }
+ }
+
+ [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
+ private static void AnimateImages50Ms()
+ {
+ while (ImageInfoList.Any())
+ {
+ // Acquire reader-lock to access imageInfoList, elemens in the list can be modified w/o needing a writer-lock.
+ // Observe that we don't need to check if the thread is waiting or a writer lock here since the thread this
+ // method runs in never acquires a writer lock.
RwImgListLock.AcquireReaderLock(Timeout.Infinite);
-
try
{
foreach (var imageInfo in ImageInfoList)
{
- // See comment in the class header about locking the image ref.
- lock (imageInfo.Image)
+ // Frame delay is measured in 1/100ths of a second. This thread
+ // sleeps for 50 ms = 5/100ths of a second between frame updates,
+ // so we increase the frame delay count 5/100ths of a second
+ // at a time.
+ //
+ imageInfo.FrameTimer += 5;
+ if (imageInfo.FrameTimer >= imageInfo.FrameDelay(imageInfo.Frame))
{
- imageInfo.UpdateFrame();
+ imageInfo.FrameTimer = 0;
+
+ if (imageInfo.Frame + 1 < imageInfo.FrameCount)
+ {
+ imageInfo.Frame++;
+ }
+ else
+ {
+ imageInfo.Frame = 0;
+ }
+
+ if (imageInfo.FrameDirty)
+ {
+ AnyFrameDirty = true;
+ }
}
}
- AnyFrameDirty = false;
}
finally
{
RwImgListLock.ReleaseReaderLock();
}
- }
- [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
- private static void AnimateImages50Ms()
- {
- while (ImageInfoList.Any())
- {
- // Acquire reader-lock to access imageInfoList, elemens in the list can be modified w/o needing a writer-lock.
- // Observe that we don't need to check if the thread is waiting or a writer lock here since the thread this
- // method runs in never acquires a writer lock.
- RwImgListLock.AcquireReaderLock(Timeout.Infinite);
- try
- {
- foreach (var imageInfo in ImageInfoList)
- {
- // Frame delay is measured in 1/100ths of a second. This thread
- // sleeps for 50 ms = 5/100ths of a second between frame updates,
- // so we increase the frame delay count 5/100ths of a second
- // at a time.
- //
- imageInfo.FrameTimer += 5;
- if (imageInfo.FrameTimer >= imageInfo.FrameDelay(imageInfo.Frame))
- {
- imageInfo.FrameTimer = 0;
-
- if (imageInfo.Frame + 1 < imageInfo.FrameCount)
- {
- imageInfo.Frame++;
- }
- else
- {
- imageInfo.Frame = 0;
- }
-
- if (imageInfo.FrameDirty)
- {
- AnyFrameDirty = true;
- }
- }
- }
- }
- finally
- {
- RwImgListLock.ReleaseReaderLock();
- }
-
- Thread.Sleep(50);
- }
+ Thread.Sleep(50);
}
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/GlobalShortcut.cs b/src/Shared/HandyControl_Shared/Tools/GlobalShortcut.cs
index 1fbc6071..830d73da 100644
--- a/src/Shared/HandyControl_Shared/Tools/GlobalShortcut.cs
+++ b/src/Shared/HandyControl_Shared/Tools/GlobalShortcut.cs
@@ -5,117 +5,116 @@ using System.Windows;
using System.Windows.Input;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class GlobalShortcut
{
- public class GlobalShortcut
+ private static ObservableCollection KeyBindingCollection;
+
+ private static readonly Dictionary CommandDic = new();
+
+ private static void KeyboardHook_KeyDown(object sender, KeyboardHookEventArgs e) => HitTest(e.Key);
+
+ static GlobalShortcut()
{
- private static ObservableCollection KeyBindingCollection;
-
- private static readonly Dictionary CommandDic = new();
-
- private static void KeyboardHook_KeyDown(object sender, KeyboardHookEventArgs e) => HitTest(e.Key);
-
- static GlobalShortcut()
- {
- KeyboardHook.KeyDown += KeyboardHook_KeyDown;
- }
-
- private static void HitTest(Key key)
- {
- if (IsModifierKey(key)) return;
-
- var modifierKeys = Keyboard.Modifiers;
- var keyStr = modifierKeys != ModifierKeys.None ? $"{modifierKeys.ToString()}, {key.ToString()}" : key.ToString();
- ExecuteCommand(keyStr);
- }
-
- private static void ExecuteCommand(string key)
- {
- if (string.IsNullOrEmpty(key)) return;
- if (CommandDic.ContainsKey(key))
- {
- var keyBinding = CommandDic[key];
- var command = keyBinding.Command;
- if (command != null && command.CanExecute(keyBinding.CommandParameter))
- {
- command.Execute(keyBinding.CommandParameter);
- }
- }
- }
-
- private static bool IsModifierKey(Key key)
- {
- return key == Key.LeftCtrl || key == Key.LeftAlt || key == Key.LeftShift || key == Key.LWin ||
- key == Key.RightCtrl || key == Key.RightAlt || key == Key.RightShift || key == Key.RWin;
- }
-
- public static void Init(List list)
- {
- CommandDic.Clear();
-
- if (list == null) return;
- KeyBindingCollection = new ObservableCollection(list);
- if (KeyBindingCollection.Count == 0) return;
-
- AddKeyBindings(KeyBindingCollection);
- KeyboardHook.Start();
- }
-
- private static void AddKeyBindings(IEnumerable keyBindings)
- {
- foreach (var item in keyBindings)
- {
- if (item.Key == Key.None) continue;
-
- if (item.Modifiers == ModifierKeys.None)
- {
- CommandDic[item.Key.ToString()] = item;
- }
- else
- {
- var keyStr = $"{item.Modifiers.ToString()}, {item.Key.ToString()}";
- CommandDic[keyStr] = item;
- }
- }
- }
-
- public static readonly DependencyProperty HostProperty = DependencyProperty.RegisterAttached(
- "Host", typeof(bool), typeof(GlobalShortcut), new PropertyMetadata(ValueBoxes.FalseBox, OnHostChanged));
-
- private static void OnHostChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
- {
- if (DesignerHelper.IsInDesignMode) return;
-
- if (KeyBindingCollection != null)
- {
- KeyBindingCollection.CollectionChanged -= KeyBindingCollection_CollectionChanged;
- }
- KeyBindingCollection = GetKeyBindings(d);
- if (KeyBindingCollection != null)
- {
- KeyBindingCollection.CollectionChanged += KeyBindingCollection_CollectionChanged;
- }
- }
-
- private static void KeyBindingCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- AddKeyBindings(KeyBindingCollection);
- KeyboardHook.Start();
- }
-
- public static void SetHost(DependencyObject element, bool value)
- => element.SetValue(HostProperty, ValueBoxes.BooleanBox(value));
-
- public static bool GetHost(DependencyObject element)
- => (bool) element.GetValue(HostProperty);
-
- public static readonly DependencyProperty KeyBindingsProperty = DependencyProperty.RegisterAttached(
- "KeyBindings", typeof(ObservableCollection), typeof(GlobalShortcut), new PropertyMetadata(new ObservableCollection()));
-
- public static void SetKeyBindings(DependencyObject element, ObservableCollection value)
- => element.SetValue(KeyBindingsProperty, value);
-
- public static ObservableCollection GetKeyBindings(DependencyObject element)
- => (ObservableCollection) element.GetValue(KeyBindingsProperty);
+ KeyboardHook.KeyDown += KeyboardHook_KeyDown;
}
+
+ private static void HitTest(Key key)
+ {
+ if (IsModifierKey(key)) return;
+
+ var modifierKeys = Keyboard.Modifiers;
+ var keyStr = modifierKeys != ModifierKeys.None ? $"{modifierKeys.ToString()}, {key.ToString()}" : key.ToString();
+ ExecuteCommand(keyStr);
+ }
+
+ private static void ExecuteCommand(string key)
+ {
+ if (string.IsNullOrEmpty(key)) return;
+ if (CommandDic.ContainsKey(key))
+ {
+ var keyBinding = CommandDic[key];
+ var command = keyBinding.Command;
+ if (command != null && command.CanExecute(keyBinding.CommandParameter))
+ {
+ command.Execute(keyBinding.CommandParameter);
+ }
+ }
+ }
+
+ private static bool IsModifierKey(Key key)
+ {
+ return key == Key.LeftCtrl || key == Key.LeftAlt || key == Key.LeftShift || key == Key.LWin ||
+ key == Key.RightCtrl || key == Key.RightAlt || key == Key.RightShift || key == Key.RWin;
+ }
+
+ public static void Init(List list)
+ {
+ CommandDic.Clear();
+
+ if (list == null) return;
+ KeyBindingCollection = new ObservableCollection(list);
+ if (KeyBindingCollection.Count == 0) return;
+
+ AddKeyBindings(KeyBindingCollection);
+ KeyboardHook.Start();
+ }
+
+ private static void AddKeyBindings(IEnumerable keyBindings)
+ {
+ foreach (var item in keyBindings)
+ {
+ if (item.Key == Key.None) continue;
+
+ if (item.Modifiers == ModifierKeys.None)
+ {
+ CommandDic[item.Key.ToString()] = item;
+ }
+ else
+ {
+ var keyStr = $"{item.Modifiers.ToString()}, {item.Key.ToString()}";
+ CommandDic[keyStr] = item;
+ }
+ }
+ }
+
+ public static readonly DependencyProperty HostProperty = DependencyProperty.RegisterAttached(
+ "Host", typeof(bool), typeof(GlobalShortcut), new PropertyMetadata(ValueBoxes.FalseBox, OnHostChanged));
+
+ private static void OnHostChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (DesignerHelper.IsInDesignMode) return;
+
+ if (KeyBindingCollection != null)
+ {
+ KeyBindingCollection.CollectionChanged -= KeyBindingCollection_CollectionChanged;
+ }
+ KeyBindingCollection = GetKeyBindings(d);
+ if (KeyBindingCollection != null)
+ {
+ KeyBindingCollection.CollectionChanged += KeyBindingCollection_CollectionChanged;
+ }
+ }
+
+ private static void KeyBindingCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
+ {
+ AddKeyBindings(KeyBindingCollection);
+ KeyboardHook.Start();
+ }
+
+ public static void SetHost(DependencyObject element, bool value)
+ => element.SetValue(HostProperty, ValueBoxes.BooleanBox(value));
+
+ public static bool GetHost(DependencyObject element)
+ => (bool) element.GetValue(HostProperty);
+
+ public static readonly DependencyProperty KeyBindingsProperty = DependencyProperty.RegisterAttached(
+ "KeyBindings", typeof(ObservableCollection), typeof(GlobalShortcut), new PropertyMetadata(new ObservableCollection()));
+
+ public static void SetKeyBindings(DependencyObject element, ObservableCollection value)
+ => element.SetValue(KeyBindingsProperty, value);
+
+ public static ObservableCollection GetKeyBindings(DependencyObject element)
+ => (ObservableCollection) element.GetValue(KeyBindingsProperty);
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/AnimationHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/AnimationHelper.cs
index bae79906..95864b90 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/AnimationHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/AnimationHelper.cs
@@ -6,89 +6,88 @@ using System.Windows.Media;
using System.Windows.Media.Animation;
using HandyControl.Tools.Extension;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 包含一些常用的动画辅助方法
+///
+public class AnimationHelper
{
///
- /// 包含一些常用的动画辅助方法
+ /// 创建一个Thickness动画
///
- public class AnimationHelper
+ ///
+ ///
+ ///
+ public static ThicknessAnimation CreateAnimation(Thickness thickness = default, double milliseconds = 200)
{
- ///
- /// 创建一个Thickness动画
- ///
- ///
- ///
- ///
- public static ThicknessAnimation CreateAnimation(Thickness thickness = default, double milliseconds = 200)
+ return new(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
{
- return new(thickness, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
- {
- EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
- };
- }
+ EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
+ };
+ }
- ///
- /// 创建一个Double动画
- ///
- ///
- ///
- ///
- public static DoubleAnimation CreateAnimation(double toValue, double milliseconds = 200)
+ ///
+ /// 创建一个Double动画
+ ///
+ ///
+ ///
+ ///
+ public static DoubleAnimation CreateAnimation(double toValue, double milliseconds = 200)
+ {
+ return new(toValue, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
{
- return new(toValue, new Duration(TimeSpan.FromMilliseconds(milliseconds)))
- {
- EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
- };
- }
+ EasingFunction = new PowerEase { EasingMode = EasingMode.EaseInOut }
+ };
+ }
- internal static void DecomposeGeometryStr(string geometryStr, out double[] arr)
+ internal static void DecomposeGeometryStr(string geometryStr, out double[] arr)
+ {
+ var collection = Regex.Matches(geometryStr, RegexPatterns.DigitsPattern);
+ arr = new double[collection.Count];
+ for (var i = 0; i < collection.Count; i++)
{
- var collection = Regex.Matches(geometryStr, RegexPatterns.DigitsPattern);
- arr = new double[collection.Count];
- for (var i = 0; i < collection.Count; i++)
- {
- arr[i] = collection[i].Value.Value();
- }
- }
-
- internal static Geometry ComposeGeometry(string[] strings, double[] arr)
- {
- var builder = new StringBuilder(strings[0]);
- for (var i = 0; i < arr.Length; i++)
- {
- var s = strings[i + 1];
- var n = arr[i];
- if (!double.IsNaN(n))
- {
- builder.Append(n).Append(s);
- }
- }
-
- return Geometry.Parse(builder.ToString());
- }
-
- internal static Geometry InterpolateGeometry(double[] from, double[] to, double progress, string[] strings)
- {
- var accumulated = new double[to.Length];
- for (var i = 0; i < to.Length; i++)
- {
- var fromValue = from[i];
- accumulated[i] = fromValue + (to[i] - fromValue) * progress;
- }
-
- return ComposeGeometry(strings, accumulated);
- }
-
- internal static double[] InterpolateGeometryValue(double[] from, double[] to, double progress)
- {
- var accumulated = new double[to.Length];
- for (var i = 0; i < to.Length; i++)
- {
- var fromValue = from[i];
- accumulated[i] = fromValue + (to[i] - fromValue) * progress;
- }
-
- return accumulated;
+ arr[i] = collection[i].Value.Value();
}
}
+
+ internal static Geometry ComposeGeometry(string[] strings, double[] arr)
+ {
+ var builder = new StringBuilder(strings[0]);
+ for (var i = 0; i < arr.Length; i++)
+ {
+ var s = strings[i + 1];
+ var n = arr[i];
+ if (!double.IsNaN(n))
+ {
+ builder.Append(n).Append(s);
+ }
+ }
+
+ return Geometry.Parse(builder.ToString());
+ }
+
+ internal static Geometry InterpolateGeometry(double[] from, double[] to, double progress, string[] strings)
+ {
+ var accumulated = new double[to.Length];
+ for (var i = 0; i < to.Length; i++)
+ {
+ var fromValue = from[i];
+ accumulated[i] = fromValue + (to[i] - fromValue) * progress;
+ }
+
+ return ComposeGeometry(strings, accumulated);
+ }
+
+ internal static double[] InterpolateGeometryValue(double[] from, double[] to, double progress)
+ {
+ var accumulated = new double[to.Length];
+ for (var i = 0; i < to.Length; i++)
+ {
+ var fromValue = from[i];
+ accumulated[i] = fromValue + (to[i] - fromValue) * progress;
+ }
+
+ return accumulated;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ArithmeticHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ArithmeticHelper.cs
index 599162c6..c0c68820 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ArithmeticHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ArithmeticHelper.cs
@@ -4,124 +4,123 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Media3D;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 包含内部使用的一些简单算法
+///
+internal class ArithmeticHelper
{
///
- /// 包含内部使用的一些简单算法
+ /// 平分一个整数到一个数组中
///
- internal class ArithmeticHelper
+ ///
+ ///
+ ///
+ public static int[] DivideInt2Arr(int num, int count)
{
- ///
- /// 平分一个整数到一个数组中
- ///
- ///
- ///
- ///
- public static int[] DivideInt2Arr(int num, int count)
+ var arr = new int[count];
+ var div = num / count;
+ var rest = num % count;
+ for (var i = 0; i < count; i++)
{
- var arr = new int[count];
- var div = num / count;
- var rest = num % count;
- for (var i = 0; i < count; i++)
+ arr[i] = div;
+ }
+ for (var i = 0; i < rest; i++)
+ {
+ arr[i] += 1;
+ }
+ return arr;
+ }
+
+ ///
+ /// 计算控件在窗口中的可见坐标
+ ///
+ public static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement, Thickness thickness = default)
+ {
+ if (element == null || showElement == null) return default;
+ var point = element.PointToScreen(new Point(0, 0));
+
+ if (point.X < 0) point.X = 0;
+ if (point.Y < 0) point.Y = 0;
+
+ var maxLeft = SystemParameters.WorkArea.Width -
+ ((double.IsNaN(showElement.Width) ? showElement.ActualWidth : showElement.Width) +
+ thickness.Left + thickness.Right);
+ var maxTop = SystemParameters.WorkArea.Height -
+ ((double.IsNaN(showElement.Height) ? showElement.ActualHeight : showElement.Height) +
+ thickness.Top + thickness.Bottom);
+ return new Point(maxLeft > point.X ? point.X : maxLeft, maxTop > point.Y ? point.Y : maxTop);
+ }
+
+ ///
+ /// 获取布局范围框
+ ///
+ ///
+ ///
+ public static Rect GetLayoutRect(FrameworkElement element)
+ {
+ var num1 = element.ActualWidth;
+ var num2 = element.ActualHeight;
+ if (element is Image || element is MediaElement)
+ if (element.Parent is Canvas)
{
- arr[i] = div;
+ num1 = double.IsNaN(element.Width) ? num1 : element.Width;
+ num2 = double.IsNaN(element.Height) ? num2 : element.Height;
}
- for (var i = 0; i < rest; i++)
+ else
{
- arr[i] += 1;
+ num1 = element.RenderSize.Width;
+ num2 = element.RenderSize.Height;
}
- return arr;
- }
-
- ///
- /// 计算控件在窗口中的可见坐标
- ///
- public static Point CalSafePoint(FrameworkElement element, FrameworkElement showElement, Thickness thickness = default)
+ var width = element.Visibility == Visibility.Collapsed ? 0.0 : num1;
+ var height = element.Visibility == Visibility.Collapsed ? 0.0 : num2;
+ var margin = element.Margin;
+ var layoutSlot = LayoutInformation.GetLayoutSlot(element);
+ var x = 0.0;
+ var y = 0.0;
+ x = element.HorizontalAlignment switch
{
- if (element == null || showElement == null) return default;
- var point = element.PointToScreen(new Point(0, 0));
-
- if (point.X < 0) point.X = 0;
- if (point.Y < 0) point.Y = 0;
-
- var maxLeft = SystemParameters.WorkArea.Width -
- ((double.IsNaN(showElement.Width) ? showElement.ActualWidth : showElement.Width) +
- thickness.Left + thickness.Right);
- var maxTop = SystemParameters.WorkArea.Height -
- ((double.IsNaN(showElement.Height) ? showElement.ActualHeight : showElement.Height) +
- thickness.Top + thickness.Bottom);
- return new Point(maxLeft > point.X ? point.X : maxLeft, maxTop > point.Y ? point.Y : maxTop);
- }
-
- ///
- /// 获取布局范围框
- ///
- ///
- ///
- public static Rect GetLayoutRect(FrameworkElement element)
+ HorizontalAlignment.Left => layoutSlot.Left + margin.Left,
+ HorizontalAlignment.Center => (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 -
+ width / 2.0,
+ HorizontalAlignment.Right => layoutSlot.Right - margin.Right - width,
+ HorizontalAlignment.Stretch => Math.Max(layoutSlot.Left + margin.Left,
+ (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - width / 2.0),
+ _ => x
+ };
+ y = element.VerticalAlignment switch
{
- var num1 = element.ActualWidth;
- var num2 = element.ActualHeight;
- if (element is Image || element is MediaElement)
- if (element.Parent is Canvas)
- {
- num1 = double.IsNaN(element.Width) ? num1 : element.Width;
- num2 = double.IsNaN(element.Height) ? num2 : element.Height;
- }
- else
- {
- num1 = element.RenderSize.Width;
- num2 = element.RenderSize.Height;
- }
- var width = element.Visibility == Visibility.Collapsed ? 0.0 : num1;
- var height = element.Visibility == Visibility.Collapsed ? 0.0 : num2;
- var margin = element.Margin;
- var layoutSlot = LayoutInformation.GetLayoutSlot(element);
- var x = 0.0;
- var y = 0.0;
- x = element.HorizontalAlignment switch
- {
- HorizontalAlignment.Left => layoutSlot.Left + margin.Left,
- HorizontalAlignment.Center => (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 -
- width / 2.0,
- HorizontalAlignment.Right => layoutSlot.Right - margin.Right - width,
- HorizontalAlignment.Stretch => Math.Max(layoutSlot.Left + margin.Left,
- (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - width / 2.0),
- _ => x
- };
- y = element.VerticalAlignment switch
- {
- VerticalAlignment.Top => layoutSlot.Top + margin.Top,
- VerticalAlignment.Center => (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 -
- height / 2.0,
- VerticalAlignment.Bottom => layoutSlot.Bottom - margin.Bottom - height,
- VerticalAlignment.Stretch => Math.Max(layoutSlot.Top + margin.Top,
- (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - height / 2.0),
- _ => y
- };
- return new Rect(x, y, width, height);
- }
+ VerticalAlignment.Top => layoutSlot.Top + margin.Top,
+ VerticalAlignment.Center => (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 -
+ height / 2.0,
+ VerticalAlignment.Bottom => layoutSlot.Bottom - margin.Bottom - height,
+ VerticalAlignment.Stretch => Math.Max(layoutSlot.Top + margin.Top,
+ (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - height / 2.0),
+ _ => y
+ };
+ return new Rect(x, y, width, height);
+ }
- ///
- /// 计算两点的连线和x轴的夹角
- ///
- ///
- ///
- ///
- public static double CalAngle(Point center, Point p) => Math.Atan2(p.Y - center.Y, p.X - center.X) * 180 / Math.PI;
+ ///
+ /// 计算两点的连线和x轴的夹角
+ ///
+ ///
+ ///
+ ///
+ public static double CalAngle(Point center, Point p) => Math.Atan2(p.Y - center.Y, p.X - center.X) * 180 / Math.PI;
- ///
- /// 计算法线
- ///
- ///
- ///
- ///
- ///
- public static Vector3D CalNormal(Point3D p0, Point3D p1, Point3D p2)
- {
- var v0 = new Vector3D(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
- var v1 = new Vector3D(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z);
- return Vector3D.CrossProduct(v0, v1);
- }
+ ///
+ /// 计算法线
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Vector3D CalNormal(Point3D p0, Point3D p1, Point3D p2)
+ {
+ var v0 = new Vector3D(p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
+ var v1 = new Vector3D(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z);
+ return Vector3D.CrossProduct(v0, v1);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/BindingHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/BindingHelper.cs
index 5a2936bb..2ffcfbff 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/BindingHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/BindingHelper.cs
@@ -2,30 +2,29 @@
using System.Windows.Controls;
using System.Windows.Data;
-namespace HandyControl.Tools.Helper
+namespace HandyControl.Tools.Helper;
+
+public class BindingHelper
{
- public class BindingHelper
+ public static string GetString(object source, string path)
{
- public static string GetString(object source, string path)
+ if (string.IsNullOrEmpty(path))
{
- if (string.IsNullOrEmpty(path))
- {
- return source == null ? string.Empty : source.ToString();
- }
-
- var tempObj = new DependencyObject();
-
- var binding = new Binding(path)
- {
- Mode = BindingMode.OneTime,
- Source = source
- };
-
- BindingOperations.SetBinding(tempObj, TextSearch.TextProperty, binding);
- var result = (string) tempObj.GetValue(TextSearch.TextProperty);
-
- BindingOperations.ClearBinding(tempObj, TextSearch.TextProperty);
- return result;
+ return source == null ? string.Empty : source.ToString();
}
+
+ var tempObj = new DependencyObject();
+
+ var binding = new Binding(path)
+ {
+ Mode = BindingMode.OneTime,
+ Source = source
+ };
+
+ BindingOperations.SetBinding(tempObj, TextSearch.TextProperty, binding);
+ var result = (string) tempObj.GetValue(TextSearch.TextProperty);
+
+ BindingOperations.ClearBinding(tempObj, TextSearch.TextProperty);
+ return result;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ColorHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ColorHelper.cs
index c0bd59dd..d17723a3 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ColorHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ColorHelper.cs
@@ -1,20 +1,19 @@
using System;
using System.Windows.Media;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class ColorHelper
{
- public class ColorHelper
+ private const int Win32RedShift = 0;
+ private const int Win32GreenShift = 8;
+ private const int Win32BlueShift = 16;
+
+ public static int ToWin32(Color c) => c.R << Win32RedShift | c.G << Win32GreenShift | c.B << Win32BlueShift;
+
+ public static Color ToColor(uint c)
{
- private const int Win32RedShift = 0;
- private const int Win32GreenShift = 8;
- private const int Win32BlueShift = 16;
-
- public static int ToWin32(Color c) => c.R << Win32RedShift | c.G << Win32GreenShift | c.B << Win32BlueShift;
-
- public static Color ToColor(uint c)
- {
- var bytes = BitConverter.GetBytes(c);
- return Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
- }
+ var bytes = BitConverter.GetBytes(c);
+ return Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
index 50945976..aab7503a 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
@@ -11,78 +11,77 @@ using System.Windows.Navigation;
using HandyControl.Data;
using HandyControl.Properties.Langs;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class ConfigHelper : INotifyPropertyChanged
{
- public class ConfigHelper : INotifyPropertyChanged
+ private ConfigHelper()
{
- private ConfigHelper()
+
+ }
+
+ public static ConfigHelper Instance = new Lazy(() => new ConfigHelper()).Value;
+
+ private XmlLanguage _lang = XmlLanguage.GetLanguage("zh-cn");
+
+ public XmlLanguage Lang
+ {
+ get => _lang;
+ set
{
-
- }
-
- public static ConfigHelper Instance = new Lazy(() => new ConfigHelper()).Value;
-
- private XmlLanguage _lang = XmlLanguage.GetLanguage("zh-cn");
-
- public XmlLanguage Lang
- {
- get => _lang;
- set
+ if (!_lang.IetfLanguageTag.Equals(value.IetfLanguageTag))
{
- if (!_lang.IetfLanguageTag.Equals(value.IetfLanguageTag))
- {
- _lang = value;
- OnPropertyChanged(nameof(Lang));
- }
+ _lang = value;
+ OnPropertyChanged(nameof(Lang));
}
}
+ }
- public void SetLang(string lang)
- {
- LangProvider.Culture = new CultureInfo(lang);
- Application.Current.Dispatcher.Thread.CurrentUICulture = new CultureInfo(lang);
- Lang = XmlLanguage.GetLanguage(lang);
- }
+ public void SetLang(string lang)
+ {
+ LangProvider.Culture = new CultureInfo(lang);
+ Application.Current.Dispatcher.Thread.CurrentUICulture = new CultureInfo(lang);
+ Lang = XmlLanguage.GetLanguage(lang);
+ }
- public void SetConfig(HandyControlConfig config)
- {
- SetLang(config.Lang);
- SetTimelineFrameRate(config.TimelineFrameRate);
- }
+ public void SetConfig(HandyControlConfig config)
+ {
+ SetLang(config.Lang);
+ SetTimelineFrameRate(config.TimelineFrameRate);
+ }
- public void SetTimelineFrameRate(int rate) =>
- Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata(rate));
+ public void SetTimelineFrameRate(int rate) =>
+ Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata(rate));
- public void SetWindowDefaultStyle(object resourceKey = null)
- {
- var metadata = resourceKey == null
- ? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(Window)))
- : new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
+ public void SetWindowDefaultStyle(object resourceKey = null)
+ {
+ var metadata = resourceKey == null
+ ? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(Window)))
+ : new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
- FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), metadata);
- }
+ FrameworkElement.StyleProperty.OverrideMetadata(typeof(Window), metadata);
+ }
- public void SetNavigationWindowDefaultStyle(object resourceKey = null)
- {
- var metadata = resourceKey == null
- ? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(NavigationWindow)))
- : new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
+ public void SetNavigationWindowDefaultStyle(object resourceKey = null)
+ {
+ var metadata = resourceKey == null
+ ? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(NavigationWindow)))
+ : new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
- FrameworkElement.StyleProperty.OverrideMetadata(typeof(NavigationWindow), metadata);
- }
+ FrameworkElement.StyleProperty.OverrideMetadata(typeof(NavigationWindow), metadata);
+ }
- public event PropertyChangedEventHandler PropertyChanged;
+ public event PropertyChangedEventHandler PropertyChanged;
#if NET40
- protected virtual void OnPropertyChanged(string propertyName)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-#else
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
-#endif
+ protected virtual void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
+#else
+ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+#endif
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/DesignerHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/DesignerHelper.cs
index 0223ca41..8b54df0e 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/DesignerHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/DesignerHelper.cs
@@ -1,22 +1,21 @@
using System.ComponentModel;
using System.Windows;
-namespace HandyControl.Tools
-{
- public class DesignerHelper
- {
- private static bool? _isInDesignMode;
+namespace HandyControl.Tools;
- public static bool IsInDesignMode
+public class DesignerHelper
+{
+ private static bool? _isInDesignMode;
+
+ public static bool IsInDesignMode
+ {
+ get
{
- get
+ if (!_isInDesignMode.HasValue)
{
- if (!_isInDesignMode.HasValue)
- {
- _isInDesignMode = (bool) DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue;
- }
- return _isInDesignMode.Value;
+ _isInDesignMode = (bool) DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue;
}
+ return _isInDesignMode.Value;
}
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
index 5f7f96b3..582a34c3 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
@@ -4,101 +4,100 @@ using System.Windows.Media;
using HandyControl.Expression.Drawing;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+internal static class DpiHelper
{
- internal static class DpiHelper
+ private const double LogicalDpi = 96.0;
+
+ [ThreadStatic]
+ private static Matrix _transformToDip;
+
+ static DpiHelper()
{
- private const double LogicalDpi = 96.0;
-
- [ThreadStatic]
- private static Matrix _transformToDip;
-
- static DpiHelper()
+ var dC = InteropMethods.GetDC(IntPtr.Zero);
+ if (dC != IntPtr.Zero)
{
- var dC = InteropMethods.GetDC(IntPtr.Zero);
- if (dC != IntPtr.Zero)
+ // 沿着屏幕宽度每逻辑英寸的像素数。在具有多个显示器的系统中,这个值对所有显示器都是相同的
+ const int logicPixelsX = 88;
+ // 沿着屏幕高度每逻辑英寸的像素数
+ const int logicPixelsY = 90;
+ DeviceDpiX = InteropMethods.GetDeviceCaps(dC, logicPixelsX);
+ DeviceDpiY = InteropMethods.GetDeviceCaps(dC, logicPixelsY);
+ InteropMethods.ReleaseDC(IntPtr.Zero, dC);
+ }
+ else
+ {
+ DeviceDpiX = LogicalDpi;
+ DeviceDpiY = LogicalDpi;
+ }
+
+ var identity = Matrix.Identity;
+ var identity2 = Matrix.Identity;
+ identity.Scale(DeviceDpiX / LogicalDpi, DeviceDpiY / LogicalDpi);
+ identity2.Scale(LogicalDpi / DeviceDpiX, LogicalDpi / DeviceDpiY);
+ TransformFromDevice = new MatrixTransform(identity2);
+ TransformFromDevice.Freeze();
+ TransformToDevice = new MatrixTransform(identity);
+ TransformToDevice.Freeze();
+ }
+
+ public static MatrixTransform TransformFromDevice { get; }
+
+ public static MatrixTransform TransformToDevice { get; }
+
+ public static double DeviceDpiX { get; }
+
+ public static double DeviceDpiY { get; }
+
+ public static double LogicalToDeviceUnitsScalingFactorX => TransformToDevice.Matrix.M11;
+
+ public static double LogicalToDeviceUnitsScalingFactorY => TransformToDevice.Matrix.M22;
+
+ public static Point DevicePixelsToLogical(Point devicePoint, double dpiScaleX, double dpiScaleY)
+ {
+ _transformToDip = Matrix.Identity;
+ _transformToDip.Scale(1d / dpiScaleX, 1d / dpiScaleY);
+ return _transformToDip.Transform(devicePoint);
+ }
+
+ public static Size DeviceSizeToLogical(Size deviceSize, double dpiScaleX, double dpiScaleY)
+ {
+ var pt = DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height), dpiScaleX, dpiScaleY);
+ return new Size(pt.X, pt.Y);
+ }
+
+ public static Rect LogicalToDeviceUnits(this Rect logicalRect)
+ {
+ var result = logicalRect;
+ result.Transform(TransformToDevice.Matrix);
+ return result;
+ }
+
+ public static Rect DeviceToLogicalUnits(this Rect deviceRect)
+ {
+ var result = deviceRect;
+ result.Transform(TransformFromDevice.Matrix);
+ return result;
+ }
+
+ public static double RoundLayoutValue(double value, double dpiScale)
+ {
+ double newValue;
+
+ if (!MathHelper.AreClose(dpiScale, 1.0))
+ {
+ newValue = Math.Round(value * dpiScale) / dpiScale;
+ if (double.IsNaN(newValue) || double.IsInfinity(newValue) || MathHelper.AreClose(newValue, double.MaxValue))
{
- // 沿着屏幕宽度每逻辑英寸的像素数。在具有多个显示器的系统中,这个值对所有显示器都是相同的
- const int logicPixelsX = 88;
- // 沿着屏幕高度每逻辑英寸的像素数
- const int logicPixelsY = 90;
- DeviceDpiX = InteropMethods.GetDeviceCaps(dC, logicPixelsX);
- DeviceDpiY = InteropMethods.GetDeviceCaps(dC, logicPixelsY);
- InteropMethods.ReleaseDC(IntPtr.Zero, dC);
+ newValue = value;
}
- else
- {
- DeviceDpiX = LogicalDpi;
- DeviceDpiY = LogicalDpi;
- }
-
- var identity = Matrix.Identity;
- var identity2 = Matrix.Identity;
- identity.Scale(DeviceDpiX / LogicalDpi, DeviceDpiY / LogicalDpi);
- identity2.Scale(LogicalDpi / DeviceDpiX, LogicalDpi / DeviceDpiY);
- TransformFromDevice = new MatrixTransform(identity2);
- TransformFromDevice.Freeze();
- TransformToDevice = new MatrixTransform(identity);
- TransformToDevice.Freeze();
}
-
- public static MatrixTransform TransformFromDevice { get; }
-
- public static MatrixTransform TransformToDevice { get; }
-
- public static double DeviceDpiX { get; }
-
- public static double DeviceDpiY { get; }
-
- public static double LogicalToDeviceUnitsScalingFactorX => TransformToDevice.Matrix.M11;
-
- public static double LogicalToDeviceUnitsScalingFactorY => TransformToDevice.Matrix.M22;
-
- public static Point DevicePixelsToLogical(Point devicePoint, double dpiScaleX, double dpiScaleY)
+ else
{
- _transformToDip = Matrix.Identity;
- _transformToDip.Scale(1d / dpiScaleX, 1d / dpiScaleY);
- return _transformToDip.Transform(devicePoint);
+ newValue = Math.Round(value);
}
- public static Size DeviceSizeToLogical(Size deviceSize, double dpiScaleX, double dpiScaleY)
- {
- var pt = DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height), dpiScaleX, dpiScaleY);
- return new Size(pt.X, pt.Y);
- }
-
- public static Rect LogicalToDeviceUnits(this Rect logicalRect)
- {
- var result = logicalRect;
- result.Transform(TransformToDevice.Matrix);
- return result;
- }
-
- public static Rect DeviceToLogicalUnits(this Rect deviceRect)
- {
- var result = deviceRect;
- result.Transform(TransformFromDevice.Matrix);
- return result;
- }
-
- public static double RoundLayoutValue(double value, double dpiScale)
- {
- double newValue;
-
- if (!MathHelper.AreClose(dpiScale, 1.0))
- {
- newValue = Math.Round(value * dpiScale) / dpiScale;
- if (double.IsNaN(newValue) || double.IsInfinity(newValue) || MathHelper.AreClose(newValue, double.MaxValue))
- {
- newValue = value;
- }
- }
- else
- {
- newValue = Math.Round(value);
- }
-
- return newValue;
- }
+ return newValue;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/FullScreenHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/FullScreenHelper.cs
index c216c20a..5c57372f 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/FullScreenHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/FullScreenHelper.cs
@@ -5,273 +5,272 @@ using System.Windows;
using System.Windows.Interop;
using HandyControl.Tools.Interop;
-namespace HandyControl.Controls
+namespace HandyControl.Controls;
+
+///
+/// 用来使窗口变得全屏的辅助类
+/// 采用设置窗口位置和尺寸,确保盖住整个屏幕的方式来实现全屏
+/// 目前已知需要满足的条件是:窗口盖住整个屏幕、窗口没有WS_THICKFRAME样式、窗口不能有标题栏且最大化
+///
+internal static class FullScreenHelper
{
///
- /// 用来使窗口变得全屏的辅助类
- /// 采用设置窗口位置和尺寸,确保盖住整个屏幕的方式来实现全屏
- /// 目前已知需要满足的条件是:窗口盖住整个屏幕、窗口没有WS_THICKFRAME样式、窗口不能有标题栏且最大化
+ /// 用于记录窗口全屏前位置的附加属性
///
- internal static class FullScreenHelper
+ private static readonly DependencyProperty BeforeFullScreenWindowPlacementProperty =
+ DependencyProperty.RegisterAttached("BeforeFullScreenWindowPlacement",
+ typeof(InteropValues.WINDOWPLACEMENT?), typeof(FullScreenHelper));
+
+ ///
+ /// 用于记录窗口全屏前样式的附加属性
+ ///
+ private static readonly DependencyProperty BeforeFullScreenWindowStyleProperty =
+ DependencyProperty.RegisterAttached("BeforeFullScreenWindowStyle",
+ typeof(InteropValues.WindowStyles?), typeof(FullScreenHelper));
+
+ ///
+ /// 开始进入全屏模式
+ /// 进入全屏模式后,窗口可通过 API 方式(也可以用 Win + Shift + Left/Right)移动,调整大小,但会根据目标矩形寻找显示器重新调整到全屏状态。
+ /// 进入全屏后,不要修改样式等窗口属性,在退出时,会恢复到进入前的状态
+ /// 进入全屏模式后会禁用 DWM 过渡动画
+ ///
+ public static void StartFullScreen(System.Windows.Window window)
{
- ///
- /// 用于记录窗口全屏前位置的附加属性
- ///
- private static readonly DependencyProperty BeforeFullScreenWindowPlacementProperty =
- DependencyProperty.RegisterAttached("BeforeFullScreenWindowPlacement",
- typeof(InteropValues.WINDOWPLACEMENT?), typeof(FullScreenHelper));
-
- ///
- /// 用于记录窗口全屏前样式的附加属性
- ///
- private static readonly DependencyProperty BeforeFullScreenWindowStyleProperty =
- DependencyProperty.RegisterAttached("BeforeFullScreenWindowStyle",
- typeof(InteropValues.WindowStyles?), typeof(FullScreenHelper));
-
- ///
- /// 开始进入全屏模式
- /// 进入全屏模式后,窗口可通过 API 方式(也可以用 Win + Shift + Left/Right)移动,调整大小,但会根据目标矩形寻找显示器重新调整到全屏状态。
- /// 进入全屏后,不要修改样式等窗口属性,在退出时,会恢复到进入前的状态
- /// 进入全屏模式后会禁用 DWM 过渡动画
- ///
- public static void StartFullScreen(System.Windows.Window window)
+ if (window == null)
{
- if (window == null)
+ throw new ArgumentNullException(nameof(window), $"{nameof(window)} 不能为 null");
+ }
+
+ //确保不在全屏模式
+ if (window.GetValue(BeforeFullScreenWindowPlacementProperty) == null &&
+ window.GetValue(BeforeFullScreenWindowStyleProperty) == null)
+ {
+ var hwnd = new WindowInteropHelper(window).EnsureHandle();
+ var hwndSource = HwndSource.FromHwnd(hwnd);
+
+ //获取当前窗口的位置大小状态并保存
+ var placement = InteropMethods.GetWindowPlacement(hwnd);
+ window.SetValue(BeforeFullScreenWindowPlacementProperty, placement);
+
+ //修改窗口样式
+ var style = (InteropValues.WindowStyles) InteropMethods.GetWindowLongPtr(hwnd, InteropValues.GWL_STYLE);
+ window.SetValue(BeforeFullScreenWindowStyleProperty, style);
+ //将窗口恢复到还原模式,在有标题栏的情况下最大化模式下无法全屏,
+ //这里采用还原,不修改标题栏的方式
+ //在退出全屏时,窗口原有的状态会恢复
+ //去掉WS_THICKFRAME,在有该样式的情况下不能全屏
+ //去掉WS_MAXIMIZEBOX,禁用最大化,如果最大化会退出全屏
+ //去掉WS_MAXIMIZE,使窗口变成还原状态,不使用ShowWindow(hwnd, ShowWindowCommands.SW_RESTORE),避免看到窗口变成还原状态这一过程(也避免影响窗口的Visible状态)
+ style &= ~(InteropValues.WindowStyles.WS_THICKFRAME | InteropValues.WindowStyles.WS_MAXIMIZEBOX | InteropValues.WindowStyles.WS_MAXIMIZE);
+ InteropMethods.SetWindowLong(hwnd, InteropValues.GWL_STYLE, (IntPtr) style);
+
+ //禁用 DWM 过渡动画 忽略返回值,若DWM关闭不做处理
+ InteropMethods.DwmSetWindowAttribute(hwnd, InteropValues.DwmWindowAttribute.DWMWA_TRANSITIONS_FORCEDISABLED, 1,
+ sizeof(int));
+
+ //添加Hook,在窗口尺寸位置等要发生变化时,确保全屏
+ hwndSource.AddHook(KeepFullScreenHook);
+
+ if (InteropMethods.GetWindowRect(hwnd, out var rect))
{
- throw new ArgumentNullException(nameof(window), $"{nameof(window)} 不能为 null");
+ //不能用 placement 的坐标,placement是工作区坐标,不是屏幕坐标。
+
+ //使用窗口当前的矩形调用下设置窗口位置和尺寸的方法,让Hook来进行调整窗口位置和尺寸到全屏模式
+ InteropMethods.SetWindowPos(hwnd, (IntPtr) InteropValues.HWND_TOP, rect.Left, rect.Top, rect.Width,
+ rect.Height, (int) InteropValues.WindowPositionFlags.SWP_NOZORDER);
+ }
+ }
+ }
+
+ ///
+ /// 退出全屏模式
+ /// 窗口会回到进入全屏模式时保存的状态
+ /// 退出全屏模式后会重新启用 DWM 过渡动画
+ ///
+ public static void EndFullScreen(System.Windows.Window window)
+ {
+ if (window == null)
+ {
+ throw new ArgumentNullException(nameof(window), $"{nameof(window)} 不能为 null");
+ }
+
+ //确保在全屏模式并获取之前保存的状态
+ if (window.GetValue(BeforeFullScreenWindowPlacementProperty) is InteropValues.WINDOWPLACEMENT placement
+ && window.GetValue(BeforeFullScreenWindowStyleProperty) is InteropValues.WindowStyles style)
+ {
+ var hwnd = new WindowInteropHelper(window).Handle;
+
+ if (hwnd == IntPtr.Zero)
+ {
+ // 句柄为 0 只有两种情况:
+ // 1. 虽然窗口已进入全屏,但窗口已被关闭;
+ // 2. 窗口初始化前,在还没有调用 StartFullScreen 的前提下就调用了此方法。
+ // 所以,直接 return 就好。
+ return;
}
- //确保不在全屏模式
- if (window.GetValue(BeforeFullScreenWindowPlacementProperty) == null &&
- window.GetValue(BeforeFullScreenWindowStyleProperty) == null)
+
+ var hwndSource = HwndSource.FromHwnd(hwnd);
+
+ //去除hook
+ hwndSource.RemoveHook(KeepFullScreenHook);
+
+ //恢复保存的状态
+ //不要改变Style里的WS_MAXIMIZE,否则会使窗口变成最大化状态,但是尺寸不对
+ //也不要设置回Style里的WS_MINIMIZE,否则会导致窗口最小化按钮显示成还原按钮
+ InteropMethods.SetWindowLong(hwnd, InteropValues.GWL_STYLE,
+ (IntPtr) (style & ~(InteropValues.WindowStyles.WS_MAXIMIZE | InteropValues.WindowStyles.WS_MINIMIZE)));
+
+ if ((style & InteropValues.WindowStyles.WS_MINIMIZE) != 0)
{
- var hwnd = new WindowInteropHelper(window).EnsureHandle();
- var hwndSource = HwndSource.FromHwnd(hwnd);
+ //如果窗口进入全屏前是最小化的,这里不让窗口恢复到之前的最小化状态,而是到还原的状态。
+ //大多数情况下,都不期望在退出全屏的时候,恢复到最小化。
+ placement.showCmd = InteropValues.SW.RESTORE;
+ }
- //获取当前窗口的位置大小状态并保存
- var placement = InteropMethods.GetWindowPlacement(hwnd);
- window.SetValue(BeforeFullScreenWindowPlacementProperty, placement);
+ if ((style & InteropValues.WindowStyles.WS_MAXIMIZE) != 0)
+ {
+ //提前调用 ShowWindow 使窗口恢复最大化,若通过 SetWindowPlacement 最大化会导致闪烁,只靠其恢复 RestoreBounds.
+ InteropMethods.ShowWindow(hwnd, InteropValues.SW.MAXIMIZE);
+ }
- //修改窗口样式
- var style = (InteropValues.WindowStyles) InteropMethods.GetWindowLongPtr(hwnd, InteropValues.GWL_STYLE);
- window.SetValue(BeforeFullScreenWindowStyleProperty, style);
- //将窗口恢复到还原模式,在有标题栏的情况下最大化模式下无法全屏,
- //这里采用还原,不修改标题栏的方式
- //在退出全屏时,窗口原有的状态会恢复
- //去掉WS_THICKFRAME,在有该样式的情况下不能全屏
- //去掉WS_MAXIMIZEBOX,禁用最大化,如果最大化会退出全屏
- //去掉WS_MAXIMIZE,使窗口变成还原状态,不使用ShowWindow(hwnd, ShowWindowCommands.SW_RESTORE),避免看到窗口变成还原状态这一过程(也避免影响窗口的Visible状态)
- style &= ~(InteropValues.WindowStyles.WS_THICKFRAME | InteropValues.WindowStyles.WS_MAXIMIZEBOX | InteropValues.WindowStyles.WS_MAXIMIZE);
- InteropMethods.SetWindowLong(hwnd, InteropValues.GWL_STYLE, (IntPtr) style);
-
- //禁用 DWM 过渡动画 忽略返回值,若DWM关闭不做处理
- InteropMethods.DwmSetWindowAttribute(hwnd, InteropValues.DwmWindowAttribute.DWMWA_TRANSITIONS_FORCEDISABLED, 1,
- sizeof(int));
-
- //添加Hook,在窗口尺寸位置等要发生变化时,确保全屏
- hwndSource.AddHook(KeepFullScreenHook);
+ InteropMethods.SetWindowPlacement(hwnd, ref placement);
+ if ((style & InteropValues.WindowStyles.WS_MAXIMIZE) ==
+ 0) //如果窗口是最大化就不要修改WPF属性,否则会破坏RestoreBounds,且WPF窗口自身在最大化时,不会修改 Left Top Width Height 属性
+ {
if (InteropMethods.GetWindowRect(hwnd, out var rect))
{
//不能用 placement 的坐标,placement是工作区坐标,不是屏幕坐标。
- //使用窗口当前的矩形调用下设置窗口位置和尺寸的方法,让Hook来进行调整窗口位置和尺寸到全屏模式
- InteropMethods.SetWindowPos(hwnd, (IntPtr) InteropValues.HWND_TOP, rect.Left, rect.Top, rect.Width,
- rect.Height, (int) InteropValues.WindowPositionFlags.SWP_NOZORDER);
- }
- }
- }
-
- ///
- /// 退出全屏模式
- /// 窗口会回到进入全屏模式时保存的状态
- /// 退出全屏模式后会重新启用 DWM 过渡动画
- ///
- public static void EndFullScreen(System.Windows.Window window)
- {
- if (window == null)
- {
- throw new ArgumentNullException(nameof(window), $"{nameof(window)} 不能为 null");
- }
-
- //确保在全屏模式并获取之前保存的状态
- if (window.GetValue(BeforeFullScreenWindowPlacementProperty) is InteropValues.WINDOWPLACEMENT placement
- && window.GetValue(BeforeFullScreenWindowStyleProperty) is InteropValues.WindowStyles style)
- {
- var hwnd = new WindowInteropHelper(window).Handle;
-
- if (hwnd == IntPtr.Zero)
- {
- // 句柄为 0 只有两种情况:
- // 1. 虽然窗口已进入全屏,但窗口已被关闭;
- // 2. 窗口初始化前,在还没有调用 StartFullScreen 的前提下就调用了此方法。
- // 所以,直接 return 就好。
- return;
- }
-
-
- var hwndSource = HwndSource.FromHwnd(hwnd);
-
- //去除hook
- hwndSource.RemoveHook(KeepFullScreenHook);
-
- //恢复保存的状态
- //不要改变Style里的WS_MAXIMIZE,否则会使窗口变成最大化状态,但是尺寸不对
- //也不要设置回Style里的WS_MINIMIZE,否则会导致窗口最小化按钮显示成还原按钮
- InteropMethods.SetWindowLong(hwnd, InteropValues.GWL_STYLE,
- (IntPtr) (style & ~(InteropValues.WindowStyles.WS_MAXIMIZE | InteropValues.WindowStyles.WS_MINIMIZE)));
-
- if ((style & InteropValues.WindowStyles.WS_MINIMIZE) != 0)
- {
- //如果窗口进入全屏前是最小化的,这里不让窗口恢复到之前的最小化状态,而是到还原的状态。
- //大多数情况下,都不期望在退出全屏的时候,恢复到最小化。
- placement.showCmd = InteropValues.SW.RESTORE;
- }
-
- if ((style & InteropValues.WindowStyles.WS_MAXIMIZE) != 0)
- {
- //提前调用 ShowWindow 使窗口恢复最大化,若通过 SetWindowPlacement 最大化会导致闪烁,只靠其恢复 RestoreBounds.
- InteropMethods.ShowWindow(hwnd, InteropValues.SW.MAXIMIZE);
- }
-
- InteropMethods.SetWindowPlacement(hwnd, ref placement);
-
- if ((style & InteropValues.WindowStyles.WS_MAXIMIZE) ==
- 0) //如果窗口是最大化就不要修改WPF属性,否则会破坏RestoreBounds,且WPF窗口自身在最大化时,不会修改 Left Top Width Height 属性
- {
- if (InteropMethods.GetWindowRect(hwnd, out var rect))
- {
- //不能用 placement 的坐标,placement是工作区坐标,不是屏幕坐标。
-
- //确保窗口的 WPF 属性与 Win32 位置一致
- var logicalPos =
- hwndSource.CompositionTarget.TransformFromDevice.Transform(
- new Point(rect.Left, rect.Top));
- var logicalSize =
- hwndSource.CompositionTarget.TransformFromDevice.Transform(
- new Point(rect.Width, rect.Height));
- window.Left = logicalPos.X;
- window.Top = logicalPos.Y;
- window.Width = logicalSize.X;
- window.Height = logicalSize.Y;
- }
- }
-
- //重新启用 DWM 过渡动画 忽略返回值,若DWM关闭不做处理
- InteropMethods.DwmSetWindowAttribute(hwnd, InteropValues.DwmWindowAttribute.DWMWA_TRANSITIONS_FORCEDISABLED, 0,
- sizeof(int));
-
- //删除保存的状态
- window.ClearValue(BeforeFullScreenWindowPlacementProperty);
- window.ClearValue(BeforeFullScreenWindowStyleProperty);
- }
- }
-
- ///
- /// 确保窗口全屏的Hook
- /// 使用HandleProcessCorruptedStateExceptions,防止访问内存过程中因为一些致命异常导致程序崩溃
- ///
- [HandleProcessCorruptedStateExceptions]
- private static IntPtr KeepFullScreenHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
- {
- //处理WM_WINDOWPOSCHANGING消息
- const int WINDOWPOSCHANGING = 0x0046;
- if (msg == WINDOWPOSCHANGING)
- {
- try
- {
- //得到WINDOWPOS结构体
- var pos = (InteropValues.WindowPosition) Marshal.PtrToStructure(lParam, typeof(InteropValues.WindowPosition));
-
- if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOMOVE) != 0 &&
- (pos.Flags & InteropValues.WindowPositionFlags.SWP_NOSIZE) != 0)
- {
- //既然你既不改变位置,也不改变尺寸,我就不管了...
- return IntPtr.Zero;
- }
-
- if (InteropMethods.IsIconic(hwnd))
- {
- // 如果在全屏期间最小化了窗口,那么忽略后续的位置调整。
- // 否则按后续逻辑,会根据窗口在 -32000 的位置,计算出错误的目标位置,然后就跳到主屏了。
- return IntPtr.Zero;
- }
-
- //获取窗口现在的矩形,下面用来参考计算目标矩形
- if (InteropMethods.GetWindowRect(hwnd, out var rect))
- {
- var targetRect = rect; //窗口想要变化的目标矩形
-
- if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOMOVE) == 0)
- {
- //需要移动
- targetRect.Left = pos.X;
- targetRect.Top = pos.Y;
- }
-
- if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOSIZE) == 0)
- {
- //要改变尺寸
- targetRect.Right = targetRect.Left + pos.Width;
- targetRect.Bottom = targetRect.Top + pos.Height;
- }
- else
- {
- //不改变尺寸
- targetRect.Right = targetRect.Left + rect.Width;
- targetRect.Bottom = targetRect.Top + rect.Height;
- }
-
- //使用目标矩形获取显示器信息
- var monitor = InteropMethods.MonitorFromRect(ref targetRect, InteropValues.MONITOR_DEFAULTTOPRIMARY);
- var info = new InteropValues.MONITORINFO();
- info.cbSize = (uint) Marshal.SizeOf(info);
- if (InteropMethods.GetMonitorInfo(monitor, ref info))
- {
- //基于显示器信息设置窗口尺寸位置
- pos.X = info.rcMonitor.Left;
- pos.Y = info.rcMonitor.Top;
- pos.Width = info.rcMonitor.Right - info.rcMonitor.Left;
- pos.Height = info.rcMonitor.Bottom - info.rcMonitor.Top;
- pos.Flags &= ~(InteropValues.WindowPositionFlags.SWP_NOSIZE | InteropValues.WindowPositionFlags.SWP_NOMOVE |
- InteropValues.WindowPositionFlags.SWP_NOREDRAW);
- pos.Flags |= InteropValues.WindowPositionFlags.SWP_NOCOPYBITS;
-
- if (rect == info.rcMonitor)
- {
- var hwndSource = HwndSource.FromHwnd(hwnd);
- if (hwndSource?.RootVisual is Window window)
- {
- //确保窗口的 WPF 属性与 Win32 位置一致,防止有逗比全屏后改 WPF 的属性,发生一些诡异的行为
- //下面这样做其实不太好,会再次触发 WM_WINDOWPOSCHANGING 来着.....但是又没有其他时机了
- // WM_WINDOWPOSCHANGED 不能用
- //(例如:在进入全屏后,修改 Left 属性,会进入 WM_WINDOWPOSCHANGING,然后在这里将消息里的结构体中的 Left 改回,
- // 使对 Left 的修改无效,那么将不会进入 WM_WINDOWPOSCHANGED,窗口尺寸正常,但窗口的 Left 属性值错误。)
- var logicalPos =
- hwndSource.CompositionTarget.TransformFromDevice.Transform(
- new Point(pos.X, pos.Y));
- var logicalSize =
- hwndSource.CompositionTarget.TransformFromDevice.Transform(
- new Point(pos.Width, pos.Height));
- window.Left = logicalPos.X;
- window.Top = logicalPos.Y;
- window.Width = logicalSize.X;
- window.Height = logicalSize.Y;
- }
- }
-
- //将修改后的结构体拷贝回去
- Marshal.StructureToPtr(pos, lParam, false);
- }
- }
- }
- catch
- {
- // 这里也不需要日志啥的,只是为了防止上面有逗比逻辑,在消息循环里面炸了
+ //确保窗口的 WPF 属性与 Win32 位置一致
+ var logicalPos =
+ hwndSource.CompositionTarget.TransformFromDevice.Transform(
+ new Point(rect.Left, rect.Top));
+ var logicalSize =
+ hwndSource.CompositionTarget.TransformFromDevice.Transform(
+ new Point(rect.Width, rect.Height));
+ window.Left = logicalPos.X;
+ window.Top = logicalPos.Y;
+ window.Width = logicalSize.X;
+ window.Height = logicalSize.Y;
}
}
- return IntPtr.Zero;
+ //重新启用 DWM 过渡动画 忽略返回值,若DWM关闭不做处理
+ InteropMethods.DwmSetWindowAttribute(hwnd, InteropValues.DwmWindowAttribute.DWMWA_TRANSITIONS_FORCEDISABLED, 0,
+ sizeof(int));
+
+ //删除保存的状态
+ window.ClearValue(BeforeFullScreenWindowPlacementProperty);
+ window.ClearValue(BeforeFullScreenWindowStyleProperty);
}
}
+
+ ///
+ /// 确保窗口全屏的Hook
+ /// 使用HandleProcessCorruptedStateExceptions,防止访问内存过程中因为一些致命异常导致程序崩溃
+ ///
+ [HandleProcessCorruptedStateExceptions]
+ private static IntPtr KeepFullScreenHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
+ {
+ //处理WM_WINDOWPOSCHANGING消息
+ const int WINDOWPOSCHANGING = 0x0046;
+ if (msg == WINDOWPOSCHANGING)
+ {
+ try
+ {
+ //得到WINDOWPOS结构体
+ var pos = (InteropValues.WindowPosition) Marshal.PtrToStructure(lParam, typeof(InteropValues.WindowPosition));
+
+ if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOMOVE) != 0 &&
+ (pos.Flags & InteropValues.WindowPositionFlags.SWP_NOSIZE) != 0)
+ {
+ //既然你既不改变位置,也不改变尺寸,我就不管了...
+ return IntPtr.Zero;
+ }
+
+ if (InteropMethods.IsIconic(hwnd))
+ {
+ // 如果在全屏期间最小化了窗口,那么忽略后续的位置调整。
+ // 否则按后续逻辑,会根据窗口在 -32000 的位置,计算出错误的目标位置,然后就跳到主屏了。
+ return IntPtr.Zero;
+ }
+
+ //获取窗口现在的矩形,下面用来参考计算目标矩形
+ if (InteropMethods.GetWindowRect(hwnd, out var rect))
+ {
+ var targetRect = rect; //窗口想要变化的目标矩形
+
+ if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOMOVE) == 0)
+ {
+ //需要移动
+ targetRect.Left = pos.X;
+ targetRect.Top = pos.Y;
+ }
+
+ if ((pos.Flags & InteropValues.WindowPositionFlags.SWP_NOSIZE) == 0)
+ {
+ //要改变尺寸
+ targetRect.Right = targetRect.Left + pos.Width;
+ targetRect.Bottom = targetRect.Top + pos.Height;
+ }
+ else
+ {
+ //不改变尺寸
+ targetRect.Right = targetRect.Left + rect.Width;
+ targetRect.Bottom = targetRect.Top + rect.Height;
+ }
+
+ //使用目标矩形获取显示器信息
+ var monitor = InteropMethods.MonitorFromRect(ref targetRect, InteropValues.MONITOR_DEFAULTTOPRIMARY);
+ var info = new InteropValues.MONITORINFO();
+ info.cbSize = (uint) Marshal.SizeOf(info);
+ if (InteropMethods.GetMonitorInfo(monitor, ref info))
+ {
+ //基于显示器信息设置窗口尺寸位置
+ pos.X = info.rcMonitor.Left;
+ pos.Y = info.rcMonitor.Top;
+ pos.Width = info.rcMonitor.Right - info.rcMonitor.Left;
+ pos.Height = info.rcMonitor.Bottom - info.rcMonitor.Top;
+ pos.Flags &= ~(InteropValues.WindowPositionFlags.SWP_NOSIZE | InteropValues.WindowPositionFlags.SWP_NOMOVE |
+ InteropValues.WindowPositionFlags.SWP_NOREDRAW);
+ pos.Flags |= InteropValues.WindowPositionFlags.SWP_NOCOPYBITS;
+
+ if (rect == info.rcMonitor)
+ {
+ var hwndSource = HwndSource.FromHwnd(hwnd);
+ if (hwndSource?.RootVisual is Window window)
+ {
+ //确保窗口的 WPF 属性与 Win32 位置一致,防止有逗比全屏后改 WPF 的属性,发生一些诡异的行为
+ //下面这样做其实不太好,会再次触发 WM_WINDOWPOSCHANGING 来着.....但是又没有其他时机了
+ // WM_WINDOWPOSCHANGED 不能用
+ //(例如:在进入全屏后,修改 Left 属性,会进入 WM_WINDOWPOSCHANGING,然后在这里将消息里的结构体中的 Left 改回,
+ // 使对 Left 的修改无效,那么将不会进入 WM_WINDOWPOSCHANGED,窗口尺寸正常,但窗口的 Left 属性值错误。)
+ var logicalPos =
+ hwndSource.CompositionTarget.TransformFromDevice.Transform(
+ new Point(pos.X, pos.Y));
+ var logicalSize =
+ hwndSource.CompositionTarget.TransformFromDevice.Transform(
+ new Point(pos.Width, pos.Height));
+ window.Left = logicalPos.X;
+ window.Top = logicalPos.Y;
+ window.Width = logicalSize.X;
+ window.Height = logicalSize.Y;
+ }
+ }
+
+ //将修改后的结构体拷贝回去
+ Marshal.StructureToPtr(pos, lParam, false);
+ }
+ }
+ }
+ catch
+ {
+ // 这里也不需要日志啥的,只是为了防止上面有逗比逻辑,在消息循环里面炸了
+ }
+ }
+
+ return IntPtr.Zero;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
index 31351071..01174bb7 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
@@ -8,290 +8,289 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+[SuppressMessage("ReSharper", "ArrangeRedundantParentheses")]
+[SuppressMessage("ReSharper", "IntVariableOverflowInUncheckedContext")]
+internal static class IconHelper
{
- [SuppressMessage("ReSharper", "ArrangeRedundantParentheses")]
- [SuppressMessage("ReSharper", "IntVariableOverflowInUncheckedContext")]
- internal static class IconHelper
+ private static Size SmallIconSize;
+
+ private static Size IconSize;
+
+ private static int SystemBitDepth;
+
+ [SecurityCritical, SecuritySafeCritical]
+ public static void GetIconHandlesFromImageSource(ImageSource image, out IconHandle largeIconHandle, out IconHandle smallIconHandle)
{
- private static Size SmallIconSize;
+ EnsureSystemMetrics();
+ largeIconHandle = CreateIconHandleFromImageSource(image, IconSize);
+ smallIconHandle = CreateIconHandleFromImageSource(image, SmallIconSize);
+ }
- private static Size IconSize;
+ [SecurityCritical]
+ public static IconHandle CreateIconHandleFromImageSource(ImageSource image, Size size)
+ {
+ EnsureSystemMetrics();
- private static int SystemBitDepth;
+ var asGoodAsItGets = false;
- [SecurityCritical, SecuritySafeCritical]
- public static void GetIconHandlesFromImageSource(ImageSource image, out IconHandle largeIconHandle, out IconHandle smallIconHandle)
+ var bf = image as BitmapFrame;
+ if (bf?.Decoder?.Frames != null)
{
- EnsureSystemMetrics();
- largeIconHandle = CreateIconHandleFromImageSource(image, IconSize);
- smallIconHandle = CreateIconHandleFromImageSource(image, SmallIconSize);
+ bf = GetBestMatch(bf.Decoder.Frames, size);
+
+ asGoodAsItGets = bf.Decoder is IconBitmapDecoder || bf.PixelWidth == (int) size.Width && bf.PixelHeight == (int) size.Height;
+
+ image = bf;
}
- [SecurityCritical]
- public static IconHandle CreateIconHandleFromImageSource(ImageSource image, Size size)
+ if (!asGoodAsItGets)
{
- EnsureSystemMetrics();
-
- var asGoodAsItGets = false;
-
- var bf = image as BitmapFrame;
- if (bf?.Decoder?.Frames != null)
- {
- bf = GetBestMatch(bf.Decoder.Frames, size);
-
- asGoodAsItGets = bf.Decoder is IconBitmapDecoder || bf.PixelWidth == (int) size.Width && bf.PixelHeight == (int) size.Height;
-
- image = bf;
- }
-
- if (!asGoodAsItGets)
- {
- bf = BitmapFrame.Create(GenerateBitmapSource(image, size));
- }
-
- return CreateIconHandleFromBitmapFrame(bf);
+ bf = BitmapFrame.Create(GenerateBitmapSource(image, size));
}
- [SecurityCritical]
- private static IconHandle CreateIconHandleFromBitmapFrame(BitmapFrame sourceBitmapFrame)
+ return CreateIconHandleFromBitmapFrame(bf);
+ }
+
+ [SecurityCritical]
+ private static IconHandle CreateIconHandleFromBitmapFrame(BitmapFrame sourceBitmapFrame)
+ {
+ BitmapSource bitmapSource = sourceBitmapFrame;
+
+ if (bitmapSource.Format != PixelFormats.Bgra32 && bitmapSource.Format != PixelFormats.Pbgra32)
{
- BitmapSource bitmapSource = sourceBitmapFrame;
-
- if (bitmapSource.Format != PixelFormats.Bgra32 && bitmapSource.Format != PixelFormats.Pbgra32)
- {
- bitmapSource = new FormatConvertedBitmap(bitmapSource, PixelFormats.Bgra32, null, 0.0);
- }
-
- var w = bitmapSource.PixelWidth;
- var h = bitmapSource.PixelHeight;
- var bpp = bitmapSource.Format.BitsPerPixel;
- var stride = (bpp * w + 31) / 32 * 4;
- var sizeCopyPixels = stride * h;
- var xor = new byte[sizeCopyPixels];
- bitmapSource.CopyPixels(xor, stride, 0);
-
- return CreateIconCursor(xor, w, h, 0, 0, true);
+ bitmapSource = new FormatConvertedBitmap(bitmapSource, PixelFormats.Bgra32, null, 0.0);
}
- [SecurityCritical]
- internal static IconHandle CreateIconCursor(byte[] colorArray, int width, int height, int xHotspot, int yHotspot, bool isIcon)
+ var w = bitmapSource.PixelWidth;
+ var h = bitmapSource.PixelHeight;
+ var bpp = bitmapSource.Format.BitsPerPixel;
+ var stride = (bpp * w + 31) / 32 * 4;
+ var sizeCopyPixels = stride * h;
+ var xor = new byte[sizeCopyPixels];
+ bitmapSource.CopyPixels(xor, stride, 0);
+
+ return CreateIconCursor(xor, w, h, 0, 0, true);
+ }
+
+ [SecurityCritical]
+ internal static IconHandle CreateIconCursor(byte[] colorArray, int width, int height, int xHotspot, int yHotspot, bool isIcon)
+ {
+ BitmapHandle colorBitmap = null;
+ BitmapHandle maskBitmap = null;
+
+ try
{
- BitmapHandle colorBitmap = null;
- BitmapHandle maskBitmap = null;
-
- try
+ var bi = new InteropValues.BITMAPINFO(width, -height, 32)
{
- var bi = new InteropValues.BITMAPINFO(width, -height, 32)
- {
- biCompression = InteropValues.BI_RGB
- };
+ biCompression = InteropValues.BI_RGB
+ };
- var bits = IntPtr.Zero;
- colorBitmap = InteropMethods.CreateDIBSection(new HandleRef(null, IntPtr.Zero), ref bi, InteropValues.DIB_RGB_COLORS, ref bits, null, 0);
+ var bits = IntPtr.Zero;
+ colorBitmap = InteropMethods.CreateDIBSection(new HandleRef(null, IntPtr.Zero), ref bi, InteropValues.DIB_RGB_COLORS, ref bits, null, 0);
- if (colorBitmap.IsInvalid || bits == IntPtr.Zero)
- {
- return IconHandle.GetInvalidIcon();
- }
-
- Marshal.Copy(colorArray, 0, bits, colorArray.Length);
- var maskArray = GenerateMaskArray(width, height, colorArray);
-
- maskBitmap = InteropMethods.CreateBitmap(width, height, 1, 1, maskArray);
- if (maskBitmap.IsInvalid)
- {
- return IconHandle.GetInvalidIcon();
- }
-
- var iconInfo = new InteropValues.ICONINFO
- {
- fIcon = isIcon,
- xHotspot = xHotspot,
- yHotspot = yHotspot,
- hbmMask = maskBitmap,
- hbmColor = colorBitmap
- };
-
- return InteropMethods.CreateIconIndirect(iconInfo);
+ if (colorBitmap.IsInvalid || bits == IntPtr.Zero)
+ {
+ return IconHandle.GetInvalidIcon();
}
- finally
+
+ Marshal.Copy(colorArray, 0, bits, colorArray.Length);
+ var maskArray = GenerateMaskArray(width, height, colorArray);
+
+ maskBitmap = InteropMethods.CreateBitmap(width, height, 1, 1, maskArray);
+ if (maskBitmap.IsInvalid)
{
- colorBitmap?.Dispose();
- maskBitmap?.Dispose();
+ return IconHandle.GetInvalidIcon();
+ }
+
+ var iconInfo = new InteropValues.ICONINFO
+ {
+ fIcon = isIcon,
+ xHotspot = xHotspot,
+ yHotspot = yHotspot,
+ hbmMask = maskBitmap,
+ hbmColor = colorBitmap
+ };
+
+ return InteropMethods.CreateIconIndirect(iconInfo);
+ }
+ finally
+ {
+ colorBitmap?.Dispose();
+ maskBitmap?.Dispose();
+ }
+ }
+
+ private static byte[] GenerateMaskArray(int width, int height, byte[] colorArray)
+ {
+ var nCount = width * height;
+ var bytesPerScanLine = AlignToBytes(width, 2) / 8;
+ var bitsMask = new byte[bytesPerScanLine * height];
+
+ for (var i = 0; i < nCount; i++)
+ {
+ var hPos = i % width;
+ var vPos = i / width;
+ var byteIndex = hPos / 8;
+ var offsetBit = (byte) (0x80 >> (hPos % 8));
+
+ if (colorArray[i * 4 + 3] == 0x00)
+ {
+ bitsMask[byteIndex + bytesPerScanLine * vPos] |= offsetBit;
+ }
+ else
+ {
+ bitsMask[byteIndex + bytesPerScanLine * vPos] &= (byte) ~offsetBit;
+ }
+
+ if (hPos == width - 1 && width == 8)
+ {
+ bitsMask[1 + bytesPerScanLine * vPos] = 0xff;
}
}
- private static byte[] GenerateMaskArray(int width, int height, byte[] colorArray)
+ return bitsMask;
+ }
+
+ internal static int AlignToBytes(double original, int nBytesCount)
+ {
+ var nBitsCount = 8 << (nBytesCount - 1);
+ return ((int) Math.Ceiling(original) + (nBitsCount - 1)) / nBitsCount * nBitsCount;
+ }
+
+ private static BitmapSource GenerateBitmapSource(ImageSource img, Size renderSize)
+ {
+ var drawingDimensions = new Rect(0, 0, renderSize.Width, renderSize.Height);
+
+ var renderRatio = renderSize.Width / renderSize.Height;
+ var aspectRatio = img.Width / img.Height;
+
+ if (img.Width <= renderSize.Width && img.Height <= renderSize.Height)
{
- var nCount = width * height;
- var bytesPerScanLine = AlignToBytes(width, 2) / 8;
- var bitsMask = new byte[bytesPerScanLine * height];
-
- for (var i = 0; i < nCount; i++)
- {
- var hPos = i % width;
- var vPos = i / width;
- var byteIndex = hPos / 8;
- var offsetBit = (byte) (0x80 >> (hPos % 8));
-
- if (colorArray[i * 4 + 3] == 0x00)
- {
- bitsMask[byteIndex + bytesPerScanLine * vPos] |= offsetBit;
- }
- else
- {
- bitsMask[byteIndex + bytesPerScanLine * vPos] &= (byte) ~offsetBit;
- }
-
- if (hPos == width - 1 && width == 8)
- {
- bitsMask[1 + bytesPerScanLine * vPos] = 0xff;
- }
- }
-
- return bitsMask;
+ drawingDimensions = new Rect((renderSize.Width - img.Width) / 2, (renderSize.Height - img.Height) / 2, img.Width, img.Height);
+ }
+ else if (renderRatio > aspectRatio)
+ {
+ var scaledRenderWidth = (img.Width / img.Height) * renderSize.Width;
+ drawingDimensions = new Rect((renderSize.Width - scaledRenderWidth) / 2, 0, scaledRenderWidth, renderSize.Height);
+ }
+ else if (renderRatio < aspectRatio)
+ {
+ var scaledRenderHeight = img.Height / img.Width * renderSize.Height;
+ drawingDimensions = new Rect(0, (renderSize.Height - scaledRenderHeight) / 2, renderSize.Width, scaledRenderHeight);
}
- internal static int AlignToBytes(double original, int nBytesCount)
+ var dv = new DrawingVisual();
+ var dc = dv.RenderOpen();
+ dc.DrawImage(img, drawingDimensions);
+ dc.Close();
+
+ var bmp = new RenderTargetBitmap((int) renderSize.Width, (int) renderSize.Height, 96, 96, PixelFormats.Pbgra32);
+ bmp.Render(dv);
+
+ return bmp;
+ }
+
+ private static BitmapFrame GetBestMatch(ReadOnlyCollection frames, Size size)
+ {
+ var bestScore = int.MaxValue;
+ var bestBpp = 0;
+ var bestIndex = 0;
+
+ var isBitmapIconDecoder = frames[0].Decoder is IconBitmapDecoder;
+
+ for (var i = 0; i < frames.Count && bestScore != 0; ++i)
{
- var nBitsCount = 8 << (nBytesCount - 1);
- return ((int) Math.Ceiling(original) + (nBitsCount - 1)) / nBitsCount * nBitsCount;
- }
+ var currentIconBitDepth = isBitmapIconDecoder ? frames[i].Thumbnail.Format.BitsPerPixel : frames[i].Format.BitsPerPixel;
- private static BitmapSource GenerateBitmapSource(ImageSource img, Size renderSize)
- {
- var drawingDimensions = new Rect(0, 0, renderSize.Width, renderSize.Height);
-
- var renderRatio = renderSize.Width / renderSize.Height;
- var aspectRatio = img.Width / img.Height;
-
- if (img.Width <= renderSize.Width && img.Height <= renderSize.Height)
+ if (currentIconBitDepth == 0)
{
- drawingDimensions = new Rect((renderSize.Width - img.Width) / 2, (renderSize.Height - img.Height) / 2, img.Width, img.Height);
- }
- else if (renderRatio > aspectRatio)
- {
- var scaledRenderWidth = (img.Width / img.Height) * renderSize.Width;
- drawingDimensions = new Rect((renderSize.Width - scaledRenderWidth) / 2, 0, scaledRenderWidth, renderSize.Height);
- }
- else if (renderRatio < aspectRatio)
- {
- var scaledRenderHeight = img.Height / img.Width * renderSize.Height;
- drawingDimensions = new Rect(0, (renderSize.Height - scaledRenderHeight) / 2, renderSize.Width, scaledRenderHeight);
+ currentIconBitDepth = 8;
}
- var dv = new DrawingVisual();
- var dc = dv.RenderOpen();
- dc.DrawImage(img, drawingDimensions);
- dc.Close();
-
- var bmp = new RenderTargetBitmap((int) renderSize.Width, (int) renderSize.Height, 96, 96, PixelFormats.Pbgra32);
- bmp.Render(dv);
-
- return bmp;
- }
-
- private static BitmapFrame GetBestMatch(ReadOnlyCollection frames, Size size)
- {
- var bestScore = int.MaxValue;
- var bestBpp = 0;
- var bestIndex = 0;
-
- var isBitmapIconDecoder = frames[0].Decoder is IconBitmapDecoder;
-
- for (var i = 0; i < frames.Count && bestScore != 0; ++i)
+ var score = MatchImage(frames[i], size, currentIconBitDepth);
+ if (score < bestScore)
{
- var currentIconBitDepth = isBitmapIconDecoder ? frames[i].Thumbnail.Format.BitsPerPixel : frames[i].Format.BitsPerPixel;
-
- if (currentIconBitDepth == 0)
- {
- currentIconBitDepth = 8;
- }
-
- var score = MatchImage(frames[i], size, currentIconBitDepth);
- if (score < bestScore)
+ bestIndex = i;
+ bestBpp = currentIconBitDepth;
+ bestScore = score;
+ }
+ else if (score == bestScore)
+ {
+ if (bestBpp < currentIconBitDepth)
{
bestIndex = i;
bestBpp = currentIconBitDepth;
- bestScore = score;
- }
- else if (score == bestScore)
- {
- if (bestBpp < currentIconBitDepth)
- {
- bestIndex = i;
- bestBpp = currentIconBitDepth;
- }
}
}
-
- return frames[bestIndex];
}
- private static int MatchImage(BitmapFrame frame, Size size, int bpp)
- {
- var score = 2 * MyAbs(bpp, SystemBitDepth, false) +
- MyAbs(frame.PixelWidth, (int) size.Width, true) +
- MyAbs(frame.PixelHeight, (int) size.Height, true);
+ return frames[bestIndex];
+ }
- return score;
+ private static int MatchImage(BitmapFrame frame, Size size, int bpp)
+ {
+ var score = 2 * MyAbs(bpp, SystemBitDepth, false) +
+ MyAbs(frame.PixelWidth, (int) size.Width, true) +
+ MyAbs(frame.PixelHeight, (int) size.Height, true);
+
+ return score;
+ }
+
+ private static int MyAbs(int valueHave, int valueWant, bool fPunish)
+ {
+ var diff = (valueHave - valueWant);
+
+ if (diff < 0)
+ {
+ diff = (fPunish ? -2 : -1) * diff;
}
- private static int MyAbs(int valueHave, int valueWant, bool fPunish)
- {
- var diff = (valueHave - valueWant);
+ return diff;
+ }
- if (diff < 0)
+ [SecurityCritical, SecuritySafeCritical]
+ private static void EnsureSystemMetrics()
+ {
+ if (SystemBitDepth == 0)
+ {
+ var hdcDesktop = new HandleRef(null, InteropMethods.GetDC(new HandleRef()));
+ try
{
- diff = (fPunish ? -2 : -1) * diff;
+ var sysBitDepth = InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.BITSPIXEL);
+ sysBitDepth *= InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.PLANES);
+
+ if (sysBitDepth == 8)
+ {
+ sysBitDepth = 4;
+ }
+
+ var cxSmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXSMICON);
+ var cySmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYSMICON);
+ var cxIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXICON);
+ var cyIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYICON);
+
+ SmallIconSize = new Size(cxSmallIcon, cySmallIcon);
+ IconSize = new Size(cxIcon, cyIcon);
+ SystemBitDepth = sysBitDepth;
}
-
- return diff;
- }
-
- [SecurityCritical, SecuritySafeCritical]
- private static void EnsureSystemMetrics()
- {
- if (SystemBitDepth == 0)
+ finally
{
- var hdcDesktop = new HandleRef(null, InteropMethods.GetDC(new HandleRef()));
- try
- {
- var sysBitDepth = InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.BITSPIXEL);
- sysBitDepth *= InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.PLANES);
-
- if (sysBitDepth == 8)
- {
- sysBitDepth = 4;
- }
-
- var cxSmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXSMICON);
- var cySmallIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYSMICON);
- var cxIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CXICON);
- var cyIcon = InteropMethods.GetSystemMetrics(InteropValues.SM.CYICON);
-
- SmallIconSize = new Size(cxSmallIcon, cySmallIcon);
- IconSize = new Size(cxIcon, cyIcon);
- SystemBitDepth = sysBitDepth;
- }
- finally
- {
- InteropMethods.ReleaseDC(new HandleRef(), hdcDesktop);
- }
+ InteropMethods.ReleaseDC(new HandleRef(), hdcDesktop);
}
}
+ }
- [SecurityCritical, SecuritySafeCritical]
- public static void GetDefaultIconHandles(out IconHandle largeIconHandle, out IconHandle smallIconHandle)
- {
- largeIconHandle = null;
- smallIconHandle = null;
+ [SecurityCritical, SecuritySafeCritical]
+ public static void GetDefaultIconHandles(out IconHandle largeIconHandle, out IconHandle smallIconHandle)
+ {
+ largeIconHandle = null;
+ smallIconHandle = null;
- SecurityHelper.DemandUIWindowPermission();
+ SecurityHelper.DemandUIWindowPermission();
- var iconModuleFile = InteropMethods.GetModuleFileName(new HandleRef());
- InteropMethods.ExtractIconEx(iconModuleFile, 0, out largeIconHandle, out smallIconHandle, 1);
- }
+ var iconModuleFile = InteropMethods.GetModuleFileName(new HandleRef());
+ InteropMethods.ExtractIconEx(iconModuleFile, 0, out largeIconHandle, out smallIconHandle, 1);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/InputClickHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/InputClickHelper.cs
index 9672d8ae..2512a3ef 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/InputClickHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/InputClickHelper.cs
@@ -2,148 +2,147 @@
using System.Windows;
using System.Windows.Input;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 输入层点击帮助类
+///
+public static class InputClickHelper
{
+ private static readonly DependencyProperty InputInfoProperty = DependencyProperty.RegisterAttached(
+ "InputInfo", typeof(InputInfo), typeof(InputClickHelper), new PropertyMetadata(default(InputInfo)));
+
+ private static void SetInputInfo(DependencyObject element, InputInfo value) => element.SetValue(InputInfoProperty, value);
+
+ private static InputInfo GetInputInfo(DependencyObject element) => (InputInfo) element.GetValue(InputInfoProperty);
+
///
- /// 输入层点击帮助类
+ /// 将 MouseDown MouseMove MouseUp 封装为点击事件
///
- public static class InputClickHelper
+ /// 要被附加的元素
+ /// 点击的事件
+ /// 因为拖动而结束点击时触发
+ public static void AttachMouseDownMoveUpToClick(UIElement element, EventHandler clickEventHandler,
+ EventHandler dragStarted = null)
{
- private static readonly DependencyProperty InputInfoProperty = DependencyProperty.RegisterAttached(
- "InputInfo", typeof(InputInfo), typeof(InputClickHelper), new PropertyMetadata(default(InputInfo)));
+ var inputInfo = GetOrCreateInputInfo(element);
+ inputInfo.ClickEventHandler += clickEventHandler;
- private static void SetInputInfo(DependencyObject element, InputInfo value) => element.SetValue(InputInfoProperty, value);
+ inputInfo.DragStarted += dragStarted;
- private static InputInfo GetInputInfo(DependencyObject element) => (InputInfo) element.GetValue(InputInfoProperty);
+ element.MouseDown -= Element_MouseDown;
+ element.MouseDown += Element_MouseDown;
+ element.MouseMove -= Element_MouseMove;
+ element.MouseMove += Element_MouseMove;
+ element.MouseUp -= Element_MouseUp;
+ element.MouseUp += Element_MouseUp;
+ element.LostMouseCapture -= Element_LostMouseCapture;
+ element.LostMouseCapture += Element_LostMouseCapture;
+ }
- ///
- /// 将 MouseDown MouseMove MouseUp 封装为点击事件
- ///
- /// 要被附加的元素
- /// 点击的事件
- /// 因为拖动而结束点击时触发
- public static void AttachMouseDownMoveUpToClick(UIElement element, EventHandler clickEventHandler,
- EventHandler dragStarted = null)
+ ///
+ /// 去掉对 的点击时间的监听
+ ///
+ ///
+ /// 点击的事件
+ /// 因为拖动而结束点击时触发的事件
+ public static void DetachMouseDownMoveUpToClick(UIElement element, EventHandler clickEventHandler,
+ EventHandler dragStarted = null)
+ {
+ var inputInfo = GetInputInfo(element);
+ if (inputInfo == null) return;
+
+ inputInfo.ClickEventHandler -= clickEventHandler;
+ inputInfo.DragStarted -= dragStarted;
+
+ if (inputInfo.IsEmpty())
{
- var inputInfo = GetOrCreateInputInfo(element);
- inputInfo.ClickEventHandler += clickEventHandler;
-
- inputInfo.DragStarted += dragStarted;
-
+ element.ClearValue(InputInfoProperty);
element.MouseDown -= Element_MouseDown;
- element.MouseDown += Element_MouseDown;
element.MouseMove -= Element_MouseMove;
- element.MouseMove += Element_MouseMove;
element.MouseUp -= Element_MouseUp;
- element.MouseUp += Element_MouseUp;
element.LostMouseCapture -= Element_LostMouseCapture;
- element.LostMouseCapture += Element_LostMouseCapture;
- }
-
- ///
- /// 去掉对 的点击时间的监听
- ///
- ///
- /// 点击的事件
- /// 因为拖动而结束点击时触发的事件
- public static void DetachMouseDownMoveUpToClick(UIElement element, EventHandler clickEventHandler,
- EventHandler dragStarted = null)
- {
- var inputInfo = GetInputInfo(element);
- if (inputInfo == null) return;
-
- inputInfo.ClickEventHandler -= clickEventHandler;
- inputInfo.DragStarted -= dragStarted;
-
- if (inputInfo.IsEmpty())
- {
- element.ClearValue(InputInfoProperty);
- element.MouseDown -= Element_MouseDown;
- element.MouseMove -= Element_MouseMove;
- element.MouseUp -= Element_MouseUp;
- element.LostMouseCapture -= Element_LostMouseCapture;
- }
- }
-
- private static void Element_LostMouseCapture(object sender, MouseEventArgs e)
- {
- var element = (UIElement) sender;
- GetInputInfo(element)?.LostCapture();
- }
-
- private static void Element_MouseUp(object sender, MouseButtonEventArgs e)
- {
- var element = (UIElement) sender;
- GetInputInfo(element)?.Up(e.GetPosition(element));
- }
-
- private static void Element_MouseMove(object sender, MouseEventArgs e)
- {
- var element = (UIElement) sender;
- GetInputInfo(element)?.Move(e.GetPosition(element));
- }
-
- private static void Element_MouseDown(object sender, MouseButtonEventArgs e)
- {
- var element = (UIElement) sender;
- GetInputInfo(element)?.Down(e.GetPosition(element));
- }
-
- private static InputInfo GetOrCreateInputInfo(UIElement element)
- {
- var inputInfo = GetInputInfo(element);
- if (inputInfo == null)
- {
- inputInfo = new InputInfo();
- SetInputInfo(element, inputInfo);
- }
-
- return inputInfo;
- }
-
- private class InputInfo
- {
- private const double ToleranceSquared = 0.01;
-
- private Point _downedPosition;
-
- private bool _isClick;
-
- public event EventHandler ClickEventHandler;
-
- public event EventHandler DragStarted;
-
- public void Down(Point position)
- {
- _downedPosition = position;
- _isClick = true;
- }
-
- public void Move(Point position)
- {
- if (!_isClick) return;
-
- if ((position - _downedPosition).LengthSquared > ToleranceSquared)
- {
- _isClick = false;
- DragStarted?.Invoke(null, EventArgs.Empty);
- }
- }
-
- public void Up(Point position)
- {
- _isClick = _isClick && (position - _downedPosition).LengthSquared <= ToleranceSquared;
-
- if (!_isClick) return;
-
- ClickEventHandler?.Invoke(null, EventArgs.Empty);
-
- _isClick = false;
- }
-
- public void LostCapture() => _isClick = false;
-
- public bool IsEmpty() => ClickEventHandler is null && DragStarted is null;
}
}
+
+ private static void Element_LostMouseCapture(object sender, MouseEventArgs e)
+ {
+ var element = (UIElement) sender;
+ GetInputInfo(element)?.LostCapture();
+ }
+
+ private static void Element_MouseUp(object sender, MouseButtonEventArgs e)
+ {
+ var element = (UIElement) sender;
+ GetInputInfo(element)?.Up(e.GetPosition(element));
+ }
+
+ private static void Element_MouseMove(object sender, MouseEventArgs e)
+ {
+ var element = (UIElement) sender;
+ GetInputInfo(element)?.Move(e.GetPosition(element));
+ }
+
+ private static void Element_MouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var element = (UIElement) sender;
+ GetInputInfo(element)?.Down(e.GetPosition(element));
+ }
+
+ private static InputInfo GetOrCreateInputInfo(UIElement element)
+ {
+ var inputInfo = GetInputInfo(element);
+ if (inputInfo == null)
+ {
+ inputInfo = new InputInfo();
+ SetInputInfo(element, inputInfo);
+ }
+
+ return inputInfo;
+ }
+
+ private class InputInfo
+ {
+ private const double ToleranceSquared = 0.01;
+
+ private Point _downedPosition;
+
+ private bool _isClick;
+
+ public event EventHandler ClickEventHandler;
+
+ public event EventHandler DragStarted;
+
+ public void Down(Point position)
+ {
+ _downedPosition = position;
+ _isClick = true;
+ }
+
+ public void Move(Point position)
+ {
+ if (!_isClick) return;
+
+ if ((position - _downedPosition).LengthSquared > ToleranceSquared)
+ {
+ _isClick = false;
+ DragStarted?.Invoke(null, EventArgs.Empty);
+ }
+ }
+
+ public void Up(Point position)
+ {
+ _isClick = _isClick && (position - _downedPosition).LengthSquared <= ToleranceSquared;
+
+ if (!_isClick) return;
+
+ ClickEventHandler?.Invoke(null, EventArgs.Empty);
+
+ _isClick = false;
+ }
+
+ public void LostCapture() => _isClick = false;
+
+ public bool IsEmpty() => ClickEventHandler is null && DragStarted is null;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ResourceHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ResourceHelper.cs
index be63404b..90b59ece 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ResourceHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ResourceHelper.cs
@@ -3,83 +3,82 @@ using System.Reflection;
using System.Windows;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 资源帮助类
+///
+public class ResourceHelper
{
+ private static ResourceDictionary _theme;
+
///
- /// 资源帮助类
+ /// 获取资源
///
- public class ResourceHelper
+ ///
+ ///
+ public static T GetResource(string key)
{
- private static ResourceDictionary _theme;
-
- ///
- /// 获取资源
- ///
- ///
- ///
- public static T GetResource(string key)
+ if (Application.Current.TryFindResource(key) is T resource)
{
- if (Application.Current.TryFindResource(key) is T resource)
- {
- return resource;
- }
-
- return default;
+ return resource;
}
- internal static T GetResourceInternal(string key)
- {
- if (GetTheme()[key] is T resource)
- {
- return resource;
- }
+ return default;
+ }
- return default;
+ internal static T GetResourceInternal(string key)
+ {
+ if (GetTheme()[key] is T resource)
+ {
+ return resource;
}
- ///
- /// 获取皮肤
- ///
- public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin)
+ return default;
+ }
+
+ ///
+ /// 获取皮肤
+ ///
+ public static ResourceDictionary GetSkin(Assembly assembly, string themePath, SkinType skin)
+ {
+ try
{
- try
+ var uri = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{skin}.xaml");
+ return new ResourceDictionary
{
- var uri = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{skin}.xaml");
- return new ResourceDictionary
- {
- Source = uri
- };
- }
- catch
- {
- return new ResourceDictionary
- {
- Source = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{SkinType.Default}.xaml")
- };
- }
+ Source = uri
+ };
}
-
- ///
- /// get HandyControl skin
- ///
- ///
- ///
- public static ResourceDictionary GetSkin(SkinType skin) => new()
+ catch
{
- Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
- };
-
- ///
- /// get HandyControl theme
- ///
- public static ResourceDictionary GetTheme() => _theme ??= GetStandaloneTheme();
-
- public static ResourceDictionary GetStandaloneTheme()
- {
- return new()
+ return new ResourceDictionary
{
- Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
+ Source = new Uri($"pack://application:,,,/{assembly.GetName().Name};component/{themePath}/Skin{SkinType.Default}.xaml")
};
}
}
+
+ ///
+ /// get HandyControl skin
+ ///
+ ///
+ ///
+ public static ResourceDictionary GetSkin(SkinType skin) => new()
+ {
+ Source = new Uri($"pack://application:,,,/HandyControl;component/Themes/Skin{skin}.xaml")
+ };
+
+ ///
+ /// get HandyControl theme
+ ///
+ public static ResourceDictionary GetTheme() => _theme ??= GetStandaloneTheme();
+
+ public static ResourceDictionary GetStandaloneTheme()
+ {
+ return new()
+ {
+ Source = new Uri("pack://application:,,,/HandyControl;component/Themes/Theme.xaml")
+ };
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
index fc7ae801..442ec6ce 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
@@ -4,82 +4,81 @@ using System.Runtime.InteropServices;
using System.Windows;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+internal class ScreenHelper
{
- internal class ScreenHelper
+ internal static void FindMaximumSingleMonitorRectangle(Rect windowRect, out Rect screenSubRect, out Rect monitorRect)
{
- internal static void FindMaximumSingleMonitorRectangle(Rect windowRect, out Rect screenSubRect, out Rect monitorRect)
- {
- var windowRect2 = new InteropValues.RECT(windowRect);
- FindMaximumSingleMonitorRectangle(windowRect2, out var rect, out var rect2);
- screenSubRect = new Rect(rect.Position, rect.Size);
- monitorRect = new Rect(rect2.Position, rect2.Size);
- }
+ var windowRect2 = new InteropValues.RECT(windowRect);
+ FindMaximumSingleMonitorRectangle(windowRect2, out var rect, out var rect2);
+ screenSubRect = new Rect(rect.Position, rect.Size);
+ monitorRect = new Rect(rect2.Position, rect2.Size);
+ }
- private static void FindMaximumSingleMonitorRectangle(InteropValues.RECT windowRect, out InteropValues.RECT screenSubRect, out InteropValues.RECT monitorRect)
- {
- var rects = new List();
- InteropMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero,
- delegate (IntPtr hMonitor, IntPtr hdcMonitor, ref InteropValues.RECT rect, IntPtr lpData)
- {
- var monitorInfo = default(InteropValues.MONITORINFO);
- monitorInfo.cbSize = (uint) Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
- InteropMethods.GetMonitorInfo(hMonitor, ref monitorInfo);
- rects.Add(monitorInfo.rcWork);
- return true;
- }, IntPtr.Zero);
-
- var num = 0L;
-
- screenSubRect = new InteropValues.RECT
+ private static void FindMaximumSingleMonitorRectangle(InteropValues.RECT windowRect, out InteropValues.RECT screenSubRect, out InteropValues.RECT monitorRect)
+ {
+ var rects = new List();
+ InteropMethods.EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero,
+ delegate (IntPtr hMonitor, IntPtr hdcMonitor, ref InteropValues.RECT rect, IntPtr lpData)
{
- Left = 0,
- Right = 0,
- Top = 0,
- Bottom = 0
- };
-
- monitorRect = new InteropValues.RECT
- {
- Left = 0,
- Right = 0,
- Top = 0,
- Bottom = 0
- };
-
- foreach (var current in rects)
- {
- var rect = current;
- InteropMethods.IntersectRect(out var rECT2, ref rect, ref windowRect);
- var num2 = (long) (rECT2.Width * rECT2.Height);
- if (num2 > num)
- {
- screenSubRect = rECT2;
- monitorRect = current;
- num = num2;
- }
- }
- }
-
- internal static void FindMonitorRectsFromPoint(Point point, out Rect monitorRect, out Rect workAreaRect)
- {
- var intPtr = InteropMethods.MonitorFromPoint(new InteropValues.POINT
- {
- X = (int) point.X,
- Y = (int) point.Y
- }, 2);
-
- monitorRect = new Rect(0.0, 0.0, 0.0, 0.0);
- workAreaRect = new Rect(0.0, 0.0, 0.0, 0.0);
-
- if (intPtr != IntPtr.Zero)
- {
- InteropValues.MONITORINFO monitorInfo = default;
+ var monitorInfo = default(InteropValues.MONITORINFO);
monitorInfo.cbSize = (uint) Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
- InteropMethods.GetMonitorInfo(intPtr, ref monitorInfo);
- monitorRect = new Rect(monitorInfo.rcMonitor.Position, monitorInfo.rcMonitor.Size);
- workAreaRect = new Rect(monitorInfo.rcWork.Position, monitorInfo.rcWork.Size);
+ InteropMethods.GetMonitorInfo(hMonitor, ref monitorInfo);
+ rects.Add(monitorInfo.rcWork);
+ return true;
+ }, IntPtr.Zero);
+
+ var num = 0L;
+
+ screenSubRect = new InteropValues.RECT
+ {
+ Left = 0,
+ Right = 0,
+ Top = 0,
+ Bottom = 0
+ };
+
+ monitorRect = new InteropValues.RECT
+ {
+ Left = 0,
+ Right = 0,
+ Top = 0,
+ Bottom = 0
+ };
+
+ foreach (var current in rects)
+ {
+ var rect = current;
+ InteropMethods.IntersectRect(out var rECT2, ref rect, ref windowRect);
+ var num2 = (long) (rECT2.Width * rECT2.Height);
+ if (num2 > num)
+ {
+ screenSubRect = rECT2;
+ monitorRect = current;
+ num = num2;
}
}
}
+
+ internal static void FindMonitorRectsFromPoint(Point point, out Rect monitorRect, out Rect workAreaRect)
+ {
+ var intPtr = InteropMethods.MonitorFromPoint(new InteropValues.POINT
+ {
+ X = (int) point.X,
+ Y = (int) point.Y
+ }, 2);
+
+ monitorRect = new Rect(0.0, 0.0, 0.0, 0.0);
+ workAreaRect = new Rect(0.0, 0.0, 0.0, 0.0);
+
+ if (intPtr != IntPtr.Zero)
+ {
+ InteropValues.MONITORINFO monitorInfo = default;
+ monitorInfo.cbSize = (uint) Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
+ InteropMethods.GetMonitorInfo(intPtr, ref monitorInfo);
+ monitorRect = new Rect(monitorInfo.rcMonitor.Position, monitorInfo.rcMonitor.Size);
+ workAreaRect = new Rect(monitorInfo.rcWork.Position, monitorInfo.rcWork.Size);
+ }
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/SecurityHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/SecurityHelper.cs
index 1b8deb4d..520d9515 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/SecurityHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/SecurityHelper.cs
@@ -2,18 +2,17 @@
using System.Security;
using System.Security.Permissions;
-namespace HandyControl.Tools
-{
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal class SecurityHelper
- {
- private static UIPermission _allWindowsUIPermission;
+namespace HandyControl.Tools;
- [SecurityCritical]
- internal static void DemandUIWindowPermission()
- {
- _allWindowsUIPermission ??= new UIPermission(UIPermissionWindow.AllWindows);
- _allWindowsUIPermission.Demand();
- }
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+internal class SecurityHelper
+{
+ private static UIPermission _allWindowsUIPermission;
+
+ [SecurityCritical]
+ internal static void DemandUIWindowPermission()
+ {
+ _allWindowsUIPermission ??= new UIPermission(UIPermissionWindow.AllWindows);
+ _allWindowsUIPermission.Demand();
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/SingleOpenHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/SingleOpenHelper.cs
index ebb1c1b1..002adc1c 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/SingleOpenHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/SingleOpenHelper.cs
@@ -3,40 +3,39 @@ using System.Linq;
using System.Windows.Media;
using HandyControl.Controls;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 该类可以为可视化元素提供单开的功能
+///
+public class SingleOpenHelper
{
+ private static readonly Dictionary OpenDic = new();
+
///
- /// 该类可以为可视化元素提供单开的功能
+ /// 根据指定的类型创建实例
///
- public class SingleOpenHelper
+ ///
+ ///
+ public static T CreateControl() where T : Visual, ISingleOpen, new()
{
- private static readonly Dictionary OpenDic = new();
+ var typeStr = typeof(T).FullName;
- ///
- /// 根据指定的类型创建实例
- ///
- ///
- ///
- public static T CreateControl() where T : Visual, ISingleOpen, new()
+ if (string.IsNullOrEmpty(typeStr)) return default;
+
+ var temp = new T();
+ if (!OpenDic.Keys.Contains(typeStr))
{
- var typeStr = typeof(T).FullName;
-
- if (string.IsNullOrEmpty(typeStr)) return default;
-
- var temp = new T();
- if (!OpenDic.Keys.Contains(typeStr))
- {
- OpenDic.Add(typeStr, temp);
- return temp;
- }
- var currentCtl = OpenDic[typeStr];
- if (currentCtl.CanDispose)
- {
- currentCtl.Dispose();
- OpenDic[typeStr] = temp;
- return temp;
- }
- return default;
+ OpenDic.Add(typeStr, temp);
+ return temp;
}
+ var currentCtl = OpenDic[typeStr];
+ if (currentCtl.CanDispose)
+ {
+ currentCtl.Dispose();
+ OpenDic[typeStr] = temp;
+ return temp;
+ }
+ return default;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/SystemHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/SystemHelper.cs
index a2349722..7e65b1a6 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/SystemHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/SystemHelper.cs
@@ -3,27 +3,26 @@ using HandyControl.Data;
using HandyControl.Tools.Interop;
using Microsoft.Win32;
-namespace HandyControl.Tools.Helper
+namespace HandyControl.Tools.Helper;
+
+internal class SystemHelper
{
- internal class SystemHelper
+ public static SystemVersionInfo GetSystemVersionInfo()
{
- public static SystemVersionInfo GetSystemVersionInfo()
- {
- var osv = new InteropValues.RTL_OSVERSIONINFOEX();
- osv.dwOSVersionInfoSize = (uint) Marshal.SizeOf(osv);
- InteropMethods.Gdip.RtlGetVersion(out osv);
- return new SystemVersionInfo((int) osv.dwMajorVersion, (int) osv.dwMinorVersion, (int) osv.dwBuildNumber);
- }
+ var osv = new InteropValues.RTL_OSVERSIONINFOEX();
+ osv.dwOSVersionInfoSize = (uint) Marshal.SizeOf(osv);
+ InteropMethods.Gdip.RtlGetVersion(out osv);
+ return new SystemVersionInfo((int) osv.dwMajorVersion, (int) osv.dwMinorVersion, (int) osv.dwBuildNumber);
+ }
- private const string SkinTypeRegistryKeyName = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
+ private const string SkinTypeRegistryKeyName = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
- private const string SkinTypeRegistryValueName = "AppsUseLightTheme";
+ private const string SkinTypeRegistryValueName = "AppsUseLightTheme";
- public static bool DetermineIfInLightThemeMode()
- {
- var value = Registry.GetValue(SkinTypeRegistryKeyName, SkinTypeRegistryValueName, "0");
+ public static bool DetermineIfInLightThemeMode()
+ {
+ var value = Registry.GetValue(SkinTypeRegistryKeyName, SkinTypeRegistryValueName, "0");
- return value != null && value.ToString() != "0";
- }
+ return value != null && value.ToString() != "0";
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/TextHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/TextHelper.cs
index a1ef12a8..b6e71a0b 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/TextHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/TextHelper.cs
@@ -2,29 +2,28 @@
using System.Windows;
using System.Windows.Media;
-namespace HandyControl.Tools.Helper
+namespace HandyControl.Tools.Helper;
+
+internal class TextHelper
{
- internal class TextHelper
+ public static FormattedText CreateFormattedText(string text, FlowDirection flowDirection, Typeface typeface, double fontSize)
{
- public static FormattedText CreateFormattedText(string text, FlowDirection flowDirection, Typeface typeface, double fontSize)
- {
#if NET40 || NET45 || NET451 || NET452 || NET46 || NET461
- var formattedText = new FormattedText(
- text,
- CultureInfo.CurrentUICulture,
- flowDirection,
- typeface,
- fontSize, Brushes.Black);
+ var formattedText = new FormattedText(
+ text,
+ CultureInfo.CurrentUICulture,
+ flowDirection,
+ typeface,
+ fontSize, Brushes.Black);
#else
- var formattedText = new FormattedText(
- text,
- CultureInfo.CurrentUICulture,
- flowDirection,
- typeface,
- fontSize, Brushes.Black, DpiHelper.DeviceDpiX);
+ var formattedText = new FormattedText(
+ text,
+ CultureInfo.CurrentUICulture,
+ flowDirection,
+ typeface,
+ fontSize, Brushes.Black, DpiHelper.DeviceDpiX);
#endif
- return formattedText;
- }
+ return formattedText;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/TokenizerHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/TokenizerHelper.cs
index 6e06838a..913cab34 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/TokenizerHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/TokenizerHelper.cs
@@ -16,218 +16,217 @@
using System;
using System.Globalization;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+internal class TokenizerHelper
{
- internal class TokenizerHelper
+ private char _quoteChar;
+
+ private char _argSeparator;
+
+ private string _str;
+
+ private int _strLen;
+
+ private int _charIndex;
+
+ private int _currentTokenIndex;
+
+ private int _currentTokenLength;
+
+ public bool FoundSeparator { get; private set; }
+
+ public TokenizerHelper(string str, IFormatProvider formatProvider)
{
- private char _quoteChar;
+ var numberSeparator = GetNumericListSeparator(formatProvider);
+ Initialize(str, '\'', numberSeparator);
+ }
- private char _argSeparator;
+ private void Initialize(string str, char quoteChar, char separator)
+ {
+ _str = str;
+ _strLen = str?.Length ?? 0;
+ _currentTokenIndex = -1;
+ _quoteChar = quoteChar;
+ _argSeparator = separator;
- private string _str;
-
- private int _strLen;
-
- private int _charIndex;
-
- private int _currentTokenIndex;
-
- private int _currentTokenLength;
-
- public bool FoundSeparator { get; private set; }
-
- public TokenizerHelper(string str, IFormatProvider formatProvider)
+ // immediately forward past any whitespace so
+ // NextToken() logic always starts on the first
+ // character of the next token.
+ while (_charIndex < _strLen)
{
- var numberSeparator = GetNumericListSeparator(formatProvider);
- Initialize(str, '\'', numberSeparator);
+ if (!char.IsWhiteSpace(_str, _charIndex))
+ {
+ break;
+ }
+
+ ++_charIndex;
+ }
+ }
+
+ public string GetCurrentToken() =>
+ _currentTokenIndex < 0 ? null : _str.Substring(_currentTokenIndex, _currentTokenLength);
+
+ internal bool NextToken() => NextToken(false);
+
+ public bool NextToken(bool allowQuotedToken) => NextToken(allowQuotedToken, _argSeparator);
+
+ public bool NextToken(bool allowQuotedToken, char separator)
+ {
+ _currentTokenIndex = -1; // reset the currentTokenIndex
+ FoundSeparator = false; // reset
+
+ // If we're at end of the string, just return false.
+ if (_charIndex >= _strLen)
+ {
+ return false;
}
- private void Initialize(string str, char quoteChar, char separator)
+ var currentChar = _str[_charIndex];
+
+ // setup the quoteCount
+ var quoteCount = 0;
+
+ // If we are allowing a quoted token and this token begins with a quote,
+ // set up the quote count and skip the initial quote
+ if (allowQuotedToken &&
+ currentChar == _quoteChar)
{
- _str = str;
- _strLen = str?.Length ?? 0;
- _currentTokenIndex = -1;
- _quoteChar = quoteChar;
- _argSeparator = separator;
-
- // immediately forward past any whitespace so
- // NextToken() logic always starts on the first
- // character of the next token.
- while (_charIndex < _strLen)
- {
- if (!char.IsWhiteSpace(_str, _charIndex))
- {
- break;
- }
-
- ++_charIndex;
- }
+ quoteCount++; // increment quote count
+ ++_charIndex; // move to next character
}
- public string GetCurrentToken() =>
- _currentTokenIndex < 0 ? null : _str.Substring(_currentTokenIndex, _currentTokenLength);
+ var newTokenIndex = _charIndex;
+ var newTokenLength = 0;
- internal bool NextToken() => NextToken(false);
-
- public bool NextToken(bool allowQuotedToken) => NextToken(allowQuotedToken, _argSeparator);
-
- public bool NextToken(bool allowQuotedToken, char separator)
+ // loop until hit end of string or hit a , or whitespace
+ // if at end of string ust return false.
+ while (_charIndex < _strLen)
{
- _currentTokenIndex = -1; // reset the currentTokenIndex
- FoundSeparator = false; // reset
+ currentChar = _str[_charIndex];
- // If we're at end of the string, just return false.
- if (_charIndex >= _strLen)
- {
- return false;
- }
-
- var currentChar = _str[_charIndex];
-
- // setup the quoteCount
- var quoteCount = 0;
-
- // If we are allowing a quoted token and this token begins with a quote,
- // set up the quote count and skip the initial quote
- if (allowQuotedToken &&
- currentChar == _quoteChar)
- {
- quoteCount++; // increment quote count
- ++_charIndex; // move to next character
- }
-
- var newTokenIndex = _charIndex;
- var newTokenLength = 0;
-
- // loop until hit end of string or hit a , or whitespace
- // if at end of string ust return false.
- while (_charIndex < _strLen)
- {
- currentChar = _str[_charIndex];
-
- // if have a QuoteCount and this is a quote
- // decrement the quoteCount
- if (quoteCount > 0)
- {
- // if anything but a quoteChar we move on
- if (currentChar == _quoteChar)
- {
- --quoteCount;
-
- // if at zero which it always should for now
- // break out of the loop
- if (0 == quoteCount)
- {
- ++_charIndex; // move past the quote
- break;
- }
- }
- }
- else if (char.IsWhiteSpace(currentChar) || currentChar == separator)
- {
- if (currentChar == separator)
- {
- FoundSeparator = true;
- }
- break;
- }
-
- ++_charIndex;
- ++newTokenLength;
- }
-
- // if quoteCount isn't zero we hit the end of the string
- // before the ending quote
+ // if have a QuoteCount and this is a quote
+ // decrement the quoteCount
if (quoteCount > 0)
{
- throw new InvalidOperationException("TokenizerHelperMissingEndQuote");
+ // if anything but a quoteChar we move on
+ if (currentChar == _quoteChar)
+ {
+ --quoteCount;
+
+ // if at zero which it always should for now
+ // break out of the loop
+ if (0 == quoteCount)
+ {
+ ++_charIndex; // move past the quote
+ break;
+ }
+ }
}
-
- ScanToNextToken(separator); // move so at the start of the nextToken for next call
-
- // finally made it, update the _currentToken values
- _currentTokenIndex = newTokenIndex;
- _currentTokenLength = newTokenLength;
-
- if (_currentTokenLength < 1)
+ else if (char.IsWhiteSpace(currentChar) || currentChar == separator)
{
- throw new InvalidOperationException("TokenizerHelperEmptyToken");
- }
-
- return true;
- }
-
- private void ScanToNextToken(char separator)
- {
- // if already at end of the string don't bother
- if (_charIndex >= _strLen) return;
-
- var currentChar = _str[_charIndex];
-
- // check that the currentChar is a space or the separator. If not
- // we have an error. this can happen in the quote case
- // that the char after the quotes string isn't a char.
- if (currentChar != separator && !char.IsWhiteSpace(currentChar))
- {
- throw new InvalidOperationException("TokenizerHelperExtraDataEncountered");
- }
-
- // loop until hit a character that isn't
- // an argument separator or whitespace.
- // !!!Todo: if more than one argSet throw an exception
- var argSepCount = 0;
- while (_charIndex < _strLen)
- {
- currentChar = _str[_charIndex];
-
if (currentChar == separator)
{
FoundSeparator = true;
- ++argSepCount;
- _charIndex++;
-
- if (argSepCount > 1)
- {
- throw new InvalidOperationException("TokenizerHelperEmptyToken");
- }
- }
- else if (char.IsWhiteSpace(currentChar))
- {
- ++_charIndex;
- }
- else
- {
- break;
}
+ break;
}
- // if there was a separatorChar then we shouldn't be
- // at the end of string or means there was a separator
- // but there isn't an arg
+ ++_charIndex;
+ ++newTokenLength;
+ }
- if (argSepCount > 0 && _charIndex >= _strLen)
+ // if quoteCount isn't zero we hit the end of the string
+ // before the ending quote
+ if (quoteCount > 0)
+ {
+ throw new InvalidOperationException("TokenizerHelperMissingEndQuote");
+ }
+
+ ScanToNextToken(separator); // move so at the start of the nextToken for next call
+
+ // finally made it, update the _currentToken values
+ _currentTokenIndex = newTokenIndex;
+ _currentTokenLength = newTokenLength;
+
+ if (_currentTokenLength < 1)
+ {
+ throw new InvalidOperationException("TokenizerHelperEmptyToken");
+ }
+
+ return true;
+ }
+
+ private void ScanToNextToken(char separator)
+ {
+ // if already at end of the string don't bother
+ if (_charIndex >= _strLen) return;
+
+ var currentChar = _str[_charIndex];
+
+ // check that the currentChar is a space or the separator. If not
+ // we have an error. this can happen in the quote case
+ // that the char after the quotes string isn't a char.
+ if (currentChar != separator && !char.IsWhiteSpace(currentChar))
+ {
+ throw new InvalidOperationException("TokenizerHelperExtraDataEncountered");
+ }
+
+ // loop until hit a character that isn't
+ // an argument separator or whitespace.
+ // !!!Todo: if more than one argSet throw an exception
+ var argSepCount = 0;
+ while (_charIndex < _strLen)
+ {
+ currentChar = _str[_charIndex];
+
+ if (currentChar == separator)
{
- throw new InvalidOperationException("TokenizerHelperEmptyToken");
+ FoundSeparator = true;
+ ++argSepCount;
+ _charIndex++;
+
+ if (argSepCount > 1)
+ {
+ throw new InvalidOperationException("TokenizerHelperEmptyToken");
+ }
+ }
+ else if (char.IsWhiteSpace(currentChar))
+ {
+ ++_charIndex;
+ }
+ else
+ {
+ break;
}
}
- internal static char GetNumericListSeparator(IFormatProvider provider)
+ // if there was a separatorChar then we shouldn't be
+ // at the end of string or means there was a separator
+ // but there isn't an arg
+
+ if (argSepCount > 0 && _charIndex >= _strLen)
{
- var numericSeparator = ',';
-
- // Get the NumberFormatInfo out of the provider, if possible
- // If the IFormatProvider doesn't not contain a NumberFormatInfo, then
- // this method returns the current culture's NumberFormatInfo.
- var numberFormat = NumberFormatInfo.GetInstance(provider);
-
- // Is the decimal separator is the same as the list separator?
- // If so, we use the ";".
- if (numberFormat.NumberDecimalSeparator.Length > 0 && numericSeparator == numberFormat.NumberDecimalSeparator[0])
- {
- numericSeparator = ';';
- }
-
- return numericSeparator;
+ throw new InvalidOperationException("TokenizerHelperEmptyToken");
}
}
+
+ internal static char GetNumericListSeparator(IFormatProvider provider)
+ {
+ var numericSeparator = ',';
+
+ // Get the NumberFormatInfo out of the provider, if possible
+ // If the IFormatProvider doesn't not contain a NumberFormatInfo, then
+ // this method returns the current culture's NumberFormatInfo.
+ var numberFormat = NumberFormatInfo.GetInstance(provider);
+
+ // Is the decimal separator is the same as the list separator?
+ // If so, we use the ";".
+ if (numberFormat.NumberDecimalSeparator.Length > 0 && numericSeparator == numberFormat.NumberDecimalSeparator[0])
+ {
+ numericSeparator = ';';
+ }
+
+ return numericSeparator;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/TouchDragMoveWindowHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/TouchDragMoveWindowHelper.cs
index ae24727f..83ba61c1 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/TouchDragMoveWindowHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/TouchDragMoveWindowHelper.cs
@@ -6,68 +6,67 @@ using System.Windows.Input;
using System.Windows.Interop;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools.Helper
+namespace HandyControl.Tools.Helper;
+
+internal class TouchDragMoveWindowHelper
{
- internal class TouchDragMoveWindowHelper
+ private const int MaxMoveSpeed = 60;
+
+ public TouchDragMoveWindowHelper(Window window)
{
- private const int MaxMoveSpeed = 60;
+ _window = window;
+ }
- public TouchDragMoveWindowHelper(Window window)
+ public void Start()
+ {
+ var window = _window;
+
+ window.PreviewMouseMove += Window_PreviewMouseMove;
+ window.PreviewMouseUp += Window_PreviewMouseUp;
+ window.LostMouseCapture += Window_LostMouseCapture;
+ }
+
+ public void Stop()
+ {
+ var window = _window;
+
+ window.PreviewMouseMove -= Window_PreviewMouseMove;
+ window.PreviewMouseUp -= Window_PreviewMouseUp;
+ window.LostMouseCapture -= Window_LostMouseCapture;
+ }
+
+ private readonly Window _window;
+
+ private InteropValues.POINT? _lastPoint;
+
+ private void Window_LostMouseCapture(object sender, MouseEventArgs e) => Stop();
+
+ private void Window_PreviewMouseUp(object sender, MouseButtonEventArgs e) => Stop();
+
+ private void Window_PreviewMouseMove(object sender, MouseEventArgs e)
+ {
+ InteropMethods.GetCursorPos(out var lpPoint);
+
+ if (_lastPoint == null)
{
- _window = window;
- }
-
- public void Start()
- {
- var window = _window;
-
- window.PreviewMouseMove += Window_PreviewMouseMove;
- window.PreviewMouseUp += Window_PreviewMouseUp;
- window.LostMouseCapture += Window_LostMouseCapture;
- }
-
- public void Stop()
- {
- var window = _window;
-
- window.PreviewMouseMove -= Window_PreviewMouseMove;
- window.PreviewMouseUp -= Window_PreviewMouseUp;
- window.LostMouseCapture -= Window_LostMouseCapture;
- }
-
- private readonly Window _window;
-
- private InteropValues.POINT? _lastPoint;
-
- private void Window_LostMouseCapture(object sender, MouseEventArgs e) => Stop();
-
- private void Window_PreviewMouseUp(object sender, MouseButtonEventArgs e) => Stop();
-
- private void Window_PreviewMouseMove(object sender, MouseEventArgs e)
- {
- InteropMethods.GetCursorPos(out var lpPoint);
-
- if (_lastPoint == null)
- {
- _lastPoint = lpPoint;
- _window.CaptureMouse();
- }
-
- var dx = lpPoint.X - _lastPoint.Value.X;
- var dy = lpPoint.Y - _lastPoint.Value.Y;
-
- if (Math.Abs(dx) < MaxMoveSpeed && Math.Abs(dy) < MaxMoveSpeed)
- {
- var handle = new WindowInteropHelper(_window).Handle;
-
- InteropMethods.GetWindowRect(handle, out var lpRect);
-
- InteropMethods.SetWindowPos(handle, IntPtr.Zero, lpRect.Left + dx, lpRect.Top + dy, 0, 0,
- (int) (InteropValues.WindowPositionFlags.SWP_NOSIZE |
- InteropValues.WindowPositionFlags.SWP_NOZORDER));
- }
-
_lastPoint = lpPoint;
+ _window.CaptureMouse();
}
+
+ var dx = lpPoint.X - _lastPoint.Value.X;
+ var dy = lpPoint.Y - _lastPoint.Value.Y;
+
+ if (Math.Abs(dx) < MaxMoveSpeed && Math.Abs(dy) < MaxMoveSpeed)
+ {
+ var handle = new WindowInteropHelper(_window).Handle;
+
+ InteropMethods.GetWindowRect(handle, out var lpRect);
+
+ InteropMethods.SetWindowPos(handle, IntPtr.Zero, lpRect.Left + dx, lpRect.Top + dy, 0, 0,
+ (int) (InteropValues.WindowPositionFlags.SWP_NOSIZE |
+ InteropValues.WindowPositionFlags.SWP_NOZORDER));
+ }
+
+ _lastPoint = lpPoint;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ValidateHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ValidateHelper.cs
index af86c119..dd40ca41 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ValidateHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ValidateHelper.cs
@@ -1,107 +1,106 @@
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 验证帮助类
+///
+public class ValidateHelper
{
///
- /// 验证帮助类
+ /// 是否在浮点数范围内
///
- public class ValidateHelper
+ ///
+ ///
+ public static bool IsInRangeOfDouble(object value)
{
- ///
- /// 是否在浮点数范围内
- ///
- ///
- ///
- public static bool IsInRangeOfDouble(object value)
- {
- var v = (double) value;
- return !(double.IsNaN(v) || double.IsInfinity(v));
- }
+ var v = (double) value;
+ return !(double.IsNaN(v) || double.IsInfinity(v));
+ }
- ///
- /// 是否在正浮点数范围内
- ///
- ///
- ///
- public static bool IsInRangeOfPosDouble(object value)
- {
- var v = (double) value;
- return !(double.IsNaN(v) || double.IsInfinity(v)) && v > 0;
- }
+ ///
+ /// 是否在正浮点数范围内
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfPosDouble(object value)
+ {
+ var v = (double) value;
+ return !(double.IsNaN(v) || double.IsInfinity(v)) && v > 0;
+ }
- ///
- /// 是否在正浮点数范围内(包括0)
- ///
- ///
- ///
- public static bool IsInRangeOfPosDoubleIncludeZero(object value)
- {
- var v = (double) value;
- return !(double.IsNaN(v) || double.IsInfinity(v)) && v >= 0;
- }
+ ///
+ /// 是否在正浮点数范围内(包括0)
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfPosDoubleIncludeZero(object value)
+ {
+ var v = (double) value;
+ return !(double.IsNaN(v) || double.IsInfinity(v)) && v >= 0;
+ }
- ///
- /// 是否在负浮点数范围内
- ///
- ///
- ///
- public static bool IsInRangeOfNegDouble(object value)
- {
- var v = (double) value;
- return !(double.IsNaN(v) || double.IsInfinity(v)) && v < 0;
- }
+ ///
+ /// 是否在负浮点数范围内
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfNegDouble(object value)
+ {
+ var v = (double) value;
+ return !(double.IsNaN(v) || double.IsInfinity(v)) && v < 0;
+ }
- ///
- /// 是否在负浮点数范围内(包括0)
- ///
- ///
- ///
- public static bool IsInRangeOfNegDoubleIncludeZero(object value)
- {
- var v = (double) value;
- return !(double.IsNaN(v) || double.IsInfinity(v)) && v <= 0;
- }
+ ///
+ /// 是否在负浮点数范围内(包括0)
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfNegDoubleIncludeZero(object value)
+ {
+ var v = (double) value;
+ return !(double.IsNaN(v) || double.IsInfinity(v)) && v <= 0;
+ }
- ///
- /// 是否在正整数范围内
- ///
- ///
- ///
- public static bool IsInRangeOfPosInt(object value)
- {
- var v = (int) value;
- return v > 0;
- }
+ ///
+ /// 是否在正整数范围内
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfPosInt(object value)
+ {
+ var v = (int) value;
+ return v > 0;
+ }
- ///
- /// 是否在正整数范围内(包括0)
- ///
- ///
- ///
- public static bool IsInRangeOfPosIntIncludeZero(object value)
- {
- var v = (int) value;
- return v >= 0;
- }
+ ///
+ /// 是否在正整数范围内(包括0)
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfPosIntIncludeZero(object value)
+ {
+ var v = (int) value;
+ return v >= 0;
+ }
- ///
- /// 是否在负整数范围内
- ///
- ///
- ///
- public static bool IsInRangeOfNegInt(object value)
- {
- var v = (int) value;
- return v < 0;
- }
+ ///
+ /// 是否在负整数范围内
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfNegInt(object value)
+ {
+ var v = (int) value;
+ return v < 0;
+ }
- ///
- /// 是否在负整数范围内(包括0)
- ///
- ///
- ///
- public static bool IsInRangeOfNegIntIncludeZero(object value)
- {
- var v = (int) value;
- return v <= 0;
- }
+ ///
+ /// 是否在负整数范围内(包括0)
+ ///
+ ///
+ ///
+ public static bool IsInRangeOfNegIntIncludeZero(object value)
+ {
+ var v = (int) value;
+ return v <= 0;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
index 01d914d3..7d4d7f76 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
@@ -5,73 +5,72 @@ using System.Windows.Interop;
using System.Windows.Media;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public static class VisualHelper
{
- public static class VisualHelper
+ internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject d, string groupName)
{
- internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject d, string groupName)
- {
- var root = GetImplementationRoot(d);
- if (root == null) return null;
+ var root = GetImplementationRoot(d);
+ if (root == null) return null;
- return VisualStateManager
- .GetVisualStateGroups(root)?
- .OfType()
- .FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
+ return VisualStateManager
+ .GetVisualStateGroups(root)?
+ .OfType()
+ .FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
+ }
+
+ internal static FrameworkElement GetImplementationRoot(DependencyObject d) =>
+ 1 == VisualTreeHelper.GetChildrenCount(d)
+ ? VisualTreeHelper.GetChild(d, 0) as FrameworkElement
+ : null;
+
+ public static T GetChild(DependencyObject d) where T : DependencyObject
+ {
+ if (d == null) return default;
+ if (d is T t) return t;
+
+ for (var i = 0; i < VisualTreeHelper.GetChildrenCount(d); i++)
+ {
+ var child = VisualTreeHelper.GetChild(d, i);
+
+ var result = GetChild(child);
+ if (result != null) return result;
}
- internal static FrameworkElement GetImplementationRoot(DependencyObject d) =>
- 1 == VisualTreeHelper.GetChildrenCount(d)
- ? VisualTreeHelper.GetChild(d, 0) as FrameworkElement
- : null;
+ return default;
+ }
- public static T GetChild(DependencyObject d) where T : DependencyObject
+ public static T GetParent(DependencyObject d) where T : DependencyObject =>
+ d switch
{
- if (d == null) return default;
- if (d is T t) return t;
+ null => default,
+ T t => t,
+ Window _ => null,
+ _ => GetParent(VisualTreeHelper.GetParent(d))
+ };
- for (var i = 0; i < VisualTreeHelper.GetChildrenCount(d); i++)
- {
- var child = VisualTreeHelper.GetChild(d, i);
+ public static IntPtr GetHandle(this Visual visual) => (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
- var result = GetChild(child);
- if (result != null) return result;
- }
+ internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback, HitTestParameters parameters) =>
+ VisualTreeHelper.HitTest(visual, ExcludeNonVisualElements, resultCallback, parameters);
- return default;
- }
+ private static HitTestFilterBehavior ExcludeNonVisualElements(DependencyObject potentialHitTestTarget)
+ {
+ if (!(potentialHitTestTarget is Visual)) return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
- public static T GetParent(DependencyObject d) where T : DependencyObject =>
- d switch
- {
- null => default,
- T t => t,
- Window _ => null,
- _ => GetParent(VisualTreeHelper.GetParent(d))
- };
+ if (!(potentialHitTestTarget is UIElement uIElement) || uIElement.IsVisible && uIElement.IsEnabled)
+ return HitTestFilterBehavior.Continue;
- public static IntPtr GetHandle(this Visual visual) => (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
+ return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
+ }
- internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback, HitTestParameters parameters) =>
- VisualTreeHelper.HitTest(visual, ExcludeNonVisualElements, resultCallback, parameters);
-
- private static HitTestFilterBehavior ExcludeNonVisualElements(DependencyObject potentialHitTestTarget)
- {
- if (!(potentialHitTestTarget is Visual)) return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
-
- if (!(potentialHitTestTarget is UIElement uIElement) || uIElement.IsVisible && uIElement.IsEnabled)
- return HitTestFilterBehavior.Continue;
-
- return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
- }
-
- internal static bool ModifyStyle(IntPtr hWnd, int styleToRemove, int styleToAdd)
- {
- var windowLong = InteropMethods.GetWindowLong(hWnd, InteropValues.GWL.STYLE);
- var num = (windowLong & ~styleToRemove) | styleToAdd;
- if (num == windowLong) return false;
- InteropMethods.SetWindowLong(hWnd, InteropValues.GWL.STYLE, num);
- return true;
- }
+ internal static bool ModifyStyle(IntPtr hWnd, int styleToRemove, int styleToAdd)
+ {
+ var windowLong = InteropMethods.GetWindowLong(hWnd, InteropValues.GWL.STYLE);
+ var num = (windowLong & ~styleToRemove) | styleToAdd;
+ if (num == windowLong) return false;
+ InteropMethods.SetWindowLong(hWnd, InteropValues.GWL.STYLE, num);
+ return true;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
index 2d155bb4..23ec5e0f 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
@@ -12,194 +12,193 @@ using HandyControl.Tools.Helper;
using HandyControl.Tools.Interop;
using Window = System.Windows.Window;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public static class WindowHelper
{
- public static class WindowHelper
+ ///
+ /// 获取当前应用中处于激活的一个窗口
+ ///
+ ///
+ public static Window GetActiveWindow() => Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
+
+ private static readonly BitArray _cacheValid = new((int) InteropValues.CacheSlot.NumSlots);
+
+ private static bool _setDpiX = true;
+
+ private static bool _dpiInitialized;
+
+ private static readonly object _dpiLock = new();
+
+ private static int _dpi;
+
+ internal static int Dpi
{
- ///
- /// 获取当前应用中处于激活的一个窗口
- ///
- ///
- public static Window GetActiveWindow() => Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
-
- private static readonly BitArray _cacheValid = new((int) InteropValues.CacheSlot.NumSlots);
-
- private static bool _setDpiX = true;
-
- private static bool _dpiInitialized;
-
- private static readonly object _dpiLock = new();
-
- private static int _dpi;
-
- internal static int Dpi
+ [SecurityCritical, SecuritySafeCritical]
+ get
{
- [SecurityCritical, SecuritySafeCritical]
- get
+ if (!_dpiInitialized)
{
- if (!_dpiInitialized)
+ lock (_dpiLock)
{
- lock (_dpiLock)
+ if (!_dpiInitialized)
{
- if (!_dpiInitialized)
+ var desktopWnd = new HandleRef(null, IntPtr.Zero);
+
+ // Win32Exception will get the Win32 error code so we don't have to
+ var dc = InteropMethods.GetDC(desktopWnd);
+
+ // Detecting error case from unmanaged call, required by PREsharp to throw a Win32Exception
+ if (dc == IntPtr.Zero)
{
- var desktopWnd = new HandleRef(null, IntPtr.Zero);
+ throw new Win32Exception();
+ }
- // Win32Exception will get the Win32 error code so we don't have to
- var dc = InteropMethods.GetDC(desktopWnd);
-
- // Detecting error case from unmanaged call, required by PREsharp to throw a Win32Exception
- if (dc == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
-
- try
- {
- _dpi = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSY);
- _dpiInitialized = true;
- }
- finally
- {
- InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
- }
+ try
+ {
+ _dpi = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSY);
+ _dpiInitialized = true;
+ }
+ finally
+ {
+ InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
}
}
}
- return _dpi;
}
+ return _dpi;
}
+ }
- private static int _dpiX;
+ private static int _dpiX;
- internal static int DpiX
+ internal static int DpiX
+ {
+ [SecurityCritical, SecuritySafeCritical]
+ get
{
- [SecurityCritical, SecuritySafeCritical]
- get
- {
- if (_setDpiX)
- {
- lock (_cacheValid)
- {
- if (_setDpiX)
- {
- _setDpiX = false;
- var desktopWnd = new HandleRef(null, IntPtr.Zero);
- var dc = InteropMethods.GetDC(desktopWnd);
- if (dc == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
- try
- {
- _dpiX = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSX);
- _cacheValid[(int) InteropValues.CacheSlot.DpiX] = true;
- }
- finally
- {
- InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
- }
- }
- }
- }
-
- return _dpiX;
- }
- }
-
- private static Thickness _windowResizeBorderThickness;
-
- internal static Thickness WindowResizeBorderThickness
- {
- [SecurityCritical]
- get
+ if (_setDpiX)
{
lock (_cacheValid)
{
- while (!_cacheValid[(int) InteropValues.CacheSlot.WindowResizeBorderThickness])
+ if (_setDpiX)
{
- _cacheValid[(int) InteropValues.CacheSlot.WindowResizeBorderThickness] = true;
-
- var frameSize = new Size(InteropMethods.GetSystemMetrics(InteropValues.SM.CXSIZEFRAME), InteropMethods.GetSystemMetrics(InteropValues.SM.CYSIZEFRAME));
- var frameSizeInDips = DpiHelper.DeviceSizeToLogical(frameSize, DpiX / 96.0, Dpi / 96.0);
-
- _windowResizeBorderThickness = new Thickness(frameSizeInDips.Width, frameSizeInDips.Height, frameSizeInDips.Width, frameSizeInDips.Height);
+ _setDpiX = false;
+ var desktopWnd = new HandleRef(null, IntPtr.Zero);
+ var dc = InteropMethods.GetDC(desktopWnd);
+ if (dc == IntPtr.Zero)
+ {
+ throw new Win32Exception();
+ }
+ try
+ {
+ _dpiX = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSX);
+ _cacheValid[(int) InteropValues.CacheSlot.DpiX] = true;
+ }
+ finally
+ {
+ InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
+ }
}
}
-
- return _windowResizeBorderThickness;
}
- }
- public static Thickness WindowMaximizedPadding
+ return _dpiX;
+ }
+ }
+
+ private static Thickness _windowResizeBorderThickness;
+
+ internal static Thickness WindowResizeBorderThickness
+ {
+ [SecurityCritical]
+ get
{
- get
+ lock (_cacheValid)
{
- InteropValues.APPBARDATA appBarData = default;
- var autoHide = InteropMethods.SHAppBarMessage(4, ref appBarData) != 0;
+ while (!_cacheValid[(int) InteropValues.CacheSlot.WindowResizeBorderThickness])
+ {
+ _cacheValid[(int) InteropValues.CacheSlot.WindowResizeBorderThickness] = true;
+
+ var frameSize = new Size(InteropMethods.GetSystemMetrics(InteropValues.SM.CXSIZEFRAME), InteropMethods.GetSystemMetrics(InteropValues.SM.CYSIZEFRAME));
+ var frameSizeInDips = DpiHelper.DeviceSizeToLogical(frameSize, DpiX / 96.0, Dpi / 96.0);
+
+ _windowResizeBorderThickness = new Thickness(frameSizeInDips.Width, frameSizeInDips.Height, frameSizeInDips.Width, frameSizeInDips.Height);
+ }
+ }
+
+ return _windowResizeBorderThickness;
+ }
+ }
+
+ public static Thickness WindowMaximizedPadding
+ {
+ get
+ {
+ InteropValues.APPBARDATA appBarData = default;
+ var autoHide = InteropMethods.SHAppBarMessage(4, ref appBarData) != 0;
#if NET40
- return WindowResizeBorderThickness.Add(new Thickness(autoHide ? -8 : 0));
+ return WindowResizeBorderThickness.Add(new Thickness(autoHide ? -8 : 0));
#elif NETCOREAPP
- var hdc = InteropMethods.GetDC(IntPtr.Zero);
- var scale = InteropMethods.GetDeviceCaps(hdc, InteropValues.DESKTOPVERTRES) / (float) InteropMethods.GetDeviceCaps(hdc, InteropValues.VERTRES);
- InteropMethods.ReleaseDC(IntPtr.Zero, hdc);
- return WindowResizeBorderThickness.Add(new Thickness((autoHide ? -4 : 4) * scale));
+ var hdc = InteropMethods.GetDC(IntPtr.Zero);
+ var scale = InteropMethods.GetDeviceCaps(hdc, InteropValues.DESKTOPVERTRES) / (float) InteropMethods.GetDeviceCaps(hdc, InteropValues.VERTRES);
+ InteropMethods.ReleaseDC(IntPtr.Zero, hdc);
+ return WindowResizeBorderThickness.Add(new Thickness((autoHide ? -4 : 4) * scale));
#else
return WindowResizeBorderThickness.Add(new Thickness(autoHide ? -4 : 4));
#endif
- }
}
-
- public static IntPtr CreateHandle() => new WindowInteropHelper(new Window()).EnsureHandle();
-
- public static IntPtr GetHandle(this Window window) => new WindowInteropHelper(window).EnsureHandle();
-
- public static HwndSource GetHwndSource(this Window window) => HwndSource.FromHwnd(window.GetHandle());
-
- ///
- /// 让窗口激活作为前台最上层窗口
- ///
- ///
- public static void SetWindowToForeground(Window window)
- {
- // [WPF 让窗口激活作为前台最上层窗口的方法 - lindexi - 博客园](https://www.cnblogs.com/lindexi/p/12749671.html)
- var interopHelper = new WindowInteropHelper(window);
- var thisWindowThreadId = InteropMethods.GetWindowThreadProcessId(interopHelper.Handle, out _);
- var currentForegroundWindow = InteropMethods.GetForegroundWindow();
- var currentForegroundWindowThreadId = InteropMethods.GetWindowThreadProcessId(currentForegroundWindow, out _);
-
- // [c# - Bring a window to the front in WPF - Stack Overflow](https://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf )
- // [SetForegroundWindow的正确用法 - 子坞 - 博客园](https://www.cnblogs.com/ziwuge/archive/2012/01/06/2315342.html )
- /*
- 1.得到窗口句柄FindWindow
- 2.切换键盘输入焦点AttachThreadInput
- 3.显示窗口ShowWindow(有些窗口被最小化/隐藏了)
- 4.更改窗口的Z Order,SetWindowPos使之最上,为了不影响后续窗口的Z Order,改完之后,再还原
- 5.最后SetForegroundWindow
- */
-
- InteropMethods.AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, true);
-
- window.Show();
- window.Activate();
- // 去掉和其他线程的输入链接
- InteropMethods.AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, false);
-
- // 用于踢掉其他的在上层的窗口
- if (window.Topmost != true)
- {
- window.Topmost = true;
- window.Topmost = false;
- }
- }
-
- ///
- /// 开始使用触摸拖动窗口,在触摸抬起后自动结束
- ///
- public static void TouchDragMove(this Window window) => new TouchDragMoveWindowHelper(window).Start();
-
- public static void StartFullScreen(this Window window) => FullScreenHelper.StartFullScreen(window);
-
- public static void EndFullScreen(this Window window) => FullScreenHelper.EndFullScreen(window);
}
+
+ public static IntPtr CreateHandle() => new WindowInteropHelper(new Window()).EnsureHandle();
+
+ public static IntPtr GetHandle(this Window window) => new WindowInteropHelper(window).EnsureHandle();
+
+ public static HwndSource GetHwndSource(this Window window) => HwndSource.FromHwnd(window.GetHandle());
+
+ ///
+ /// 让窗口激活作为前台最上层窗口
+ ///
+ ///
+ public static void SetWindowToForeground(Window window)
+ {
+ // [WPF 让窗口激活作为前台最上层窗口的方法 - lindexi - 博客园](https://www.cnblogs.com/lindexi/p/12749671.html)
+ var interopHelper = new WindowInteropHelper(window);
+ var thisWindowThreadId = InteropMethods.GetWindowThreadProcessId(interopHelper.Handle, out _);
+ var currentForegroundWindow = InteropMethods.GetForegroundWindow();
+ var currentForegroundWindowThreadId = InteropMethods.GetWindowThreadProcessId(currentForegroundWindow, out _);
+
+ // [c# - Bring a window to the front in WPF - Stack Overflow](https://stackoverflow.com/questions/257587/bring-a-window-to-the-front-in-wpf )
+ // [SetForegroundWindow的正确用法 - 子坞 - 博客园](https://www.cnblogs.com/ziwuge/archive/2012/01/06/2315342.html )
+ /*
+ 1.得到窗口句柄FindWindow
+ 2.切换键盘输入焦点AttachThreadInput
+ 3.显示窗口ShowWindow(有些窗口被最小化/隐藏了)
+ 4.更改窗口的Z Order,SetWindowPos使之最上,为了不影响后续窗口的Z Order,改完之后,再还原
+ 5.最后SetForegroundWindow
+ */
+
+ InteropMethods.AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, true);
+
+ window.Show();
+ window.Activate();
+ // 去掉和其他线程的输入链接
+ InteropMethods.AttachThreadInput(currentForegroundWindowThreadId, thisWindowThreadId, false);
+
+ // 用于踢掉其他的在上层的窗口
+ if (window.Topmost != true)
+ {
+ window.Topmost = true;
+ window.Topmost = false;
+ }
+ }
+
+ ///
+ /// 开始使用触摸拖动窗口,在触摸抬起后自动结束
+ ///
+ public static void TouchDragMove(this Window window) => new TouchDragMoveWindowHelper(window).Start();
+
+ public static void StartFullScreen(this Window window) => FullScreenHelper.StartFullScreen(window);
+
+ public static void EndFullScreen(this Window window) => FullScreenHelper.EndFullScreen(window);
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
index ca85415b..25916a90 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
@@ -2,56 +2,55 @@
using System.Windows.Interop;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class ClipboardHook
{
- public class ClipboardHook
+ public static event Action ContentChanged;
+
+ private static HwndSource HWndSource;
+
+ private static IntPtr HookId = IntPtr.Zero;
+
+ private static int Count;
+
+ public static void Start()
{
- public static event Action ContentChanged;
-
- private static HwndSource HWndSource;
-
- private static IntPtr HookId = IntPtr.Zero;
-
- private static int Count;
-
- public static void Start()
+ if (HookId == IntPtr.Zero)
{
- if (HookId == IntPtr.Zero)
+ HookId = WindowHelper.CreateHandle();
+ HWndSource = HwndSource.FromHwnd(HookId);
+ if (HWndSource != null)
{
- HookId = WindowHelper.CreateHandle();
- HWndSource = HwndSource.FromHwnd(HookId);
- if (HWndSource != null)
- {
- HWndSource.AddHook(WinProc);
- InteropMethods.AddClipboardFormatListener(HookId);
- }
- }
-
- if (HookId != IntPtr.Zero)
- {
- Count++;
+ HWndSource.AddHook(WinProc);
+ InteropMethods.AddClipboardFormatListener(HookId);
}
}
- public static void Stop()
+ if (HookId != IntPtr.Zero)
{
- Count--;
- if (Count < 1)
- {
- HWndSource.RemoveHook(WinProc);
- InteropMethods.RemoveClipboardFormatListener(HookId);
-
- HookId = IntPtr.Zero;
- }
- }
-
- private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
- {
- if (msg == InteropValues.WM_CLIPBOARDUPDATE)
- {
- ContentChanged?.Invoke();
- }
- return IntPtr.Zero;
+ Count++;
}
}
+
+ public static void Stop()
+ {
+ Count--;
+ if (Count < 1)
+ {
+ HWndSource.RemoveHook(WinProc);
+ InteropMethods.RemoveClipboardFormatListener(HookId);
+
+ HookId = IntPtr.Zero;
+ }
+ }
+
+ private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
+ {
+ if (msg == InteropValues.WM_CLIPBOARDUPDATE)
+ {
+ ContentChanged?.Invoke();
+ }
+ return IntPtr.Zero;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
index 18ea9bcc..f9cca1f0 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
@@ -4,102 +4,101 @@ using System.Runtime.InteropServices;
using HandyControl.Data;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class KeyboardHook
{
- public class KeyboardHook
+ public static event EventHandler KeyDown;
+
+ public static event EventHandler KeyUp;
+
+ private static IntPtr HookId = IntPtr.Zero;
+
+ private static readonly InteropValues.HookProc Proc = HookCallback;
+
+ private static int VirtualKey;
+
+ private static readonly IntPtr KeyDownIntPtr = (IntPtr) InteropValues.WM_KEYDOWN;
+
+ private static readonly IntPtr KeyUpIntPtr = (IntPtr) InteropValues.WM_KEYUP;
+
+ private static readonly IntPtr SyskeyDownIntPtr = (IntPtr) InteropValues.WM_SYSKEYDOWN;
+
+ private static readonly IntPtr SyskeyUpIntPtr = (IntPtr) InteropValues.WM_SYSKEYUP;
+
+ private static int Count;
+
+ public static void Start()
{
- public static event EventHandler KeyDown;
-
- public static event EventHandler KeyUp;
-
- private static IntPtr HookId = IntPtr.Zero;
-
- private static readonly InteropValues.HookProc Proc = HookCallback;
-
- private static int VirtualKey;
-
- private static readonly IntPtr KeyDownIntPtr = (IntPtr) InteropValues.WM_KEYDOWN;
-
- private static readonly IntPtr KeyUpIntPtr = (IntPtr) InteropValues.WM_KEYUP;
-
- private static readonly IntPtr SyskeyDownIntPtr = (IntPtr) InteropValues.WM_SYSKEYDOWN;
-
- private static readonly IntPtr SyskeyUpIntPtr = (IntPtr) InteropValues.WM_SYSKEYUP;
-
- private static int Count;
-
- public static void Start()
+ if (HookId == IntPtr.Zero)
{
- if (HookId == IntPtr.Zero)
- {
- HookId = SetHook(Proc);
- }
-
- if (HookId != IntPtr.Zero)
- {
- Count++;
- }
+ HookId = SetHook(Proc);
}
- public static void Stop()
+ if (HookId != IntPtr.Zero)
{
- Count--;
- if (Count < 1)
- {
- InteropMethods.UnhookWindowsHookEx(HookId);
- HookId = IntPtr.Zero;
- }
- }
-
- private static IntPtr SetHook(InteropValues.HookProc proc)
- {
- using var curProcess = Process.GetCurrentProcess();
- using var curModule = curProcess.MainModule;
-
- if (curModule != null)
- {
- return InteropMethods.SetWindowsHookEx((int) InteropValues.HookType.WH_KEYBOARD_LL, proc,
- InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
- }
- return IntPtr.Zero;
- }
-
- private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
- {
- if (nCode >= 0)
- {
- if (wParam == KeyDownIntPtr)
- {
- var virtualKey = Marshal.ReadInt32(lParam);
- if (VirtualKey != virtualKey)
- {
- VirtualKey = virtualKey;
- KeyDown?.Invoke(null, new KeyboardHookEventArgs(virtualKey, false));
- }
- }
- else if (wParam == SyskeyDownIntPtr)
- {
- var virtualKey = Marshal.ReadInt32(lParam);
- if (VirtualKey != virtualKey)
- {
- VirtualKey = virtualKey;
- KeyDown?.Invoke(null, new KeyboardHookEventArgs(virtualKey, true));
- }
- }
- else if (wParam == KeyUpIntPtr)
- {
- var virtualKey = Marshal.ReadInt32(lParam);
- VirtualKey = -1;
- KeyUp?.Invoke(null, new KeyboardHookEventArgs(virtualKey, false));
- }
- else if (wParam == SyskeyUpIntPtr)
- {
- var virtualKey = Marshal.ReadInt32(lParam);
- VirtualKey = -1;
- KeyUp?.Invoke(null, new KeyboardHookEventArgs(virtualKey, true));
- }
- }
- return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ Count++;
}
}
+
+ public static void Stop()
+ {
+ Count--;
+ if (Count < 1)
+ {
+ InteropMethods.UnhookWindowsHookEx(HookId);
+ HookId = IntPtr.Zero;
+ }
+ }
+
+ private static IntPtr SetHook(InteropValues.HookProc proc)
+ {
+ using var curProcess = Process.GetCurrentProcess();
+ using var curModule = curProcess.MainModule;
+
+ if (curModule != null)
+ {
+ return InteropMethods.SetWindowsHookEx((int) InteropValues.HookType.WH_KEYBOARD_LL, proc,
+ InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
+ }
+ return IntPtr.Zero;
+ }
+
+ private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
+ {
+ if (nCode >= 0)
+ {
+ if (wParam == KeyDownIntPtr)
+ {
+ var virtualKey = Marshal.ReadInt32(lParam);
+ if (VirtualKey != virtualKey)
+ {
+ VirtualKey = virtualKey;
+ KeyDown?.Invoke(null, new KeyboardHookEventArgs(virtualKey, false));
+ }
+ }
+ else if (wParam == SyskeyDownIntPtr)
+ {
+ var virtualKey = Marshal.ReadInt32(lParam);
+ if (VirtualKey != virtualKey)
+ {
+ VirtualKey = virtualKey;
+ KeyDown?.Invoke(null, new KeyboardHookEventArgs(virtualKey, true));
+ }
+ }
+ else if (wParam == KeyUpIntPtr)
+ {
+ var virtualKey = Marshal.ReadInt32(lParam);
+ VirtualKey = -1;
+ KeyUp?.Invoke(null, new KeyboardHookEventArgs(virtualKey, false));
+ }
+ else if (wParam == SyskeyUpIntPtr)
+ {
+ var virtualKey = Marshal.ReadInt32(lParam);
+ VirtualKey = -1;
+ KeyUp?.Invoke(null, new KeyboardHookEventArgs(virtualKey, true));
+ }
+ }
+ return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
index 8710d622..149a1a8a 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
@@ -4,65 +4,64 @@ using System.Runtime.InteropServices;
using HandyControl.Data;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+internal class MouseHook
{
- internal class MouseHook
+ public static event EventHandler StatusChanged;
+
+ private static IntPtr HookId = IntPtr.Zero;
+
+ private static readonly InteropValues.HookProc Proc = HookCallback;
+
+ private static int Count;
+
+ public static void Start()
{
- public static event EventHandler StatusChanged;
-
- private static IntPtr HookId = IntPtr.Zero;
-
- private static readonly InteropValues.HookProc Proc = HookCallback;
-
- private static int Count;
-
- public static void Start()
+ if (HookId == IntPtr.Zero)
{
- if (HookId == IntPtr.Zero)
- {
- HookId = SetHook(Proc);
- }
-
- if (HookId != IntPtr.Zero)
- {
- Count++;
- }
+ HookId = SetHook(Proc);
}
- public static void Stop()
+ if (HookId != IntPtr.Zero)
{
- Count--;
- if (Count < 1)
- {
- InteropMethods.UnhookWindowsHookEx(HookId);
- HookId = IntPtr.Zero;
- }
- }
-
- private static IntPtr SetHook(InteropValues.HookProc proc)
- {
- using var curProcess = Process.GetCurrentProcess();
- using var curModule = curProcess.MainModule;
-
- if (curModule != null)
- {
- return InteropMethods.SetWindowsHookEx((int) InteropValues.HookType.WH_MOUSE_LL, proc,
- InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
- }
- return IntPtr.Zero;
- }
-
- private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
- {
- if (nCode < 0) return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
- var hookStruct = (InteropValues.MOUSEHOOKSTRUCT) Marshal.PtrToStructure(lParam, typeof(InteropValues.MOUSEHOOKSTRUCT));
- StatusChanged?.Invoke(null, new MouseHookEventArgs
- {
- MessageType = (MouseHookMessageType) wParam,
- Point = new InteropValues.POINT(hookStruct.pt.X, hookStruct.pt.Y)
- });
-
- return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ Count++;
}
}
+
+ public static void Stop()
+ {
+ Count--;
+ if (Count < 1)
+ {
+ InteropMethods.UnhookWindowsHookEx(HookId);
+ HookId = IntPtr.Zero;
+ }
+ }
+
+ private static IntPtr SetHook(InteropValues.HookProc proc)
+ {
+ using var curProcess = Process.GetCurrentProcess();
+ using var curModule = curProcess.MainModule;
+
+ if (curModule != null)
+ {
+ return InteropMethods.SetWindowsHookEx((int) InteropValues.HookType.WH_MOUSE_LL, proc,
+ InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
+ }
+ return IntPtr.Zero;
+ }
+
+ private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
+ {
+ if (nCode < 0) return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ var hookStruct = (InteropValues.MOUSEHOOKSTRUCT) Marshal.PtrToStructure(lParam, typeof(InteropValues.MOUSEHOOKSTRUCT));
+ StatusChanged?.Invoke(null, new MouseHookEventArgs
+ {
+ MessageType = (MouseHookMessageType) wParam,
+ Point = new InteropValues.POINT(hookStruct.pt.X, hookStruct.pt.Y)
+ });
+
+ return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs
index a0a2e8d1..235bdcb7 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs
@@ -4,50 +4,49 @@ using System.Windows;
using System.Windows.Interop;
using HandyControl.Tools.Interop;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class SystemMenuHook
{
- public class SystemMenuHook
+ private static readonly Dictionary DataDic = new();
+
+ public static event Action Click;
+
+ public static void Insert(int index, int id, string text, Window window)
{
- private static readonly Dictionary DataDic = new();
-
- public static event Action Click;
-
- public static void Insert(int index, int id, string text, Window window)
+ var hookId = window.GetHandle();
+ var source = HwndSource.FromHwnd(hookId);
+ if (source != null)
{
- var hookId = window.GetHandle();
- var source = HwndSource.FromHwnd(hookId);
- if (source != null)
- {
- DataDic[id] = source;
- InteropMethods.InsertMenu(InteropMethods.GetSystemMenu(hookId, false), index, InteropValues.MF_BYPOSITION, id, text);
- source.AddHook(WinProc);
- }
- }
-
- public static void InsertSeperator(int index, Window window) => InteropMethods.InsertMenu(
- InteropMethods.GetSystemMenu(window.GetHandle(), false), index,
- InteropValues.MF_BYPOSITION | InteropValues.MF_SEPARATOR, 0, "");
-
- public static void Remove(int id)
- {
- if (DataDic.TryGetValue(id, out var data))
- {
- data.RemoveHook(WinProc);
- DataDic.Remove(id);
- }
- }
-
- private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
- {
- if (msg == InteropValues.WM_SYSCOMMAND)
- {
- var id = wparam.ToInt32();
- if (DataDic.ContainsKey(id))
- {
- Click?.Invoke(id);
- }
- }
- return IntPtr.Zero;
+ DataDic[id] = source;
+ InteropMethods.InsertMenu(InteropMethods.GetSystemMenu(hookId, false), index, InteropValues.MF_BYPOSITION, id, text);
+ source.AddHook(WinProc);
}
}
+
+ public static void InsertSeperator(int index, Window window) => InteropMethods.InsertMenu(
+ InteropMethods.GetSystemMenu(window.GetHandle(), false), index,
+ InteropValues.MF_BYPOSITION | InteropValues.MF_SEPARATOR, 0, "");
+
+ public static void Remove(int id)
+ {
+ if (DataDic.TryGetValue(id, out var data))
+ {
+ data.RemoveHook(WinProc);
+ DataDic.Remove(id);
+ }
+ }
+
+ private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
+ {
+ if (msg == InteropValues.WM_SYSCOMMAND)
+ {
+ var id = wparam.ToInt32();
+ if (DataDic.ContainsKey(id))
+ {
+ Click?.Invoke(id);
+ }
+ }
+ return IntPtr.Zero;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
index 411c075c..4a8047ae 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
@@ -4,42 +4,41 @@ using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+[SuppressMessage("ReSharper", "UnusedMember.Local")]
+internal sealed class BitmapHandle : WpfSafeHandle
{
- [SuppressMessage("ReSharper", "UnusedMember.Local")]
- internal sealed class BitmapHandle : WpfSafeHandle
+ [SecurityCritical]
+ private BitmapHandle() : this(true)
{
- [SecurityCritical]
- private BitmapHandle() : this(true)
- {
- //请不要删除此构造函数,否则当使用自定义ico文件时会报错
- }
+ //请不要删除此构造函数,否则当使用自定义ico文件时会报错
+ }
- [SecurityCritical]
- private BitmapHandle(bool ownsHandle) : base(ownsHandle, CommonHandles.GDI)
- {
- }
+ [SecurityCritical]
+ private BitmapHandle(bool ownsHandle) : base(ownsHandle, CommonHandles.GDI)
+ {
+ }
- [SecurityCritical]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- protected override bool ReleaseHandle()
- {
- return InteropMethods.DeleteObject(handle);
- }
+ [SecurityCritical]
+ [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
+ protected override bool ReleaseHandle()
+ {
+ return InteropMethods.DeleteObject(handle);
+ }
- [SecurityCritical]
- internal HandleRef MakeHandleRef(object obj)
- {
- return new(obj, handle);
- }
+ [SecurityCritical]
+ internal HandleRef MakeHandleRef(object obj)
+ {
+ return new(obj, handle);
+ }
- [SecurityCritical]
- internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle = true)
+ [SecurityCritical]
+ internal static BitmapHandle CreateFromHandle(IntPtr hbitmap, bool ownsHandle = true)
+ {
+ return new(ownsHandle)
{
- return new(ownsHandle)
- {
- handle = hbitmap,
- };
- }
+ handle = hbitmap,
+ };
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs
index ad178b03..3a4401c1 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs
@@ -1,16 +1,15 @@
using System.Diagnostics.CodeAnalysis;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+[SuppressMessage("ReSharper", "InconsistentNaming")]
+internal static class CommonHandles
{
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal static class CommonHandles
- {
- public static readonly int Icon = HandleCollector.RegisterType(nameof(Icon), 20, 500);
+ public static readonly int Icon = HandleCollector.RegisterType(nameof(Icon), 20, 500);
- public static readonly int HDC = HandleCollector.RegisterType(nameof(HDC), 100, 2);
+ public static readonly int HDC = HandleCollector.RegisterType(nameof(HDC), 100, 2);
- public static readonly int GDI = HandleCollector.RegisterType(nameof(GDI), 50, 500);
+ public static readonly int GDI = HandleCollector.RegisterType(nameof(GDI), 50, 500);
- public static readonly int Kernel = HandleCollector.RegisterType(nameof(Kernel), 0, 1000);
- }
+ public static readonly int Kernel = HandleCollector.RegisterType(nameof(Kernel), 0, 1000);
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs
index 7c17ce52..c8613ef4 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs
@@ -3,129 +3,128 @@
using System;
using System.Runtime.InteropServices;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal static class HandleCollector
{
- internal static class HandleCollector
+ private static HandleType[] HandleTypes;
+ private static int HandleTypeCount;
+
+ private static readonly object HandleMutex = new();
+
+ internal static IntPtr Add(IntPtr handle, int type)
{
- private static HandleType[] HandleTypes;
- private static int HandleTypeCount;
+ HandleTypes[type - 1].Add();
+ return handle;
+ }
- private static readonly object HandleMutex = new();
+ [System.Security.SecuritySafeCritical]
+ internal static SafeHandle Add(SafeHandle handle, int type)
+ {
+ HandleTypes[type - 1].Add();
+ return handle;
+ }
- internal static IntPtr Add(IntPtr handle, int type)
+ internal static void Add(int type)
+ {
+ HandleTypes[type - 1].Add();
+ }
+
+ internal static int RegisterType(string typeName, int expense, int initialThreshold)
+ {
+ lock (HandleMutex)
{
- HandleTypes[type - 1].Add();
- return handle;
- }
-
- [System.Security.SecuritySafeCritical]
- internal static SafeHandle Add(SafeHandle handle, int type)
- {
- HandleTypes[type - 1].Add();
- return handle;
- }
-
- internal static void Add(int type)
- {
- HandleTypes[type - 1].Add();
- }
-
- internal static int RegisterType(string typeName, int expense, int initialThreshold)
- {
- lock (HandleMutex)
+ if (HandleTypeCount == 0 || HandleTypeCount == HandleTypes.Length)
{
- if (HandleTypeCount == 0 || HandleTypeCount == HandleTypes.Length)
+ HandleType[] newTypes = new HandleType[HandleTypeCount + 10];
+ if (HandleTypes != null)
{
- HandleType[] newTypes = new HandleType[HandleTypeCount + 10];
- if (HandleTypes != null)
- {
- Array.Copy(HandleTypes, 0, newTypes, 0, HandleTypeCount);
- }
- HandleTypes = newTypes;
+ Array.Copy(HandleTypes, 0, newTypes, 0, HandleTypeCount);
}
-
- HandleTypes[HandleTypeCount++] = new HandleType(expense, initialThreshold);
- return HandleTypeCount;
- }
- }
-
- internal static IntPtr Remove(IntPtr handle, int type)
- {
- HandleTypes[type - 1].Remove();
- return handle;
- }
-
- [System.Security.SecuritySafeCritical]
- internal static SafeHandle Remove(SafeHandle handle, int type)
- {
- HandleTypes[type - 1].Remove();
- return handle;
- }
-
- internal static void Remove(int type)
- {
- HandleTypes[type - 1].Remove();
- }
-
- private class HandleType
- {
- private readonly int _initialThreshHold;
- private int _threshHold;
- private int _handleCount;
- private readonly int _deltaPercent;
-
- internal HandleType(int expense, int initialThreshHold)
- {
- _initialThreshHold = initialThreshHold;
- _threshHold = initialThreshHold;
- _deltaPercent = 100 - expense;
+ HandleTypes = newTypes;
}
- internal void Add()
+ HandleTypes[HandleTypeCount++] = new HandleType(expense, initialThreshold);
+ return HandleTypeCount;
+ }
+ }
+
+ internal static IntPtr Remove(IntPtr handle, int type)
+ {
+ HandleTypes[type - 1].Remove();
+ return handle;
+ }
+
+ [System.Security.SecuritySafeCritical]
+ internal static SafeHandle Remove(SafeHandle handle, int type)
+ {
+ HandleTypes[type - 1].Remove();
+ return handle;
+ }
+
+ internal static void Remove(int type)
+ {
+ HandleTypes[type - 1].Remove();
+ }
+
+ private class HandleType
+ {
+ private readonly int _initialThreshHold;
+ private int _threshHold;
+ private int _handleCount;
+ private readonly int _deltaPercent;
+
+ internal HandleType(int expense, int initialThreshHold)
+ {
+ _initialThreshHold = initialThreshHold;
+ _threshHold = initialThreshHold;
+ _deltaPercent = 100 - expense;
+ }
+
+ internal void Add()
+ {
+ lock (this)
{
- lock (this)
+ _handleCount++;
+ var performCollect = NeedCollection();
+
+ if (!performCollect)
{
- _handleCount++;
- var performCollect = NeedCollection();
-
- if (!performCollect)
- {
- return;
- }
+ return;
}
-
- GC.Collect();
-
- var sleep = (100 - _deltaPercent) / 4;
- System.Threading.Thread.Sleep(sleep);
}
- private bool NeedCollection()
+ GC.Collect();
+
+ var sleep = (100 - _deltaPercent) / 4;
+ System.Threading.Thread.Sleep(sleep);
+ }
+
+ private bool NeedCollection()
+ {
+
+ if (_handleCount > _threshHold)
{
-
- if (_handleCount > _threshHold)
- {
- _threshHold = _handleCount + _handleCount * _deltaPercent / 100;
- return true;
- }
-
- var oldThreshHold = 100 * _threshHold / (100 + _deltaPercent);
- if (oldThreshHold >= _initialThreshHold && _handleCount < (int) (oldThreshHold * .9F))
- {
- _threshHold = oldThreshHold;
- }
-
- return false;
+ _threshHold = _handleCount + _handleCount * _deltaPercent / 100;
+ return true;
}
- internal void Remove()
+ var oldThreshHold = 100 * _threshHold / (100 + _deltaPercent);
+ if (oldThreshHold >= _initialThreshHold && _handleCount < (int) (oldThreshHold * .9F))
{
- lock (this)
- {
- _handleCount--;
+ _threshHold = oldThreshHold;
+ }
- _handleCount = Math.Max(0, _handleCount);
- }
+ return false;
+ }
+
+ internal void Remove()
+ {
+ lock (this)
+ {
+ _handleCount--;
+
+ _handleCount = Math.Max(0, _handleCount);
}
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
index 08a19a6e..d59d8338 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
@@ -2,32 +2,31 @@
using System.Runtime.ConstrainedExecution;
using System.Security;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal sealed class IconHandle : WpfSafeHandle
{
- internal sealed class IconHandle : WpfSafeHandle
+ [SecurityCritical]
+ private IconHandle() : base(true, CommonHandles.Icon)
{
- [SecurityCritical]
- private IconHandle() : base(true, CommonHandles.Icon)
- {
- }
+ }
- [SecurityCritical]
- [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
- protected override bool ReleaseHandle()
- {
- return InteropMethods.DestroyIcon(handle);
- }
+ [SecurityCritical]
+ [ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
+ protected override bool ReleaseHandle()
+ {
+ return InteropMethods.DestroyIcon(handle);
+ }
- [SecurityCritical, SecuritySafeCritical]
- internal static IconHandle GetInvalidIcon()
- {
- return new();
- }
+ [SecurityCritical, SecuritySafeCritical]
+ internal static IconHandle GetInvalidIcon()
+ {
+ return new();
+ }
- [SecurityCritical]
- internal IntPtr CriticalGetHandle()
- {
- return handle;
- }
+ [SecurityCritical]
+ internal IntPtr CriticalGetHandle()
+ {
+ return handle;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
index 6aa05d77..4e24b6db 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
@@ -4,47 +4,46 @@ using System.Security;
using System.Security.Permissions;
using Microsoft.Win32.SafeHandles;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
{
- internal sealed class SafeFileMappingHandle : SafeHandleZeroOrMinusOneIsInvalid
+ [SecurityCritical]
+ internal SafeFileMappingHandle(IntPtr handle) : base(false)
{
- [SecurityCritical]
- internal SafeFileMappingHandle(IntPtr handle) : base(false)
- {
- SetHandle(handle);
- }
+ SetHandle(handle);
+ }
+ [SecurityCritical, SecuritySafeCritical]
+ internal SafeFileMappingHandle() : base(true)
+ {
+ }
+
+ public override bool IsInvalid
+ {
[SecurityCritical, SecuritySafeCritical]
- internal SafeFileMappingHandle() : base(true)
- {
- }
+ get => handle == IntPtr.Zero;
+ }
- public override bool IsInvalid
+ [SecurityCritical, SecuritySafeCritical]
+ protected override bool ReleaseHandle()
+ {
+ new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
+ try
{
- [SecurityCritical, SecuritySafeCritical]
- get => handle == IntPtr.Zero;
+ return CloseHandleNoThrow(new HandleRef(null, handle));
}
-
- [SecurityCritical, SecuritySafeCritical]
- protected override bool ReleaseHandle()
+ finally
{
- new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert();
- try
- {
- return CloseHandleNoThrow(new HandleRef(null, handle));
- }
- finally
- {
- CodeAccessPermission.RevertAssert();
- }
- }
-
- [SecurityCritical]
- public static bool CloseHandleNoThrow(HandleRef handle)
- {
- HandleCollector.Remove((IntPtr) handle, CommonHandles.Kernel);
- var result = InteropMethods.IntCloseHandle(handle);
- return result;
+ CodeAccessPermission.RevertAssert();
}
}
+
+ [SecurityCritical]
+ public static bool CloseHandleNoThrow(HandleRef handle)
+ {
+ HandleCollector.Remove((IntPtr) handle, CommonHandles.Kernel);
+ var result = InteropMethods.IntCloseHandle(handle);
+ return result;
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs
index 487751c8..cbdc4768 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs
@@ -1,24 +1,23 @@
using System.Security;
using Microsoft.Win32.SafeHandles;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal abstract class WpfSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
{
- internal abstract class WpfSafeHandle : SafeHandleZeroOrMinusOneIsInvalid
+ private readonly int _collectorId;
+
+ [SecurityCritical]
+ protected WpfSafeHandle(bool ownsHandle, int collectorId) : base(ownsHandle)
{
- private readonly int _collectorId;
+ HandleCollector.Add(collectorId);
+ _collectorId = collectorId;
+ }
- [SecurityCritical]
- protected WpfSafeHandle(bool ownsHandle, int collectorId) : base(ownsHandle)
- {
- HandleCollector.Add(collectorId);
- _collectorId = collectorId;
- }
-
- [SecurityCritical, SecuritySafeCritical]
- protected override void Dispose(bool disposing)
- {
- HandleCollector.Remove(_collectorId);
- base.Dispose(disposing);
- }
+ [SecurityCritical, SecuritySafeCritical]
+ protected override void Dispose(bool disposing)
+ {
+ HandleCollector.Remove(_collectorId);
+ base.Dispose(disposing);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
index 7fc72dd9..4749a44e 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
@@ -11,738 +11,737 @@ using System.Security.Permissions;
using System.Text;
using System.Threading;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal class InteropMethods
{
- internal class InteropMethods
+ #region common
+
+ internal const int E_FAIL = unchecked((int) 0x80004005);
+
+ internal static readonly IntPtr HRGN_NONE = new(-1);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int RegisterWindowMessage(string msg);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
+ int dwSize, out int lpNumberOfBytesRead);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
+ internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.RECT lpBuffer,
+ int dwSize, out int lpNumberOfBytesRead);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
+ internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TRAYDATA lpBuffer,
+ int dwSize, out int lpNumberOfBytesRead);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
+ internal static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern bool AttachThreadInput(in uint currentForegroundWindowThreadId,
+ in uint thisWindowThreadId, bool isAttach);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern IntPtr GetForegroundWindow();
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern IntPtr OpenProcess(InteropValues.ProcessAccess dwDesiredAccess,
+ [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize,
+ InteropValues.AllocationType flAllocationType, InteropValues.MemoryProtection flProtect);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern int CloseHandle(IntPtr hObject);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
+ internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, InteropValues.FreeType dwFreeType);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
+ string lpszWindow);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern bool GetWindowRect(IntPtr hwnd, out InteropValues.RECT lpRect);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
+ internal static extern bool GetCursorPos(out InteropValues.POINT pt);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr GetDesktopWindow();
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool AddClipboardFormatListener(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern bool EnableMenuItem(IntPtr hMenu, int UIDEnabledItem, int uEnable);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
+
+ [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = "DestroyMenu", CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern bool IntDestroyMenu(HandleRef hMenu);
+
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = nameof(GetDC),
+ CharSet = CharSet.Auto)]
+ internal static extern IntPtr IntGetDC(HandleRef hWnd);
+
+ [SecurityCritical]
+ internal static IntPtr GetDC(HandleRef hWnd)
{
- #region common
+ var hDc = IntGetDC(hWnd);
+ if (hDc == IntPtr.Zero) throw new Win32Exception();
- internal const int E_FAIL = unchecked((int) 0x80004005);
+ return HandleCollector.Add(hDc, CommonHandles.HDC);
+ }
- internal static readonly IntPtr HRGN_NONE = new(-1);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = nameof(ReleaseDC), CharSet = CharSet.Auto)]
+ internal static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int RegisterWindowMessage(string msg);
+ [SecurityCritical]
+ internal static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
+ {
+ HandleCollector.Remove((IntPtr) hDC, CommonHandles.HDC);
+ return IntReleaseDC(hWnd, hDC);
+ }
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TBBUTTON lpBuffer,
- int dwSize, out int lpNumberOfBytesRead);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
+ internal static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
- internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.RECT lpBuffer,
- int dwSize, out int lpNumberOfBytesRead);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern int GetSystemMetrics(InteropValues.SM nIndex);
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true)]
- internal static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out InteropValues.TRAYDATA lpBuffer,
- int dwSize, out int lpNumberOfBytesRead);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32, EntryPoint = nameof(DestroyIcon), CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern bool IntDestroyIcon(IntPtr hIcon);
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
+ [SecurityCritical]
+ internal static bool DestroyIcon(IntPtr hIcon)
+ {
+ var result = IntDestroyIcon(hIcon);
+ return result;
+ }
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Gdi32, EntryPoint = nameof(DeleteObject), CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern bool IntDeleteObject(IntPtr hObject);
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern bool AttachThreadInput(in uint currentForegroundWindowThreadId,
- in uint thisWindowThreadId, bool isAttach);
+ [SecurityCritical]
+ internal static bool DeleteObject(IntPtr hObject)
+ {
+ var result = IntDeleteObject(hObject);
+ return result;
+ }
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern IntPtr GetForegroundWindow();
+ [SecurityCritical]
+ internal static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
+ ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
+ {
+ hSection ??= new SafeFileMappingHandle(IntPtr.Zero);
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern IntPtr OpenProcess(InteropValues.ProcessAccess dwDesiredAccess,
- [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
+ var hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset);
+ return hBitmap;
+ }
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize,
- InteropValues.AllocationType flAllocationType, InteropValues.MemoryProtection flProtect);
+ [DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "CloseHandle", CharSet = CharSet.Auto, SetLastError = true)]
+ internal static extern bool IntCloseHandle(HandleRef handle);
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern int CloseHandle(IntPtr hObject);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
+ EntryPoint = nameof(CreateDIBSection))]
+ private static extern BitmapHandle PrivateCreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
+ ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset);
- [DllImport(InteropValues.ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- internal static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, InteropValues.FreeType dwFreeType);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
+ EntryPoint = nameof(CreateIconIndirect))]
+ private static extern IconHandle PrivateCreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
+ InteropValues.ICONINFO iconInfo);
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
+ [SecurityCritical]
+ internal static IconHandle CreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
+ InteropValues.ICONINFO iconInfo)
+ {
+ var hIcon = PrivateCreateIconIndirect(iconInfo);
+ return hIcon;
+ }
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass,
- string lpszWindow);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
+ EntryPoint = nameof(CreateBitmap))]
+ private static extern BitmapHandle PrivateCreateBitmap(int width, int height, int planes, int bitsPerPixel,
+ byte[] lpvBits);
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern bool GetWindowRect(IntPtr hwnd, out InteropValues.RECT lpRect);
+ [SecurityCritical]
+ internal static BitmapHandle CreateBitmap(int width, int height, int planes, int bitsPerPixel, byte[] lpvBits)
+ {
+ var hBitmap = PrivateCreateBitmap(width, height, planes, bitsPerPixel, lpvBits);
+ return hBitmap;
+ }
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern bool GetCursorPos(out InteropValues.POINT pt);
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "GetModuleFileName", CharSet = CharSet.Unicode,
+ SetLastError = true)]
+ private static extern int IntGetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr GetDesktopWindow();
-
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool AddClipboardFormatListener(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern bool EnableMenuItem(IntPtr hMenu, int UIDEnabledItem, int uEnable);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
-
- [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = "DestroyMenu", CharSet = CharSet.Auto)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern bool IntDestroyMenu(HandleRef hMenu);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = nameof(GetDC),
- CharSet = CharSet.Auto)]
- internal static extern IntPtr IntGetDC(HandleRef hWnd);
-
- [SecurityCritical]
- internal static IntPtr GetDC(HandleRef hWnd)
+ [SecurityCritical]
+ internal static string GetModuleFileName(HandleRef hModule)
+ {
+ var buffer = new StringBuilder(InteropValues.Win32Constant.MAX_PATH);
+ while (true)
{
- var hDc = IntGetDC(hWnd);
- if (hDc == IntPtr.Zero) throw new Win32Exception();
+ var size = IntGetModuleFileName(hModule, buffer, buffer.Capacity);
+ if (size == 0) throw new Win32Exception();
- return HandleCollector.Add(hDc, CommonHandles.HDC);
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, EntryPoint = nameof(ReleaseDC), CharSet = CharSet.Auto)]
- internal static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
-
- [SecurityCritical]
- internal static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
- {
- HandleCollector.Remove((IntPtr) hDC, CommonHandles.HDC);
- return IntReleaseDC(hWnd, hDC);
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- internal static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern int GetSystemMetrics(InteropValues.SM nIndex);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32, EntryPoint = nameof(DestroyIcon), CharSet = CharSet.Auto, SetLastError = true)]
- private static extern bool IntDestroyIcon(IntPtr hIcon);
-
- [SecurityCritical]
- internal static bool DestroyIcon(IntPtr hIcon)
- {
- var result = IntDestroyIcon(hIcon);
- return result;
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Gdi32, EntryPoint = nameof(DeleteObject), CharSet = CharSet.Auto, SetLastError = true)]
- private static extern bool IntDeleteObject(IntPtr hObject);
-
- [SecurityCritical]
- internal static bool DeleteObject(IntPtr hObject)
- {
- var result = IntDeleteObject(hObject);
- return result;
- }
-
- [SecurityCritical]
- internal static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
- ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
- {
- hSection ??= new SafeFileMappingHandle(IntPtr.Zero);
-
- var hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset);
- return hBitmap;
- }
-
- [DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "CloseHandle", CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern bool IntCloseHandle(HandleRef handle);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
- EntryPoint = nameof(CreateDIBSection))]
- private static extern BitmapHandle PrivateCreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
- ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
- EntryPoint = nameof(CreateIconIndirect))]
- private static extern IconHandle PrivateCreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
- InteropValues.ICONINFO iconInfo);
-
- [SecurityCritical]
- internal static IconHandle CreateIconIndirect([In] [MarshalAs(UnmanagedType.LPStruct)]
- InteropValues.ICONINFO iconInfo)
- {
- var hIcon = PrivateCreateIconIndirect(iconInfo);
- return hIcon;
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto,
- EntryPoint = nameof(CreateBitmap))]
- private static extern BitmapHandle PrivateCreateBitmap(int width, int height, int planes, int bitsPerPixel,
- byte[] lpvBits);
-
- [SecurityCritical]
- internal static BitmapHandle CreateBitmap(int width, int height, int planes, int bitsPerPixel, byte[] lpvBits)
- {
- var hBitmap = PrivateCreateBitmap(width, height, planes, bitsPerPixel, lpvBits);
- return hBitmap;
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Kernel32, EntryPoint = "GetModuleFileName", CharSet = CharSet.Unicode,
- SetLastError = true)]
- private static extern int IntGetModuleFileName(HandleRef hModule, StringBuilder buffer, int length);
-
- [SecurityCritical]
- internal static string GetModuleFileName(HandleRef hModule)
- {
- var buffer = new StringBuilder(InteropValues.Win32Constant.MAX_PATH);
- while (true)
+ if (size == buffer.Capacity)
{
- var size = IntGetModuleFileName(hModule, buffer, buffer.Capacity);
- if (size == 0) throw new Win32Exception();
-
- if (size == buffer.Capacity)
- {
- buffer.EnsureCapacity(buffer.Capacity * 2);
- continue;
- }
-
- return buffer.ToString();
- }
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
- internal static extern int ExtractIconEx(string szExeFileName, int nIconIndex, out IconHandle phiconLarge,
- out IconHandle phiconSmall, int nIcons);
-
- [DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto)]
- internal static extern int Shell_NotifyIcon(int message, InteropValues.NOTIFYICONDATA pnid);
-
- [SecurityCritical]
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW")]
- internal static extern IntPtr CreateWindowEx(
- int dwExStyle,
- [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
- [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
- int dwStyle,
- int x,
- int y,
- int nWidth,
- int nHeight,
- IntPtr hWndParent,
- IntPtr hMenu,
- IntPtr hInstance,
- IntPtr lpParam);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
- internal static extern short RegisterClass(InteropValues.WNDCLASS4ICON wc);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
-
- [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
- internal static extern bool SetForegroundWindow(IntPtr hWnd);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
-
- [DllImport(InteropValues.ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern IntPtr GetModuleHandle(string lpModuleName);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- internal static extern IntPtr SetWindowsHookEx(int idHook, InteropValues.HookProc lpfn, IntPtr hMod, uint dwThreadId);
-
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- internal static extern IntPtr GetWindowDC(IntPtr window);
-
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
- internal static extern uint GetPixel(IntPtr dc, int x, int y);
-
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- internal static extern int ReleaseDC(IntPtr window, IntPtr dc);
-
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- internal static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
- internal static extern IntPtr GetDC(IntPtr ptr);
-
- [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool GetWindowPlacement(IntPtr hwnd, InteropValues.WINDOWPLACEMENT lpwndpl);
-
- internal static InteropValues.WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
- {
- InteropValues.WINDOWPLACEMENT wINDOWPLACEMENT = new InteropValues.WINDOWPLACEMENT();
- if (GetWindowPlacement(hwnd, wINDOWPLACEMENT))
- {
- return wINDOWPLACEMENT;
- }
- throw new Win32Exception(Marshal.GetLastWin32Error());
- }
-
- internal static int GetXLParam(int lParam) => LoWord(lParam);
-
- internal static int GetYLParam(int lParam) => HiWord(lParam);
-
- internal static int HiWord(int value) => (short) (value >> 16);
-
- internal static int LoWord(int value) => (short) (value & 65535);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool EnumThreadWindows(uint dwThreadId, InteropValues.EnumWindowsProc lpfn, IntPtr lParam);
-
- [DllImport(InteropValues.ExternDll.Gdi32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool DeleteDC(IntPtr hdc);
-
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
- internal static extern IntPtr CreateCompatibleDC(IntPtr hdc);
-
- [DllImport(InteropValues.ExternDll.Gdi32, ExactSpelling = true, SetLastError = true)]
- internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr MonitorFromPoint(InteropValues.POINT pt, int flags);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr GetWindow(IntPtr hwnd, int nCmd);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool IsWindowVisible(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool IsIconic(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool IsZoomed(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, ExactSpelling = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);
-
- internal static System.Windows.Point GetCursorPos()
- {
- var result = default(System.Windows.Point);
- if (GetCursorPos(out var point))
- {
- result.X = point.X;
- result.Y = point.Y;
- }
- return result;
- }
-
- [DllImport(InteropValues.ExternDll.User32)]
- private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
-
- internal static int GetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex) => GetWindowLong(hWnd, (int) nIndex);
-
- internal static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong) => IntPtr.Size == 4
- ? SetWindowLongPtr32(hWnd, nIndex, dwNewLong)
- : SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")]
- internal static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")]
- internal static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
- private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
- private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
-
- internal static IntPtr SetWindowLongPtr(IntPtr hWnd, InteropValues.GWLP nIndex, IntPtr dwNewLong)
- {
- if (IntPtr.Size == 8)
- {
- return SetWindowLongPtr(hWnd, (int) nIndex, dwNewLong);
- }
- return new IntPtr(SetWindowLong(hWnd, (int) nIndex, dwNewLong.ToInt32()));
- }
-
- internal static int SetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex, int dwNewLong) => SetWindowLong(hWnd, (int) nIndex, dwNewLong);
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
- internal static extern ushort RegisterClass(ref InteropValues.WNDCLASS lpWndClass);
-
- [DllImport(InteropValues.ExternDll.Kernel32)]
- internal static extern uint GetCurrentThreadId();
-
- [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool DestroyWindow(IntPtr hwnd);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool UnregisterClass(IntPtr classAtom, IntPtr hInstance);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDest, ref InteropValues.POINT pptDest, ref InteropValues.SIZE psize, IntPtr hdcSrc, ref InteropValues.POINT pptSrc, uint crKey, [In] ref InteropValues.BLENDFUNCTION pblend, uint dwFlags);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, InteropValues.RedrawWindowFlags flags);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, InteropValues.EnumMonitorsDelegate lpfnEnum, IntPtr dwData);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool IntersectRect(out InteropValues.RECT lprcDst, [In] ref InteropValues.RECT lprcSrc1, [In] ref InteropValues.RECT lprcSrc2);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref InteropValues.MONITORINFO monitorInfo);
-
- [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true)]
- [ResourceExposure(ResourceScope.None)]
- public static extern IntPtr MonitorFromRect(ref InteropValues.RECT rect, int flags);
-
- [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
- internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref InteropValues.BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
-
- [DllImport(InteropValues.ExternDll.MsImg)]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, InteropValues.BLENDFUNCTION pfn);
-
- internal static int GET_SC_WPARAM(IntPtr wParam) => (int) wParam & 65520;
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern IntPtr ChildWindowFromPointEx(IntPtr hwndParent, InteropValues.POINT pt, int uFlags);
-
- [DllImport(InteropValues.ExternDll.Gdi32)]
- internal static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int width, int height);
-
- [DllImport(InteropValues.ExternDll.Gdi32)]
- internal static extern bool BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
-
- [DllImport(InteropValues.ExternDll.User32)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern bool EnableWindow(IntPtr hWnd, bool enable);
-
- [DllImport(InteropValues.ExternDll.User32)]
- public static extern bool ShowWindow(IntPtr hwnd, InteropValues.SW nCmdShow);
-
- [ReflectionPermission(SecurityAction.Assert, Unrestricted = true), SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
- internal static object PtrToStructure(IntPtr lparam, Type cls) => Marshal.PtrToStructure(lparam, cls);
-
- [ReflectionPermission(SecurityAction.Assert, Unrestricted = true),
- SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
- internal static void PtrToStructure(IntPtr lparam, object data) => Marshal.PtrToStructure(lparam, data);
-
- [DllImport(InteropValues.ExternDll.Shell32, CallingConvention = CallingConvention.StdCall)]
- internal static extern uint SHAppBarMessage(int dwMessage, ref InteropValues.APPBARDATA pData);
-
- [SecurityCritical]
- [DllImport(InteropValues.ExternDll.DwmApi, EntryPoint = "DwmGetColorizationColor", PreserveSig = true)]
- internal static extern int DwmGetColorizationColor(out uint pcrColorization, out bool pfOpaqueBlend);
-
- [DllImport(InteropValues.ExternDll.DwmApi, ExactSpelling = true, SetLastError = true)]
- internal static extern int DwmSetWindowAttribute(IntPtr hwnd, InteropValues.DwmWindowAttribute dwAttribute,
- in int pvAttribute, uint cbAttribute);
-
- [DllImport(InteropValues.ExternDll.User32, EntryPoint = "GetWindowLong")]
- private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);
-
- [DllImport(InteropValues.ExternDll.User32, EntryPoint = "GetWindowLongPtr")]
- private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
-
- internal static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) =>
- IntPtr.Size == 8 ? GetWindowLongPtr64(hWnd, nIndex) : GetWindowLongPtr32(hWnd, nIndex);
-
- [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref InteropValues.WINDOWPLACEMENT placement);
-
- #endregion
-
- internal class Gdip
- {
- private const string ThreadDataSlotName = "system.drawing.threaddata";
-
- private static IntPtr InitToken;
-
- private static bool Initialized => InitToken != IntPtr.Zero;
-
- internal const int
- Ok = 0,
- GenericError = 1,
- InvalidParameter = 2,
- OutOfMemory = 3,
- ObjectBusy = 4,
- InsufficientBuffer = 5,
- NotImplemented = 6,
- Win32Error = 7,
- WrongState = 8,
- Aborted = 9,
- FileNotFound = 10,
- ValueOverflow = 11,
- AccessDenied = 12,
- UnknownImageFormat = 13,
- FontFamilyNotFound = 14,
- FontStyleNotFound = 15,
- NotTrueTypeFont = 16,
- UnsupportedGdiplusVersion = 17,
- GdiplusNotInitialized = 18,
- PropertyNotFound = 19,
- PropertyNotSupported = 20,
- E_UNEXPECTED = unchecked((int) 0x8000FFFF);
-
- static Gdip()
- {
- Initialize();
+ buffer.EnsureCapacity(buffer.Capacity * 2);
+ continue;
}
- [StructLayout(LayoutKind.Sequential)]
- private struct StartupInput
- {
- private int GdiplusVersion;
-
- private readonly IntPtr DebugEventCallback;
-
- private bool SuppressBackgroundThread;
-
- private bool SuppressExternalCodecs;
-
- public static StartupInput GetDefault()
- {
- var result = new StartupInput
- {
- GdiplusVersion = 1,
- SuppressBackgroundThread = false,
- SuppressExternalCodecs = false
- };
- return result;
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- private readonly struct StartupOutput
- {
- private readonly IntPtr hook;
-
- private readonly IntPtr unhook;
- }
-
- [ResourceExposure(ResourceScope.None)]
- [ResourceConsumption(ResourceScope.AppDomain, ResourceScope.AppDomain)]
- [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
- private static void Initialize()
- {
- var input = StartupInput.GetDefault();
-
- var status = GdiplusStartup(out InitToken, ref input, out _);
-
- if (status != Ok)
- {
- throw StatusException(status);
- }
-
- var currentDomain = AppDomain.CurrentDomain;
- currentDomain.ProcessExit += OnProcessExit;
-
- if (!currentDomain.IsDefaultAppDomain())
- {
- currentDomain.DomainUnload += OnProcessExit;
- }
- }
-
- [PrePrepareMethod]
- [ResourceExposure(ResourceScope.AppDomain)]
- [ResourceConsumption(ResourceScope.AppDomain)]
- private static void OnProcessExit(object sender, EventArgs e) => Shutdown();
-
- [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
- [ResourceExposure(ResourceScope.AppDomain)]
- [ResourceConsumption(ResourceScope.AppDomain)]
- private static void Shutdown()
- {
- if (Initialized)
- {
- ClearThreadData();
- // unhook our shutdown handlers as we do not need to shut down more than once
- var currentDomain = AppDomain.CurrentDomain;
- currentDomain.ProcessExit -= OnProcessExit;
- if (!currentDomain.IsDefaultAppDomain())
- {
- currentDomain.DomainUnload -= OnProcessExit;
- }
- }
- }
-
- [MethodImpl(MethodImplOptions.NoInlining)]
- private static void ClearThreadData()
- {
- var slot = Thread.GetNamedDataSlot(ThreadDataSlotName);
- Thread.SetData(slot, null);
- }
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipImageGetFrameDimensionsCount(HandleRef image, out int count);
-
- internal static Exception StatusException(int status)
- {
- return status switch
- {
- GenericError => new ExternalException("GdiplusGenericError"),
- InvalidParameter => new ArgumentException("GdiplusInvalidParameter"),
- OutOfMemory => new OutOfMemoryException("GdiplusOutOfMemory"),
- ObjectBusy => new InvalidOperationException("GdiplusObjectBusy"),
- InsufficientBuffer => new OutOfMemoryException("GdiplusInsufficientBuffer"),
- NotImplemented => new NotImplementedException("GdiplusNotImplemented"),
- Win32Error => new ExternalException("GdiplusGenericError"),
- WrongState => new InvalidOperationException("GdiplusWrongState"),
- Aborted => new ExternalException("GdiplusAborted"),
- FileNotFound => new FileNotFoundException("GdiplusFileNotFound"),
- ValueOverflow => new OverflowException("GdiplusOverflow"),
- AccessDenied => new ExternalException("GdiplusAccessDenied"),
- UnknownImageFormat => new ArgumentException("GdiplusUnknownImageFormat"),
- PropertyNotFound => new ArgumentException("GdiplusPropertyNotFoundError"),
- PropertyNotSupported => new ArgumentException("GdiplusPropertyNotSupportedError"),
- FontFamilyNotFound => new ArgumentException("GdiplusFontFamilyNotFound"),
- FontStyleNotFound => new ArgumentException("GdiplusFontStyleNotFound"),
- NotTrueTypeFont => new ArgumentException("GdiplusNotTrueTypeFont_NoName"),
- UnsupportedGdiplusVersion => new ExternalException("GdiplusUnsupportedGdiplusVersion"),
- GdiplusNotInitialized => new ExternalException("GdiplusNotInitialized"),
- _ => new ExternalException("GdiplusUnknown")
- };
- }
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipImageGetFrameDimensionsList(HandleRef image, IntPtr buffer, int count);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipImageGetFrameCount(HandleRef image, ref Guid dimensionId, int[] count);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetPropertyItemSize(HandleRef image, int propid, out int size);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetPropertyItem(HandleRef image, int propid, int size, IntPtr buffer);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.Machine)]
- internal static extern int GdipCreateHBITMAPFromBitmap(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipImageSelectActiveFrame(HandleRef image, ref Guid dimensionId, int frameIndex);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.Machine)]
- internal static extern int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipImageForceValidation(HandleRef image);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, EntryPoint = "GdipDisposeImage", CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- private static extern int IntGdipDisposeImage(HandleRef image);
-
- internal static int GdipDisposeImage(HandleRef image)
- {
- if (!Initialized) return Ok;
- var result = IntGdipDisposeImage(image);
- return result;
- }
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.Process)]
- private static extern int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetImageRawFormat(HandleRef image, ref Guid format);
-
- [DllImport(InteropValues.ExternDll.User32)]
- internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref InteropValues.WINCOMPATTRDATA data);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.Machine)]
- internal static extern int GdipCreateBitmapFromStream(InteropValues.IStream stream, out IntPtr bitmap);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.Machine)]
- internal static extern int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetImageEncodersSize(out int numEncoders, out int size);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetImageDecodersSize(out int numDecoders, out int size);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders);
-
- [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
- [ResourceExposure(ResourceScope.None)]
- internal static extern int GdipSaveImageToStream(HandleRef image, InteropValues.IStream stream, ref Guid classId, HandleRef encoderParams);
-
- [DllImport(InteropValues.ExternDll.NTdll)]
- internal static extern int RtlGetVersion(out InteropValues.RTL_OSVERSIONINFOEX lpVersionInformation);
-
+ return buffer.ToString();
}
}
+
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto, BestFitMapping = false, ThrowOnUnmappableChar = true)]
+ internal static extern int ExtractIconEx(string szExeFileName, int nIconIndex, out IconHandle phiconLarge,
+ out IconHandle phiconSmall, int nIcons);
+
+ [DllImport(InteropValues.ExternDll.Shell32, CharSet = CharSet.Auto)]
+ internal static extern int Shell_NotifyIcon(int message, InteropValues.NOTIFYICONDATA pnid);
+
+ [SecurityCritical]
+ [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW")]
+ internal static extern IntPtr CreateWindowEx(
+ int dwExStyle,
+ [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
+ [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName,
+ int dwStyle,
+ int x,
+ int y,
+ int nWidth,
+ int nHeight,
+ IntPtr hWndParent,
+ IntPtr hMenu,
+ IntPtr hInstance,
+ IntPtr lpParam);
+
+ [SecurityCritical]
+ [SuppressUnmanagedCodeSecurity]
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
+ internal static extern short RegisterClass(InteropValues.WNDCLASS4ICON wc);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
+ internal static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ internal static extern bool SetForegroundWindow(IntPtr hWnd);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
+ internal static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
+
+ [DllImport(InteropValues.ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
+ internal static extern IntPtr GetModuleHandle(string lpModuleName);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
+ internal static extern bool UnhookWindowsHookEx(IntPtr hhk);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
+ internal static extern IntPtr SetWindowsHookEx(int idHook, InteropValues.HookProc lpfn, IntPtr hMod, uint dwThreadId);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ internal static extern IntPtr GetWindowDC(IntPtr window);
+
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
+ internal static extern uint GetPixel(IntPtr dc, int x, int y);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ internal static extern int ReleaseDC(IntPtr window, IntPtr dc);
+
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
+ internal static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto)]
+ internal static extern IntPtr GetDC(IntPtr ptr);
+
+ [DllImport(InteropValues.ExternDll.User32, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool GetWindowPlacement(IntPtr hwnd, InteropValues.WINDOWPLACEMENT lpwndpl);
+
+ internal static InteropValues.WINDOWPLACEMENT GetWindowPlacement(IntPtr hwnd)
+ {
+ InteropValues.WINDOWPLACEMENT wINDOWPLACEMENT = InteropValues.WINDOWPLACEMENT.Default;
+ if (GetWindowPlacement(hwnd, wINDOWPLACEMENT))
+ {
+ return wINDOWPLACEMENT;
+ }
+ throw new Win32Exception(Marshal.GetLastWin32Error());
+ }
+
+ internal static int GetXLParam(int lParam) => LoWord(lParam);
+
+ internal static int GetYLParam(int lParam) => HiWord(lParam);
+
+ internal static int HiWord(int value) => (short) (value >> 16);
+
+ internal static int LoWord(int value) => (short) (value & 65535);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool EnumThreadWindows(uint dwThreadId, InteropValues.EnumWindowsProc lpfn, IntPtr lParam);
+
+ [DllImport(InteropValues.ExternDll.Gdi32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool DeleteDC(IntPtr hdc);
+
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
+ internal static extern IntPtr CreateCompatibleDC(IntPtr hdc);
+
+ [DllImport(InteropValues.ExternDll.Gdi32, ExactSpelling = true, SetLastError = true)]
+ internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr MonitorFromPoint(InteropValues.POINT pt, int flags);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr GetWindow(IntPtr hwnd, int nCmd);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool IsWindowVisible(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool IsIconic(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool IsZoomed(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, ExactSpelling = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int flags);
+
+ internal static System.Windows.Point GetCursorPos()
+ {
+ var result = default(System.Windows.Point);
+ if (GetCursorPos(out var point))
+ {
+ result.X = point.X;
+ result.Y = point.Y;
+ }
+ return result;
+ }
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
+
+ internal static int GetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex) => GetWindowLong(hWnd, (int) nIndex);
+
+ internal static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong) => IntPtr.Size == 4
+ ? SetWindowLongPtr32(hWnd, nIndex, dwNewLong)
+ : SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")]
+ internal static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")]
+ internal static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
+ private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
+ private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
+
+ internal static IntPtr SetWindowLongPtr(IntPtr hWnd, InteropValues.GWLP nIndex, IntPtr dwNewLong)
+ {
+ if (IntPtr.Size == 8)
+ {
+ return SetWindowLongPtr(hWnd, (int) nIndex, dwNewLong);
+ }
+ return new IntPtr(SetWindowLong(hWnd, (int) nIndex, dwNewLong.ToInt32()));
+ }
+
+ internal static int SetWindowLong(IntPtr hWnd, InteropValues.GWL nIndex, int dwNewLong) => SetWindowLong(hWnd, (int) nIndex, dwNewLong);
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode)]
+ internal static extern ushort RegisterClass(ref InteropValues.WNDCLASS lpWndClass);
+
+ [DllImport(InteropValues.ExternDll.Kernel32)]
+ internal static extern uint GetCurrentThreadId();
+
+ [DllImport(InteropValues.ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static extern IntPtr CreateWindowEx(int dwExStyle, IntPtr classAtom, string lpWindowName, int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool DestroyWindow(IntPtr hwnd);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool UnregisterClass(IntPtr classAtom, IntPtr hInstance);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDest, ref InteropValues.POINT pptDest, ref InteropValues.SIZE psize, IntPtr hdcSrc, ref InteropValues.POINT pptSrc, uint crKey, [In] ref InteropValues.BLENDFUNCTION pblend, uint dwFlags);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern bool RedrawWindow(IntPtr hWnd, IntPtr lprcUpdate, IntPtr hrgnUpdate, InteropValues.RedrawWindowFlags flags);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr lprcClip, InteropValues.EnumMonitorsDelegate lpfnEnum, IntPtr dwData);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool IntersectRect(out InteropValues.RECT lprcDst, [In] ref InteropValues.RECT lprcSrc1, [In] ref InteropValues.RECT lprcSrc2);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool GetMonitorInfo(IntPtr hMonitor, ref InteropValues.MONITORINFO monitorInfo);
+
+ [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true)]
+ [ResourceExposure(ResourceScope.None)]
+ public static extern IntPtr MonitorFromRect(ref InteropValues.RECT rect, int flags);
+
+ [DllImport(InteropValues.ExternDll.Gdi32, SetLastError = true)]
+ internal static extern IntPtr CreateDIBSection(IntPtr hdc, ref InteropValues.BITMAPINFO pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);
+
+ [DllImport(InteropValues.ExternDll.MsImg)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal static extern bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, InteropValues.BLENDFUNCTION pfn);
+
+ internal static int GET_SC_WPARAM(IntPtr wParam) => (int) wParam & 65520;
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern IntPtr ChildWindowFromPointEx(IntPtr hwndParent, InteropValues.POINT pt, int uFlags);
+
+ [DllImport(InteropValues.ExternDll.Gdi32)]
+ internal static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int width, int height);
+
+ [DllImport(InteropValues.ExternDll.Gdi32)]
+ internal static extern bool BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern bool EnableWindow(IntPtr hWnd, bool enable);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ public static extern bool ShowWindow(IntPtr hwnd, InteropValues.SW nCmdShow);
+
+ [ReflectionPermission(SecurityAction.Assert, Unrestricted = true), SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
+ internal static object PtrToStructure(IntPtr lparam, Type cls) => Marshal.PtrToStructure(lparam, cls);
+
+ [ReflectionPermission(SecurityAction.Assert, Unrestricted = true),
+ SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)]
+ internal static void PtrToStructure(IntPtr lparam, object data) => Marshal.PtrToStructure(lparam, data);
+
+ [DllImport(InteropValues.ExternDll.Shell32, CallingConvention = CallingConvention.StdCall)]
+ internal static extern uint SHAppBarMessage(int dwMessage, ref InteropValues.APPBARDATA pData);
+
+ [SecurityCritical]
+ [DllImport(InteropValues.ExternDll.DwmApi, EntryPoint = "DwmGetColorizationColor", PreserveSig = true)]
+ internal static extern int DwmGetColorizationColor(out uint pcrColorization, out bool pfOpaqueBlend);
+
+ [DllImport(InteropValues.ExternDll.DwmApi, ExactSpelling = true, SetLastError = true)]
+ internal static extern int DwmSetWindowAttribute(IntPtr hwnd, InteropValues.DwmWindowAttribute dwAttribute,
+ in int pvAttribute, uint cbAttribute);
+
+ [DllImport(InteropValues.ExternDll.User32, EntryPoint = "GetWindowLong")]
+ private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);
+
+ [DllImport(InteropValues.ExternDll.User32, EntryPoint = "GetWindowLongPtr")]
+ private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
+
+ internal static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) =>
+ IntPtr.Size == 8 ? GetWindowLongPtr64(hWnd, nIndex) : GetWindowLongPtr32(hWnd, nIndex);
+
+ [DllImport(InteropValues.ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref InteropValues.WINDOWPLACEMENT placement);
+
+ #endregion
+
+ internal class Gdip
+ {
+ private const string ThreadDataSlotName = "system.drawing.threaddata";
+
+ private static IntPtr InitToken;
+
+ private static bool Initialized => InitToken != IntPtr.Zero;
+
+ internal const int
+ Ok = 0,
+ GenericError = 1,
+ InvalidParameter = 2,
+ OutOfMemory = 3,
+ ObjectBusy = 4,
+ InsufficientBuffer = 5,
+ NotImplemented = 6,
+ Win32Error = 7,
+ WrongState = 8,
+ Aborted = 9,
+ FileNotFound = 10,
+ ValueOverflow = 11,
+ AccessDenied = 12,
+ UnknownImageFormat = 13,
+ FontFamilyNotFound = 14,
+ FontStyleNotFound = 15,
+ NotTrueTypeFont = 16,
+ UnsupportedGdiplusVersion = 17,
+ GdiplusNotInitialized = 18,
+ PropertyNotFound = 19,
+ PropertyNotSupported = 20,
+ E_UNEXPECTED = unchecked((int) 0x8000FFFF);
+
+ static Gdip()
+ {
+ Initialize();
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct StartupInput
+ {
+ private int GdiplusVersion;
+
+ private readonly IntPtr DebugEventCallback;
+
+ private bool SuppressBackgroundThread;
+
+ private bool SuppressExternalCodecs;
+
+ public static StartupInput GetDefault()
+ {
+ var result = new StartupInput
+ {
+ GdiplusVersion = 1,
+ SuppressBackgroundThread = false,
+ SuppressExternalCodecs = false
+ };
+ return result;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private readonly struct StartupOutput
+ {
+ private readonly IntPtr hook;
+
+ private readonly IntPtr unhook;
+ }
+
+ [ResourceExposure(ResourceScope.None)]
+ [ResourceConsumption(ResourceScope.AppDomain, ResourceScope.AppDomain)]
+ [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")]
+ private static void Initialize()
+ {
+ var input = StartupInput.GetDefault();
+
+ var status = GdiplusStartup(out InitToken, ref input, out _);
+
+ if (status != Ok)
+ {
+ throw StatusException(status);
+ }
+
+ var currentDomain = AppDomain.CurrentDomain;
+ currentDomain.ProcessExit += OnProcessExit;
+
+ if (!currentDomain.IsDefaultAppDomain())
+ {
+ currentDomain.DomainUnload += OnProcessExit;
+ }
+ }
+
+ [PrePrepareMethod]
+ [ResourceExposure(ResourceScope.AppDomain)]
+ [ResourceConsumption(ResourceScope.AppDomain)]
+ private static void OnProcessExit(object sender, EventArgs e) => Shutdown();
+
+ [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods")]
+ [ResourceExposure(ResourceScope.AppDomain)]
+ [ResourceConsumption(ResourceScope.AppDomain)]
+ private static void Shutdown()
+ {
+ if (Initialized)
+ {
+ ClearThreadData();
+ // unhook our shutdown handlers as we do not need to shut down more than once
+ var currentDomain = AppDomain.CurrentDomain;
+ currentDomain.ProcessExit -= OnProcessExit;
+ if (!currentDomain.IsDefaultAppDomain())
+ {
+ currentDomain.DomainUnload -= OnProcessExit;
+ }
+ }
+ }
+
+ [MethodImpl(MethodImplOptions.NoInlining)]
+ private static void ClearThreadData()
+ {
+ var slot = Thread.GetNamedDataSlot(ThreadDataSlotName);
+ Thread.SetData(slot, null);
+ }
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipImageGetFrameDimensionsCount(HandleRef image, out int count);
+
+ internal static Exception StatusException(int status)
+ {
+ return status switch
+ {
+ GenericError => new ExternalException("GdiplusGenericError"),
+ InvalidParameter => new ArgumentException("GdiplusInvalidParameter"),
+ OutOfMemory => new OutOfMemoryException("GdiplusOutOfMemory"),
+ ObjectBusy => new InvalidOperationException("GdiplusObjectBusy"),
+ InsufficientBuffer => new OutOfMemoryException("GdiplusInsufficientBuffer"),
+ NotImplemented => new NotImplementedException("GdiplusNotImplemented"),
+ Win32Error => new ExternalException("GdiplusGenericError"),
+ WrongState => new InvalidOperationException("GdiplusWrongState"),
+ Aborted => new ExternalException("GdiplusAborted"),
+ FileNotFound => new FileNotFoundException("GdiplusFileNotFound"),
+ ValueOverflow => new OverflowException("GdiplusOverflow"),
+ AccessDenied => new ExternalException("GdiplusAccessDenied"),
+ UnknownImageFormat => new ArgumentException("GdiplusUnknownImageFormat"),
+ PropertyNotFound => new ArgumentException("GdiplusPropertyNotFoundError"),
+ PropertyNotSupported => new ArgumentException("GdiplusPropertyNotSupportedError"),
+ FontFamilyNotFound => new ArgumentException("GdiplusFontFamilyNotFound"),
+ FontStyleNotFound => new ArgumentException("GdiplusFontStyleNotFound"),
+ NotTrueTypeFont => new ArgumentException("GdiplusNotTrueTypeFont_NoName"),
+ UnsupportedGdiplusVersion => new ExternalException("GdiplusUnsupportedGdiplusVersion"),
+ GdiplusNotInitialized => new ExternalException("GdiplusNotInitialized"),
+ _ => new ExternalException("GdiplusUnknown")
+ };
+ }
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipImageGetFrameDimensionsList(HandleRef image, IntPtr buffer, int count);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipImageGetFrameCount(HandleRef image, ref Guid dimensionId, int[] count);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetPropertyItemSize(HandleRef image, int propid, out int size);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetPropertyItem(HandleRef image, int propid, int size, IntPtr buffer);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.Machine)]
+ internal static extern int GdipCreateHBITMAPFromBitmap(HandleRef nativeBitmap, out IntPtr hbitmap, int argbBackground);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipImageSelectActiveFrame(HandleRef image, ref Guid dimensionId, int frameIndex);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.Machine)]
+ internal static extern int GdipCreateBitmapFromFile(string filename, out IntPtr bitmap);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipImageForceValidation(HandleRef image);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, EntryPoint = "GdipDisposeImage", CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ private static extern int IntGdipDisposeImage(HandleRef image);
+
+ internal static int GdipDisposeImage(HandleRef image)
+ {
+ if (!Initialized) return Ok;
+ var result = IntGdipDisposeImage(image);
+ return result;
+ }
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.Process)]
+ private static extern int GdiplusStartup(out IntPtr token, ref StartupInput input, out StartupOutput output);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetImageRawFormat(HandleRef image, ref Guid format);
+
+ [DllImport(InteropValues.ExternDll.User32)]
+ internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref InteropValues.WINCOMPATTRDATA data);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.Machine)]
+ internal static extern int GdipCreateBitmapFromStream(InteropValues.IStream stream, out IntPtr bitmap);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.Machine)]
+ internal static extern int GdipCreateBitmapFromHBITMAP(HandleRef hbitmap, HandleRef hpalette, out IntPtr bitmap);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetImageEncodersSize(out int numEncoders, out int size);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetImageDecodersSize(out int numDecoders, out int size);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetImageDecoders(int numDecoders, int size, IntPtr decoders);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipGetImageEncoders(int numEncoders, int size, IntPtr encoders);
+
+ [DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
+ [ResourceExposure(ResourceScope.None)]
+ internal static extern int GdipSaveImageToStream(HandleRef image, InteropValues.IStream stream, ref Guid classId, HandleRef encoderParams);
+
+ [DllImport(InteropValues.ExternDll.NTdll)]
+ internal static extern int RtlGetVersion(out InteropValues.RTL_OSVERSIONINFOEX lpVersionInformation);
+
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
index 78ef2903..66f055b4 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
@@ -5,1175 +5,1187 @@ using System.Runtime.InteropServices;
using System.Security;
using System.Windows;
-namespace HandyControl.Tools.Interop
+namespace HandyControl.Tools.Interop;
+
+internal class InteropValues
{
- internal class InteropValues
+ internal static class ExternDll
{
- internal static class ExternDll
+ public const string
+ User32 = "user32.dll",
+ Gdi32 = "gdi32.dll",
+ GdiPlus = "gdiplus.dll",
+ Kernel32 = "kernel32.dll",
+ Shell32 = "shell32.dll",
+ MsImg = "msimg32.dll",
+ NTdll = "ntdll.dll",
+ DwmApi = "dwmapi.dll";
+ }
+
+ internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
+
+ internal delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
+
+ [return: MarshalAs(UnmanagedType.Bool)]
+ internal delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData);
+
+ internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
+
+ internal const int
+ BITSPIXEL = 12,
+ PLANES = 14,
+ BI_RGB = 0,
+ DIB_RGB_COLORS = 0,
+ E_FAIL = unchecked((int) 0x80004005),
+ HWND_TOP = 0,
+ GWL_STYLE = -16,
+ NIF_MESSAGE = 0x00000001,
+ NIF_ICON = 0x00000002,
+ NIF_TIP = 0x00000004,
+ NIF_INFO = 0x00000010,
+ NIM_ADD = 0x00000000,
+ NIM_MODIFY = 0x00000001,
+ NIM_DELETE = 0x00000002,
+ NIIF_NONE = 0x00000000,
+ NIIF_INFO = 0x00000001,
+ NIIF_WARNING = 0x00000002,
+ NIIF_ERROR = 0x00000003,
+ WM_ACTIVATE = 0x0006,
+ WM_QUIT = 0x0012,
+ WM_GETMINMAXINFO = 0x0024,
+ WM_WINDOWPOSCHANGING = 0x0046,
+ WM_WINDOWPOSCHANGED = 0x0047,
+ WM_SETICON = 0x0080,
+ WM_NCCREATE = 0x0081,
+ WM_NCDESTROY = 0x0082,
+ WM_NCHITTEST = 0x0084,
+ WM_NCACTIVATE = 0x0086,
+ WM_NCRBUTTONDOWN = 0x00A4,
+ WM_NCRBUTTONUP = 0x00A5,
+ WM_NCRBUTTONDBLCLK = 0x00A6,
+ WM_NCUAHDRAWCAPTION = 0x00AE,
+ WM_NCUAHDRAWFRAME = 0x00AF,
+ WM_KEYDOWN = 0x0100,
+ WM_KEYUP = 0x0101,
+ WM_SYSKEYDOWN = 0x0104,
+ WM_SYSKEYUP = 0x0105,
+ WM_SYSCOMMAND = 0x112,
+ WM_MOUSEMOVE = 0x0200,
+ WM_LBUTTONUP = 0x0202,
+ WM_LBUTTONDBLCLK = 0x0203,
+ WM_RBUTTONUP = 0x0205,
+ WM_ENTERSIZEMOVE = 0x0231,
+ WM_EXITSIZEMOVE = 0x0232,
+ WM_CLIPBOARDUPDATE = 0x031D,
+ WM_USER = 0x0400,
+ WS_VISIBLE = 0x10000000,
+ MF_BYCOMMAND = 0x00000000,
+ MF_BYPOSITION = 0x400,
+ MF_GRAYED = 0x00000001,
+ MF_SEPARATOR = 0x800,
+ TB_GETBUTTON = WM_USER + 23,
+ TB_BUTTONCOUNT = WM_USER + 24,
+ TB_GETITEMRECT = WM_USER + 29,
+ VERTRES = 10,
+ DESKTOPVERTRES = 117,
+ LOGPIXELSX = 88,
+ LOGPIXELSY = 90,
+ SC_CLOSE = 0xF060,
+ SC_SIZE = 0xF000,
+ SC_MOVE = 0xF010,
+ SC_MINIMIZE = 0xF020,
+ SC_MAXIMIZE = 0xF030,
+ SC_RESTORE = 0xF120,
+ SRCCOPY = 0x00CC0020,
+ MONITOR_DEFAULTTOPRIMARY = 0x00000001,
+ MONITOR_DEFAULTTONEAREST = 0x00000002;
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ internal class NOTIFYICONDATA
+ {
+ public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
+ public IntPtr hWnd;
+ public int uID;
+ public int uFlags;
+ public int uCallbackMessage;
+ public IntPtr hIcon;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
+ public string szTip = string.Empty;
+ public int dwState = 0x01;
+ public int dwStateMask = 0x01;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+ public string szInfo = string.Empty;
+ public int uTimeoutOrVersion;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
+ public string szInfoTitle = string.Empty;
+ public int dwInfoFlags;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 1)]
+ internal struct TBBUTTON
+ {
+ public int iBitmap;
+ public int idCommand;
+ public IntPtr fsStateStylePadding;
+ public IntPtr dwData;
+ public IntPtr iString;
+ }
+
+ [Flags]
+ internal enum AllocationType
+ {
+ Commit = 0x1000,
+ Reserve = 0x2000,
+ Decommit = 0x4000,
+ Release = 0x8000,
+ Reset = 0x80000,
+ Physical = 0x400000,
+ TopDown = 0x100000,
+ WriteWatch = 0x200000,
+ LargePages = 0x20000000
+ }
+
+ [Flags]
+ internal enum MemoryProtection
+ {
+ Execute = 0x10,
+ ExecuteRead = 0x20,
+ ExecuteReadWrite = 0x40,
+ ExecuteWriteCopy = 0x80,
+ NoAccess = 0x01,
+ ReadOnly = 0x02,
+ ReadWrite = 0x04,
+ WriteCopy = 0x08,
+ GuardModifierflag = 0x100,
+ NoCacheModifierflag = 0x200,
+ WriteCombineModifierflag = 0x400
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct TRAYDATA
+ {
+ public IntPtr hwnd;
+ public uint uID;
+ public uint uCallbackMessage;
+ public uint bReserved0;
+ public uint bReserved1;
+ public IntPtr hIcon;
+ }
+
+ [Flags]
+ internal enum FreeType
+ {
+ Decommit = 0x4000,
+ Release = 0x8000,
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct POINT
+ {
+ public int X;
+ public int Y;
+
+ public POINT(int x, int y)
{
- public const string
- User32 = "user32.dll",
- Gdi32 = "gdi32.dll",
- GdiPlus = "gdiplus.dll",
- Kernel32 = "kernel32.dll",
- Shell32 = "shell32.dll",
- MsImg = "msimg32.dll",
- NTdll = "ntdll.dll",
- DwmApi = "dwmapi.dll";
- }
-
- internal delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
-
- internal delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
-
- [return: MarshalAs(UnmanagedType.Bool)]
- internal delegate bool EnumMonitorsDelegate(IntPtr hMonitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr dwData);
-
- internal delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
-
- internal const int
- BITSPIXEL = 12,
- PLANES = 14,
- BI_RGB = 0,
- DIB_RGB_COLORS = 0,
- E_FAIL = unchecked((int) 0x80004005),
- HWND_TOP = 0,
- GWL_STYLE = -16,
- NIF_MESSAGE = 0x00000001,
- NIF_ICON = 0x00000002,
- NIF_TIP = 0x00000004,
- NIF_INFO = 0x00000010,
- NIM_ADD = 0x00000000,
- NIM_MODIFY = 0x00000001,
- NIM_DELETE = 0x00000002,
- NIIF_NONE = 0x00000000,
- NIIF_INFO = 0x00000001,
- NIIF_WARNING = 0x00000002,
- NIIF_ERROR = 0x00000003,
- WM_ACTIVATE = 0x0006,
- WM_QUIT = 0x0012,
- WM_GETMINMAXINFO = 0x0024,
- WM_WINDOWPOSCHANGING = 0x0046,
- WM_WINDOWPOSCHANGED = 0x0047,
- WM_SETICON = 0x0080,
- WM_NCCREATE = 0x0081,
- WM_NCDESTROY = 0x0082,
- WM_NCHITTEST = 0x0084,
- WM_NCACTIVATE = 0x0086,
- WM_NCRBUTTONDOWN = 0x00A4,
- WM_NCRBUTTONUP = 0x00A5,
- WM_NCRBUTTONDBLCLK = 0x00A6,
- WM_NCUAHDRAWCAPTION = 0x00AE,
- WM_NCUAHDRAWFRAME = 0x00AF,
- WM_KEYDOWN = 0x0100,
- WM_KEYUP = 0x0101,
- WM_SYSKEYDOWN = 0x0104,
- WM_SYSKEYUP = 0x0105,
- WM_SYSCOMMAND = 0x112,
- WM_MOUSEMOVE = 0x0200,
- WM_LBUTTONUP = 0x0202,
- WM_LBUTTONDBLCLK = 0x0203,
- WM_RBUTTONUP = 0x0205,
- WM_ENTERSIZEMOVE = 0x0231,
- WM_EXITSIZEMOVE = 0x0232,
- WM_CLIPBOARDUPDATE = 0x031D,
- WM_USER = 0x0400,
- WS_VISIBLE = 0x10000000,
- MF_BYCOMMAND = 0x00000000,
- MF_BYPOSITION = 0x400,
- MF_GRAYED = 0x00000001,
- MF_SEPARATOR = 0x800,
- TB_GETBUTTON = WM_USER + 23,
- TB_BUTTONCOUNT = WM_USER + 24,
- TB_GETITEMRECT = WM_USER + 29,
- VERTRES = 10,
- DESKTOPVERTRES = 117,
- LOGPIXELSX = 88,
- LOGPIXELSY = 90,
- SC_CLOSE = 0xF060,
- SC_SIZE = 0xF000,
- SC_MOVE = 0xF010,
- SC_MINIMIZE = 0xF020,
- SC_MAXIMIZE = 0xF030,
- SC_RESTORE = 0xF120,
- SRCCOPY = 0x00CC0020,
- MONITOR_DEFAULTTOPRIMARY = 0x00000001,
- MONITOR_DEFAULTTONEAREST = 0x00000002;
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal class NOTIFYICONDATA
- {
- public int cbSize = Marshal.SizeOf(typeof(NOTIFYICONDATA));
- public IntPtr hWnd;
- public int uID;
- public int uFlags;
- public int uCallbackMessage;
- public IntPtr hIcon;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- public string szTip = string.Empty;
- public int dwState = 0x01;
- public int dwStateMask = 0x01;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
- public string szInfo = string.Empty;
- public int uTimeoutOrVersion;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
- public string szInfoTitle = string.Empty;
- public int dwInfoFlags;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- internal struct TBBUTTON
- {
- public int iBitmap;
- public int idCommand;
- public IntPtr fsStateStylePadding;
- public IntPtr dwData;
- public IntPtr iString;
- }
-
- [Flags]
- internal enum AllocationType
- {
- Commit = 0x1000,
- Reserve = 0x2000,
- Decommit = 0x4000,
- Release = 0x8000,
- Reset = 0x80000,
- Physical = 0x400000,
- TopDown = 0x100000,
- WriteWatch = 0x200000,
- LargePages = 0x20000000
- }
-
- [Flags]
- internal enum MemoryProtection
- {
- Execute = 0x10,
- ExecuteRead = 0x20,
- ExecuteReadWrite = 0x40,
- ExecuteWriteCopy = 0x80,
- NoAccess = 0x01,
- ReadOnly = 0x02,
- ReadWrite = 0x04,
- WriteCopy = 0x08,
- GuardModifierflag = 0x100,
- NoCacheModifierflag = 0x200,
- WriteCombineModifierflag = 0x400
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct TRAYDATA
- {
- public IntPtr hwnd;
- public uint uID;
- public uint uCallbackMessage;
- public uint bReserved0;
- public uint bReserved1;
- public IntPtr hIcon;
- }
-
- [Flags]
- internal enum FreeType
- {
- Decommit = 0x4000,
- Release = 0x8000,
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct POINT
- {
- public int X;
- public int Y;
-
- public POINT(int x, int y)
- {
- X = x;
- Y = y;
- }
- }
-
- internal enum HookType
- {
- WH_KEYBOARD_LL = 13,
- WH_MOUSE_LL = 14
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct MOUSEHOOKSTRUCT
- {
- public POINT pt;
- public IntPtr hwnd;
- public uint wHitTestCode;
- public IntPtr dwExtraInfo;
- }
-
- [Flags]
- internal enum ProcessAccess
- {
- AllAccess = CreateThread | DuplicateHandle | QueryInformation | SetInformation | Terminate | VMOperation | VMRead | VMWrite | Synchronize,
- CreateThread = 0x2,
- DuplicateHandle = 0x40,
- QueryInformation = 0x400,
- SetInformation = 0x200,
- Terminate = 0x1,
- VMOperation = 0x8,
- VMRead = 0x10,
- VMWrite = 0x20,
- Synchronize = 0x100000
- }
-
- [Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal struct RECT
- {
- public int Left;
- public int Top;
- public int Right;
- public int Bottom;
-
- public RECT(int left, int top, int right, int bottom)
- {
- Left = left;
- Top = top;
- Right = right;
- Bottom = bottom;
- }
-
- public RECT(Rect rect)
- {
- Left = (int) rect.Left;
- Top = (int) rect.Top;
- Right = (int) rect.Right;
- Bottom = (int) rect.Bottom;
- }
-
- public Point Position => new(Left, Top);
- public Size Size => new(Width, Height);
-
- public int Height
- {
- get => Bottom - Top;
- set => Bottom = Top + value;
- }
-
- public int Width
- {
- get => Right - Left;
- set => Right = Left + value;
- }
-
- public bool Equals(RECT other)
- {
- return Left == other.Left && Right == other.Right && Top == other.Top && Bottom == other.Bottom;
- }
-
- public override bool Equals(object obj)
- {
- return obj is RECT rectangle && Equals(rectangle);
- }
-
- public static bool operator ==(RECT left, RECT right)
- {
- return left.Equals(right);
- }
-
- public static bool operator !=(RECT left, RECT right)
- {
- return !(left == right);
- }
-
- public override int GetHashCode()
- {
- unchecked
- {
- var hashCode = Left;
- hashCode = (hashCode * 397) ^ Top;
- hashCode = (hashCode * 397) ^ Right;
- hashCode = (hashCode * 397) ^ Bottom;
- return hashCode;
- }
- }
- }
-
- internal struct BLENDFUNCTION
- {
- public byte BlendOp;
- public byte BlendFlags;
- public byte SourceConstantAlpha;
- public byte AlphaFormat;
- }
-
- internal enum GWL
- {
- STYLE = -16,
- EXSTYLE = -20
- }
-
- internal enum GWLP
- {
- WNDPROC = -4,
- HINSTANCE = -6,
- HWNDPARENT = -8,
- USERDATA = -21,
- ID = -12
- }
-
- internal struct BITMAPINFOHEADER
- {
- internal uint biSize;
- internal int biWidth;
- internal int biHeight;
- internal ushort biPlanes;
- internal ushort biBitCount;
- internal uint biCompression;
- internal uint biSizeImage;
- internal int biXPelsPerMeter;
- internal int biYPelsPerMeter;
- internal uint biClrUsed;
- internal uint biClrImportant;
- }
-
- [Flags]
- internal enum RedrawWindowFlags : uint
- {
- Invalidate = 1u,
- InternalPaint = 2u,
- Erase = 4u,
- Validate = 8u,
- NoInternalPaint = 16u,
- NoErase = 32u,
- NoChildren = 64u,
- AllChildren = 128u,
- UpdateNow = 256u,
- EraseNow = 512u,
- Frame = 1024u,
- NoFrame = 2048u
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal class WINDOWPOS
- {
- public IntPtr hwnd;
- public IntPtr hwndInsertAfter;
- public int x;
- public int y;
- public int cx;
- public int cy;
- public uint flags;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct WINDOWPLACEMENT
- {
- public int length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
- public int flags;
- public SW showCmd;
- public POINT ptMinPosition;
- public POINT ptMaxPosition;
- public RECT rcNormalPosition;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 4)]
- internal struct SIZE
- {
- [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
- public int cx;
- [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
- public int cy;
- }
-
- internal struct MONITORINFO
- {
- public uint cbSize;
- public RECT rcMonitor;
- public RECT rcWork;
- public uint dwFlags;
- }
-
- internal enum SM
- {
- CXSCREEN = 0,
- CYSCREEN = 1,
- CXVSCROLL = 2,
- CYHSCROLL = 3,
- CYCAPTION = 4,
- CXBORDER = 5,
- CYBORDER = 6,
- CXFIXEDFRAME = 7,
- CYFIXEDFRAME = 8,
- CYVTHUMB = 9,
- CXHTHUMB = 10,
- CXICON = 11,
- CYICON = 12,
- CXCURSOR = 13,
- CYCURSOR = 14,
- CYMENU = 15,
- CXFULLSCREEN = 16,
- CYFULLSCREEN = 17,
- CYKANJIWINDOW = 18,
- MOUSEPRESENT = 19,
- CYVSCROLL = 20,
- CXHSCROLL = 21,
- DEBUG = 22,
- SWAPBUTTON = 23,
- CXMIN = 28,
- CYMIN = 29,
- CXSIZE = 30,
- CYSIZE = 31,
- CXFRAME = 32,
- CXSIZEFRAME = CXFRAME,
- CYFRAME = 33,
- CYSIZEFRAME = CYFRAME,
- CXMINTRACK = 34,
- CYMINTRACK = 35,
- CXDOUBLECLK = 36,
- CYDOUBLECLK = 37,
- CXICONSPACING = 38,
- CYICONSPACING = 39,
- MENUDROPALIGNMENT = 40,
- PENWINDOWS = 41,
- DBCSENABLED = 42,
- CMOUSEBUTTONS = 43,
- SECURE = 44,
- CXEDGE = 45,
- CYEDGE = 46,
- CXMINSPACING = 47,
- CYMINSPACING = 48,
- CXSMICON = 49,
- CYSMICON = 50,
- CYSMCAPTION = 51,
- CXSMSIZE = 52,
- CYSMSIZE = 53,
- CXMENUSIZE = 54,
- CYMENUSIZE = 55,
- ARRANGE = 56,
- CXMINIMIZED = 57,
- CYMINIMIZED = 58,
- CXMAXTRACK = 59,
- CYMAXTRACK = 60,
- CXMAXIMIZED = 61,
- CYMAXIMIZED = 62,
- NETWORK = 63,
- CLEANBOOT = 67,
- CXDRAG = 68,
- CYDRAG = 69,
- SHOWSOUNDS = 70,
- CXMENUCHECK = 71,
- CYMENUCHECK = 72,
- SLOWMACHINE = 73,
- MIDEASTENABLED = 74,
- MOUSEWHEELPRESENT = 75,
- XVIRTUALSCREEN = 76,
- YVIRTUALSCREEN = 77,
- CXVIRTUALSCREEN = 78,
- CYVIRTUALSCREEN = 79,
- CMONITORS = 80,
- SAMEDISPLAYFORMAT = 81,
- IMMENABLED = 82,
- CXFOCUSBORDER = 83,
- CYFOCUSBORDER = 84,
- TABLETPC = 86,
- MEDIACENTER = 87,
- REMOTESESSION = 0x1000,
- REMOTECONTROL = 0x2001
- }
-
- internal enum CacheSlot
- {
- DpiX,
-
- FocusBorderWidth,
- FocusBorderHeight,
- HighContrast,
- MouseVanish,
-
- DropShadow,
- FlatMenu,
- WorkAreaInternal,
- WorkArea,
-
- IconMetrics,
-
- KeyboardCues,
- KeyboardDelay,
- KeyboardPreference,
- KeyboardSpeed,
- SnapToDefaultButton,
- WheelScrollLines,
- MouseHoverTime,
- MouseHoverHeight,
- MouseHoverWidth,
-
- MenuDropAlignment,
- MenuFade,
- MenuShowDelay,
-
- ComboBoxAnimation,
- ClientAreaAnimation,
- CursorShadow,
- GradientCaptions,
- HotTracking,
- ListBoxSmoothScrolling,
- MenuAnimation,
- SelectionFade,
- StylusHotTracking,
- ToolTipAnimation,
- ToolTipFade,
- UIEffects,
-
- MinimizeAnimation,
- Border,
- CaretWidth,
- ForegroundFlashCount,
- DragFullWindows,
- NonClientMetrics,
-
- ThinHorizontalBorderHeight,
- ThinVerticalBorderWidth,
- CursorWidth,
- CursorHeight,
- ThickHorizontalBorderHeight,
- ThickVerticalBorderWidth,
- MinimumHorizontalDragDistance,
- MinimumVerticalDragDistance,
- FixedFrameHorizontalBorderHeight,
- FixedFrameVerticalBorderWidth,
- FocusHorizontalBorderHeight,
- FocusVerticalBorderWidth,
- FullPrimaryScreenWidth,
- FullPrimaryScreenHeight,
- HorizontalScrollBarButtonWidth,
- HorizontalScrollBarHeight,
- HorizontalScrollBarThumbWidth,
- IconWidth,
- IconHeight,
- IconGridWidth,
- IconGridHeight,
- MaximizedPrimaryScreenWidth,
- MaximizedPrimaryScreenHeight,
- MaximumWindowTrackWidth,
- MaximumWindowTrackHeight,
- MenuCheckmarkWidth,
- MenuCheckmarkHeight,
- MenuButtonWidth,
- MenuButtonHeight,
- MinimumWindowWidth,
- MinimumWindowHeight,
- MinimizedWindowWidth,
- MinimizedWindowHeight,
- MinimizedGridWidth,
- MinimizedGridHeight,
- MinimumWindowTrackWidth,
- MinimumWindowTrackHeight,
- PrimaryScreenWidth,
- PrimaryScreenHeight,
- WindowCaptionButtonWidth,
- WindowCaptionButtonHeight,
- ResizeFrameHorizontalBorderHeight,
- ResizeFrameVerticalBorderWidth,
- SmallIconWidth,
- SmallIconHeight,
- SmallWindowCaptionButtonWidth,
- SmallWindowCaptionButtonHeight,
- VirtualScreenWidth,
- VirtualScreenHeight,
- VerticalScrollBarWidth,
- VerticalScrollBarButtonHeight,
- WindowCaptionHeight,
- KanjiWindowHeight,
- MenuBarHeight,
- VerticalScrollBarThumbHeight,
- IsImmEnabled,
- IsMediaCenter,
- IsMenuDropRightAligned,
- IsMiddleEastEnabled,
- IsMousePresent,
- IsMouseWheelPresent,
- IsPenWindows,
- IsRemotelyControlled,
- IsRemoteSession,
- ShowSounds,
- IsSlowMachine,
- SwapButtons,
- IsTabletPC,
- VirtualScreenLeft,
- VirtualScreenTop,
-
- PowerLineStatus,
-
- IsGlassEnabled,
- UxThemeName,
- UxThemeColor,
- WindowCornerRadius,
- WindowGlassColor,
- WindowGlassBrush,
- WindowNonClientFrameThickness,
- WindowResizeBorderThickness,
-
- NumSlots
- }
-
- internal static class Win32Constant
- {
- internal const int MAX_PATH = 260;
- internal const int INFOTIPSIZE = 1024;
- internal const int TRUE = 1;
- internal const int FALSE = 0;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
- internal struct WNDCLASS
- {
- public uint style;
- public Delegate lpfnWndProc;
- public int cbClsExtra;
- public int cbWndExtra;
- public IntPtr hInstance;
- public IntPtr hIcon;
- public IntPtr hCursor;
- public IntPtr hbrBackground;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string lpszMenuName;
- [MarshalAs(UnmanagedType.LPWStr)]
- public string lpszClassName;
- }
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- internal class WNDCLASS4ICON
- {
- public int style;
- public WndProc lpfnWndProc;
- public int cbClsExtra;
- public int cbWndExtra;
- public IntPtr hInstance;
- public IntPtr hIcon;
- public IntPtr hCursor;
- public IntPtr hbrBackground;
- public string lpszMenuName;
- public string lpszClassName;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- internal struct BITMAPINFO
- {
- public int biSize;
-
- public int biWidth;
-
- public int biHeight;
-
- public short biPlanes;
-
- public short biBitCount;
-
- public int biCompression;
-
- public int biSizeImage;
-
- public int biXPelsPerMeter;
-
- public int biYPelsPerMeter;
-
- public int biClrUsed;
-
- public int biClrImportant;
-
- public BITMAPINFO(int width, int height, short bpp)
- {
- biSize = SizeOf();
- biWidth = width;
- biHeight = height;
- biPlanes = 1;
- biBitCount = bpp;
- biCompression = 0;
- biSizeImage = 0;
- biXPelsPerMeter = 0;
- biYPelsPerMeter = 0;
- biClrUsed = 0;
- biClrImportant = 0;
- }
-
- [SecuritySafeCritical]
- private static int SizeOf()
- {
- return Marshal.SizeOf(typeof(BITMAPINFO));
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal class ICONINFO
- {
- public bool fIcon = false;
- public int xHotspot = 0;
- public int yHotspot = 0;
- public BitmapHandle hbmMask = null;
- public BitmapHandle hbmColor = null;
- }
-
- internal enum WINDOWCOMPOSITIONATTRIB
- {
- WCA_ACCENT_POLICY = 19
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct WINCOMPATTRDATA
- {
- public WINDOWCOMPOSITIONATTRIB Attribute;
- public IntPtr Data;
- public int DataSize;
- }
-
- internal enum ACCENTSTATE
- {
- ACCENT_DISABLED = 0,
- ACCENT_ENABLE_GRADIENT = 1,
- ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
- ACCENT_ENABLE_BLURBEHIND = 3,
- ACCENT_ENABLE_ACRYLICBLURBEHIND = 4,
- ACCENT_INVALID_STATE = 5
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct ACCENTPOLICY
- {
- public ACCENTSTATE AccentState;
- public int AccentFlags;
- public uint GradientColor;
- public int AnimationId;
- }
-
- [ComImport, Guid("0000000C-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
- internal interface IStream
- {
- int Read([In] IntPtr buf, [In] int len);
-
- int Write([In] IntPtr buf, [In] int len);
-
- [return: MarshalAs(UnmanagedType.I8)]
- long Seek([In, MarshalAs(UnmanagedType.I8)] long dlibMove, [In] int dwOrigin);
-
- void SetSize([In, MarshalAs(UnmanagedType.I8)] long libNewSize);
-
- [return: MarshalAs(UnmanagedType.I8)]
- long CopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.I8)] long cb, [Out, MarshalAs(UnmanagedType.LPArray)] long[] pcbRead);
-
- void Commit([In] int grfCommitFlags);
-
- void Revert();
-
- void LockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
-
- void UnlockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
-
- void Stat([In] IntPtr pStatstg, [In] int grfStatFlag);
-
- [return: MarshalAs(UnmanagedType.Interface)]
- IStream Clone();
- }
-
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal class StreamConsts
- {
- public const int LOCK_WRITE = 0x1;
- public const int LOCK_EXCLUSIVE = 0x2;
- public const int LOCK_ONLYONCE = 0x4;
- public const int STATFLAG_DEFAULT = 0x0;
- public const int STATFLAG_NONAME = 0x1;
- public const int STATFLAG_NOOPEN = 0x2;
- public const int STGC_DEFAULT = 0x0;
- public const int STGC_OVERWRITE = 0x1;
- public const int STGC_ONLYIFCURRENT = 0x2;
- public const int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 0x4;
- public const int STREAM_SEEK_SET = 0x0;
- public const int STREAM_SEEK_CUR = 0x1;
- public const int STREAM_SEEK_END = 0x2;
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 8)]
- internal class ImageCodecInfoPrivate
- {
- [MarshalAs(UnmanagedType.Struct)]
- public Guid Clsid;
- [MarshalAs(UnmanagedType.Struct)]
- public Guid FormatID;
-
- public IntPtr CodecName = IntPtr.Zero;
- public IntPtr DllName = IntPtr.Zero;
- public IntPtr FormatDescription = IntPtr.Zero;
- public IntPtr FilenameExtension = IntPtr.Zero;
- public IntPtr MimeType = IntPtr.Zero;
-
- public int Flags;
- public int Version;
- public int SigCount;
- public int SigSize;
-
- public IntPtr SigPattern = IntPtr.Zero;
- public IntPtr SigMask = IntPtr.Zero;
- }
-
- internal class ComStreamFromDataStream : IStream
- {
- protected Stream DataStream;
-
- // to support seeking ahead of the stream length...
- private long _virtualPosition = -1;
-
- internal ComStreamFromDataStream(Stream dataStream)
- {
- this.DataStream = dataStream ?? throw new ArgumentNullException(nameof(dataStream));
- }
-
- private void ActualizeVirtualPosition()
- {
- if (_virtualPosition == -1) return;
-
- if (_virtualPosition > DataStream.Length)
- DataStream.SetLength(_virtualPosition);
-
- DataStream.Position = _virtualPosition;
-
- _virtualPosition = -1;
- }
-
- public virtual IStream Clone()
- {
- NotImplemented();
- return null;
- }
-
- public virtual void Commit(int grfCommitFlags)
- {
- DataStream.Flush();
- ActualizeVirtualPosition();
- }
-
- public virtual long CopyTo(IStream pstm, long cb, long[] pcbRead)
- {
- const int bufsize = 4096; // one page
- var buffer = Marshal.AllocHGlobal(bufsize);
- if (buffer == IntPtr.Zero) throw new OutOfMemoryException();
- long written = 0;
-
- try
- {
- while (written < cb)
- {
- var toRead = bufsize;
- if (written + toRead > cb) toRead = (int) (cb - written);
- var read = Read(buffer, toRead);
- if (read == 0) break;
- if (pstm.Write(buffer, read) != read)
- {
- throw EFail("Wrote an incorrect number of bytes");
- }
- written += read;
- }
- }
- finally
- {
- Marshal.FreeHGlobal(buffer);
- }
- if (pcbRead != null && pcbRead.Length > 0)
- {
- pcbRead[0] = written;
- }
-
- return written;
- }
-
- public virtual Stream GetDataStream() => DataStream;
-
- public virtual void LockRegion(long libOffset, long cb, int dwLockType)
- {
- }
-
- protected static ExternalException EFail(string msg) => throw new ExternalException(msg, E_FAIL);
-
- protected static void NotImplemented() => throw new NotImplementedException();
-
- public virtual int Read(IntPtr buf, int length)
- {
- var buffer = new byte[length];
- var count = Read(buffer, length);
- Marshal.Copy(buffer, 0, buf, length);
- return count;
- }
-
- public virtual int Read(byte[] buffer, int length)
- {
- ActualizeVirtualPosition();
- return DataStream.Read(buffer, 0, length);
- }
-
- public virtual void Revert() => NotImplemented();
-
- public virtual long Seek(long offset, int origin)
- {
- var pos = _virtualPosition;
- if (_virtualPosition == -1)
- {
- pos = DataStream.Position;
- }
- var len = DataStream.Length;
-
- switch (origin)
- {
- case StreamConsts.STREAM_SEEK_SET:
- if (offset <= len)
- {
- DataStream.Position = offset;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = offset;
- }
- break;
- case StreamConsts.STREAM_SEEK_END:
- if (offset <= 0)
- {
- DataStream.Position = len + offset;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = len + offset;
- }
- break;
- case StreamConsts.STREAM_SEEK_CUR:
- if (offset + pos <= len)
- {
- DataStream.Position = pos + offset;
- _virtualPosition = -1;
- }
- else
- {
- _virtualPosition = offset + pos;
- }
- break;
- }
-
- return _virtualPosition != -1 ? _virtualPosition : DataStream.Position;
- }
-
- public virtual void SetSize(long value) => DataStream.SetLength(value);
-
- public virtual void Stat(IntPtr pstatstg, int grfStatFlag) => NotImplemented();
-
- public virtual void UnlockRegion(long libOffset, long cb, int dwLockType)
- {
- }
-
- public virtual int Write(IntPtr buf, int length)
- {
- var buffer = new byte[length];
- Marshal.Copy(buf, buffer, 0, length);
- return Write(buffer, length);
- }
-
- public virtual int Write(byte[] buffer, int length)
- {
- ActualizeVirtualPosition();
- DataStream.Write(buffer, 0, length);
- return length;
- }
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal class MINMAXINFO
- {
- public POINT ptReserved;
- public POINT ptMaxSize;
- public POINT ptMaxPosition;
- public POINT ptMinTrackSize;
- public POINT ptMaxTrackSize;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct APPBARDATA
- {
- public int cbSize;
- public IntPtr hWnd;
- public uint uCallbackMessage;
- public uint uEdge;
- public RECT rc;
- public int lParam;
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct RTL_OSVERSIONINFOEX
- {
- internal uint dwOSVersionInfoSize;
- internal uint dwMajorVersion;
- internal uint dwMinorVersion;
- internal uint dwBuildNumber;
- internal uint dwPlatformId;
- [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
- internal string szCSDVersion;
- }
-
- [Flags]
- internal enum WindowPositionFlags
- {
- ///
- /// If the calling thread and the thread that owns the window are attached to different input queues, the system posts
- /// the request to the thread that owns the window. This prevents the calling thread from blocking its execution while
- /// other threads process the request.
- ///
- SWP_ASYNCWINDOWPOS = 0x4000,
-
- ///
- /// Prevents generation of the WM_SYNCPAINT message.
- ///
- SWP_DEFERERASE = 0x2000,
-
- ///
- /// Draws a frame (defined in the window's class description) around the window.
- ///
- SWP_DRAWFRAME = 0x0020,
-
- ///
- /// 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,
-
- ///
- /// Hides the window.
- ///
- SWP_HIDEWINDOW = 0x0080,
-
- ///
- /// 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,
-
- ///
- /// Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client
- /// area are saved and copied back into the client area after the window is sized or repositioned.
- ///
- SWP_NOCOPYBITS = 0x0100,
-
- ///
- /// Retains the current position (ignores X and Y parameters).
- ///
- SWP_NOMOVE = 0x0002,
-
- ///
- /// Does not change the owner window's position in the Z order.
- ///
- SWP_NOOWNERZORDER = 0x0200,
-
- ///
- /// 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,
-
- ///
- /// Same as the SWP_NOOWNERZORDER flag.
- ///
- SWP_NOREPOSITION = 0x0200,
-
- ///
- /// Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
- ///
- SWP_NOSENDCHANGING = 0x0400,
-
- ///
- /// Retains the current size (ignores the cx and cy parameters).
- ///
- SWP_NOSIZE = 0x0001,
-
- ///
- /// Retains the current Z order (ignores the hWndInsertAfter parameter).
- ///
- SWP_NOZORDER = 0x0004,
-
- ///
- /// Displays the window.
- ///
- SWP_SHOWWINDOW = 0x0040
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct WindowPosition
- {
- public IntPtr Hwnd;
- public IntPtr HwndZOrderInsertAfter;
- public int X;
- public int Y;
- public int Width;
- public int Height;
- public WindowPositionFlags Flags;
- }
-
- [Flags]
- internal enum DwmWindowAttribute : uint
- {
- DWMWA_NCRENDERING_ENABLED = 1,
- DWMWA_NCRENDERING_POLICY,
- DWMWA_TRANSITIONS_FORCEDISABLED,
- DWMWA_ALLOW_NCPAINT,
- DWMWA_CAPTION_BUTTON_BOUNDS,
- DWMWA_NONCLIENT_RTL_LAYOUT,
- DWMWA_FORCE_ICONIC_REPRESENTATION,
- DWMWA_FLIP3D_POLICY,
- DWMWA_EXTENDED_FRAME_BOUNDS,
- DWMWA_HAS_ICONIC_BITMAP,
- DWMWA_DISALLOW_PEEK,
- DWMWA_EXCLUDED_FROM_PEEK,
- DWMWA_LAST
- }
-
- [Flags]
- internal enum WindowStyles
- {
- ///
- /// The window is initially maximized.
- ///
- WS_MAXIMIZE = 0x01000000,
-
- ///
- /// 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 is initially minimized. Same as the WS_ICONIC style.
- ///
- WS_MINIMIZE = 0x20000000,
-
- ///
- /// The window has a sizing border. Same as the WS_SIZEBOX style.
- ///
- WS_THICKFRAME = 0x00040000,
- }
-
- ///
- /// ShowWindow options
- ///
- internal enum SW
- {
- HIDE = 0,
- SHOWNORMAL = 1,
- NORMAL = 1,
- SHOWMINIMIZED = 2,
- SHOWMAXIMIZED = 3,
- MAXIMIZE = 3,
- SHOWNOACTIVATE = 4,
- SHOW = 5,
- MINIMIZE = 6,
- SHOWMINNOACTIVE = 7,
- SHOWNA = 8,
- RESTORE = 9,
- SHOWDEFAULT = 10,
- FORCEMINIMIZE = 11,
+ X = x;
+ Y = y;
}
}
+
+ internal enum HookType
+ {
+ WH_KEYBOARD_LL = 13,
+ WH_MOUSE_LL = 14
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct MOUSEHOOKSTRUCT
+ {
+ public POINT pt;
+ public IntPtr hwnd;
+ public uint wHitTestCode;
+ public IntPtr dwExtraInfo;
+ }
+
+ [Flags]
+ internal enum ProcessAccess
+ {
+ AllAccess = CreateThread | DuplicateHandle | QueryInformation | SetInformation | Terminate | VMOperation | VMRead | VMWrite | Synchronize,
+ CreateThread = 0x2,
+ DuplicateHandle = 0x40,
+ QueryInformation = 0x400,
+ SetInformation = 0x200,
+ Terminate = 0x1,
+ VMOperation = 0x8,
+ VMRead = 0x10,
+ VMWrite = 0x20,
+ Synchronize = 0x100000
+ }
+
+ [Serializable, StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ internal struct RECT
+ {
+ public int Left;
+ public int Top;
+ public int Right;
+ public int Bottom;
+
+ public RECT(int left, int top, int right, int bottom)
+ {
+ Left = left;
+ Top = top;
+ Right = right;
+ Bottom = bottom;
+ }
+
+ public RECT(Rect rect)
+ {
+ Left = (int) rect.Left;
+ Top = (int) rect.Top;
+ Right = (int) rect.Right;
+ Bottom = (int) rect.Bottom;
+ }
+
+ public Point Position => new(Left, Top);
+ public Size Size => new(Width, Height);
+
+ public int Height
+ {
+ get => Bottom - Top;
+ set => Bottom = Top + value;
+ }
+
+ public int Width
+ {
+ get => Right - Left;
+ set => Right = Left + value;
+ }
+
+ public bool Equals(RECT other)
+ {
+ return Left == other.Left && Right == other.Right && Top == other.Top && Bottom == other.Bottom;
+ }
+
+ public override bool Equals(object obj)
+ {
+ return obj is RECT rectangle && Equals(rectangle);
+ }
+
+ public static bool operator ==(RECT left, RECT right)
+ {
+ return left.Equals(right);
+ }
+
+ public static bool operator !=(RECT left, RECT right)
+ {
+ return !(left == right);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ var hashCode = Left;
+ hashCode = (hashCode * 397) ^ Top;
+ hashCode = (hashCode * 397) ^ Right;
+ hashCode = (hashCode * 397) ^ Bottom;
+ return hashCode;
+ }
+ }
+ }
+
+ internal struct BLENDFUNCTION
+ {
+ public byte BlendOp;
+ public byte BlendFlags;
+ public byte SourceConstantAlpha;
+ public byte AlphaFormat;
+ }
+
+ internal enum GWL
+ {
+ STYLE = -16,
+ EXSTYLE = -20
+ }
+
+ internal enum GWLP
+ {
+ WNDPROC = -4,
+ HINSTANCE = -6,
+ HWNDPARENT = -8,
+ USERDATA = -21,
+ ID = -12
+ }
+
+ internal struct BITMAPINFOHEADER
+ {
+ internal uint biSize;
+ internal int biWidth;
+ internal int biHeight;
+ internal ushort biPlanes;
+ internal ushort biBitCount;
+ internal uint biCompression;
+ internal uint biSizeImage;
+ internal int biXPelsPerMeter;
+ internal int biYPelsPerMeter;
+ internal uint biClrUsed;
+ internal uint biClrImportant;
+ }
+
+ [Flags]
+ internal enum RedrawWindowFlags : uint
+ {
+ Invalidate = 1u,
+ InternalPaint = 2u,
+ Erase = 4u,
+ Validate = 8u,
+ NoInternalPaint = 16u,
+ NoErase = 32u,
+ NoChildren = 64u,
+ AllChildren = 128u,
+ UpdateNow = 256u,
+ EraseNow = 512u,
+ Frame = 1024u,
+ NoFrame = 2048u
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal class WINDOWPOS
+ {
+ public IntPtr hwnd;
+ public IntPtr hwndInsertAfter;
+ public int x;
+ public int y;
+ public int cx;
+ public int cy;
+ public uint flags;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WINDOWPLACEMENT
+ {
+ public int length;
+ public int flags;
+ public SW showCmd;
+ public POINT ptMinPosition;
+ public POINT ptMaxPosition;
+ public RECT rcNormalPosition;
+
+ ///
+ /// Gets the default (empty) value.
+ ///
+ public static WINDOWPLACEMENT Default
+ {
+ get
+ {
+ WINDOWPLACEMENT result = new WINDOWPLACEMENT();
+ result.length = Marshal.SizeOf(result);
+ return result;
+ }
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 4)]
+ internal struct SIZE
+ {
+ [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
+ public int cx;
+ [ComAliasName("Microsoft.VisualStudio.OLE.Interop.LONG")]
+ public int cy;
+ }
+
+ internal struct MONITORINFO
+ {
+ public uint cbSize;
+ public RECT rcMonitor;
+ public RECT rcWork;
+ public uint dwFlags;
+ }
+
+ internal enum SM
+ {
+ CXSCREEN = 0,
+ CYSCREEN = 1,
+ CXVSCROLL = 2,
+ CYHSCROLL = 3,
+ CYCAPTION = 4,
+ CXBORDER = 5,
+ CYBORDER = 6,
+ CXFIXEDFRAME = 7,
+ CYFIXEDFRAME = 8,
+ CYVTHUMB = 9,
+ CXHTHUMB = 10,
+ CXICON = 11,
+ CYICON = 12,
+ CXCURSOR = 13,
+ CYCURSOR = 14,
+ CYMENU = 15,
+ CXFULLSCREEN = 16,
+ CYFULLSCREEN = 17,
+ CYKANJIWINDOW = 18,
+ MOUSEPRESENT = 19,
+ CYVSCROLL = 20,
+ CXHSCROLL = 21,
+ DEBUG = 22,
+ SWAPBUTTON = 23,
+ CXMIN = 28,
+ CYMIN = 29,
+ CXSIZE = 30,
+ CYSIZE = 31,
+ CXFRAME = 32,
+ CXSIZEFRAME = CXFRAME,
+ CYFRAME = 33,
+ CYSIZEFRAME = CYFRAME,
+ CXMINTRACK = 34,
+ CYMINTRACK = 35,
+ CXDOUBLECLK = 36,
+ CYDOUBLECLK = 37,
+ CXICONSPACING = 38,
+ CYICONSPACING = 39,
+ MENUDROPALIGNMENT = 40,
+ PENWINDOWS = 41,
+ DBCSENABLED = 42,
+ CMOUSEBUTTONS = 43,
+ SECURE = 44,
+ CXEDGE = 45,
+ CYEDGE = 46,
+ CXMINSPACING = 47,
+ CYMINSPACING = 48,
+ CXSMICON = 49,
+ CYSMICON = 50,
+ CYSMCAPTION = 51,
+ CXSMSIZE = 52,
+ CYSMSIZE = 53,
+ CXMENUSIZE = 54,
+ CYMENUSIZE = 55,
+ ARRANGE = 56,
+ CXMINIMIZED = 57,
+ CYMINIMIZED = 58,
+ CXMAXTRACK = 59,
+ CYMAXTRACK = 60,
+ CXMAXIMIZED = 61,
+ CYMAXIMIZED = 62,
+ NETWORK = 63,
+ CLEANBOOT = 67,
+ CXDRAG = 68,
+ CYDRAG = 69,
+ SHOWSOUNDS = 70,
+ CXMENUCHECK = 71,
+ CYMENUCHECK = 72,
+ SLOWMACHINE = 73,
+ MIDEASTENABLED = 74,
+ MOUSEWHEELPRESENT = 75,
+ XVIRTUALSCREEN = 76,
+ YVIRTUALSCREEN = 77,
+ CXVIRTUALSCREEN = 78,
+ CYVIRTUALSCREEN = 79,
+ CMONITORS = 80,
+ SAMEDISPLAYFORMAT = 81,
+ IMMENABLED = 82,
+ CXFOCUSBORDER = 83,
+ CYFOCUSBORDER = 84,
+ TABLETPC = 86,
+ MEDIACENTER = 87,
+ REMOTESESSION = 0x1000,
+ REMOTECONTROL = 0x2001
+ }
+
+ internal enum CacheSlot
+ {
+ DpiX,
+
+ FocusBorderWidth,
+ FocusBorderHeight,
+ HighContrast,
+ MouseVanish,
+
+ DropShadow,
+ FlatMenu,
+ WorkAreaInternal,
+ WorkArea,
+
+ IconMetrics,
+
+ KeyboardCues,
+ KeyboardDelay,
+ KeyboardPreference,
+ KeyboardSpeed,
+ SnapToDefaultButton,
+ WheelScrollLines,
+ MouseHoverTime,
+ MouseHoverHeight,
+ MouseHoverWidth,
+
+ MenuDropAlignment,
+ MenuFade,
+ MenuShowDelay,
+
+ ComboBoxAnimation,
+ ClientAreaAnimation,
+ CursorShadow,
+ GradientCaptions,
+ HotTracking,
+ ListBoxSmoothScrolling,
+ MenuAnimation,
+ SelectionFade,
+ StylusHotTracking,
+ ToolTipAnimation,
+ ToolTipFade,
+ UIEffects,
+
+ MinimizeAnimation,
+ Border,
+ CaretWidth,
+ ForegroundFlashCount,
+ DragFullWindows,
+ NonClientMetrics,
+
+ ThinHorizontalBorderHeight,
+ ThinVerticalBorderWidth,
+ CursorWidth,
+ CursorHeight,
+ ThickHorizontalBorderHeight,
+ ThickVerticalBorderWidth,
+ MinimumHorizontalDragDistance,
+ MinimumVerticalDragDistance,
+ FixedFrameHorizontalBorderHeight,
+ FixedFrameVerticalBorderWidth,
+ FocusHorizontalBorderHeight,
+ FocusVerticalBorderWidth,
+ FullPrimaryScreenWidth,
+ FullPrimaryScreenHeight,
+ HorizontalScrollBarButtonWidth,
+ HorizontalScrollBarHeight,
+ HorizontalScrollBarThumbWidth,
+ IconWidth,
+ IconHeight,
+ IconGridWidth,
+ IconGridHeight,
+ MaximizedPrimaryScreenWidth,
+ MaximizedPrimaryScreenHeight,
+ MaximumWindowTrackWidth,
+ MaximumWindowTrackHeight,
+ MenuCheckmarkWidth,
+ MenuCheckmarkHeight,
+ MenuButtonWidth,
+ MenuButtonHeight,
+ MinimumWindowWidth,
+ MinimumWindowHeight,
+ MinimizedWindowWidth,
+ MinimizedWindowHeight,
+ MinimizedGridWidth,
+ MinimizedGridHeight,
+ MinimumWindowTrackWidth,
+ MinimumWindowTrackHeight,
+ PrimaryScreenWidth,
+ PrimaryScreenHeight,
+ WindowCaptionButtonWidth,
+ WindowCaptionButtonHeight,
+ ResizeFrameHorizontalBorderHeight,
+ ResizeFrameVerticalBorderWidth,
+ SmallIconWidth,
+ SmallIconHeight,
+ SmallWindowCaptionButtonWidth,
+ SmallWindowCaptionButtonHeight,
+ VirtualScreenWidth,
+ VirtualScreenHeight,
+ VerticalScrollBarWidth,
+ VerticalScrollBarButtonHeight,
+ WindowCaptionHeight,
+ KanjiWindowHeight,
+ MenuBarHeight,
+ VerticalScrollBarThumbHeight,
+ IsImmEnabled,
+ IsMediaCenter,
+ IsMenuDropRightAligned,
+ IsMiddleEastEnabled,
+ IsMousePresent,
+ IsMouseWheelPresent,
+ IsPenWindows,
+ IsRemotelyControlled,
+ IsRemoteSession,
+ ShowSounds,
+ IsSlowMachine,
+ SwapButtons,
+ IsTabletPC,
+ VirtualScreenLeft,
+ VirtualScreenTop,
+
+ PowerLineStatus,
+
+ IsGlassEnabled,
+ UxThemeName,
+ UxThemeColor,
+ WindowCornerRadius,
+ WindowGlassColor,
+ WindowGlassBrush,
+ WindowNonClientFrameThickness,
+ WindowResizeBorderThickness,
+
+ NumSlots
+ }
+
+ internal static class Win32Constant
+ {
+ internal const int MAX_PATH = 260;
+ internal const int INFOTIPSIZE = 1024;
+ internal const int TRUE = 1;
+ internal const int FALSE = 0;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ internal struct WNDCLASS
+ {
+ public uint style;
+ public Delegate lpfnWndProc;
+ public int cbClsExtra;
+ public int cbWndExtra;
+ public IntPtr hInstance;
+ public IntPtr hIcon;
+ public IntPtr hCursor;
+ public IntPtr hbrBackground;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszMenuName;
+ [MarshalAs(UnmanagedType.LPWStr)]
+ public string lpszClassName;
+ }
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ internal class WNDCLASS4ICON
+ {
+ public int style;
+ public WndProc lpfnWndProc;
+ public int cbClsExtra;
+ public int cbWndExtra;
+ public IntPtr hInstance;
+ public IntPtr hIcon;
+ public IntPtr hCursor;
+ public IntPtr hbrBackground;
+ public string lpszMenuName;
+ public string lpszClassName;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 2)]
+ internal struct BITMAPINFO
+ {
+ public int biSize;
+
+ public int biWidth;
+
+ public int biHeight;
+
+ public short biPlanes;
+
+ public short biBitCount;
+
+ public int biCompression;
+
+ public int biSizeImage;
+
+ public int biXPelsPerMeter;
+
+ public int biYPelsPerMeter;
+
+ public int biClrUsed;
+
+ public int biClrImportant;
+
+ public BITMAPINFO(int width, int height, short bpp)
+ {
+ biSize = SizeOf();
+ biWidth = width;
+ biHeight = height;
+ biPlanes = 1;
+ biBitCount = bpp;
+ biCompression = 0;
+ biSizeImage = 0;
+ biXPelsPerMeter = 0;
+ biYPelsPerMeter = 0;
+ biClrUsed = 0;
+ biClrImportant = 0;
+ }
+
+ [SecuritySafeCritical]
+ private static int SizeOf()
+ {
+ return Marshal.SizeOf(typeof(BITMAPINFO));
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal class ICONINFO
+ {
+ public bool fIcon = false;
+ public int xHotspot = 0;
+ public int yHotspot = 0;
+ public BitmapHandle hbmMask = null;
+ public BitmapHandle hbmColor = null;
+ }
+
+ internal enum WINDOWCOMPOSITIONATTRIB
+ {
+ WCA_ACCENT_POLICY = 19
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WINCOMPATTRDATA
+ {
+ public WINDOWCOMPOSITIONATTRIB Attribute;
+ public IntPtr Data;
+ public int DataSize;
+ }
+
+ internal enum ACCENTSTATE
+ {
+ ACCENT_DISABLED = 0,
+ ACCENT_ENABLE_GRADIENT = 1,
+ ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
+ ACCENT_ENABLE_BLURBEHIND = 3,
+ ACCENT_ENABLE_ACRYLICBLURBEHIND = 4,
+ ACCENT_INVALID_STATE = 5
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct ACCENTPOLICY
+ {
+ public ACCENTSTATE AccentState;
+ public int AccentFlags;
+ public uint GradientColor;
+ public int AnimationId;
+ }
+
+ [ComImport, Guid("0000000C-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ internal interface IStream
+ {
+ int Read([In] IntPtr buf, [In] int len);
+
+ int Write([In] IntPtr buf, [In] int len);
+
+ [return: MarshalAs(UnmanagedType.I8)]
+ long Seek([In, MarshalAs(UnmanagedType.I8)] long dlibMove, [In] int dwOrigin);
+
+ void SetSize([In, MarshalAs(UnmanagedType.I8)] long libNewSize);
+
+ [return: MarshalAs(UnmanagedType.I8)]
+ long CopyTo([In, MarshalAs(UnmanagedType.Interface)] IStream pstm, [In, MarshalAs(UnmanagedType.I8)] long cb, [Out, MarshalAs(UnmanagedType.LPArray)] long[] pcbRead);
+
+ void Commit([In] int grfCommitFlags);
+
+ void Revert();
+
+ void LockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
+
+ void UnlockRegion([In, MarshalAs(UnmanagedType.I8)] long libOffset, [In, MarshalAs(UnmanagedType.I8)] long cb, [In] int dwLockType);
+
+ void Stat([In] IntPtr pStatstg, [In] int grfStatFlag);
+
+ [return: MarshalAs(UnmanagedType.Interface)]
+ IStream Clone();
+ }
+
+ [SuppressMessage("ReSharper", "InconsistentNaming")]
+ internal class StreamConsts
+ {
+ public const int LOCK_WRITE = 0x1;
+ public const int LOCK_EXCLUSIVE = 0x2;
+ public const int LOCK_ONLYONCE = 0x4;
+ public const int STATFLAG_DEFAULT = 0x0;
+ public const int STATFLAG_NONAME = 0x1;
+ public const int STATFLAG_NOOPEN = 0x2;
+ public const int STGC_DEFAULT = 0x0;
+ public const int STGC_OVERWRITE = 0x1;
+ public const int STGC_ONLYIFCURRENT = 0x2;
+ public const int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 0x4;
+ public const int STREAM_SEEK_SET = 0x0;
+ public const int STREAM_SEEK_CUR = 0x1;
+ public const int STREAM_SEEK_END = 0x2;
+ }
+
+ [StructLayout(LayoutKind.Sequential, Pack = 8)]
+ internal class ImageCodecInfoPrivate
+ {
+ [MarshalAs(UnmanagedType.Struct)]
+ public Guid Clsid;
+ [MarshalAs(UnmanagedType.Struct)]
+ public Guid FormatID;
+
+ public IntPtr CodecName = IntPtr.Zero;
+ public IntPtr DllName = IntPtr.Zero;
+ public IntPtr FormatDescription = IntPtr.Zero;
+ public IntPtr FilenameExtension = IntPtr.Zero;
+ public IntPtr MimeType = IntPtr.Zero;
+
+ public int Flags;
+ public int Version;
+ public int SigCount;
+ public int SigSize;
+
+ public IntPtr SigPattern = IntPtr.Zero;
+ public IntPtr SigMask = IntPtr.Zero;
+ }
+
+ internal class ComStreamFromDataStream : IStream
+ {
+ protected Stream DataStream;
+
+ // to support seeking ahead of the stream length...
+ private long _virtualPosition = -1;
+
+ internal ComStreamFromDataStream(Stream dataStream)
+ {
+ this.DataStream = dataStream ?? throw new ArgumentNullException(nameof(dataStream));
+ }
+
+ private void ActualizeVirtualPosition()
+ {
+ if (_virtualPosition == -1) return;
+
+ if (_virtualPosition > DataStream.Length)
+ DataStream.SetLength(_virtualPosition);
+
+ DataStream.Position = _virtualPosition;
+
+ _virtualPosition = -1;
+ }
+
+ public virtual IStream Clone()
+ {
+ NotImplemented();
+ return null;
+ }
+
+ public virtual void Commit(int grfCommitFlags)
+ {
+ DataStream.Flush();
+ ActualizeVirtualPosition();
+ }
+
+ public virtual long CopyTo(IStream pstm, long cb, long[] pcbRead)
+ {
+ const int bufsize = 4096; // one page
+ var buffer = Marshal.AllocHGlobal(bufsize);
+ if (buffer == IntPtr.Zero) throw new OutOfMemoryException();
+ long written = 0;
+
+ try
+ {
+ while (written < cb)
+ {
+ var toRead = bufsize;
+ if (written + toRead > cb) toRead = (int) (cb - written);
+ var read = Read(buffer, toRead);
+ if (read == 0) break;
+ if (pstm.Write(buffer, read) != read)
+ {
+ throw EFail("Wrote an incorrect number of bytes");
+ }
+ written += read;
+ }
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(buffer);
+ }
+ if (pcbRead != null && pcbRead.Length > 0)
+ {
+ pcbRead[0] = written;
+ }
+
+ return written;
+ }
+
+ public virtual Stream GetDataStream() => DataStream;
+
+ public virtual void LockRegion(long libOffset, long cb, int dwLockType)
+ {
+ }
+
+ protected static ExternalException EFail(string msg) => throw new ExternalException(msg, E_FAIL);
+
+ protected static void NotImplemented() => throw new NotImplementedException();
+
+ public virtual int Read(IntPtr buf, int length)
+ {
+ var buffer = new byte[length];
+ var count = Read(buffer, length);
+ Marshal.Copy(buffer, 0, buf, length);
+ return count;
+ }
+
+ public virtual int Read(byte[] buffer, int length)
+ {
+ ActualizeVirtualPosition();
+ return DataStream.Read(buffer, 0, length);
+ }
+
+ public virtual void Revert() => NotImplemented();
+
+ public virtual long Seek(long offset, int origin)
+ {
+ var pos = _virtualPosition;
+ if (_virtualPosition == -1)
+ {
+ pos = DataStream.Position;
+ }
+ var len = DataStream.Length;
+
+ switch (origin)
+ {
+ case StreamConsts.STREAM_SEEK_SET:
+ if (offset <= len)
+ {
+ DataStream.Position = offset;
+ _virtualPosition = -1;
+ }
+ else
+ {
+ _virtualPosition = offset;
+ }
+ break;
+ case StreamConsts.STREAM_SEEK_END:
+ if (offset <= 0)
+ {
+ DataStream.Position = len + offset;
+ _virtualPosition = -1;
+ }
+ else
+ {
+ _virtualPosition = len + offset;
+ }
+ break;
+ case StreamConsts.STREAM_SEEK_CUR:
+ if (offset + pos <= len)
+ {
+ DataStream.Position = pos + offset;
+ _virtualPosition = -1;
+ }
+ else
+ {
+ _virtualPosition = offset + pos;
+ }
+ break;
+ }
+
+ return _virtualPosition != -1 ? _virtualPosition : DataStream.Position;
+ }
+
+ public virtual void SetSize(long value) => DataStream.SetLength(value);
+
+ public virtual void Stat(IntPtr pstatstg, int grfStatFlag) => NotImplemented();
+
+ public virtual void UnlockRegion(long libOffset, long cb, int dwLockType)
+ {
+ }
+
+ public virtual int Write(IntPtr buf, int length)
+ {
+ var buffer = new byte[length];
+ Marshal.Copy(buf, buffer, 0, length);
+ return Write(buffer, length);
+ }
+
+ public virtual int Write(byte[] buffer, int length)
+ {
+ ActualizeVirtualPosition();
+ DataStream.Write(buffer, 0, length);
+ return length;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal class MINMAXINFO
+ {
+ public POINT ptReserved;
+ public POINT ptMaxSize;
+ public POINT ptMaxPosition;
+ public POINT ptMinTrackSize;
+ public POINT ptMaxTrackSize;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct APPBARDATA
+ {
+ public int cbSize;
+ public IntPtr hWnd;
+ public uint uCallbackMessage;
+ public uint uEdge;
+ public RECT rc;
+ public int lParam;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct RTL_OSVERSIONINFOEX
+ {
+ internal uint dwOSVersionInfoSize;
+ internal uint dwMajorVersion;
+ internal uint dwMinorVersion;
+ internal uint dwBuildNumber;
+ internal uint dwPlatformId;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
+ internal string szCSDVersion;
+ }
+
+ [Flags]
+ internal enum WindowPositionFlags
+ {
+ ///
+ /// If the calling thread and the thread that owns the window are attached to different input queues, the system posts
+ /// the request to the thread that owns the window. This prevents the calling thread from blocking its execution while
+ /// other threads process the request.
+ ///
+ SWP_ASYNCWINDOWPOS = 0x4000,
+
+ ///
+ /// Prevents generation of the WM_SYNCPAINT message.
+ ///
+ SWP_DEFERERASE = 0x2000,
+
+ ///
+ /// Draws a frame (defined in the window's class description) around the window.
+ ///
+ SWP_DRAWFRAME = 0x0020,
+
+ ///
+ /// 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,
+
+ ///
+ /// Hides the window.
+ ///
+ SWP_HIDEWINDOW = 0x0080,
+
+ ///
+ /// 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,
+
+ ///
+ /// Discards the entire contents of the client area. If this flag is not specified, the valid contents of the client
+ /// area are saved and copied back into the client area after the window is sized or repositioned.
+ ///
+ SWP_NOCOPYBITS = 0x0100,
+
+ ///
+ /// Retains the current position (ignores X and Y parameters).
+ ///
+ SWP_NOMOVE = 0x0002,
+
+ ///
+ /// Does not change the owner window's position in the Z order.
+ ///
+ SWP_NOOWNERZORDER = 0x0200,
+
+ ///
+ /// 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,
+
+ ///
+ /// Same as the SWP_NOOWNERZORDER flag.
+ ///
+ SWP_NOREPOSITION = 0x0200,
+
+ ///
+ /// Prevents the window from receiving the WM_WINDOWPOSCHANGING message.
+ ///
+ SWP_NOSENDCHANGING = 0x0400,
+
+ ///
+ /// Retains the current size (ignores the cx and cy parameters).
+ ///
+ SWP_NOSIZE = 0x0001,
+
+ ///
+ /// Retains the current Z order (ignores the hWndInsertAfter parameter).
+ ///
+ SWP_NOZORDER = 0x0004,
+
+ ///
+ /// Displays the window.
+ ///
+ SWP_SHOWWINDOW = 0x0040
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct WindowPosition
+ {
+ public IntPtr Hwnd;
+ public IntPtr HwndZOrderInsertAfter;
+ public int X;
+ public int Y;
+ public int Width;
+ public int Height;
+ public WindowPositionFlags Flags;
+ }
+
+ [Flags]
+ internal enum DwmWindowAttribute : uint
+ {
+ DWMWA_NCRENDERING_ENABLED = 1,
+ DWMWA_NCRENDERING_POLICY,
+ DWMWA_TRANSITIONS_FORCEDISABLED,
+ DWMWA_ALLOW_NCPAINT,
+ DWMWA_CAPTION_BUTTON_BOUNDS,
+ DWMWA_NONCLIENT_RTL_LAYOUT,
+ DWMWA_FORCE_ICONIC_REPRESENTATION,
+ DWMWA_FLIP3D_POLICY,
+ DWMWA_EXTENDED_FRAME_BOUNDS,
+ DWMWA_HAS_ICONIC_BITMAP,
+ DWMWA_DISALLOW_PEEK,
+ DWMWA_EXCLUDED_FROM_PEEK,
+ DWMWA_LAST
+ }
+
+ [Flags]
+ internal enum WindowStyles
+ {
+ ///
+ /// The window is initially maximized.
+ ///
+ WS_MAXIMIZE = 0x01000000,
+
+ ///
+ /// 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 is initially minimized. Same as the WS_ICONIC style.
+ ///
+ WS_MINIMIZE = 0x20000000,
+
+ ///
+ /// The window has a sizing border. Same as the WS_SIZEBOX style.
+ ///
+ WS_THICKFRAME = 0x00040000,
+ }
+
+ ///
+ /// ShowWindow options
+ ///
+ internal enum SW
+ {
+ HIDE = 0,
+ SHOWNORMAL = 1,
+ NORMAL = 1,
+ SHOWMINIMIZED = 2,
+ SHOWMAXIMIZED = 3,
+ MAXIMIZE = 3,
+ SHOWNOACTIVATE = 4,
+ SHOW = 5,
+ MINIMIZE = 6,
+ SHOWMINNOACTIVE = 7,
+ SHOWNA = 8,
+ RESTORE = 9,
+ SHOWDEFAULT = 10,
+ FORCEMINIMIZE = 11,
+ }
}
diff --git a/src/Shared/HandyControl_Shared/Tools/RegexJudgment.cs b/src/Shared/HandyControl_Shared/Tools/RegexJudgment.cs
index 0c1c4321..7c8d479d 100644
--- a/src/Shared/HandyControl_Shared/Tools/RegexJudgment.cs
+++ b/src/Shared/HandyControl_Shared/Tools/RegexJudgment.cs
@@ -2,96 +2,95 @@
using System.Text.RegularExpressions;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 包含一些正则验证操作
+///
+public static class RegexJudgment
{
+ private static readonly RegexPatterns RegexPatterns = new();
+
///
- /// 包含一些正则验证操作
+ /// 判断字符串格式是否符合某种要求
///
- public static class RegexJudgment
+ /// 需要判断的字符串
+ /// 正则表达式
+ ///
+ public static bool IsKindOf(this string str, string pattern)
{
- private static readonly RegexPatterns RegexPatterns = new();
+ return Regex.IsMatch(str, pattern);
+ }
- ///
- /// 判断字符串格式是否符合某种要求
- ///
- /// 需要判断的字符串
- /// 正则表达式
- ///
- public static bool IsKindOf(this string str, string pattern)
- {
- return Regex.IsMatch(str, pattern);
- }
+ ///
+ /// 判断字符串是否满足指定的格式
+ ///
+ /// 需要判断的字符串
+ /// 指定格式的文本
+ ///
+ public static bool IsKindOf(this string text, TextType textType)
+ {
+ if (textType == TextType.Common) return true;
+ return Regex.IsMatch(text,
+ RegexPatterns.GetValue(Enum.GetName(typeof(TextType), textType) + "Pattern").ToString());
+ }
- ///
- /// 判断字符串是否满足指定的格式
- ///
- /// 需要判断的字符串
- /// 指定格式的文本
- ///
- public static bool IsKindOf(this string text, TextType textType)
- {
- if (textType == TextType.Common) return true;
- return Regex.IsMatch(text,
- RegexPatterns.GetValue(Enum.GetName(typeof(TextType), textType) + "Pattern").ToString());
- }
+ ///
+ /// 判断字符串格式是否为电子邮件
+ ///
+ /// 需要判断的Email字符串
+ /// 方法返回布尔值
+ public static bool IsEmail(this string email)
+ {
+ return Regex.IsMatch(email, RegexPatterns.MailPattern);
+ }
- ///
- /// 判断字符串格式是否为电子邮件
- ///
- /// 需要判断的Email字符串
- /// 方法返回布尔值
- public static bool IsEmail(this string email)
+ ///
+ /// 判断字符串格式是否为指定类型的IP地址
+ ///
+ /// 需要判断的IP字符串
+ /// 指定的IP类型
+ /// 方法返回布尔值
+ public static bool IsIp(this string ip, IpType ipType)
+ {
+ return ipType switch
{
- return Regex.IsMatch(email, RegexPatterns.MailPattern);
- }
+ IpType.A => Regex.IsMatch(ip, RegexPatterns.IpAPattern),
+ IpType.B => Regex.IsMatch(ip, RegexPatterns.IpBPattern),
+ IpType.C => Regex.IsMatch(ip, RegexPatterns.IpCPattern),
+ IpType.D => Regex.IsMatch(ip, RegexPatterns.IpDPattern),
+ IpType.E => Regex.IsMatch(ip, RegexPatterns.IpEPattern),
+ _ => false
+ };
+ }
- ///
- /// 判断字符串格式是否为指定类型的IP地址
- ///
- /// 需要判断的IP字符串
- /// 指定的IP类型
- /// 方法返回布尔值
- public static bool IsIp(this string ip, IpType ipType)
- {
- return ipType switch
- {
- IpType.A => Regex.IsMatch(ip, RegexPatterns.IpAPattern),
- IpType.B => Regex.IsMatch(ip, RegexPatterns.IpBPattern),
- IpType.C => Regex.IsMatch(ip, RegexPatterns.IpCPattern),
- IpType.D => Regex.IsMatch(ip, RegexPatterns.IpDPattern),
- IpType.E => Regex.IsMatch(ip, RegexPatterns.IpEPattern),
- _ => false
- };
- }
+ ///
+ /// 判断字符串格式是否为IP地址
+ ///
+ /// 需要判断的IP字符串
+ /// 方法返回布尔值
+ public static bool IsIp(this string ip)
+ {
+ return Regex.IsMatch(ip, RegexPatterns.IpPattern);
+ }
- ///
- /// 判断字符串格式是否为IP地址
- ///
- /// 需要判断的IP字符串
- /// 方法返回布尔值
- public static bool IsIp(this string ip)
- {
- return Regex.IsMatch(ip, RegexPatterns.IpPattern);
- }
+ ///
+ /// 判断字符串格式是否为单个汉字
+ ///
+ /// 需要判断的单个汉字字符串
+ /// 方法返回布尔值
+ public static bool IsChinese(this string str)
+ {
+ return Regex.IsMatch(str, RegexPatterns.ChinesePattern);
+ }
- ///
- /// 判断字符串格式是否为单个汉字
- ///
- /// 需要判断的单个汉字字符串
- /// 方法返回布尔值
- public static bool IsChinese(this string str)
- {
- return Regex.IsMatch(str, RegexPatterns.ChinesePattern);
- }
-
- ///
- /// 判断字符串格式是否为url
- ///
- /// 需要判断的url字符串
- /// 方法返回布尔值
- public static bool IsUrl(this string str)
- {
- return Regex.IsMatch(str, RegexPatterns.UrlPattern);
- }
+ ///
+ /// 判断字符串格式是否为url
+ ///
+ /// 需要判断的url字符串
+ /// 方法返回布尔值
+ public static bool IsUrl(this string str)
+ {
+ return Regex.IsMatch(str, RegexPatterns.UrlPattern);
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/RegexPatterns.cs b/src/Shared/HandyControl_Shared/Tools/RegexPatterns.cs
index 9b105780..b01ecb95 100644
--- a/src/Shared/HandyControl_Shared/Tools/RegexPatterns.cs
+++ b/src/Shared/HandyControl_Shared/Tools/RegexPatterns.cs
@@ -1,151 +1,150 @@
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+///
+/// 包含一些正则验证所需要的字符串
+///
+public sealed class RegexPatterns
{
///
- /// 包含一些正则验证所需要的字符串
+ /// 邮件正则匹配表达式
///
- public sealed class RegexPatterns
- {
- ///
- /// 邮件正则匹配表达式
- ///
- public const string MailPattern =
- @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
+ public const string MailPattern =
+ @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
- ///
- /// 手机号正则匹配表达式
- ///
- public const string PhonePattern = @"^((13[0-9])|(15[^4,\d])|(18[0,5-9]))\d{8}$";
+ ///
+ /// 手机号正则匹配表达式
+ ///
+ public const string PhonePattern = @"^((13[0-9])|(15[^4,\d])|(18[0,5-9]))\d{8}$";
- ///
- /// IP正则匹配
- ///
- public const string IpPattern =
- @"^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// IP正则匹配
+ ///
+ public const string IpPattern =
+ @"^(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// A类IP正则匹配
- ///
- public const string IpAPattern =
- @"^(12[0-6]|1[0-1]\d|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// A类IP正则匹配
+ ///
+ public const string IpAPattern =
+ @"^(12[0-6]|1[0-1]\d|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// B类IP正则匹配
- ///
- public const string IpBPattern =
- @"^(19[0-1]|12[8-9]|1[3-8]\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// B类IP正则匹配
+ ///
+ public const string IpBPattern =
+ @"^(19[0-1]|12[8-9]|1[3-8]\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// C类IP正则匹配
- ///
- public const string IpCPattern =
- @"^(19[2-9]|22[0-3]|2[0-1]\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// C类IP正则匹配
+ ///
+ public const string IpCPattern =
+ @"^(19[2-9]|22[0-3]|2[0-1]\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// D类IP正则匹配
- ///
- public const string IpDPattern =
- @"^(22[4-9]|23\d\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// D类IP正则匹配
+ ///
+ public const string IpDPattern =
+ @"^(22[4-9]|23\d\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// E类IP正则匹配
- ///
- public const string IpEPattern =
- @"^(25[0-5]|24\d\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
- + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
+ ///
+ /// E类IP正则匹配
+ ///
+ public const string IpEPattern =
+ @"^(25[0-5]|24\d\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)\."
+ + @"(25[0-5]|2[0-4]\d|1\d{2}|[1-9]?\d)$";
- ///
- /// 汉字正则匹配
- ///
- public const string ChinesePattern = @"^[\u4e00-\u9fa5]$";
+ ///
+ /// 汉字正则匹配
+ ///
+ public const string ChinesePattern = @"^[\u4e00-\u9fa5]$";
- ///
- /// Url正则匹配
- ///
- public const string UrlPattern =
- @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?";
+ ///
+ /// Url正则匹配
+ ///
+ public const string UrlPattern =
+ @"((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?";
- ///
- /// 数字正则匹配
- ///
- public const string NumberPattern = @"^\d+$";
+ ///
+ /// 数字正则匹配
+ ///
+ public const string NumberPattern = @"^\d+$";
- ///
- /// 计算性质数字正则匹配
- ///
- public const string DigitsPattern = @"[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?";
+ ///
+ /// 计算性质数字正则匹配
+ ///
+ public const string DigitsPattern = @"[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?";
- ///
- /// 正整数正则匹配
- ///
- public const string PIntPattern = @"^[1-9]\d*$";
+ ///
+ /// 正整数正则匹配
+ ///
+ public const string PIntPattern = @"^[1-9]\d*$";
- ///
- /// 负整数正则匹配
- ///
- public const string NIntPattern = @"^-[1-9]\d*$ ";
+ ///
+ /// 负整数正则匹配
+ ///
+ public const string NIntPattern = @"^-[1-9]\d*$ ";
- ///
- /// 整数正则匹配
- ///
- public const string IntPattern = @"^-?[1-9]\d*|0$";
+ ///
+ /// 整数正则匹配
+ ///
+ public const string IntPattern = @"^-?[1-9]\d*|0$";
- ///
- /// 非负整数正则匹配
- ///
- public const string NnIntPattern = @"^[1-9]\d*|0$";
+ ///
+ /// 非负整数正则匹配
+ ///
+ public const string NnIntPattern = @"^[1-9]\d*|0$";
- ///
- /// 非正整数正则匹配
- ///
- public const string NpIntPattern = @"^-[1-9]\d*|0$";
+ ///
+ /// 非正整数正则匹配
+ ///
+ public const string NpIntPattern = @"^-[1-9]\d*|0$";
- ///
- /// 正浮点数正则匹配
- ///
- public const string PDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$";
+ ///
+ /// 正浮点数正则匹配
+ ///
+ public const string PDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$";
- ///
- /// 负浮点数正则匹配
- ///
- public const string NDoublePattern = @"^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$";
+ ///
+ /// 负浮点数正则匹配
+ ///
+ public const string NDoublePattern = @"^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$";
- ///
- /// 浮点数正则匹配
- ///
- public const string DoublePattern = @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$";
+ ///
+ /// 浮点数正则匹配
+ ///
+ public const string DoublePattern = @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$";
- ///
- /// 非负浮点数正则匹配
- ///
- public const string NnDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$";
+ ///
+ /// 非负浮点数正则匹配
+ ///
+ public const string NnDoublePattern = @"^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$";
- ///
- /// 非正浮点数正则匹配
- ///
- public const string NpDoublePattern = @"^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$";
+ ///
+ /// 非正浮点数正则匹配
+ ///
+ public const string NpDoublePattern = @"^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$";
- ///
- /// 根据属性名称使用反射来获取值
- ///
- ///
- ///
- public object GetValue(string propertyName) => GetType().GetField(propertyName).GetValue(null);
- }
+ ///
+ /// 根据属性名称使用反射来获取值
+ ///
+ ///
+ ///
+ public object GetValue(string propertyName) => GetType().GetField(propertyName).GetValue(null);
}
diff --git a/src/Shared/HandyControl_Shared/Tools/StyleSelector/ButtonGroupItemStyleSelector.cs b/src/Shared/HandyControl_Shared/Tools/StyleSelector/ButtonGroupItemStyleSelector.cs
index 7877494b..6dca25eb 100644
--- a/src/Shared/HandyControl_Shared/Tools/StyleSelector/ButtonGroupItemStyleSelector.cs
+++ b/src/Shared/HandyControl_Shared/Tools/StyleSelector/ButtonGroupItemStyleSelector.cs
@@ -1,112 +1,121 @@
using System.Collections.Generic;
+using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using HandyControl.Controls;
using HandyControl.Data;
-namespace HandyControl.Tools
+namespace HandyControl.Tools;
+
+public class ButtonGroupItemStyleSelector : StyleSelector
{
- public class ButtonGroupItemStyleSelector : StyleSelector
+ private static readonly Dictionary StyleDict = new()
{
- private static readonly Dictionary StyleDict = new()
+ [ResourceToken.RadioGroupItemSingle] = ResourceHelper.GetResourceInternal