diff --git a/README.md b/README.md
index c7f5735d..b644e505 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,8 @@
+
+
## Backers
@@ -48,6 +50,9 @@
+
+
+
## Special thanks to
@@ -93,6 +98,18 @@ Step 4:enjoy coding
## Latest examples
+### GlowWindow
+
+
+
+### FlowDocumentScrollViewerStyle
+
+
+
+### PinBox
+
+
+
### Effects

@@ -101,6 +118,8 @@ Step 4:enjoy coding

+## History publication
+
### Drawer

@@ -113,8 +132,6 @@ Step 4:enjoy coding

-## History publication
-
### GeometryAnimation

diff --git a/doc/source/handycontrol/extend_controls/calendarWithClock/index.md b/doc/source/handycontrol/extend_controls/calendarWithClock/index.md
index ca12ad62..1705ddf9 100644
--- a/doc/source/handycontrol/extend_controls/calendarWithClock/index.md
+++ b/doc/source/handycontrol/extend_controls/calendarWithClock/index.md
@@ -1,5 +1,66 @@
---
-title: 建设中
+title: CalendarWithClock
---
-建设中
\ No newline at end of file
+
+CalendarWithClock 控件由日历和时钟组成,允许用户通过鼠标选择日期和时间。
+
+``` CS
+[TemplatePart(Name = ElementButtonConfirm, Type = typeof(Button))]
+[TemplatePart(Name = ElementClockPresenter, Type = typeof(ContentPresenter))]
+[TemplatePart(Name = ElementCalendarPresenter, Type = typeof(ContentPresenter))]
+public class CalendarWithClock : Control
+```
+
+# 创建日期选取器
+
+``` XML
+
+```
+
+``` CS
+var dateTimePicker = new CalendarWithClock();
+```
+
+生成的CalendarWithClock如下图所示:
+
+
+
+
+
+# 选择日期和时间
+
+通过鼠标分别在日历和时钟上选择日期和时间,然后点击 **确定** 按钮即可更新CalendarWithClock控件的日期和时间。
+
+
+也可以在XAML钟或代码中这样设置日期。
+
+``` XML
+
+```
+
+``` CS
+calendarWithClock.SelectedDateTime = DateTime.Now;
+```
+
+
+
+# 属性
+
+| 属性 | 描述 |
+| ---------------- | ------------------ |
+| SelectedDateTime | 获取或设置当前选中的日期和时间 |
+| DateTimeFormat | 获取或设置用于显示选定日期和时间的格式 |
+| DisplayDateTime | 获取或设置要显示的日期 |
+| ShowConfirmButton | 获取或设置一个值,该值指示是是否显示 **确定** 按钮 |
+| VerifyFunc | 获取或设置数据验证委托 |
+| IsError | 获取或设置数据是否错误 |
+| ErrorStr | 获取或设置错误提示 |
+| TextType | 获取或设置文本类型 |
+| ShowClearButton | 获取或设置是否显示清除按钮 |
+
+# 方法
+
+| 方法 | 描述 |
+| ---------------- | ------------------ |
+| VerifyData() | 验证数据 |
\ No newline at end of file
diff --git a/doc/source/handycontrol/extend_controls/datePicker/index.md b/doc/source/handycontrol/extend_controls/datePicker/index.md
index ca12ad62..f61a8282 100644
--- a/doc/source/handycontrol/extend_controls/datePicker/index.md
+++ b/doc/source/handycontrol/extend_controls/datePicker/index.md
@@ -1,5 +1,74 @@
---
-title: 建设中
+title: DatePicker
---
-建设中
\ No newline at end of file
+DatePicker 控件允许用户通过在文本框中键入日期或使用下拉的日历控件来选择日期。
+
+``` CS
+[TemplatePart(Name = ElementTextBox, Type = typeof(DatePickerTextBox))]
+public class DatePicker : System.Windows.Controls.DatePicker, IDataInput
+```
+
+# 创建DatePicker
+
+``` XML
+
+```
+
+``` CS
+var datePicker = new DatePicker();
+```
+
+生成的DatePicker如下图所示:
+
+
+
+
+
+# 选择日期
+
+可以通过文本框输入日期,或者点击文本框右边的按钮打开下拉的日历控件选择日期。
+
+
+
+也可以在XAML钟或代码中这样设置日期。
+
+``` XML
+
+```
+
+``` CS
+datePicker.SelectedDate = DateTime.Now;
+```
+
+# 设置标题和占位符文本
+
+你可以将 Header(标题)和 Placeholder(占位符)添加到DatePicker,以向用户指示其用途。
+
+``` XML
+
+```
+
+
+
+
+# 属性
+
+| 属性 | 描述 |
+| ---------------- | ------------------ |
+| SelectedDate | 获取或设置当前选中的日期 |
+| VerifyFunc | 获取或设置数据验证委托 |
+| IsError | 获取或设置数据是否错误 |
+| ErrorStr | 获取或设置错误提示 |
+| TextType | 获取或设置文本类型 |
+| ShowClearButton | 获取或设置是否显示清除按钮 |
+
+# 方法
+
+| 方法 | 描述 |
+| ---------------- | ------------------ |
+| VerifyData() | 验证数据 |
+
diff --git a/doc/source/handycontrol/extend_controls/dateTimePicker/index.md b/doc/source/handycontrol/extend_controls/dateTimePicker/index.md
index ca12ad62..8dbbe027 100644
--- a/doc/source/handycontrol/extend_controls/dateTimePicker/index.md
+++ b/doc/source/handycontrol/extend_controls/dateTimePicker/index.md
@@ -1,5 +1,82 @@
---
-title: 建设中
+title: DateTimePicker
---
-建设中
\ No newline at end of file
+
+DatePicker 控件允许用户通过在文本框中键入日期和时间,或使用下拉的日历控件来选择日期和时间。
+
+``` CS
+[TemplatePart(Name = ElementRoot, Type = typeof(Grid))]
+[TemplatePart(Name = ElementTextBox, Type = typeof(WatermarkTextBox))]
+[TemplatePart(Name = ElementButton, Type = typeof(Button))]
+[TemplatePart(Name = ElementPopup, Type = typeof(Popup))]
+public class DateTimePicker : Control, IDataInput
+```
+
+# 创建DateTimePicker
+
+``` XML
+
+```
+
+``` CS
+var dateTimePicker = new DateTimePicker();
+```
+
+生成的DateTimePicker如下图所示:
+
+
+
+
+
+# 选择日期和时间
+
+可以通过文本框输入日期和时间,或者点击文本框右边的按钮打开下拉的日历和时钟控件选择日期和时间。
+
+
+
+也可以在XAML中或代码中这样设置日期。
+
+``` XML
+
+```
+
+``` CS
+dateTimePicker.SelectedDateTime = DateTime.Now;
+```
+
+# 设置标题和占位符文本
+
+你可以将 Header(标题)和 Placeholder(占位符)添加到DatePicker,以向用户指示其用途。要使用这两个属性,首先需要应用 **DateTimePickerExtend** 或 **DateTimePickerPlus** 样式。
+
+``` XML
+
+```
+
+
+
+
+# 属性
+
+| 属性 | 描述 |
+| ---------------- | ------------------ |
+| SelectedDateTime | 获取或设置当前选中的日期和时间 |
+| DateTimeFormat | 获取或设置用于显示选定日期和时间的格式 |
+| CalendarStyle | 获取或设置在呈现日历时使用的样式 |
+| DisplayDateTime | 获取或设置要显示的日期 |
+| IsDropDownOpen | 获取或设置一个值,该值指示是打开还是关闭下拉 Calendar |
+| Text | 获取由 **DateTimePicker** 显示的文本,或设置选定日期和时间 |
+| VerifyFunc | 获取或设置数据验证委托 |
+| IsError | 获取或设置数据是否错误 |
+| ErrorStr | 获取或设置错误提示 |
+| TextType | 获取或设置文本类型 |
+| ShowClearButton | 获取或设置是否显示清除按钮 |
+
+# 方法
+
+| 方法 | 描述 |
+| ---------------- | ------------------ |
+| VerifyData() | 验证数据 |
\ No newline at end of file
diff --git a/doc/source/handycontrol/extend_controls/timePicker/index.md b/doc/source/handycontrol/extend_controls/timePicker/index.md
index ca12ad62..5c65e872 100644
--- a/doc/source/handycontrol/extend_controls/timePicker/index.md
+++ b/doc/source/handycontrol/extend_controls/timePicker/index.md
@@ -1,5 +1,95 @@
---
-title: 建设中
+title: TimePicker
---
-建设中
\ No newline at end of file
+TimePicker 控件允许用户通过在文本框中键入时间或使用下拉的日历控件来选择时间。
+
+``` CS
+[TemplatePart(Name = ElementRoot, Type = typeof(Grid))]
+[TemplatePart(Name = ElementTextBox, Type = typeof(WatermarkTextBox))]
+[TemplatePart(Name = ElementButton, Type = typeof(Button))]
+[TemplatePart(Name = ElementPopup, Type = typeof(Popup))]
+public class TimePicker : Control, IDataInput
+```
+
+# 创建TimePicker
+
+``` XML
+
+```
+
+``` CS
+var timePicker = new TimePicker();
+```
+
+生成的TimePicker如下图所示:
+
+
+
+
+
+# 选择时间
+
+可以通过文本框输入时间,或者点击文本框右边的按钮打开下拉的时钟控件选择时间。
+
+
+
+也可以在XAML钟或代码中这样设置日期。
+
+``` XML
+
+```
+
+``` CS
+timePicker.SelectedTime = DateTime.Now;
+```
+
+# 更改时钟样式
+
+通过更改Clock属性,TimePicker可以更改时钟的样式。
+
+``` XML
+
+
+
+
+
+```
+
+
+
+# 设置标题和占位符文本
+
+你可以将 Header(标题)和 Placeholder(占位符)添加到DatePicker,以向用户指示其用途。要使用这两个属性,首先需要应用 **TimePickerExtend** 或 **TimePickerPlus** 样式。
+
+``` XML
+
+```
+
+
+
+
+# 属性
+
+| 属性 | 描述 |
+| ---------------- | ------------------ |
+| SelectedTime | 获取或设置当前选中的时间 |
+| Clock | 获取或设置下拉时钟 |
+| TimeFormat | 获取或设置用于显示选定的时间的格式 |
+| DisplayTime | 获取或设置要显示的时间 |
+| IsDropDownOpen | 获取或设置一个值,该值指示是打开还是关闭下拉时钟 |
+| Text | 获取由 **TimePicker** 显示的文本,或设置选定的时间 |
+| VerifyFunc | 获取或设置数据验证委托 |
+| IsError | 获取或设置数据是否错误 |
+| ErrorStr | 获取或设置错误提示 |
+| TextType | 获取或设置文本类型 |
+| ShowClearButton | 获取或设置是否显示清除按钮 |
+
+# 方法
+
+| 方法 | 描述 |
+| ---------------- | ------------------ |
+| VerifyData() | 验证数据 |
+
diff --git a/doc/source/handycontrol/tnx/index.md b/doc/source/handycontrol/tnx/index.md
index 8f738933..565cb3ca 100644
--- a/doc/source/handycontrol/tnx/index.md
+++ b/doc/source/handycontrol/tnx/index.md
@@ -4,7 +4,7 @@ title: 鸣谢
# 感谢以下Coder提供代码贡献
-








+








# 感谢以下组织机构提供开源许可
@@ -12,4 +12,4 @@ title: 鸣谢
# 感谢以下捐赠者
-







\ No newline at end of file
+












\ No newline at end of file
diff --git a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
index b343a399..80a476b3 100644
--- a/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
+++ b/src/Core_30/HandyControlDemo_Core_30/HandyControlDemo_Core30.csproj
@@ -8,7 +8,7 @@
2.4.0
..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico
Debug;Release
- Copyright © HandyOrg 2018-2019
+ Copyright © HandyOrg 2018-2020
2.4.0.0
2.4.0.0
8.0
@@ -454,6 +454,15 @@
Resources\Img\LeftMainContent\Effects_16x.png
+
+ Resources\Img\LeftMainContent\Ellipsis_16x.png
+
+
+ Resources\Img\LeftMainContent\WPFFlowDocument_16x.png
+
+
+ Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png
+
@@ -465,6 +474,9 @@
Properties\Langs\Lang.fr.resx
+
+ Properties\Langs\Lang.ko-KR.resx
+
Properties\Langs\Lang.resx
PublicResXFileCodeGenerator
diff --git a/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj b/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj
index 97e75628..4f61f64f 100644
--- a/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj
+++ b/src/Core_30/HandyControl_Core_30/HandyControl_Core_30.csproj
@@ -8,7 +8,7 @@
2.4.0.0
false
false
- Copyright © HandyOrg 2018-2019
+ Copyright © HandyOrg 2018-2020
Contains some commonly used simple WPF controls
Debug;Release
8.0
@@ -39,6 +39,9 @@
Properties\Langs\Lang.fr.resx
+
+ Properties\Langs\Lang.ko-KR.resx
+
Properties\Langs\Lang.resx
PublicResXFileCodeGenerator
@@ -65,4 +68,54 @@
Resources\Effects\GrayScaleEffect.ps
+
+
+ Resources\Images\GlowWindow\bottom.png
+
+
+ Resources\Images\GlowWindow\bottomleft.png
+
+
+ Resources\Images\GlowWindow\bottomright.png
+
+
+ Resources\Images\GlowWindow\cornerbottomleft.png
+
+
+ Resources\Images\GlowWindow\cornerbottomright.png
+
+
+ Resources\Images\GlowWindow\cornertopleft.png
+
+
+ Resources\Images\GlowWindow\cornertopright.png
+
+
+ Resources\Images\GlowWindow\left.png
+
+
+ Resources\Images\GlowWindow\leftbottom.png
+
+
+ Resources\Images\GlowWindow\lefttop.png
+
+
+ Resources\Images\GlowWindow\right.png
+
+
+ Resources\Images\GlowWindow\rightbottom.png
+
+
+ Resources\Images\GlowWindow\righttop.png
+
+
+ Resources\Images\GlowWindow\top.png
+
+
+ Resources\Images\GlowWindow\topleft.png
+
+
+ Resources\Images\GlowWindow\topright.png
+
+
\ No newline at end of file
diff --git a/src/Core_30/HandyControl_Core_30/Themes/Styles/Window.xaml b/src/Core_30/HandyControl_Core_30/Themes/Styles/Window.xaml
index f0c9acdb..15e08920 100644
--- a/src/Core_30/HandyControl_Core_30/Themes/Styles/Window.xaml
+++ b/src/Core_30/HandyControl_Core_30/Themes/Styles/Window.xaml
@@ -48,18 +48,15 @@
-
-
+
+
-
-
+
+
-
-
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/SeparatorBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/SeparatorBaseStyle.xaml
new file mode 100644
index 00000000..2b9f91b0
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/SeparatorBaseStyle.xaml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/SliderBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/SliderBaseStyle.xaml
index 9d71bc2a..d371ad3a 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/SliderBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/SliderBaseStyle.xaml
@@ -72,7 +72,7 @@
-
+
@@ -103,7 +103,7 @@
-
+
@@ -134,7 +134,7 @@
-
+
@@ -165,7 +165,7 @@
-
+
@@ -223,14 +223,14 @@
-
+
-
+
@@ -280,14 +280,14 @@
-
+
-
+
@@ -709,7 +709,7 @@
-
+
@@ -740,7 +740,7 @@
-
+
@@ -771,7 +771,7 @@
-
+
@@ -802,7 +802,7 @@
-
+
@@ -862,7 +862,7 @@
-
+
@@ -870,7 +870,7 @@
-
+
@@ -920,7 +920,7 @@
-
+
@@ -928,7 +928,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/StatusBarBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/StatusBarBaseStyle.xaml
new file mode 100644
index 00000000..1da267ba
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/StatusBarBaseStyle.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
index b2179bd3..97beb5d6 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/TextBoxBaseStyle.xaml
@@ -24,7 +24,7 @@
-
+
@@ -51,7 +51,7 @@
-
+
@@ -81,7 +81,7 @@
-
+
@@ -110,7 +110,7 @@
-
+
@@ -167,7 +167,7 @@
-
+
@@ -227,7 +227,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/FlowDocumentScrollViewer.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/FlowDocumentScrollViewer.xaml
new file mode 100644
index 00000000..e64aedab
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/FlowDocumentScrollViewer.xaml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/PinBox.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/PinBox.xaml
new file mode 100644
index 00000000..1ad0f94d
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/PinBox.xaml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Separator.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Separator.xaml
new file mode 100644
index 00000000..f50f2ab3
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Separator.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/StatusBar.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/StatusBar.xaml
new file mode 100644
index 00000000..9f2a27b3
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/StatusBar.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml
index 62a380e9..5a7386e4 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml
@@ -78,6 +78,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/TransitioningContentControl.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/TransitioningContentControl.xaml
index 8d7d7d4a..b9b21f96 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/TransitioningContentControl.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/TransitioningContentControl.xaml
@@ -1,5 +1,6 @@
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:controls="clr-namespace:HandyControl.Controls">
@@ -73,4 +74,8 @@
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs
new file mode 100644
index 00000000..779d25bf
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/DependencyObjectExtension.cs
@@ -0,0 +1,18 @@
+using System.Windows;
+using System.Windows.Media;
+
+namespace HandyControl.Tools.Extension
+{
+ public static class DependencyObjectExtension
+ {
+ public static DependencyObject GetVisualOrLogicalParent(this DependencyObject sourceElement)
+ {
+ return sourceElement switch
+ {
+ null => null,
+ Visual _ => (VisualTreeHelper.GetParent(sourceElement) ?? LogicalTreeHelper.GetParent(sourceElement)),
+ _ => LogicalTreeHelper.GetParent(sourceElement)
+ };
+ }
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
index 68232166..3d5685db 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/EnumerableExtension.cs
@@ -16,5 +16,16 @@ namespace HandyControl.Tools.Extension
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;
+ }
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
index 21357505..f15e82a5 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ConfigHelper.cs
@@ -52,6 +52,15 @@ namespace HandyControl.Tools
SetLang(config.Lang);
}
+ public void SetWindowDefaultStyle(object resourceKey = null)
+ {
+ var metadata = resourceKey == null
+ ? new FrameworkPropertyMetadata(Application.Current.FindResource(typeof(System.Windows.Window)))
+ : new FrameworkPropertyMetadata(Application.Current.FindResource(resourceKey));
+
+ FrameworkElement.StyleProperty.OverrideMetadata(typeof(System.Windows.Window), metadata);
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
#if netle40
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
index 76134f6a..d7669756 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/DpiHelper.cs
@@ -1,14 +1,54 @@
using System;
using System.Windows;
using System.Windows.Media;
+using HandyControl.Tools.Interop;
namespace HandyControl.Tools
{
- internal class DpiHelper
+ internal static class DpiHelper
{
- [ThreadStatic]
+ private const double LogicalDpi = 96.0;
+
+ [ThreadStatic]
private static Matrix _transformToDip;
+ static DpiHelper()
+ {
+ var dC = InteropMethods.GetDC(IntPtr.Zero);
+ if (dC != IntPtr.Zero)
+ {
+ DeviceDpiX = InteropMethods.GetDeviceCaps(dC, 88);
+ DeviceDpiY = InteropMethods.GetDeviceCaps(dC, 90);
+ 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;
@@ -18,9 +58,22 @@ namespace HandyControl.Tools
public static Size DeviceSizeToLogical(Size deviceSize, double dpiScaleX, double dpiScaleY)
{
- Point pt = DevicePixelsToLogical(new Point(deviceSize.Width, deviceSize.Height), dpiScaleX, 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;
+ }
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
index 225302dd..f5f1bfb4 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/IconHelper.cs
@@ -79,13 +79,13 @@ namespace HandyControl.Tools
try
{
- var bi = new BITMAPINFO(width, -height, 32)
+ var bi = new InteropValues.BITMAPINFO(width, -height, 32)
{
- bmiHeader_biCompression = NativeMethods.BI_RGB
+ biCompression = InteropValues.BI_RGB
};
var bits = IntPtr.Zero;
- colorBitmap = UnsafeNativeMethods.CreateDIBSection(new HandleRef(null, IntPtr.Zero), ref bi, NativeMethods.DIB_RGB_COLORS, ref bits, null, 0);
+ colorBitmap = InteropMethods.CreateDIBSection(new HandleRef(null, IntPtr.Zero), ref bi, InteropValues.DIB_RGB_COLORS, ref bits, null, 0);
if (colorBitmap.IsInvalid || bits == IntPtr.Zero)
{
@@ -95,13 +95,13 @@ namespace HandyControl.Tools
Marshal.Copy(colorArray, 0, bits, colorArray.Length);
var maskArray = GenerateMaskArray(width, height, colorArray);
- maskBitmap = UnsafeNativeMethods.CreateBitmap(width, height, 1, 1, maskArray);
+ maskBitmap = InteropMethods.CreateBitmap(width, height, 1, 1, maskArray);
if (maskBitmap.IsInvalid)
{
return IconHandle.GetInvalidIcon();
}
- var iconInfo = new ICONINFO
+ var iconInfo = new InteropValues.ICONINFO
{
fIcon = isIcon,
xHotspot = xHotspot,
@@ -110,7 +110,7 @@ namespace HandyControl.Tools
hbmColor = colorBitmap
};
- return UnsafeNativeMethods.CreateIconIndirect(iconInfo);
+ return InteropMethods.CreateIconIndirect(iconInfo);
}
finally
{
@@ -252,21 +252,21 @@ namespace HandyControl.Tools
{
if (SystemBitDepth == 0)
{
- var hdcDesktop = new HandleRef(null, UnsafeNativeMethods.GetDC(new HandleRef()));
+ var hdcDesktop = new HandleRef(null, InteropMethods.GetDC(new HandleRef()));
try
{
- var sysBitDepth = UnsafeNativeMethods.GetDeviceCaps(hdcDesktop, NativeMethods.BITSPIXEL);
- sysBitDepth *= UnsafeNativeMethods.GetDeviceCaps(hdcDesktop, NativeMethods.PLANES);
+ var sysBitDepth = InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.BITSPIXEL);
+ sysBitDepth *= InteropMethods.GetDeviceCaps(hdcDesktop, InteropValues.PLANES);
if (sysBitDepth == 8)
{
sysBitDepth = 4;
}
- var cxSmallIcon = UnsafeNativeMethods.GetSystemMetrics(SM.CXSMICON);
- var cySmallIcon = UnsafeNativeMethods.GetSystemMetrics(SM.CYSMICON);
- var cxIcon = UnsafeNativeMethods.GetSystemMetrics(SM.CXICON);
- var cyIcon = UnsafeNativeMethods.GetSystemMetrics(SM.CYICON);
+ 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);
@@ -274,7 +274,7 @@ namespace HandyControl.Tools
}
finally
{
- UnsafeNativeMethods.ReleaseDC(new HandleRef(), hdcDesktop);
+ InteropMethods.ReleaseDC(new HandleRef(), hdcDesktop);
}
}
}
@@ -287,8 +287,8 @@ namespace HandyControl.Tools
SecurityHelper.DemandUIWindowPermission();
- var iconModuleFile = UnsafeNativeMethods.GetModuleFileName(new HandleRef());
- UnsafeNativeMethods.ExtractIconEx(iconModuleFile, 0, out largeIconHandle, out smallIconHandle, 1);
+ var iconModuleFile = InteropMethods.GetModuleFileName(new HandleRef());
+ InteropMethods.ExtractIconEx(iconModuleFile, 0, out largeIconHandle, out smallIconHandle, 1);
}
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
new file mode 100644
index 00000000..9bcfab2f
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Windows;
+using HandyControl.Tools.Interop;
+
+namespace HandyControl.Tools
+{
+ internal class ScreenHelper
+ {
+ 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);
+ }
+
+ 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
+ {
+ 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);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
index 489a0d49..b6351478 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
@@ -3,6 +3,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
+using HandyControl.Tools.Interop;
namespace HandyControl.Tools
{
@@ -11,10 +12,7 @@ namespace HandyControl.Tools
internal static VisualStateGroup TryGetVisualStateGroup(DependencyObject d, string groupName)
{
var root = GetImplementationRoot(d);
- if (root == null)
- {
- return null;
- }
+ if (root == null) return null;
return VisualStateManager
.GetVisualStateGroups(root)?
@@ -31,10 +29,7 @@ namespace HandyControl.Tools
public static T GetChild(DependencyObject d) where T : DependencyObject
{
- if (d is T t)
- {
- return t;
- }
+ if (d is T t) return t;
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(d); i++)
{
@@ -47,7 +42,34 @@ namespace HandyControl.Tools
return default;
}
- public static IntPtr GetHandle(this Visual visual) =>
- (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
+ public static IntPtr GetHandle(this Visual visual)
+ {
+ return (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
+ }
+
+ 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;
+ }
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
index c606d165..818df6bc 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/WindowHelper.cs
@@ -19,7 +19,7 @@ namespace HandyControl.Tools
///
public static Window GetActiveWindow() => Application.Current.Windows.OfType().SingleOrDefault(x => x.IsActive);
- private static readonly BitArray _cacheValid = new BitArray((int)CacheSlot.NumSlots);
+ private static readonly BitArray _cacheValid = new BitArray((int)InteropValues.CacheSlot.NumSlots);
private static bool _setDpiX = true;
@@ -43,7 +43,7 @@ namespace HandyControl.Tools
var desktopWnd = new HandleRef(null, IntPtr.Zero);
// Win32Exception will get the Win32 error code so we don't have to
- var dc = UnsafeNativeMethods.GetDC(desktopWnd);
+ var dc = InteropMethods.GetDC(desktopWnd);
// Detecting error case from unmanaged call, required by PREsharp to throw a Win32Exception
if (dc == IntPtr.Zero)
@@ -53,12 +53,12 @@ namespace HandyControl.Tools
try
{
- _dpi = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, dc), NativeMethods.LOGPIXELSY);
+ _dpi = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSY);
_dpiInitialized = true;
}
finally
{
- UnsafeNativeMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
+ InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
}
}
}
@@ -82,19 +82,19 @@ namespace HandyControl.Tools
{
_setDpiX = false;
var desktopWnd = new HandleRef(null, IntPtr.Zero);
- var dc = UnsafeNativeMethods.GetDC(desktopWnd);
+ var dc = InteropMethods.GetDC(desktopWnd);
if (dc == IntPtr.Zero)
{
throw new Win32Exception();
}
try
{
- _dpiX = UnsafeNativeMethods.GetDeviceCaps(new HandleRef(null, dc), NativeMethods.LOGPIXELSX);
- _cacheValid[(int)CacheSlot.DpiX] = true;
+ _dpiX = InteropMethods.GetDeviceCaps(new HandleRef(null, dc), InteropValues.LOGPIXELSX);
+ _cacheValid[(int)InteropValues.CacheSlot.DpiX] = true;
}
finally
{
- UnsafeNativeMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
+ InteropMethods.ReleaseDC(desktopWnd, new HandleRef(null, dc));
}
}
}
@@ -113,11 +113,11 @@ namespace HandyControl.Tools
{
lock (_cacheValid)
{
- while (!_cacheValid[(int)CacheSlot.WindowResizeBorderThickness])
+ while (!_cacheValid[(int)InteropValues.CacheSlot.WindowResizeBorderThickness])
{
- _cacheValid[(int)CacheSlot.WindowResizeBorderThickness] = true;
+ _cacheValid[(int)InteropValues.CacheSlot.WindowResizeBorderThickness] = true;
- var frameSize = new Size(NativeMethods.GetSystemMetrics(SM.CXSIZEFRAME), NativeMethods.GetSystemMetrics(SM.CYSIZEFRAME));
+ 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);
@@ -135,9 +135,9 @@ namespace HandyControl.Tools
#if netle40
return WindowResizeBorderThickness;
#elif Core
- var hdc = UnsafeNativeMethods.GetDC(IntPtr.Zero);
- var scale = UnsafeNativeMethods.GetDeviceCaps(hdc, NativeMethods.DESKTOPVERTRES) / (float)UnsafeNativeMethods.GetDeviceCaps(hdc, NativeMethods.VERTRES);
- UnsafeNativeMethods.ReleaseDC(IntPtr.Zero, hdc);
+ 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(4 * scale));
#else
return WindowResizeBorderThickness.Add(new Thickness(4));
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
index b98bb50a..61c9fc8f 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/ClipboardHook.cs
@@ -24,19 +24,19 @@ namespace HandyControl.Tools
if (HWndSource != null)
{
HWndSource.AddHook(WinProc);
- NativeMethods.AddClipboardFormatListener(HookId);
+ InteropMethods.AddClipboardFormatListener(HookId);
}
}
public static void Stop()
{
HWndSource.RemoveHook(WinProc);
- NativeMethods.RemoveClipboardFormatListener(HookId);
+ InteropMethods.RemoveClipboardFormatListener(HookId);
}
private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
{
- if (msg == NativeMethods.WM_CLIPBOARDUPDATE)
+ if (msg == InteropValues.WM_CLIPBOARDUPDATE)
{
ContentChanged?.Invoke();
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
index 07ce92b6..58388c83 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/KeyboardHook.cs
@@ -14,17 +14,17 @@ namespace HandyControl.Tools
private static IntPtr HookId = IntPtr.Zero;
- private static readonly UnsafeNativeMethods.HookProc Proc = HookCallback;
+ private static readonly InteropValues.HookProc Proc = HookCallback;
private static int VirtualKey;
- private static readonly IntPtr KeyDownIntPtr = (IntPtr)NativeMethods.WM_KEYDOWN;
+ private static readonly IntPtr KeyDownIntPtr = (IntPtr)InteropValues.WM_KEYDOWN;
- private static readonly IntPtr KeyUpIntPtr = (IntPtr)NativeMethods.WM_KEYUP;
+ private static readonly IntPtr KeyUpIntPtr = (IntPtr)InteropValues.WM_KEYUP;
- private static readonly IntPtr SyskeyDownIntPtr = (IntPtr)NativeMethods.WM_SYSKEYDOWN;
+ private static readonly IntPtr SyskeyDownIntPtr = (IntPtr)InteropValues.WM_SYSKEYDOWN;
- private static readonly IntPtr SyskeyUpIntPtr = (IntPtr)NativeMethods.WM_SYSKEYUP;
+ private static readonly IntPtr SyskeyUpIntPtr = (IntPtr)InteropValues.WM_SYSKEYUP;
public static void Start()
{
@@ -35,17 +35,17 @@ namespace HandyControl.Tools
HookId = SetHook(Proc);
}
- public static void Stop() => UnsafeNativeMethods.UnhookWindowsHookEx(HookId);
+ public static void Stop() => InteropMethods.UnhookWindowsHookEx(HookId);
- private static IntPtr SetHook(UnsafeNativeMethods.HookProc proc)
+ private static IntPtr SetHook(InteropValues.HookProc proc)
{
using (var curProcess = Process.GetCurrentProcess())
using (var curModule = curProcess.MainModule)
{
if (curModule != null)
{
- return UnsafeNativeMethods.SetWindowsHookEx((int)UnsafeNativeMethods.HookType.WH_KEYBOARD_LL, proc,
- UnsafeNativeMethods.GetModuleHandle(curModule.ModuleName), 0);
+ return InteropMethods.SetWindowsHookEx((int)InteropValues.HookType.WH_KEYBOARD_LL, proc,
+ InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
}
return IntPtr.Zero;
}
@@ -86,7 +86,7 @@ namespace HandyControl.Tools
KeyUp?.Invoke(null, new KeyboardHookEventArgs(virtualKey, true));
}
}
- return UnsafeNativeMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ return InteropMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
}
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs b/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
index 5405c6cf..90b1f0d6 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/MouseHook.cs
@@ -12,7 +12,7 @@ namespace HandyControl.Tools
private static IntPtr HookId = IntPtr.Zero;
- private static readonly UnsafeNativeMethods.HookProc Proc = HookCallback;
+ private static readonly InteropValues.HookProc Proc = HookCallback;
public static void Start()
{
@@ -23,17 +23,17 @@ namespace HandyControl.Tools
HookId = SetHook(Proc);
}
- public static void Stop() => UnsafeNativeMethods.UnhookWindowsHookEx(HookId);
+ public static void Stop() => InteropMethods.UnhookWindowsHookEx(HookId);
- private static IntPtr SetHook(UnsafeNativeMethods.HookProc proc)
+ private static IntPtr SetHook(InteropValues.HookProc proc)
{
using (var curProcess = Process.GetCurrentProcess())
using (var curModule = curProcess.MainModule)
{
if (curModule != null)
{
- return UnsafeNativeMethods.SetWindowsHookEx((int) UnsafeNativeMethods.HookType.WH_MOUSE_LL, proc,
- UnsafeNativeMethods.GetModuleHandle(curModule.ModuleName), 0);
+ return InteropMethods.SetWindowsHookEx((int)InteropValues.HookType.WH_MOUSE_LL, proc,
+ InteropMethods.GetModuleHandle(curModule.ModuleName), 0);
}
return IntPtr.Zero;
}
@@ -41,15 +41,15 @@ namespace HandyControl.Tools
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
- if (nCode < 0) return UnsafeNativeMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
- var hookStruct = (UnsafeNativeMethods.MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(UnsafeNativeMethods.MOUSEHOOKSTRUCT));
+ 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
{
Message = (MouseHookMessageType)wParam,
- Point = new NativeMethods.POINT(hookStruct.pt.X, hookStruct.pt.Y)
+ Point = new InteropValues.POINT(hookStruct.pt.X, hookStruct.pt.Y)
});
- return UnsafeNativeMethods.CallNextHookEx(HookId, nCode, wParam, lParam);
+ 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 afe6f66b..af10084f 100644
--- a/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Hook/SystemMenuHook.cs
@@ -19,14 +19,14 @@ namespace HandyControl.Tools
if (source != null)
{
DataDic[id] = source;
- NativeMethods.InsertMenu(NativeMethods.GetSystemMenu(hookId, false), index, NativeMethods.MF_BYPOSITION, id, text);
+ InteropMethods.InsertMenu(InteropMethods.GetSystemMenu(hookId, false), index, InteropValues.MF_BYPOSITION, id, text);
source.AddHook(WinProc);
}
}
- public static void InsertSeperator(int index, Window window) => NativeMethods.InsertMenu(
- NativeMethods.GetSystemMenu(window.GetHandle(), false), index,
- NativeMethods.MF_BYPOSITION | NativeMethods.MF_SEPARATOR, 0, "");
+ 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)
{
@@ -39,7 +39,7 @@ namespace HandyControl.Tools
private static IntPtr WinProc(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam, ref bool handled)
{
- if (msg == NativeMethods.WM_SYSCOMMAND)
+ if (msg == InteropValues.WM_SYSCOMMAND)
{
var id = wparam.ToInt32();
if (DataDic.ContainsKey(id))
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/BITMAPINFO.cs b/src/Shared/HandyControl_Shared/Tools/Interop/BITMAPINFO.cs
deleted file mode 100644
index 4938fbdd..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/BITMAPINFO.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-using System.Security;
-
-namespace HandyControl.Tools.Interop
-{
- [StructLayout(LayoutKind.Sequential, Pack = 2)]
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal struct BITMAPINFO
- {
- public int bmiHeader_biSize;
-
- public int bmiHeader_biWidth;
-
- public int bmiHeader_biHeight;
-
- public short bmiHeader_biPlanes;
-
- public short bmiHeader_biBitCount;
-
- public int bmiHeader_biCompression;
-
- public int bmiHeader_biSizeImage;
-
- public int bmiHeader_biXPelsPerMeter;
-
- public int bmiHeader_biYPelsPerMeter;
-
- public int bmiHeader_biClrUsed;
-
- public int bmiHeader_biClrImportant;
-
- public BITMAPINFO(int width, int height, short bpp)
- {
- bmiHeader_biSize = SizeOf();
- bmiHeader_biWidth = width;
- bmiHeader_biHeight = height;
- bmiHeader_biPlanes = 1;
- bmiHeader_biBitCount = bpp;
- bmiHeader_biCompression = 0;
- bmiHeader_biSizeImage = 0;
- bmiHeader_biXPelsPerMeter = 0;
- bmiHeader_biYPelsPerMeter = 0;
- bmiHeader_biClrUsed = 0;
- bmiHeader_biClrImportant = 0;
- }
-
- [SecuritySafeCritical]
- private static int SizeOf()
- {
- return Marshal.SizeOf(typeof(BITMAPINFO));
- }
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/ExternDll.cs b/src/Shared/HandyControl_Shared/Tools/Interop/ExternDll.cs
deleted file mode 100644
index 81fa0c71..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/ExternDll.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace HandyControl.Tools.Interop
-{
- internal static class ExternDll
- {
- public const string
- User32 = "user32.dll",
- Gdi32 = "gdi32.dll",
- Kernel32 = "kernel32.dll",
- Shell32 = "shell32.dll";
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/BitmapHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
similarity index 95%
rename from src/Shared/HandyControl_Shared/Tools/Interop/BitmapHandle.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
index 1e893fa9..2fda6685 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/BitmapHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/BitmapHandle.cs
@@ -24,7 +24,7 @@ namespace HandyControl.Tools.Interop
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
- return UnsafeNativeMethods.DeleteObject(handle);
+ return InteropMethods.DeleteObject(handle);
}
[SecurityCritical]
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/CommonHandles.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs
similarity index 100%
rename from src/Shared/HandyControl_Shared/Tools/Interop/CommonHandles.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/CommonHandles.cs
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/HandleCollector.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs
similarity index 100%
rename from src/Shared/HandyControl_Shared/Tools/Interop/HandleCollector.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/HandleCollector.cs
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/IconHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
similarity index 92%
rename from src/Shared/HandyControl_Shared/Tools/Interop/IconHandle.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
index cbaec541..96de9b10 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/IconHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/IconHandle.cs
@@ -15,7 +15,7 @@ namespace HandyControl.Tools.Interop
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
protected override bool ReleaseHandle()
{
- return UnsafeNativeMethods.DestroyIcon(handle);
+ return InteropMethods.DestroyIcon(handle);
}
[SecurityCritical, SecuritySafeCritical]
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/SafeFileMappingHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
similarity index 95%
rename from src/Shared/HandyControl_Shared/Tools/Interop/SafeFileMappingHandle.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
index ad26db90..c4aade37 100644
--- a/src/Shared/HandyControl_Shared/Tools/Interop/SafeFileMappingHandle.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/SafeFileMappingHandle.cs
@@ -43,7 +43,7 @@ namespace HandyControl.Tools.Interop
public static bool CloseHandleNoThrow(HandleRef handle)
{
HandleCollector.Remove((IntPtr)handle, CommonHandles.Kernel);
- var result = UnsafeNativeMethods.IntCloseHandle(handle);
+ var result = InteropMethods.IntCloseHandle(handle);
return result;
}
}
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/WpfSafeHandle.cs b/src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs
similarity index 100%
rename from src/Shared/HandyControl_Shared/Tools/Interop/WpfSafeHandle.cs
rename to src/Shared/HandyControl_Shared/Tools/Interop/Handle/WpfSafeHandle.cs
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/ICONINFO.cs b/src/Shared/HandyControl_Shared/Tools/Interop/ICONINFO.cs
deleted file mode 100644
index 659c98e6..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/ICONINFO.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-namespace HandyControl.Tools.Interop
-{
- [StructLayout(LayoutKind.Sequential)]
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal class ICONINFO
- {
- public bool fIcon = false;
- public int xHotspot = 0;
- public int yHotspot = 0;
- public BitmapHandle hbmMask = null;
- public BitmapHandle hbmColor = null;
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
new file mode 100644
index 00000000..2af265bf
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
@@ -0,0 +1,437 @@
+using System;
+using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
+using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
+using System.Security;
+using System.Text;
+
+namespace HandyControl.Tools.Interop
+{
+ internal class InteropMethods
+ {
+ internal static readonly IntPtr HRGN_NONE = new IntPtr(-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.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 int 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 InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
+
+ [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)
+ {
+ var hDc = IntGetDC(hWnd);
+ if (hDc == IntPtr.Zero) 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)
+ {
+ if (hSection == null) 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)
+ {
+ 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.WNDCLASS 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)
+ {
+ if (IntPtr.Size == 4)
+ {
+ return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
+ }
+ return 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.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;
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
new file mode 100644
index 00000000..c183fb44
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
@@ -0,0 +1,620 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Windows;
+
+namespace HandyControl.Tools.Interop
+{
+ internal class InteropValues
+ {
+ internal static class ExternDll
+ {
+ public const string
+ User32 = "user32.dll",
+ Gdi32 = "gdi32.dll",
+ Kernel32 = "kernel32.dll",
+ Shell32 = "shell32.dll",
+ MsImg = "msimg32.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,
+ 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_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_CLIPBOARDUPDATE = 0x031D,
+ WM_USER = 0x0400,
+ MF_BYPOSITION = 0x400,
+ 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;
+
+ [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(Rect rect)
+ {
+ Left = (int)rect.Left;
+ Top = (int)rect.Top;
+ Right = (int)rect.Right;
+ Bottom = (int)rect.Bottom;
+ }
+
+ public Point Position => new Point(Left, Top);
+ public Size Size => new Size(Width, Height);
+
+ public int Height
+ {
+ get => Bottom - Top;
+ set => Bottom = Top + value;
+ }
+
+ public int Width
+ {
+ get => Right - Left;
+ set => Right = Left + value;
+ }
+ }
+
+ 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 class WINDOWPLACEMENT
+ {
+ public int length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
+ public int flags;
+ public int 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, 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/NOTIFYICONDATA.cs b/src/Shared/HandyControl_Shared/Tools/Interop/NOTIFYICONDATA.cs
deleted file mode 100644
index c57d604a..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/NOTIFYICONDATA.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-namespace HandyControl.Tools.Interop
-{
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- public 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;
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/NativeMethods.cs b/src/Shared/HandyControl_Shared/Tools/Interop/NativeMethods.cs
deleted file mode 100644
index b4885c5f..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/NativeMethods.cs
+++ /dev/null
@@ -1,246 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
-using System.Security;
-
-namespace HandyControl.Tools.Interop
-{
- public delegate IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
-
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- [SuppressMessage("ReSharper", "IdentifierTypo")]
- internal class NativeMethods
- {
- public const int
- WS_CHILD = 0x40000000,
- BITSPIXEL = 12,
- PLANES = 14,
- BI_RGB = 0,
- DIB_RGB_COLORS = 0,
- NIF_MESSAGE = 0x00000001,
- NIF_ICON = 0x00000002,
- NIF_TIP = 0x00000004,
- NIF_INFO = 0x00000010,
- NIN_BALLOONSHOW = WM_USER + 2,
- NIN_BALLOONHIDE = WM_USER + 3,
- NIN_BALLOONTIMEOUT = WM_USER + 4,
- NIM_ADD = 0x00000000,
- NIM_MODIFY = 0x00000001,
- NIM_DELETE = 0x00000002,
- NIIF_NONE = 0x00000000,
- NIIF_INFO = 0x00000001,
- NIIF_WARNING = 0x00000002,
- NIIF_ERROR = 0x00000003,
- NIIF_LARGE_ICON = 0x00000020,
- WM_KEYDOWN = 0x0100,
- WM_KEYUP = 0x0101,
- WM_SYSKEYDOWN = 0x0104,
- WM_SYSKEYUP = 0x0105,
- WM_SYSCOMMAND = 0x112,
- WM_MOUSEMOVE = 0x0200,
- WM_LBUTTONDOWN = 0x0201,
- WM_LBUTTONUP = 0x0202,
- WM_LBUTTONDBLCLK = 0x0203,
- WM_RBUTTONDOWN = 0x0204,
- WM_RBUTTONUP = 0x0205,
- WM_RBUTTONDBLCLK = 0x0206,
- WM_MBUTTONDOWN = 0x0207,
- WM_MBUTTONUP = 0x0208,
- WM_MBUTTONDBLCLK = 0x0209,
- WM_CLIPBOARDUPDATE = 0x031D,
- WM_USER = 0x0400,
- MF_BYPOSITION = 0x400,
- MF_SEPARATOR = 0x800,
- TB_GETBUTTON = WM_USER + 23,
- TB_BUTTONCOUNT = WM_USER + 24,
- TB_GETITEMRECT = WM_USER + 29,
- STANDARD_RIGHTS_REQUIRED = 0x000F0000,
- SYNCHRONIZE = 0x00100000,
- PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFF,
- MEM_COMMIT = 0x1000,
- MEM_RELEASE = 0x8000,
- PAGE_READWRITE = 0x04,
- TBSTATE_HIDDEN = 0x08,
- VERTRES = 10,
- HORZRES = 8,
- DESKTOPVERTRES = 117,
- DESKTOPHORZRES = 118,
- LOGPIXELSX = 88,
- LOGPIXELSY = 90,
- CXFRAME = 32,
- CXSIZEFRAME = CXFRAME,
- SW_HIDE = 0;
-
- [Flags]
- public 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)]
- public 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;
- }
- }
-
- [StructLayout(LayoutKind.Sequential, Pack = 1)]
- public struct TBBUTTON
- {
- public int iBitmap;
- public int idCommand;
- public IntPtr fsStateStylePadding;
- public IntPtr dwData;
- public IntPtr iString;
- }
-
- [Flags]
- public enum AllocationType
- {
- Commit = 0x1000,
- Reserve = 0x2000,
- Decommit = 0x4000,
- Release = 0x8000,
- Reset = 0x80000,
- Physical = 0x400000,
- TopDown = 0x100000,
- WriteWatch = 0x200000,
- LargePages = 0x20000000
- }
-
- [Flags]
- public 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)]
- public struct TRAYDATA
- {
- public IntPtr hwnd;
- public uint uID;
- public uint uCallbackMessage;
- public uint bReserved0;
- public uint bReserved1;
- public IntPtr hIcon;
- }
-
- [Flags]
- public enum FreeType
- {
- Decommit = 0x4000,
- Release = 0x8000,
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct POINT
- {
- public int X;
- public int Y;
-
- public POINT(int x, int y)
- {
- X = x;
- Y = y;
- }
- }
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- [ResourceExposure(ResourceScope.None)]
- public static extern int RegisterWindowMessage(string msg);
-
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern int MapWindowPoints(IntPtr hWndFrom, IntPtr hWndTo, ref RECT lpPoints, uint cPoints);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out TBBUTTON lpBuffer, int dwSize, out int lpNumberOfBytesRead);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true)]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out RECT lpBuffer, int dwSize, out int lpNumberOfBytesRead);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true)]
- public static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, out TRAYDATA lpBuffer, int dwSize, out int lpNumberOfBytesRead);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- public static extern uint SendMessage(IntPtr hWnd, uint Msg, uint wParam, IntPtr lParam);
-
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern IntPtr OpenProcess(ProcessAccess dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, uint dwProcessId);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern int CloseHandle(IntPtr hObject);
-
- [DllImport(ExternDll.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
- public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress, int dwSize, FreeType dwFreeType);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
-
- [DllImport(ExternDll.User32)]
- public static extern int GetWindowRect(IntPtr hwnd, out RECT lpRect);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- public static extern bool GetCursorPos(out POINT pt);
-
- [SecurityCritical]
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- [DllImport(ExternDll.User32)]
- public static extern int GetSystemMetrics(SM nIndex);
-
- [DllImport(ExternDll.User32)]
- public static extern IntPtr GetDesktopWindow();
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool AddClipboardFormatListener(IntPtr hwnd);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- [return: MarshalAs(UnmanagedType.Bool)]
- public static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
-
- [DllImport(ExternDll.User32)]
- public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
-
- [DllImport(ExternDll.User32)]
- public static extern bool InsertMenu(IntPtr hMenu, int wPosition, int wFlags, int wIDNewItem, string lpNewItem);
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/NativeValues.cs b/src/Shared/HandyControl_Shared/Tools/Interop/NativeValues.cs
deleted file mode 100644
index 94c1e09b..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/NativeValues.cs
+++ /dev/null
@@ -1,235 +0,0 @@
-// ReSharper disable InconsistentNaming
-
-namespace HandyControl.Tools.Interop
-{
- 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;
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/UnsafeNativeMethods.cs b/src/Shared/HandyControl_Shared/Tools/Interop/UnsafeNativeMethods.cs
deleted file mode 100644
index 378eab05..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/UnsafeNativeMethods.cs
+++ /dev/null
@@ -1,225 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
-
-namespace HandyControl.Tools.Interop
-{
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- internal class UnsafeNativeMethods
- {
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, EntryPoint = nameof(GetDC), CharSet = CharSet.Auto)]
- public static extern IntPtr IntGetDC(HandleRef hWnd);
-
- [SecurityCritical]
- public static IntPtr GetDC(HandleRef hWnd)
- {
- var hDc = IntGetDC(hWnd);
- if (hDc == IntPtr.Zero)
- {
- throw new Win32Exception();
- }
-
- return HandleCollector.Add(hDc, CommonHandles.HDC);
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.User32, ExactSpelling = true, EntryPoint = nameof(ReleaseDC), CharSet = CharSet.Auto)]
- public static extern int IntReleaseDC(HandleRef hWnd, HandleRef hDC);
-
- [SecurityCritical]
- public static int ReleaseDC(HandleRef hWnd, HandleRef hDC)
- {
- HandleCollector.Remove((IntPtr)hDC, CommonHandles.HDC);
- return IntReleaseDC(hWnd, hDC);
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int GetDeviceCaps(HandleRef hDC, int nIndex);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.User32)]
- public static extern int GetSystemMetrics(SM nIndex);
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.User32, EntryPoint = nameof(DestroyIcon), CharSet = CharSet.Auto, SetLastError = true)]
- private static extern bool IntDestroyIcon(IntPtr hIcon);
-
- [SecurityCritical]
- public static bool DestroyIcon(IntPtr hIcon)
- {
- var result = IntDestroyIcon(hIcon);
- return result;
- }
-
- [SecurityCritical]
- [SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.Gdi32, EntryPoint = nameof(DeleteObject), CharSet = CharSet.Auto, SetLastError = true)]
- private static extern bool IntDeleteObject(IntPtr hObject);
-
- [SecurityCritical]
- public static bool DeleteObject(IntPtr hObject)
- {
- var result = IntDeleteObject(hObject);
- return result;
- }
-
- [SecurityCritical]
- public static BitmapHandle CreateDIBSection(HandleRef hdc, ref BITMAPINFO bitmapInfo, int iUsage, ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
- {
- if (hSection == null)
- {
- hSection = new SafeFileMappingHandle(IntPtr.Zero);
- }
-
- var hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset);
- return hBitmap;
- }
-
- [DllImport(ExternDll.Kernel32, EntryPoint = "CloseHandle", CharSet = CharSet.Auto, SetLastError = true)]
- public static extern bool IntCloseHandle(HandleRef handle);
-
- [SecurityCritical, SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = nameof(CreateDIBSection))]
- private static extern BitmapHandle PrivateCreateDIBSection(HandleRef hdc, ref BITMAPINFO bitmapInfo, int iUsage, ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset);
-
- [SecurityCritical, SuppressUnmanagedCodeSecurity]
- [DllImport(ExternDll.User32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto, EntryPoint = nameof(CreateIconIndirect))]
- private static extern IconHandle PrivateCreateIconIndirect([In, MarshalAs(UnmanagedType.LPStruct)]ICONINFO iconInfo);
-
- [SecurityCritical]
- public static IconHandle CreateIconIndirect([In, MarshalAs(UnmanagedType.LPStruct)]ICONINFO iconInfo)
- {
- var hIcon = PrivateCreateIconIndirect(iconInfo);
- return hIcon;
- }
-
- [SecurityCritical, SuppressUnmanagedCodeSecurity]
- [DllImport(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(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(Win32Constant.MAX_PATH);
- while (true)
- {
- 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(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(ExternDll.Shell32, CharSet = CharSet.Auto)]
- public static extern int Shell_NotifyIcon(int message, NOTIFYICONDATA pnid);
-
- [SecurityCritical]
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- [DllImport(ExternDll.User32, SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateWindowExW")]
- public 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(ExternDll.User32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
- public static extern short RegisterClass(WNDCLASS wc);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- public static extern IntPtr DefWindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
-
- [DllImport(ExternDll.User32, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern bool SetForegroundWindow(IntPtr hWnd);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- public static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
-
- [DllImport(ExternDll.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
- public static extern IntPtr GetModuleHandle(string lpModuleName);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- public static extern bool UnhookWindowsHookEx(IntPtr hhk);
-
- public enum HookType
- {
- WH_KEYBOARD_LL = 13,
- WH_MOUSE_LL = 14
- }
-
- [StructLayout(LayoutKind.Sequential)]
- public struct MOUSEHOOKSTRUCT
- {
- public NativeMethods.POINT pt;
- public IntPtr hwnd;
- public uint wHitTestCode;
- public IntPtr dwExtraInfo;
- }
-
- public delegate IntPtr HookProc(int code, IntPtr wParam, IntPtr lParam);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto, SetLastError = true)]
- public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, uint dwThreadId);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern IntPtr GetDesktopWindow();
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern IntPtr GetWindowDC(IntPtr window);
-
- [DllImport(ExternDll.Gdi32, SetLastError = true)]
- public static extern uint GetPixel(IntPtr dc, int x, int y);
-
- [DllImport(ExternDll.User32, SetLastError = true)]
- public static extern int ReleaseDC(IntPtr window, IntPtr dc);
-
- [DllImport(ExternDll.Gdi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Auto)]
- public static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
-
- [DllImport(ExternDll.User32, CharSet = CharSet.Auto)]
- public static extern IntPtr GetDC(IntPtr ptr);
- }
-}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Interop/WNDCLASS.cs b/src/Shared/HandyControl_Shared/Tools/Interop/WNDCLASS.cs
deleted file mode 100644
index 33dd3903..00000000
--- a/src/Shared/HandyControl_Shared/Tools/Interop/WNDCLASS.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.InteropServices;
-
-namespace HandyControl.Tools.Interop
-{
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- [SuppressMessage("ReSharper", "InconsistentNaming")]
- [SuppressMessage("ReSharper", "IdentifierTypo")]
- internal class WNDCLASS
- {
- 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;
- }
-}
\ No newline at end of file