@ -97,6 +97,10 @@ Step 4:enjoy coding
|
||||
|
||||
## Latest examples
|
||||
|
||||
### GlowWindow
|
||||
|
||||
![GlowWindow](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/GlowWindow.png)
|
||||
|
||||
### FlowDocumentScrollViewerStyle
|
||||
|
||||
![FlowDocumentScrollViewerStyle](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/FlowDocumentScrollViewer.png)
|
||||
@ -113,12 +117,12 @@ Step 4:enjoy coding
|
||||
|
||||
![RelativePanel](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/RelativePanel.png)
|
||||
|
||||
## History publication
|
||||
|
||||
### Drawer
|
||||
|
||||
![Drawer](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/Drawer.gif)
|
||||
|
||||
## History publication
|
||||
|
||||
### Poptip
|
||||
|
||||
![Poptip](https://raw.githubusercontent.com/HandyOrg/HandyOrgResource/master/HandyControl/Resources/Poptip.gif)
|
||||
|
@ -460,6 +460,9 @@
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\WPFFlowDocument_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\WPFFlowDocument_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="..\..\Shared\HandyControlDemo_Shared\Properties\Langs\Lang.en.resx">
|
||||
|
@ -68,4 +68,54 @@
|
||||
<Link>Resources\Effects\GrayScaleEffect.ps</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottom.png">
|
||||
<Link>Resources\Images\GlowWindow\bottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\left.png">
|
||||
<Link>Resources\Images\GlowWindow\left.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\leftbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\leftbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\lefttop.png">
|
||||
<Link>Resources\Images\GlowWindow\lefttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\right.png">
|
||||
<Link>Resources\Images\GlowWindow\right.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\rightbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\rightbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\righttop.png">
|
||||
<Link>Resources\Images\GlowWindow\righttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\top.png">
|
||||
<Link>Resources\Images\GlowWindow\top.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topleft.png">
|
||||
<Link>Resources\Images\GlowWindow\topleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topright.png">
|
||||
<Link>Resources\Images\GlowWindow\topright.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -48,18 +48,15 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowDefault" TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowWin10" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@ -181,6 +178,12 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="MinWidth" Value="400"/>
|
||||
|
@ -526,6 +526,9 @@
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\WPFFlowDocument_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\WPFFlowDocument_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Data\DemoInfo.json">
|
||||
|
@ -120,6 +120,56 @@
|
||||
<Link>Resources\Effects\GrayScaleEffect.ps</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottom.png">
|
||||
<Link>Resources\Images\GlowWindow\bottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\left.png">
|
||||
<Link>Resources\Images\GlowWindow\left.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\leftbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\leftbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\lefttop.png">
|
||||
<Link>Resources\Images\GlowWindow\lefttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\right.png">
|
||||
<Link>Resources\Images\GlowWindow\right.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\rightbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\rightbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\righttop.png">
|
||||
<Link>Resources\Images\GlowWindow\righttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\top.png">
|
||||
<Link>Resources\Images\GlowWindow\top.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topleft.png">
|
||||
<Link>Resources\Images\GlowWindow\topleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topright.png">
|
||||
<Link>Resources\Images\GlowWindow\topright.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\Shared\HandyControl_Shared\HandyControl_Shared.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -49,18 +49,15 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowDefault" BasedOn="{x:Null}" TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowWin10" BasedOn="{x:Null}" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@ -182,6 +179,12 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="MinWidth" Value="400"/>
|
||||
|
@ -589,6 +589,9 @@
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\WPFFlowDocument_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\WPFFlowDocument_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\OutlinedRectangleTool_16x.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
|
||||
|
@ -191,6 +191,56 @@
|
||||
<Link>Resources\Effects\GrayScaleEffect.ps</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottom.png">
|
||||
<Link>Resources\Images\GlowWindow\bottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\bottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\bottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornerbottomright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornerbottomright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopleft.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\cornertopright.png">
|
||||
<Link>Resources\Images\GlowWindow\cornertopright.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\left.png">
|
||||
<Link>Resources\Images\GlowWindow\left.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\leftbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\leftbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\lefttop.png">
|
||||
<Link>Resources\Images\GlowWindow\lefttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\right.png">
|
||||
<Link>Resources\Images\GlowWindow\right.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\rightbottom.png">
|
||||
<Link>Resources\Images\GlowWindow\rightbottom.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\righttop.png">
|
||||
<Link>Resources\Images\GlowWindow\righttop.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\top.png">
|
||||
<Link>Resources\Images\GlowWindow\top.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topleft.png">
|
||||
<Link>Resources\Images\GlowWindow\topleft.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControl_Shared\Resources\Images\GlowWindow\topright.png">
|
||||
<Link>Resources\Images\GlowWindow\topright.png</Link>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\Shared\HandyControl_Shared\HandyControl_Shared.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
@ -48,18 +48,15 @@
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Window">
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowDefault" TargetType="Window">
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowWin10" TargetType="controls:Window">
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="BorderBrush" Value="#262e2f"/>
|
||||
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
|
||||
<Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="UseLayoutRounding" Value="True"/>
|
||||
<Setter Property="NonClientAreaBackground" Value="{DynamicResource RegionBrush}"/>
|
||||
@ -181,6 +178,12 @@
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="WindowGlow" BasedOn="{StaticResource WindowWin10}" TargetType="controls:GlowWindow">
|
||||
<Setter Property="ActiveGlowColor" Value="#262e2f"/>
|
||||
<Setter Property="InactiveGlowColor" Value="{DynamicResource BorderColor}"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="controls:ImageBrowser">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="MinWidth" Value="400"/>
|
||||
|
@ -56,6 +56,7 @@ namespace HandyControlDemo
|
||||
UpdateSkin(GlobalData.Config.Skin);
|
||||
}
|
||||
|
||||
ConfigHelper.Instance.SetWindowDefaultStyle();
|
||||
ConfigHelper.Instance.SetSystemVersionInfo(CommonHelper.GetSystemVersionInfo());
|
||||
|
||||
ServicePointManager.SecurityProtocol = (SecurityProtocolType)(SslProtocols)0x00000C00;
|
||||
|
@ -45,7 +45,7 @@
|
||||
[ "ButtonGroup", "ButtonGroupDemoCtl", "ButtonGroup_16x", "" ],
|
||||
[ "ProgressButton", "ProgressButtonDemoCtl", "ProgressButton_16x", "" ],
|
||||
[ "ChatBubble", "ChatBubbleDemoCtl", "Bubble_16xLG", "" ],
|
||||
[ "Poptip", "PoptipDemoCtl", "PopupCursor_16x", "1" ],
|
||||
[ "Poptip", "PoptipDemoCtl", "PopupCursor_16x", "" ],
|
||||
[ "NotifyIcon", "NotifyIconDemoCtl", "NotificationHub_16x", "" ],
|
||||
[ "NumericUpDown", "NumericUpDownDemoCtl", "NumericListBox_16x", "" ],
|
||||
[ "TextBox", "TextBoxDemoCtl", "TextBox_16x", "" ],
|
||||
@ -74,7 +74,7 @@
|
||||
[ "WaterfallPanel", "WaterfallPanelDemoCtl", "Panel_16x", "" ],
|
||||
[ "HoneycombPanel", "HoneycombPanelDemoCtl", "PolygonHexagon_16x", "" ],
|
||||
[ "TransitioningContentControl", "TransitioningContentControlDemoCtl", "TransitioningContentControl_16x", "" ],
|
||||
[ "Drawer", "DrawerDemoCtl", "View_Portrait_16x", "1" ],
|
||||
[ "Drawer", "DrawerDemoCtl", "View_Portrait_16x", "" ],
|
||||
[ "CoverView", "CoverViewDemoCtl", "DetailDataView_16x", "" ],
|
||||
[ "CoverFlow", "CoverFlowDemoCtl", "LinearCarousel_16x", "" ],
|
||||
[ "ProgressBar", "ProgressBarDemoCtl", "ProgressBar_16x", "" ],
|
||||
@ -96,7 +96,7 @@
|
||||
[ "Sprite", "SpriteDemoCtl", "HandyControl", "" ],
|
||||
[ "Notification", "NotificationDemoCtl", "Procedure_16x", "" ],
|
||||
[ "Dialog", "DialogDemoCtl", "Dialog_16x", "" ],
|
||||
[ "Window", "WindowDemoCtl", "WindowsForm_16x", "" ]
|
||||
[ "Window", "WindowDemoCtl", "WindowsForm_16x", "1" ]
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -40,5 +40,7 @@
|
||||
|
||||
public static readonly string QQGroupView = nameof(QQGroupView);
|
||||
|
||||
public static readonly string GlowWindow = nameof(GlowWindow);
|
||||
|
||||
}
|
||||
}
|
@ -22,7 +22,8 @@ var messageList = new List<string>
|
||||
"BlurWindow",
|
||||
"CustomNonClientAreaWindow",
|
||||
"NoNonClientAreaDragableWindow",
|
||||
"QQGroupView"
|
||||
"QQGroupView",
|
||||
"GlowWindow"
|
||||
};
|
||||
#>
|
||||
namespace HandyControlDemo.Data
|
||||
|
@ -407,6 +407,9 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Window\DialogDemoWindow.xaml.cs">
|
||||
<DependentUpon>DialogDemoWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Window\GlowWindow.xaml.cs">
|
||||
<DependentUpon>GlowWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Window\GrowlDemoWindow.xaml.cs">
|
||||
<DependentUpon>GrowlDemoWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -923,6 +926,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)Window\GlowWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)Window\GrowlDemoWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
@ -7,7 +7,6 @@
|
||||
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
|
||||
xmlns:data="clr-namespace:HandyControlDemo.Data"
|
||||
mc:Ignorable="d"
|
||||
Style="{StaticResource WindowBlur}"
|
||||
Title="HandyControlDemo"
|
||||
ShowTitle="False"
|
||||
ResizeMode="CanResizeWithGrip"
|
||||
|
@ -1050,6 +1050,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 点击打开辉光窗口 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string OpenGlowWindow {
|
||||
get {
|
||||
return ResourceManager.GetString("OpenGlowWindow", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 点击打开图片浏览器 的本地化字符串。
|
||||
/// </summary>
|
||||
|
@ -717,4 +717,7 @@
|
||||
<data name="FlowDocumentScrollViewer" xml:space="preserve">
|
||||
<value>FlowDocumentScrollViewer</value>
|
||||
</data>
|
||||
<data name="OpenGlowWindow" xml:space="preserve">
|
||||
<value>Open glowWindow</value>
|
||||
</data>
|
||||
</root>
|
@ -717,4 +717,7 @@
|
||||
<data name="FlowDocumentScrollViewer" xml:space="preserve">
|
||||
<value>FlowDocumentScrollViewer</value>
|
||||
</data>
|
||||
<data name="OpenGlowWindow" xml:space="preserve">
|
||||
<value>Open glowWindow</value>
|
||||
</data>
|
||||
</root>
|
@ -717,4 +717,7 @@
|
||||
<data name="FlowDocumentScrollViewer" xml:space="preserve">
|
||||
<value>FlowDocumentScrollViewer</value>
|
||||
</data>
|
||||
<data name="OpenGlowWindow" xml:space="preserve">
|
||||
<value>Open glowWindow</value>
|
||||
</data>
|
||||
</root>
|
@ -717,4 +717,7 @@
|
||||
<data name="FlowDocumentScrollViewer" xml:space="preserve">
|
||||
<value>FlowDocumentScrollViewer</value>
|
||||
</data>
|
||||
<data name="OpenGlowWindow" xml:space="preserve">
|
||||
<value>Open glowWindow</value>
|
||||
</data>
|
||||
</root>
|
@ -717,4 +717,7 @@
|
||||
<data name="FlowDocumentScrollViewer" xml:space="preserve">
|
||||
<value>流文档滚动视图</value>
|
||||
</data>
|
||||
<data name="OpenGlowWindow" xml:space="preserve">
|
||||
<value>点击打开辉光窗口</value>
|
||||
</data>
|
||||
</root>
|
After Width: | Height: | Size: 133 B |
@ -16,6 +16,9 @@
|
||||
<Button Click="ButtonCustomContent_OnClick" Content="{x:Static langs:Lang.OpenCustomContentWindow}"/>
|
||||
<Button Name="ButtonMouseFollow" Click="ButtonMouseFollow_OnClick" Content="{x:Static langs:Lang.OpenMouseFollowWindow}"/>
|
||||
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.NoNonClientAreaDragableWindow}" Content="{x:Static langs:Lang.OpenNoNonClientAreaDragableWindow}"/>
|
||||
<hc:Badge Text="New" Style="{StaticResource BadgeDanger}" VerticalAlignment="Center" HorizontalAlignment="Center" BadgeMargin="0,-10,-20,0">
|
||||
<Button Command="{Binding OpenWindowCmd}" CommandParameter="{x:Static data:MessageToken.GlowWindow}" Content="{x:Static langs:Lang.OpenGlowWindow}"/>
|
||||
</hc:Badge>
|
||||
</UniformGrid>
|
||||
</hc:TransitioningContentControl>
|
||||
</UserControl>
|
||||
|
@ -10,7 +10,6 @@
|
||||
ShowTitle="True"
|
||||
BorderThickness="1"
|
||||
BorderBrush="#262e2f"
|
||||
Style="{StaticResource WindowWin10}"
|
||||
ResizeMode="NoResize"
|
||||
ShowInTaskbar="False"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
|
@ -1,15 +1,14 @@
|
||||
<hc:BlurWindow x:Class="HandyControlDemo.Window.BlurWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
Style="{StaticResource WindowBlur}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
||||
</hc:BlurWindow>
|
||||
|
@ -8,7 +8,6 @@
|
||||
mc:Ignorable="d"
|
||||
Background="{DynamicResource MainContentBackgroundBrush}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Style="{StaticResource WindowWin10}"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
|
@ -12,7 +12,6 @@
|
||||
NonClientAreaHeight="69"
|
||||
Background="{DynamicResource MainContentBackgroundBrush}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Style="{StaticResource WindowWin10}"
|
||||
ShowTitle="False"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
Height="450"
|
||||
|
17
src/Shared/HandyControlDemo_Shared/Window/GlowWindow.xaml
Normal file
@ -0,0 +1,17 @@
|
||||
<hc:GlowWindow x:Class="HandyControlDemo.Window.GlowWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
mc:Ignorable="d"
|
||||
Background="{DynamicResource MainContentBackgroundBrush}"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="{x:Static langs:Lang.Title}"
|
||||
ActiveGlowColor="{DynamicResource PrimaryColor}"
|
||||
Height="450"
|
||||
Width="800"
|
||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
|
||||
<Border Background="{DynamicResource MainContentForegroundDrawingBrush}"/>
|
||||
</hc:GlowWindow>
|
10
src/Shared/HandyControlDemo_Shared/Window/GlowWindow.xaml.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.Window
|
||||
{
|
||||
public partial class GlowWindow
|
||||
{
|
||||
public GlowWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,6 @@
|
||||
mc:Ignorable="d"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowTitle="True"
|
||||
Style="{StaticResource WindowBlur}"
|
||||
Icon="/HandyControlDemo;component/Resources/Img/icon.ico"
|
||||
ShowNonClientArea="False"
|
||||
Title="NoClientDragableWindow"
|
||||
|
@ -97,7 +97,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var _ = new WindowInteropHelper(window)
|
||||
{
|
||||
Owner = NativeMethods.GetDesktopWindow()
|
||||
Owner = InteropMethods.GetDesktopWindow()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +96,10 @@ namespace HandyControl.Controls
|
||||
|
||||
public static Color GetColorAt(int x, int y)
|
||||
{
|
||||
var desk = UnsafeNativeMethods.GetDesktopWindow();
|
||||
var dc = UnsafeNativeMethods.GetWindowDC(desk);
|
||||
var a = (int)UnsafeNativeMethods.GetPixel(dc, x, y);
|
||||
UnsafeNativeMethods.ReleaseDC(desk, dc);
|
||||
var desk = InteropMethods.GetDesktopWindow();
|
||||
var dc = InteropMethods.GetWindowDC(desk);
|
||||
var a = (int)InteropMethods.GetPixel(dc, x, y);
|
||||
InteropMethods.ReleaseDC(desk, dc);
|
||||
return Color.FromArgb(255, (byte) ((a >> 0) & 0xff), (byte) ((a >> 8) & 0xff), (byte) ((a >> 16) & 0xff));
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private IconHandle _iconHandle;
|
||||
|
||||
private const int WmTrayMouseMessage = NativeMethods.WM_USER + 1024;
|
||||
private const int WmTrayMouseMessage = InteropValues.WM_USER + 1024;
|
||||
|
||||
private string _windowClassName;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private IntPtr _messageWindowHandle;
|
||||
|
||||
private readonly WndProc _callback;
|
||||
private readonly InteropValues.WndProc _callback;
|
||||
|
||||
private Popup _contextContent;
|
||||
|
||||
@ -165,9 +165,9 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (!_added || DesignerHelper.IsInDesignMode) return;
|
||||
|
||||
var data = new NOTIFYICONDATA
|
||||
var data = new InteropValues.NOTIFYICONDATA
|
||||
{
|
||||
uFlags = NativeMethods.NIF_INFO,
|
||||
uFlags = InteropValues.NIF_INFO,
|
||||
hWnd = _messageWindowHandle,
|
||||
uID = _id,
|
||||
szInfoTitle = title ?? string.Empty,
|
||||
@ -177,20 +177,20 @@ namespace HandyControl.Controls
|
||||
switch (infoType)
|
||||
{
|
||||
case NotifyIconInfoType.Info:
|
||||
data.dwInfoFlags = NativeMethods.NIIF_INFO;
|
||||
data.dwInfoFlags = InteropValues.NIIF_INFO;
|
||||
break;
|
||||
case NotifyIconInfoType.Warning:
|
||||
data.dwInfoFlags = NativeMethods.NIIF_WARNING;
|
||||
data.dwInfoFlags = InteropValues.NIIF_WARNING;
|
||||
break;
|
||||
case NotifyIconInfoType.Error:
|
||||
data.dwInfoFlags = NativeMethods.NIIF_ERROR;
|
||||
data.dwInfoFlags = InteropValues.NIIF_ERROR;
|
||||
break;
|
||||
case NotifyIconInfoType.None:
|
||||
data.dwInfoFlags = NativeMethods.NIIF_NONE;
|
||||
data.dwInfoFlags = InteropValues.NIIF_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
UnsafeNativeMethods.Shell_NotifyIcon(NativeMethods.NIM_MODIFY, data);
|
||||
InteropMethods.Shell_NotifyIcon(InteropValues.NIM_MODIFY, data);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -330,7 +330,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var isTrue = FindNotifyIcon(out var rectNotify);
|
||||
if (!isTrue) return false;
|
||||
NativeMethods.GetCursorPos(out var point);
|
||||
InteropMethods.GetCursorPos(out var point);
|
||||
if (point.X >= rectNotify.Left && point.X <= rectNotify.Right &&
|
||||
point.Y >= rectNotify.Top && point.Y <= rectNotify.Bottom)
|
||||
{
|
||||
@ -368,17 +368,17 @@ namespace HandyControl.Controls
|
||||
//referenced from http://www.cnblogs.com/sczmzx/p/5158127.html
|
||||
private IntPtr FindTrayToolbarWindow()
|
||||
{
|
||||
var hWnd = NativeMethods.FindWindow("Shell_TrayWnd", null);
|
||||
var hWnd = InteropMethods.FindWindow("Shell_TrayWnd", null);
|
||||
if (hWnd != IntPtr.Zero)
|
||||
{
|
||||
hWnd = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "TrayNotifyWnd", null);
|
||||
hWnd = InteropMethods.FindWindowEx(hWnd, IntPtr.Zero, "TrayNotifyWnd", null);
|
||||
if (hWnd != IntPtr.Zero)
|
||||
{
|
||||
|
||||
hWnd = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "SysPager", null);
|
||||
hWnd = InteropMethods.FindWindowEx(hWnd, IntPtr.Zero, "SysPager", null);
|
||||
if (hWnd != IntPtr.Zero)
|
||||
{
|
||||
hWnd = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "ToolbarWindow32", null);
|
||||
hWnd = InteropMethods.FindWindowEx(hWnd, IntPtr.Zero, "ToolbarWindow32", null);
|
||||
|
||||
}
|
||||
}
|
||||
@ -389,17 +389,17 @@ namespace HandyControl.Controls
|
||||
//referenced from http://www.cnblogs.com/sczmzx/p/5158127.html
|
||||
private IntPtr FindTrayToolbarOverFlowWindow()
|
||||
{
|
||||
var hWnd = NativeMethods.FindWindow("NotifyIconOverflowWindow", null);
|
||||
var hWnd = InteropMethods.FindWindow("NotifyIconOverflowWindow", null);
|
||||
if (hWnd != IntPtr.Zero)
|
||||
{
|
||||
hWnd = NativeMethods.FindWindowEx(hWnd, IntPtr.Zero, "ToolbarWindow32", null);
|
||||
hWnd = InteropMethods.FindWindowEx(hWnd, IntPtr.Zero, "ToolbarWindow32", null);
|
||||
}
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
private bool FindNotifyIcon(out NativeMethods.RECT rect)
|
||||
private bool FindNotifyIcon(out InteropValues.RECT rect)
|
||||
{
|
||||
var rectNotify = new NativeMethods.RECT();
|
||||
var rectNotify = new InteropValues.RECT();
|
||||
var hTrayWnd = FindTrayToolbarWindow();
|
||||
var isTrue = FindNotifyIcon(hTrayWnd, ref rectNotify);
|
||||
if (!isTrue)
|
||||
@ -412,48 +412,48 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
//referenced from http://www.cnblogs.com/sczmzx/p/5158127.html
|
||||
private bool FindNotifyIcon(IntPtr hTrayWnd, ref NativeMethods.RECT rectNotify)
|
||||
private bool FindNotifyIcon(IntPtr hTrayWnd, ref InteropValues.RECT rectNotify)
|
||||
{
|
||||
NativeMethods.GetWindowRect(hTrayWnd, out var rectTray);
|
||||
var count = (int)NativeMethods.SendMessage(hTrayWnd, NativeMethods.TB_BUTTONCOUNT, 0, IntPtr.Zero);
|
||||
InteropMethods.GetWindowRect(hTrayWnd, out var rectTray);
|
||||
var count = (int)InteropMethods.SendMessage(hTrayWnd, InteropValues.TB_BUTTONCOUNT, 0, IntPtr.Zero);
|
||||
|
||||
var isFind = false;
|
||||
if (count > 0)
|
||||
{
|
||||
NativeMethods.GetWindowThreadProcessId(hTrayWnd, out var trayPid);
|
||||
var hProcess = NativeMethods.OpenProcess(NativeMethods.ProcessAccess.VMOperation | NativeMethods.ProcessAccess.VMRead | NativeMethods.ProcessAccess.VMWrite, false, trayPid);
|
||||
var address = NativeMethods.VirtualAllocEx(hProcess, IntPtr.Zero, 1024, NativeMethods.AllocationType.Commit, NativeMethods.MemoryProtection.ReadWrite);
|
||||
InteropMethods.GetWindowThreadProcessId(hTrayWnd, out var trayPid);
|
||||
var hProcess = InteropMethods.OpenProcess(InteropValues.ProcessAccess.VMOperation | InteropValues.ProcessAccess.VMRead | InteropValues.ProcessAccess.VMWrite, false, trayPid);
|
||||
var address = InteropMethods.VirtualAllocEx(hProcess, IntPtr.Zero, 1024, InteropValues.AllocationType.Commit, InteropValues.MemoryProtection.ReadWrite);
|
||||
|
||||
var btnData = new NativeMethods.TBBUTTON();
|
||||
var trayData = new NativeMethods.TRAYDATA();
|
||||
var btnData = new InteropValues.TBBUTTON();
|
||||
var trayData = new InteropValues.TRAYDATA();
|
||||
var handel = Process.GetCurrentProcess().Id;
|
||||
|
||||
for (uint i = 0; i < count; i++)
|
||||
{
|
||||
NativeMethods.SendMessage(hTrayWnd, NativeMethods.TB_GETBUTTON, i, address);
|
||||
var isTrue = NativeMethods.ReadProcessMemory(hProcess, address, out btnData, Marshal.SizeOf(btnData), out _);
|
||||
InteropMethods.SendMessage(hTrayWnd, InteropValues.TB_GETBUTTON, i, address);
|
||||
var isTrue = InteropMethods.ReadProcessMemory(hProcess, address, out btnData, Marshal.SizeOf(btnData), out _);
|
||||
if (!isTrue) continue;
|
||||
if (btnData.dwData == IntPtr.Zero)
|
||||
{
|
||||
btnData.dwData = btnData.iString;
|
||||
}
|
||||
NativeMethods.ReadProcessMemory(hProcess, btnData.dwData, out trayData, Marshal.SizeOf(trayData), out _);
|
||||
NativeMethods.GetWindowThreadProcessId(trayData.hwnd, out var dwProcessId);
|
||||
InteropMethods.ReadProcessMemory(hProcess, btnData.dwData, out trayData, Marshal.SizeOf(trayData), out _);
|
||||
InteropMethods.GetWindowThreadProcessId(trayData.hwnd, out var dwProcessId);
|
||||
if (dwProcessId == (uint)handel)
|
||||
{
|
||||
var rect = new NativeMethods.RECT();
|
||||
var lngRect = NativeMethods.VirtualAllocEx(hProcess, IntPtr.Zero, Marshal.SizeOf(typeof(Rect)), NativeMethods.AllocationType.Commit, NativeMethods.MemoryProtection.ReadWrite);
|
||||
NativeMethods.SendMessage(hTrayWnd, NativeMethods.TB_GETITEMRECT, i, lngRect);
|
||||
NativeMethods.ReadProcessMemory(hProcess, lngRect, out rect, Marshal.SizeOf(rect), out _);
|
||||
var rect = new InteropValues.RECT();
|
||||
var lngRect = InteropMethods.VirtualAllocEx(hProcess, IntPtr.Zero, Marshal.SizeOf(typeof(Rect)), InteropValues.AllocationType.Commit, InteropValues.MemoryProtection.ReadWrite);
|
||||
InteropMethods.SendMessage(hTrayWnd, InteropValues.TB_GETITEMRECT, i, lngRect);
|
||||
InteropMethods.ReadProcessMemory(hProcess, lngRect, out rect, Marshal.SizeOf(rect), out _);
|
||||
|
||||
NativeMethods.VirtualFreeEx(hProcess, lngRect, Marshal.SizeOf(rect), NativeMethods.FreeType.Decommit);
|
||||
NativeMethods.VirtualFreeEx(hProcess, lngRect, 0, NativeMethods.FreeType.Release);
|
||||
InteropMethods.VirtualFreeEx(hProcess, lngRect, Marshal.SizeOf(rect), InteropValues.FreeType.Decommit);
|
||||
InteropMethods.VirtualFreeEx(hProcess, lngRect, 0, InteropValues.FreeType.Release);
|
||||
|
||||
var left = rectTray.Left + rect.Left;
|
||||
var top = rectTray.Top + rect.Top;
|
||||
var botton = rectTray.Top + rect.Bottom;
|
||||
var right = rectTray.Left + rect.Right;
|
||||
rectNotify = new NativeMethods.RECT
|
||||
rectNotify = new InteropValues.RECT
|
||||
{
|
||||
Left = left,
|
||||
Right = right,
|
||||
@ -464,9 +464,9 @@ namespace HandyControl.Controls
|
||||
break;
|
||||
}
|
||||
}
|
||||
NativeMethods.VirtualFreeEx(hProcess, address, 0x4096, NativeMethods.FreeType.Decommit);
|
||||
NativeMethods.VirtualFreeEx(hProcess, address, 0, NativeMethods.FreeType.Release);
|
||||
NativeMethods.CloseHandle(hProcess);
|
||||
InteropMethods.VirtualFreeEx(hProcess, address, 0x4096, InteropValues.FreeType.Decommit);
|
||||
InteropMethods.VirtualFreeEx(hProcess, address, 0, InteropValues.FreeType.Release);
|
||||
InteropMethods.CloseHandle(hProcess);
|
||||
}
|
||||
return isFind;
|
||||
}
|
||||
@ -496,13 +496,13 @@ namespace HandyControl.Controls
|
||||
if (DesignerHelper.IsInDesignMode) return;
|
||||
|
||||
_isTransparent = isTransparent;
|
||||
var data = new NOTIFYICONDATA
|
||||
var data = new InteropValues.NOTIFYICONDATA
|
||||
{
|
||||
uCallbackMessage = WmTrayMouseMessage,
|
||||
uFlags = NativeMethods.NIF_MESSAGE | NativeMethods.NIF_ICON | NativeMethods.NIF_TIP,
|
||||
uFlags = InteropValues.NIF_MESSAGE | InteropValues.NIF_ICON | InteropValues.NIF_TIP,
|
||||
hWnd = _messageWindowHandle,
|
||||
uID = _id,
|
||||
dwInfoFlags = NativeMethods.NIF_TIP,
|
||||
dwInfoFlags = InteropValues.NIF_TIP,
|
||||
hIcon = isTransparent ? IntPtr.Zero : _iconCurrentHandle,
|
||||
szTip = Text
|
||||
};
|
||||
@ -511,17 +511,17 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (!_added)
|
||||
{
|
||||
UnsafeNativeMethods.Shell_NotifyIcon(NativeMethods.NIM_ADD, data);
|
||||
InteropMethods.Shell_NotifyIcon(InteropValues.NIM_ADD, data);
|
||||
_added = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnsafeNativeMethods.Shell_NotifyIcon(NativeMethods.NIM_MODIFY, data);
|
||||
InteropMethods.Shell_NotifyIcon(InteropValues.NIM_MODIFY, data);
|
||||
}
|
||||
}
|
||||
else if (_added)
|
||||
{
|
||||
UnsafeNativeMethods.Shell_NotifyIcon(NativeMethods.NIM_DELETE, data);
|
||||
InteropMethods.Shell_NotifyIcon(InteropValues.NIM_DELETE, data);
|
||||
_added = false;
|
||||
}
|
||||
}
|
||||
@ -530,7 +530,7 @@ namespace HandyControl.Controls
|
||||
private void RegisterClass()
|
||||
{
|
||||
_windowClassName = $"HandyControl.Controls.NotifyIcon{Guid.NewGuid()}";
|
||||
var wndclass = new WNDCLASS
|
||||
var wndclass = new InteropValues.WNDCLASS
|
||||
{
|
||||
style = 0,
|
||||
lpfnWndProc = _callback,
|
||||
@ -544,9 +544,9 @@ namespace HandyControl.Controls
|
||||
lpszClassName = _windowClassName
|
||||
};
|
||||
|
||||
UnsafeNativeMethods.RegisterClass(wndclass);
|
||||
_wmTaskbarCreated = NativeMethods.RegisterWindowMessage("TaskbarCreated");
|
||||
_messageWindowHandle = UnsafeNativeMethods.CreateWindowEx(0, _windowClassName, "", 0, 0, 0, 1, 1,
|
||||
InteropMethods.RegisterClass(wndclass);
|
||||
_wmTaskbarCreated = InteropMethods.RegisterWindowMessage("TaskbarCreated");
|
||||
_messageWindowHandle = InteropMethods.CreateWindowEx(0, _windowClassName, "", 0, 0, 0, 1, 1,
|
||||
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
@ -562,17 +562,17 @@ namespace HandyControl.Controls
|
||||
{
|
||||
switch (lparam.ToInt64())
|
||||
{
|
||||
case NativeMethods.WM_LBUTTONDBLCLK:
|
||||
case InteropValues.WM_LBUTTONDBLCLK:
|
||||
WmMouseDown(MouseButton.Left, 2);
|
||||
break;
|
||||
case NativeMethods.WM_LBUTTONUP:
|
||||
case InteropValues.WM_LBUTTONUP:
|
||||
WmMouseUp(MouseButton.Left);
|
||||
break;
|
||||
case NativeMethods.WM_RBUTTONUP:
|
||||
case InteropValues.WM_RBUTTONUP:
|
||||
ShowContextMenu();
|
||||
WmMouseUp(MouseButton.Right);
|
||||
break;
|
||||
case NativeMethods.WM_MOUSEMOVE:
|
||||
case InteropValues.WM_MOUSEMOVE:
|
||||
if (!_dispatcherTimerPos.IsEnabled)
|
||||
{
|
||||
_dispatcherTimerPos.Interval = TimeSpan.FromMilliseconds(200);
|
||||
@ -583,7 +583,7 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
return UnsafeNativeMethods.DefWindowProc(hWnd, msg, wparam, lparam);
|
||||
return InteropMethods.DefWindowProc(hWnd, msg, wparam, lparam);
|
||||
}
|
||||
|
||||
private void WmMouseDown(MouseButton button, int clicks)
|
||||
@ -632,7 +632,7 @@ namespace HandyControl.Controls
|
||||
Content = ContextContent
|
||||
};
|
||||
_contextContent.IsOpen = true;
|
||||
UnsafeNativeMethods.SetForegroundWindow(_contextContent.Child.GetHandle());
|
||||
InteropMethods.SetForegroundWindow(_contextContent.Child.GetHandle());
|
||||
}
|
||||
else if (ContextMenu != null)
|
||||
{
|
||||
@ -655,7 +655,7 @@ namespace HandyControl.Controls
|
||||
ContextMenu.Placement = PlacementMode.Mouse;
|
||||
ContextMenu.IsOpen = true;
|
||||
|
||||
UnsafeNativeMethods.SetForegroundWindow(ContextMenu.GetHandle());
|
||||
InteropMethods.SetForegroundWindow(ContextMenu.GetHandle());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
@ -7,6 +8,11 @@ namespace HandyControl.Controls
|
||||
{
|
||||
public class BlurWindow : Window
|
||||
{
|
||||
static BlurWindow()
|
||||
{
|
||||
StyleProperty.OverrideMetadata(typeof(BlurWindow), new FrameworkPropertyMetadata(Application.Current.FindResource(ResourceToken.WindowBlur)));
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
461
src/Shared/HandyControl_Shared/Controls/Window/GlowWindow.cs
Normal file
@ -0,0 +1,461 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Expression.Drawing;
|
||||
using HandyControl.Tools;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class GlowWindow : Window
|
||||
{
|
||||
internal int DeferGlowChangesCount;
|
||||
|
||||
private readonly GlowEdge[] _glowEdges = new GlowEdge[4];
|
||||
|
||||
private DispatcherTimer _makeGlowVisibleTimer;
|
||||
|
||||
private bool _isGlowVisible;
|
||||
|
||||
private bool _useLogicalSizeForRestore;
|
||||
|
||||
private bool _updatingZOrder;
|
||||
|
||||
private Rect _logicalSizeForRestore = Rect.Empty;
|
||||
|
||||
public static readonly DependencyProperty ActiveGlowColorProperty = DependencyProperty.Register(
|
||||
"ActiveGlowColor", typeof(Color), typeof(GlowWindow), new PropertyMetadata(default(Color), OnGlowColorChanged));
|
||||
|
||||
public Color ActiveGlowColor
|
||||
{
|
||||
get => (Color)GetValue(ActiveGlowColorProperty);
|
||||
set => SetValue(ActiveGlowColorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty InactiveGlowColorProperty = DependencyProperty.Register(
|
||||
"InactiveGlowColor", typeof(Color), typeof(GlowWindow), new PropertyMetadata(default(Color), OnGlowColorChanged));
|
||||
|
||||
public Color InactiveGlowColor
|
||||
{
|
||||
get => (Color)GetValue(InactiveGlowColorProperty);
|
||||
set => SetValue(InactiveGlowColorProperty, value);
|
||||
}
|
||||
|
||||
static GlowWindow()
|
||||
{
|
||||
StyleProperty.OverrideMetadata(typeof(GlowWindow), new FrameworkPropertyMetadata(Application.Current.FindResource(ResourceToken.WindowGlow)));
|
||||
ResizeModeProperty.OverrideMetadata(typeof(GlowWindow), new FrameworkPropertyMetadata(OnResizeModeChanged));
|
||||
}
|
||||
|
||||
#region internal
|
||||
|
||||
internal void EndDeferGlowChanges()
|
||||
{
|
||||
foreach (var current in LoadedGlowWindows) current.CommitChanges();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region protected
|
||||
|
||||
protected virtual bool ShouldShowGlow
|
||||
{
|
||||
get
|
||||
{
|
||||
var handle = this.GetHandle();
|
||||
return InteropMethods.IsWindowVisible(handle) && !InteropMethods.IsIconic(handle) &&
|
||||
!InteropMethods.IsZoomed(handle) && ResizeMode != ResizeMode.NoResize;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IntPtr HwndSourceHook(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||
{
|
||||
if (msg <= 71)
|
||||
{
|
||||
if (msg == 6)
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
if (msg != 12)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 70:
|
||||
WmWindowPosChanging(lParam);
|
||||
return IntPtr.Zero;
|
||||
case 71:
|
||||
WmWindowPosChanged(lParam);
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg <= 166)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 128:
|
||||
break;
|
||||
case 129:
|
||||
case 130:
|
||||
return IntPtr.Zero;
|
||||
case 134:
|
||||
handled = true;
|
||||
return WmNcActivate(hWnd, wParam);
|
||||
default:
|
||||
switch (msg)
|
||||
{
|
||||
case 164:
|
||||
case 165:
|
||||
case 166:
|
||||
handled = true;
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case 174:
|
||||
case 175:
|
||||
handled = true;
|
||||
return IntPtr.Zero;
|
||||
default:
|
||||
if (msg != 274) return IntPtr.Zero;
|
||||
WmSysCommand(hWnd, wParam);
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handled = true;
|
||||
return CallDefWindowProcWithoutVisibleStyle(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
protected override void OnActivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnActivated(e);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated(EventArgs e)
|
||||
{
|
||||
UpdateGlowActiveState();
|
||||
base.OnDeactivated(e);
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
StopTimer();
|
||||
DestroyGlowWindows();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
protected override void OnSourceInitialized(EventArgs e)
|
||||
{
|
||||
var hwndSource = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
hwndSource.AddHook(HwndSourceHook);
|
||||
CreateGlowWindowHandles();
|
||||
}
|
||||
|
||||
base.OnSourceInitialized(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
private IEnumerable<GlowEdge> LoadedGlowWindows => from w in _glowEdges where w != null select w;
|
||||
|
||||
private bool IsGlowVisible
|
||||
{
|
||||
get => _isGlowVisible;
|
||||
set
|
||||
{
|
||||
if (_isGlowVisible != value)
|
||||
{
|
||||
_isGlowVisible = value;
|
||||
for (var i = 0; i < _glowEdges.Length; i++)
|
||||
{
|
||||
GetOrCreateGlowWindow(i).IsVisible = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GlowEdge GetOrCreateGlowWindow(int direction)
|
||||
{
|
||||
return _glowEdges[direction] ?? (_glowEdges[direction] = new GlowEdge(this, (Dock)direction)
|
||||
{
|
||||
ActiveGlowColor = ActiveGlowColor,
|
||||
InactiveGlowColor = InactiveGlowColor,
|
||||
IsActive = IsActive
|
||||
});
|
||||
}
|
||||
|
||||
private static void OnResizeModeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var customChromeWindow = (GlowWindow)obj;
|
||||
customChromeWindow.UpdateGlowVisibility(false);
|
||||
}
|
||||
|
||||
private static void OnGlowColorChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args) => ((GlowWindow)obj).UpdateGlowColors();
|
||||
|
||||
private void UpdateGlowColors()
|
||||
{
|
||||
using (DeferGlowChanges())
|
||||
{
|
||||
foreach (var current in LoadedGlowWindows)
|
||||
{
|
||||
current.ActiveGlowColor = ActiveGlowColor;
|
||||
current.InactiveGlowColor = InactiveGlowColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGlowVisibility(bool delayIfNecessary)
|
||||
{
|
||||
var shouldShowGlow = ShouldShowGlow;
|
||||
if (shouldShowGlow != IsGlowVisible)
|
||||
{
|
||||
if (SystemParameters.MinimizeAnimation && shouldShowGlow && delayIfNecessary)
|
||||
{
|
||||
if (_makeGlowVisibleTimer != null)
|
||||
{
|
||||
_makeGlowVisibleTimer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
_makeGlowVisibleTimer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(200.0)
|
||||
};
|
||||
_makeGlowVisibleTimer.Tick += OnDelayedVisibilityTimerTick;
|
||||
}
|
||||
|
||||
_makeGlowVisibleTimer.Start();
|
||||
return;
|
||||
}
|
||||
|
||||
StopTimer();
|
||||
IsGlowVisible = shouldShowGlow;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopTimer()
|
||||
{
|
||||
if (_makeGlowVisibleTimer != null)
|
||||
{
|
||||
_makeGlowVisibleTimer.Stop();
|
||||
_makeGlowVisibleTimer.Tick -= OnDelayedVisibilityTimerTick;
|
||||
_makeGlowVisibleTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDelayedVisibilityTimerTick(object sender, EventArgs e)
|
||||
{
|
||||
StopTimer();
|
||||
UpdateGlowWindowPositions(false);
|
||||
}
|
||||
|
||||
private void UpdateGlowWindowPositions(bool delayIfNecessary)
|
||||
{
|
||||
using (DeferGlowChanges())
|
||||
{
|
||||
UpdateGlowVisibility(delayIfNecessary);
|
||||
foreach (var current in LoadedGlowWindows) current.UpdateWindowPos();
|
||||
}
|
||||
}
|
||||
|
||||
private IDisposable DeferGlowChanges() => new ChangeScope(this);
|
||||
|
||||
private void UpdateGlowActiveState()
|
||||
{
|
||||
using (DeferGlowChanges())
|
||||
{
|
||||
foreach (var current in LoadedGlowWindows)
|
||||
{
|
||||
current.IsActive = IsActive;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DestroyGlowWindows()
|
||||
{
|
||||
for (var i = 0; i < _glowEdges.Length; i++)
|
||||
{
|
||||
using (_glowEdges[i])
|
||||
{
|
||||
_glowEdges[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void WmWindowPosChanging(IntPtr lParam)
|
||||
{
|
||||
var windowpos = (InteropValues.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(InteropValues.WINDOWPOS));
|
||||
if ((windowpos.flags & 2u) == 0u && (windowpos.flags & 1u) == 0u && windowpos.cx > 0 && windowpos.cy > 0)
|
||||
{
|
||||
var rect = new Rect(windowpos.x, windowpos.y, windowpos.cx, windowpos.cy);
|
||||
rect = rect.DeviceToLogicalUnits();
|
||||
if (_useLogicalSizeForRestore)
|
||||
{
|
||||
rect = _logicalSizeForRestore;
|
||||
_logicalSizeForRestore = Rect.Empty;
|
||||
_useLogicalSizeForRestore = false;
|
||||
}
|
||||
|
||||
var logicalRect = GetOnScreenPosition(rect);
|
||||
logicalRect = logicalRect.LogicalToDeviceUnits();
|
||||
windowpos.x = (int)logicalRect.X;
|
||||
windowpos.y = (int)logicalRect.Y;
|
||||
Marshal.StructureToPtr(windowpos, lParam, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateZOrderOfOwner(IntPtr hwndOwner)
|
||||
{
|
||||
var lastOwnedWindow = IntPtr.Zero;
|
||||
InteropMethods.EnumThreadWindows(InteropMethods.GetCurrentThreadId(), delegate (IntPtr hwnd, IntPtr lParam)
|
||||
{
|
||||
if (InteropMethods.GetWindow(hwnd, 4) == hwndOwner) lastOwnedWindow = hwnd;
|
||||
return true;
|
||||
}, IntPtr.Zero);
|
||||
|
||||
if (lastOwnedWindow != IntPtr.Zero && InteropMethods.GetWindow(hwndOwner, 3) != lastOwnedWindow)
|
||||
InteropMethods.SetWindowPos(hwndOwner, lastOwnedWindow, 0, 0, 0, 0, 19);
|
||||
}
|
||||
|
||||
private void UpdateZOrderOfThisAndOwner()
|
||||
{
|
||||
if (_updatingZOrder) return;
|
||||
try
|
||||
{
|
||||
_updatingZOrder = true;
|
||||
var windowInteropHelper = new WindowInteropHelper(this);
|
||||
var handle = windowInteropHelper.Handle;
|
||||
foreach (var current in LoadedGlowWindows)
|
||||
{
|
||||
var window = InteropMethods.GetWindow(current.Handle, 3);
|
||||
if (window != handle) InteropMethods.SetWindowPos(current.Handle, handle, 0, 0, 0, 0, 19);
|
||||
handle = current.Handle;
|
||||
}
|
||||
|
||||
var owner = windowInteropHelper.Owner;
|
||||
if (owner != IntPtr.Zero) UpdateZOrderOfOwner(owner);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_updatingZOrder = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void WmWindowPosChanged(IntPtr lParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
var windowpos = (InteropValues.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(InteropValues.WINDOWPOS));
|
||||
|
||||
UpdateGlowWindowPositions((windowpos.flags & 64u) == 0u);
|
||||
UpdateZOrderOfThisAndOwner();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
private Rect GetOnScreenPosition(Rect floatRect)
|
||||
{
|
||||
var result = floatRect;
|
||||
floatRect = floatRect.LogicalToDeviceUnits();
|
||||
ScreenHelper.FindMaximumSingleMonitorRectangle(floatRect, out _, out var rect2);
|
||||
if (!floatRect.IntersectsWith(rect2))
|
||||
{
|
||||
ScreenHelper.FindMonitorRectsFromPoint(InteropMethods.GetCursorPos(), out _, out rect2);
|
||||
rect2 = rect2.DeviceToLogicalUnits();
|
||||
if (result.Width > rect2.Width) result.Width = rect2.Width;
|
||||
if (result.Height > rect2.Height) result.Height = rect2.Height;
|
||||
if (rect2.Right <= result.X) result.X = rect2.Right - result.Width;
|
||||
if (rect2.Left > result.X + result.Width) result.X = rect2.Left;
|
||||
if (rect2.Bottom <= result.Y) result.Y = rect2.Bottom - result.Height;
|
||||
if (rect2.Top > result.Y + result.Height) result.Y = rect2.Top;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static InteropValues.MONITORINFO MonitorInfoFromWindow(IntPtr hWnd)
|
||||
{
|
||||
var hMonitor = InteropMethods.MonitorFromWindow(hWnd, 2);
|
||||
var result = default(InteropValues.MONITORINFO);
|
||||
result.cbSize = (uint)Marshal.SizeOf(typeof(InteropValues.MONITORINFO));
|
||||
InteropMethods.GetMonitorInfo(hMonitor, ref result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private IntPtr WmNcActivate(IntPtr hWnd, IntPtr wParam) => InteropMethods.DefWindowProc(hWnd, 134, wParam, InteropMethods.HRGN_NONE);
|
||||
|
||||
private bool IsAeroSnappedToMonitor(IntPtr hWnd)
|
||||
{
|
||||
var monitorinfo = MonitorInfoFromWindow(hWnd);
|
||||
var logicalRect = new Rect(Left, Top, Width, Height);
|
||||
logicalRect = logicalRect.LogicalToDeviceUnits();
|
||||
return MathHelper.AreClose(monitorinfo.rcWork.Height, logicalRect.Height) && MathHelper.AreClose(monitorinfo.rcWork.Top, logicalRect.Top);
|
||||
}
|
||||
|
||||
private void WmSysCommand(IntPtr hWnd, IntPtr wParam)
|
||||
{
|
||||
var num = InteropMethods.GET_SC_WPARAM(wParam);
|
||||
if (num == 61456)
|
||||
InteropMethods.RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero,
|
||||
InteropValues.RedrawWindowFlags.Invalidate | InteropValues.RedrawWindowFlags.NoChildren |
|
||||
InteropValues.RedrawWindowFlags.UpdateNow | InteropValues.RedrawWindowFlags.Frame);
|
||||
if ((num == 61488 || num == 61472 || num == 61456 || num == 61440) && WindowState == WindowState.Normal &&
|
||||
!IsAeroSnappedToMonitor(hWnd)) _logicalSizeForRestore = new Rect(Left, Top, Width, Height);
|
||||
if (num == 61456 && WindowState == WindowState.Maximized && _logicalSizeForRestore == Rect.Empty)
|
||||
_logicalSizeForRestore = new Rect(Left, Top, Width, Height);
|
||||
if (num == 61728 && WindowState != WindowState.Minimized && _logicalSizeForRestore.Width > 0.0 &&
|
||||
_logicalSizeForRestore.Height > 0.0)
|
||||
{
|
||||
Left = _logicalSizeForRestore.Left;
|
||||
Top = _logicalSizeForRestore.Top;
|
||||
Width = _logicalSizeForRestore.Width;
|
||||
Height = _logicalSizeForRestore.Height;
|
||||
_useLogicalSizeForRestore = true;
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr CallDefWindowProcWithoutVisibleStyle(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
var flag = VisualHelper.ModifyStyle(hWnd, 268435456, 0);
|
||||
var result = InteropMethods.DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
if (flag) VisualHelper.ModifyStyle(hWnd, 0, 268435456);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CreateGlowWindowHandles()
|
||||
{
|
||||
for (var i = 0; i < _glowEdges.Length; i++) GetOrCreateGlowWindow(i).EnsureHandle();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -63,7 +63,7 @@ namespace HandyControl.Controls
|
||||
|
||||
public static readonly DependencyProperty NonClientAreaHeightProperty = DependencyProperty.Register(
|
||||
"NonClientAreaHeight", typeof(double), typeof(Window),
|
||||
new PropertyMetadata(26.0));
|
||||
new PropertyMetadata(22.0));
|
||||
|
||||
public static readonly DependencyProperty ShowNonClientAreaProperty = DependencyProperty.Register(
|
||||
"ShowNonClientArea", typeof(bool), typeof(Window),
|
||||
@ -80,8 +80,6 @@ namespace HandyControl.Controls
|
||||
|
||||
private Thickness _actualBorderThickness;
|
||||
|
||||
private UIElement _nonClientArea;
|
||||
|
||||
private bool _showNonClientArea = true;
|
||||
|
||||
private double _tempNonClientAreaHeight;
|
||||
@ -92,6 +90,13 @@ namespace HandyControl.Controls
|
||||
|
||||
private ResizeMode _tempResizeMode;
|
||||
|
||||
private UIElement _nonClientArea;
|
||||
|
||||
static Window()
|
||||
{
|
||||
StyleProperty.OverrideMetadata(typeof(Window), new FrameworkPropertyMetadata(Application.Current.FindResource(ResourceToken.WindowWin10)));
|
||||
}
|
||||
|
||||
public Window()
|
||||
{
|
||||
#if netle40
|
||||
|
@ -7,6 +7,6 @@ namespace HandyControl.Data
|
||||
{
|
||||
public MouseHookMessageType Message { get; set; }
|
||||
|
||||
public NativeMethods.POINT Point { get; set; }
|
||||
public InteropValues.POINT Point { get; set; }
|
||||
}
|
||||
}
|
69
src/Shared/HandyControl_Shared/Data/DisposableObject.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public class DisposableObject : IDisposable
|
||||
{
|
||||
private EventHandler _disposing;
|
||||
|
||||
public bool IsDisposed { get; private set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~DisposableObject()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
public event EventHandler Disposing
|
||||
{
|
||||
add
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
_disposing += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
_disposing -= value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ThrowIfDisposed()
|
||||
{
|
||||
if (IsDisposed) throw new ObjectDisposedException(GetType().Name);
|
||||
}
|
||||
|
||||
protected void Dispose(bool disposing)
|
||||
{
|
||||
if (IsDisposed) return;
|
||||
|
||||
try
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_disposing?.Invoke(this, EventArgs.Empty);
|
||||
_disposing = null;
|
||||
DisposeManagedResources();
|
||||
}
|
||||
|
||||
DisposeNativeResources();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DisposeManagedResources()
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void DisposeNativeResources()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using HandyControl.Controls;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class ChangeScope : DisposableObject
|
||||
{
|
||||
private readonly GlowWindow _window;
|
||||
|
||||
public ChangeScope(GlowWindow window)
|
||||
{
|
||||
_window = window;
|
||||
_window.DeferGlowChangesCount++;
|
||||
}
|
||||
|
||||
protected override void DisposeManagedResources()
|
||||
{
|
||||
_window.DeferGlowChangesCount--;
|
||||
if (_window.DeferGlowChangesCount == 0) _window.EndDeferGlowChanges();
|
||||
}
|
||||
}
|
||||
}
|
113
src/Shared/HandyControl_Shared/Data/GlowWindow/GlowBitmap.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class GlowBitmap : DisposableObject
|
||||
{
|
||||
internal const int GlowBitmapPartCount = 16;
|
||||
|
||||
private const int BytesPerPixelBgra32 = 4;
|
||||
|
||||
private static readonly CachedBitmapInfo[] _transparencyMasks = new CachedBitmapInfo[GlowBitmapPartCount];
|
||||
|
||||
private readonly InteropValues.BITMAPINFO _bitmapInfo;
|
||||
|
||||
private readonly IntPtr _pbits;
|
||||
|
||||
internal GlowBitmap(IntPtr hdcScreen, int width, int height)
|
||||
{
|
||||
_bitmapInfo.biSize = Marshal.SizeOf(typeof(InteropValues.BITMAPINFOHEADER));
|
||||
_bitmapInfo.biPlanes = 1;
|
||||
_bitmapInfo.biBitCount = 32;
|
||||
_bitmapInfo.biCompression = 0;
|
||||
_bitmapInfo.biXPelsPerMeter = 0;
|
||||
_bitmapInfo.biYPelsPerMeter = 0;
|
||||
_bitmapInfo.biWidth = width;
|
||||
_bitmapInfo.biHeight = -height;
|
||||
|
||||
Handle = InteropMethods.CreateDIBSection(
|
||||
hdcScreen,
|
||||
ref _bitmapInfo,
|
||||
0u,
|
||||
out _pbits,
|
||||
IntPtr.Zero,
|
||||
0u);
|
||||
}
|
||||
|
||||
internal IntPtr Handle { get; }
|
||||
|
||||
internal IntPtr DIBits => _pbits;
|
||||
|
||||
internal int Width => _bitmapInfo.biWidth;
|
||||
|
||||
internal int Height => -_bitmapInfo.biHeight;
|
||||
|
||||
protected override void DisposeNativeResources() => InteropMethods.DeleteObject(Handle);
|
||||
|
||||
private static byte PremultiplyAlpha(byte channel, byte alpha) => (byte)(channel * alpha / 255.0);
|
||||
|
||||
internal static GlowBitmap Create(GlowDrawingContext drawingContext, GlowBitmapPart bitmapPart, Color color)
|
||||
{
|
||||
var orCreateAlphaMask =
|
||||
GetOrCreateAlphaMask(bitmapPart);
|
||||
|
||||
var glowBitmap =
|
||||
new GlowBitmap(
|
||||
drawingContext.ScreenDC,
|
||||
orCreateAlphaMask.Width,
|
||||
orCreateAlphaMask.Height);
|
||||
|
||||
for (var i = 0; i < orCreateAlphaMask.DIBits.Length; i += BytesPerPixelBgra32)
|
||||
{
|
||||
var b = orCreateAlphaMask.DIBits[i + 3];
|
||||
var val = PremultiplyAlpha(color.R, b);
|
||||
var val2 = PremultiplyAlpha(color.G, b);
|
||||
var val3 = PremultiplyAlpha(color.B, b);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i, val3);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 1, val2);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 2, val);
|
||||
Marshal.WriteByte(glowBitmap.DIBits, i + 3, b);
|
||||
}
|
||||
|
||||
return glowBitmap;
|
||||
}
|
||||
|
||||
private static CachedBitmapInfo GetOrCreateAlphaMask(GlowBitmapPart bitmapPart)
|
||||
{
|
||||
if (_transparencyMasks[(int)bitmapPart] == null)
|
||||
{
|
||||
var bitmapImage = new BitmapImage(new Uri($"pack://application:,,,/HandyControl;Component/Resources/Images/GlowWindow/{bitmapPart}.png"));
|
||||
|
||||
var array = new byte[BytesPerPixelBgra32 * bitmapImage.PixelWidth * bitmapImage.PixelHeight];
|
||||
var stride = BytesPerPixelBgra32 * bitmapImage.PixelWidth;
|
||||
bitmapImage.CopyPixels(array, stride, 0);
|
||||
|
||||
_transparencyMasks[(int)bitmapPart] =
|
||||
new CachedBitmapInfo(
|
||||
array,
|
||||
bitmapImage.PixelWidth,
|
||||
bitmapImage.PixelHeight);
|
||||
}
|
||||
|
||||
return _transparencyMasks[(int)bitmapPart];
|
||||
}
|
||||
|
||||
private sealed class CachedBitmapInfo
|
||||
{
|
||||
internal readonly byte[] DIBits;
|
||||
internal readonly int Height;
|
||||
internal readonly int Width;
|
||||
|
||||
internal CachedBitmapInfo(byte[] diBits, int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
DIBits = diBits;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal enum GlowBitmapPart
|
||||
{
|
||||
CornerTopLeft,
|
||||
CornerTopRight,
|
||||
CornerBottomLeft,
|
||||
CornerBottomRight,
|
||||
TopLeft,
|
||||
Top,
|
||||
TopRight,
|
||||
LeftTop,
|
||||
Left,
|
||||
LeftBottom,
|
||||
BottomLeft,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
RightTop,
|
||||
Right,
|
||||
RightBottom
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class GlowDrawingContext : DisposableObject
|
||||
{
|
||||
private readonly GlowBitmap _windowBitmap;
|
||||
|
||||
internal InteropValues.BLENDFUNCTION Blend;
|
||||
|
||||
internal GlowDrawingContext(int width, int height)
|
||||
{
|
||||
ScreenDC = InteropMethods.GetDC(IntPtr.Zero);
|
||||
if (ScreenDC == IntPtr.Zero) return;
|
||||
WindowDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (WindowDC == IntPtr.Zero) return;
|
||||
BackgroundDC = InteropMethods.CreateCompatibleDC(ScreenDC);
|
||||
if (BackgroundDC == IntPtr.Zero) return;
|
||||
Blend.BlendOp = 0;
|
||||
Blend.BlendFlags = 0;
|
||||
Blend.SourceConstantAlpha = 255;
|
||||
Blend.AlphaFormat = 1;
|
||||
_windowBitmap = new GlowBitmap(ScreenDC, width, height);
|
||||
InteropMethods.SelectObject(WindowDC, _windowBitmap.Handle);
|
||||
}
|
||||
|
||||
internal bool IsInitialized =>
|
||||
ScreenDC != IntPtr.Zero && WindowDC != IntPtr.Zero &&
|
||||
BackgroundDC != IntPtr.Zero && _windowBitmap != null;
|
||||
|
||||
internal IntPtr ScreenDC { get; }
|
||||
|
||||
internal IntPtr WindowDC { get; }
|
||||
|
||||
internal IntPtr BackgroundDC { get; }
|
||||
|
||||
internal int Width => _windowBitmap.Width;
|
||||
|
||||
internal int Height => _windowBitmap.Height;
|
||||
|
||||
protected override void DisposeManagedResources() => _windowBitmap.Dispose();
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
if (ScreenDC != IntPtr.Zero) InteropMethods.ReleaseDC(IntPtr.Zero, ScreenDC);
|
||||
if (WindowDC != IntPtr.Zero) InteropMethods.DeleteDC(WindowDC);
|
||||
if (BackgroundDC != IntPtr.Zero) InteropMethods.DeleteDC(BackgroundDC);
|
||||
}
|
||||
}
|
||||
}
|
587
src/Shared/HandyControl_Shared/Data/GlowWindow/GlowEdge.cs
Normal file
@ -0,0 +1,587 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
internal class GlowEdge : HwndWrapper
|
||||
{
|
||||
private const string GlowEdgeClassName = "HandyControlGlowEdge";
|
||||
|
||||
private const int GlowDepth = 9;
|
||||
|
||||
private const int CornerGripThickness = 18;
|
||||
|
||||
private static ushort _sharedWindowClassAtom;
|
||||
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
private static InteropValues.WndProc _sharedWndProc;
|
||||
|
||||
private readonly GlowBitmap[] _activeGlowBitmaps = new GlowBitmap[16];
|
||||
|
||||
private readonly GlowBitmap[] _inactiveGlowBitmaps = new GlowBitmap[16];
|
||||
|
||||
private readonly Dock _orientation;
|
||||
|
||||
private readonly GlowWindow _targetWindow;
|
||||
|
||||
private Color _activeGlowColor = Colors.Transparent;
|
||||
|
||||
private int _height;
|
||||
|
||||
private Color _inactiveGlowColor = Colors.Transparent;
|
||||
|
||||
private FieldInvalidationTypes _invalidatedValues;
|
||||
|
||||
private bool _isActive;
|
||||
|
||||
private bool _isVisible;
|
||||
|
||||
private int _left;
|
||||
|
||||
private bool _pendingDelayRender;
|
||||
|
||||
private int _top;
|
||||
|
||||
private int _width;
|
||||
|
||||
internal static long CreatedGlowEdges { get; private set; }
|
||||
|
||||
internal static long DisposedGlowEdges { get; private set; }
|
||||
|
||||
internal GlowEdge(GlowWindow owner, Dock orientation)
|
||||
{
|
||||
_targetWindow = owner ?? throw new ArgumentNullException(nameof(owner));
|
||||
_orientation = orientation;
|
||||
CreatedGlowEdges += 1L;
|
||||
}
|
||||
|
||||
private bool IsDeferringChanges => _targetWindow.DeferGlowChangesCount > 0;
|
||||
|
||||
private static ushort SharedWindowClassAtom
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_sharedWindowClassAtom == 0)
|
||||
{
|
||||
var wndclass = default(InteropValues.WNDCLASS);
|
||||
|
||||
wndclass.cbClsExtra = 0;
|
||||
wndclass.cbWndExtra = 0;
|
||||
wndclass.hbrBackground = IntPtr.Zero;
|
||||
wndclass.hCursor = IntPtr.Zero;
|
||||
wndclass.hIcon = IntPtr.Zero;
|
||||
wndclass.lpfnWndProc = _sharedWndProc = InteropMethods.DefWindowProc;
|
||||
wndclass.lpszClassName = GlowEdgeClassName;
|
||||
wndclass.lpszMenuName = null;
|
||||
wndclass.style = 0u;
|
||||
|
||||
_sharedWindowClassAtom = InteropMethods.RegisterClass(ref wndclass);
|
||||
}
|
||||
|
||||
return _sharedWindowClassAtom;
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsVisible
|
||||
{
|
||||
get => _isVisible;
|
||||
set => UpdateProperty(ref _isVisible, value, FieldInvalidationTypes.Render | FieldInvalidationTypes.Visibility);
|
||||
}
|
||||
|
||||
internal int Left
|
||||
{
|
||||
get => _left;
|
||||
set => UpdateProperty(ref _left, value, FieldInvalidationTypes.Location);
|
||||
}
|
||||
|
||||
internal int Top
|
||||
{
|
||||
get => _top;
|
||||
set => UpdateProperty(ref _top, value, FieldInvalidationTypes.Location);
|
||||
}
|
||||
|
||||
internal int Width
|
||||
{
|
||||
get => _width;
|
||||
set => UpdateProperty( ref _width, value, FieldInvalidationTypes.Size | FieldInvalidationTypes.Render);
|
||||
}
|
||||
|
||||
internal int Height
|
||||
{
|
||||
get => _height;
|
||||
set => UpdateProperty(ref _height, value, FieldInvalidationTypes.Size | FieldInvalidationTypes.Render);
|
||||
}
|
||||
|
||||
internal bool IsActive
|
||||
{
|
||||
get => _isActive;
|
||||
set => UpdateProperty(ref _isActive, value, FieldInvalidationTypes.Render);
|
||||
}
|
||||
|
||||
internal Color ActiveGlowColor
|
||||
{
|
||||
get => _activeGlowColor;
|
||||
set => UpdateProperty(ref _activeGlowColor, value, FieldInvalidationTypes.ActiveColor | FieldInvalidationTypes.Render);
|
||||
}
|
||||
|
||||
internal Color InactiveGlowColor
|
||||
{
|
||||
get => _inactiveGlowColor;
|
||||
set => UpdateProperty(ref _inactiveGlowColor, value, FieldInvalidationTypes.InactiveColor | FieldInvalidationTypes.Render);
|
||||
}
|
||||
|
||||
private IntPtr TargetWindowHandle => new WindowInteropHelper(_targetWindow).Handle;
|
||||
|
||||
protected override bool IsWindowSubclassed => true;
|
||||
|
||||
private bool IsPositionValid => (_invalidatedValues & (FieldInvalidationTypes.Location | FieldInvalidationTypes.Size | FieldInvalidationTypes.Visibility)) == FieldInvalidationTypes.None;
|
||||
|
||||
private void UpdateProperty<T>(ref T field, T value, FieldInvalidationTypes invalidatedValues) where T : struct
|
||||
{
|
||||
if (!field.Equals(value))
|
||||
{
|
||||
field = value;
|
||||
_invalidatedValues |= invalidatedValues;
|
||||
if (!IsDeferringChanges) CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
protected override ushort CreateWindowClassCore() => SharedWindowClassAtom;
|
||||
|
||||
protected override void DestroyWindowClassCore()
|
||||
{
|
||||
}
|
||||
|
||||
protected override IntPtr CreateWindowCore()
|
||||
{
|
||||
return InteropMethods.CreateWindowEx(
|
||||
524416,
|
||||
new IntPtr(WindowClassAtom),
|
||||
string.Empty,
|
||||
-2046820352,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
new WindowInteropHelper(_targetWindow).Owner,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero);
|
||||
}
|
||||
|
||||
internal void ChangeOwner(IntPtr newOwner) => InteropMethods.SetWindowLongPtr(Handle, InteropValues.GWLP.HWNDPARENT, newOwner);
|
||||
|
||||
protected override IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (msg <= 70)
|
||||
{
|
||||
if (msg == 6) return IntPtr.Zero;
|
||||
if (msg == 70)
|
||||
{
|
||||
var windowpos = (InteropValues.WINDOWPOS)Marshal.PtrToStructure(lParam, typeof(InteropValues.WINDOWPOS));
|
||||
windowpos.flags |= 16u;
|
||||
Marshal.StructureToPtr(windowpos, lParam, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msg != 126)
|
||||
{
|
||||
if (msg == 132) return new IntPtr(WmNcHitTest(lParam));
|
||||
switch (msg)
|
||||
{
|
||||
case 161:
|
||||
case 163:
|
||||
case 164:
|
||||
case 166:
|
||||
case 167:
|
||||
case 169:
|
||||
case 171:
|
||||
case 173:
|
||||
{
|
||||
var targetWindowHandle = TargetWindowHandle;
|
||||
InteropMethods.SendMessage(targetWindowHandle, 6, new IntPtr(2), IntPtr.Zero);
|
||||
InteropMethods.SendMessage(targetWindowHandle, msg, wParam, IntPtr.Zero);
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsVisible) RenderLayeredWindow();
|
||||
}
|
||||
}
|
||||
|
||||
return base.WndProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
private int WmNcHitTest(IntPtr lParam)
|
||||
{
|
||||
var xLParam = InteropMethods.GetXLParam(lParam.ToInt32());
|
||||
var yLParam = InteropMethods.GetYLParam(lParam.ToInt32());
|
||||
InteropMethods.GetWindowRect(Handle, out var rect);
|
||||
switch (_orientation)
|
||||
{
|
||||
case Dock.Left:
|
||||
if (yLParam - CornerGripThickness < rect.Top) return 13;
|
||||
if (yLParam + CornerGripThickness > rect.Bottom) return 16;
|
||||
return 10;
|
||||
case Dock.Top:
|
||||
if (xLParam - CornerGripThickness < rect.Left) return 13;
|
||||
if (xLParam + CornerGripThickness > rect.Right) return 14;
|
||||
return 12;
|
||||
case Dock.Right:
|
||||
if (yLParam - CornerGripThickness < rect.Top) return 14;
|
||||
if (yLParam + CornerGripThickness > rect.Bottom) return 17;
|
||||
return 11;
|
||||
default:
|
||||
if (xLParam - CornerGripThickness < rect.Left) return 16;
|
||||
if (xLParam + CornerGripThickness > rect.Right) return 17;
|
||||
return 15;
|
||||
}
|
||||
}
|
||||
|
||||
internal void CommitChanges()
|
||||
{
|
||||
InvalidateCachedBitmaps();
|
||||
UpdateWindowPosCore();
|
||||
UpdateLayeredWindowCore();
|
||||
_invalidatedValues = FieldInvalidationTypes.None;
|
||||
}
|
||||
|
||||
private void InvalidateCachedBitmaps()
|
||||
{
|
||||
if (_invalidatedValues.HasFlag(FieldInvalidationTypes.ActiveColor)) ClearCache(_activeGlowBitmaps);
|
||||
if (_invalidatedValues.HasFlag(FieldInvalidationTypes.InactiveColor)) ClearCache(_inactiveGlowBitmaps);
|
||||
}
|
||||
|
||||
private void UpdateWindowPosCore()
|
||||
{
|
||||
if (_invalidatedValues.HasFlag(FieldInvalidationTypes.Location) ||
|
||||
_invalidatedValues.HasFlag(FieldInvalidationTypes.Size) ||
|
||||
_invalidatedValues.HasFlag(FieldInvalidationTypes.Visibility))
|
||||
{
|
||||
var num = 532;
|
||||
if (_invalidatedValues.HasFlag(FieldInvalidationTypes.Visibility))
|
||||
{
|
||||
if (IsVisible)
|
||||
num |= 64;
|
||||
else
|
||||
num |= 131;
|
||||
}
|
||||
|
||||
if (!_invalidatedValues.HasFlag(FieldInvalidationTypes.Location)) num |= 2;
|
||||
if (!_invalidatedValues.HasFlag(FieldInvalidationTypes.Size)) num |= 1;
|
||||
InteropMethods.SetWindowPos(Handle, IntPtr.Zero, Left, Top, Width, Height, num);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLayeredWindowCore()
|
||||
{
|
||||
if (IsVisible && _invalidatedValues.HasFlag(FieldInvalidationTypes.Render))
|
||||
{
|
||||
if (IsPositionValid)
|
||||
{
|
||||
BeginDelayedRender();
|
||||
return;
|
||||
}
|
||||
|
||||
CancelDelayedRender();
|
||||
RenderLayeredWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void BeginDelayedRender()
|
||||
{
|
||||
if (!_pendingDelayRender)
|
||||
{
|
||||
_pendingDelayRender = true;
|
||||
CompositionTarget.Rendering += CommitDelayedRender;
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelDelayedRender()
|
||||
{
|
||||
if (_pendingDelayRender)
|
||||
{
|
||||
_pendingDelayRender = false;
|
||||
CompositionTarget.Rendering -= CommitDelayedRender;
|
||||
}
|
||||
}
|
||||
|
||||
private void CommitDelayedRender(object sender, EventArgs e)
|
||||
{
|
||||
CancelDelayedRender();
|
||||
if (IsVisible) RenderLayeredWindow();
|
||||
}
|
||||
|
||||
private void RenderLayeredWindow()
|
||||
{
|
||||
using var glowDrawingContext = new GlowDrawingContext(Width, Height);
|
||||
if (glowDrawingContext.IsInitialized)
|
||||
{
|
||||
switch (_orientation)
|
||||
{
|
||||
case Dock.Left:
|
||||
DrawLeft(glowDrawingContext);
|
||||
break;
|
||||
case Dock.Top:
|
||||
DrawTop(glowDrawingContext);
|
||||
break;
|
||||
case Dock.Right:
|
||||
DrawRight(glowDrawingContext);
|
||||
break;
|
||||
default:
|
||||
DrawBottom(glowDrawingContext);
|
||||
break;
|
||||
}
|
||||
|
||||
var point = new InteropValues.POINT
|
||||
{
|
||||
X = Left,
|
||||
Y = Top
|
||||
};
|
||||
var size = new InteropValues.SIZE
|
||||
{
|
||||
cx = Width,
|
||||
cy = Height
|
||||
};
|
||||
var point2 = new InteropValues.POINT
|
||||
{
|
||||
X = 0,
|
||||
Y = 0
|
||||
};
|
||||
|
||||
InteropMethods.UpdateLayeredWindow(
|
||||
Handle,
|
||||
glowDrawingContext.ScreenDC,
|
||||
ref point,
|
||||
ref size,
|
||||
glowDrawingContext.WindowDC,
|
||||
ref point2,
|
||||
0u,
|
||||
ref glowDrawingContext.Blend,
|
||||
2u);
|
||||
}
|
||||
}
|
||||
|
||||
private GlowBitmap GetOrCreateBitmap(GlowDrawingContext drawingContext, GlowBitmapPart bitmapPart)
|
||||
{
|
||||
GlowBitmap[] array;
|
||||
Color color;
|
||||
if (IsActive)
|
||||
{
|
||||
array = _activeGlowBitmaps;
|
||||
color = ActiveGlowColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
array = _inactiveGlowBitmaps;
|
||||
color = InactiveGlowColor;
|
||||
}
|
||||
|
||||
return array[(int) bitmapPart] ?? (array[(int) bitmapPart] = GlowBitmap.Create(drawingContext, bitmapPart, color));
|
||||
}
|
||||
|
||||
private void ClearCache(GlowBitmap[] cache)
|
||||
{
|
||||
for (var i = 0; i < cache.Length; i++)
|
||||
using (cache[i])
|
||||
{
|
||||
cache[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeManagedResources()
|
||||
{
|
||||
ClearCache(_activeGlowBitmaps);
|
||||
ClearCache(_inactiveGlowBitmaps);
|
||||
}
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
base.DisposeNativeResources();
|
||||
DisposedGlowEdges += 1L;
|
||||
}
|
||||
|
||||
private void DrawLeft(GlowDrawingContext drawingContext)
|
||||
{
|
||||
var orCreateBitmap = GetOrCreateBitmap(drawingContext, GlowBitmapPart.CornerTopLeft);
|
||||
var orCreateBitmap2 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.LeftTop);
|
||||
var orCreateBitmap3 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.Left);
|
||||
var orCreateBitmap4 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.LeftBottom);
|
||||
var orCreateBitmap5 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.CornerBottomLeft);
|
||||
var height = orCreateBitmap.Height;
|
||||
var num = height + orCreateBitmap2.Height;
|
||||
var num2 = drawingContext.Height - orCreateBitmap5.Height;
|
||||
var num3 = num2 - orCreateBitmap4.Height;
|
||||
var num4 = num3 - num;
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.Blend);
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap2.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, height, orCreateBitmap2.Width,
|
||||
orCreateBitmap2.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap2.Width,
|
||||
orCreateBitmap2.Height, drawingContext.Blend);
|
||||
if (num4 > 0)
|
||||
{
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap3.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num, orCreateBitmap3.Width, num4,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap3.Width, orCreateBitmap3.Height,
|
||||
drawingContext.Blend);
|
||||
}
|
||||
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap4.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num3, orCreateBitmap4.Width,
|
||||
orCreateBitmap4.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap4.Width,
|
||||
orCreateBitmap4.Height, drawingContext.Blend);
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap5.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num2, orCreateBitmap5.Width,
|
||||
orCreateBitmap5.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap5.Width,
|
||||
orCreateBitmap5.Height, drawingContext.Blend);
|
||||
}
|
||||
|
||||
private void DrawRight(GlowDrawingContext drawingContext)
|
||||
{
|
||||
var orCreateBitmap = GetOrCreateBitmap(drawingContext, GlowBitmapPart.CornerTopRight);
|
||||
var orCreateBitmap2 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.RightTop);
|
||||
var orCreateBitmap3 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.Right);
|
||||
var orCreateBitmap4 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.RightBottom);
|
||||
var orCreateBitmap5 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.CornerBottomRight);
|
||||
var height = orCreateBitmap.Height;
|
||||
var num = height + orCreateBitmap2.Height;
|
||||
var num2 = drawingContext.Height - orCreateBitmap5.Height;
|
||||
var num3 = num2 - orCreateBitmap4.Height;
|
||||
var num4 = num3 - num;
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.Blend);
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap2.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, height, orCreateBitmap2.Width,
|
||||
orCreateBitmap2.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap2.Width,
|
||||
orCreateBitmap2.Height, drawingContext.Blend);
|
||||
if (num4 > 0)
|
||||
{
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap3.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num, orCreateBitmap3.Width, num4,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap3.Width, orCreateBitmap3.Height,
|
||||
drawingContext.Blend);
|
||||
}
|
||||
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap4.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num3, orCreateBitmap4.Width,
|
||||
orCreateBitmap4.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap4.Width,
|
||||
orCreateBitmap4.Height, drawingContext.Blend);
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap5.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, 0, num2, orCreateBitmap5.Width,
|
||||
orCreateBitmap5.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap5.Width,
|
||||
orCreateBitmap5.Height, drawingContext.Blend);
|
||||
}
|
||||
|
||||
private void DrawTop(GlowDrawingContext drawingContext)
|
||||
{
|
||||
var orCreateBitmap = GetOrCreateBitmap(drawingContext, GlowBitmapPart.TopLeft);
|
||||
var orCreateBitmap2 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.Top);
|
||||
var orCreateBitmap3 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.TopRight);
|
||||
var num2 = GlowDepth + orCreateBitmap.Width;
|
||||
var num3 = drawingContext.Width - GlowDepth - orCreateBitmap3.Width;
|
||||
var num4 = num3 - num2;
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, GlowDepth, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.Blend);
|
||||
if (num4 > 0)
|
||||
{
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap2.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, num2, 0, num4, orCreateBitmap2.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap2.Width, orCreateBitmap2.Height,
|
||||
drawingContext.Blend);
|
||||
}
|
||||
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap3.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, num3, 0, orCreateBitmap3.Width,
|
||||
orCreateBitmap3.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap3.Width,
|
||||
orCreateBitmap3.Height, drawingContext.Blend);
|
||||
}
|
||||
|
||||
private void DrawBottom(GlowDrawingContext drawingContext)
|
||||
{
|
||||
var orCreateBitmap = GetOrCreateBitmap(drawingContext, GlowBitmapPart.BottomLeft);
|
||||
var orCreateBitmap2 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.Bottom);
|
||||
var orCreateBitmap3 = GetOrCreateBitmap(drawingContext, GlowBitmapPart.BottomRight);
|
||||
var num2 = GlowDepth + orCreateBitmap.Width;
|
||||
var num3 = drawingContext.Width - GlowDepth - orCreateBitmap3.Width;
|
||||
var num4 = num3 - num2;
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, GlowDepth, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap.Width, orCreateBitmap.Height,
|
||||
drawingContext.Blend);
|
||||
if (num4 > 0)
|
||||
{
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap2.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, num2, 0, num4, orCreateBitmap2.Height,
|
||||
drawingContext.BackgroundDC, 0, 0, orCreateBitmap2.Width, orCreateBitmap2.Height,
|
||||
drawingContext.Blend);
|
||||
}
|
||||
|
||||
InteropMethods.SelectObject(drawingContext.BackgroundDC, orCreateBitmap3.Handle);
|
||||
InteropMethods.AlphaBlend(drawingContext.WindowDC, num3, 0, orCreateBitmap3.Width,
|
||||
orCreateBitmap3.Height, drawingContext.BackgroundDC, 0, 0, orCreateBitmap3.Width,
|
||||
orCreateBitmap3.Height, drawingContext.Blend);
|
||||
}
|
||||
|
||||
internal void UpdateWindowPos()
|
||||
{
|
||||
var targetWindowHandle = TargetWindowHandle;
|
||||
InteropMethods.GetWindowRect(targetWindowHandle, out var rect);
|
||||
InteropMethods.GetWindowPlacement(targetWindowHandle);
|
||||
if (IsVisible)
|
||||
switch (_orientation)
|
||||
{
|
||||
case Dock.Left:
|
||||
Left = rect.Left - GlowDepth;
|
||||
Top = rect.Top - GlowDepth;
|
||||
Width = GlowDepth;
|
||||
Height = rect.Height + CornerGripThickness;
|
||||
return;
|
||||
case Dock.Top:
|
||||
Left = rect.Left - GlowDepth;
|
||||
Top = rect.Top - GlowDepth;
|
||||
Width = rect.Width + CornerGripThickness;
|
||||
Height = GlowDepth;
|
||||
return;
|
||||
case Dock.Right:
|
||||
Left = rect.Right;
|
||||
Top = rect.Top - GlowDepth;
|
||||
Width = GlowDepth;
|
||||
Height = rect.Height + CornerGripThickness;
|
||||
return;
|
||||
default:
|
||||
Left = rect.Left - GlowDepth;
|
||||
Top = rect.Bottom;
|
||||
Width = rect.Width + CornerGripThickness;
|
||||
Height = GlowDepth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum FieldInvalidationTypes
|
||||
{
|
||||
None = 0,
|
||||
Location = 1,
|
||||
Size = 2,
|
||||
ActiveColor = 4,
|
||||
InactiveColor = 8,
|
||||
Render = 16,
|
||||
Visibility = 32
|
||||
}
|
||||
}
|
||||
}
|
102
src/Shared/HandyControl_Shared/Data/HwndWrapper.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public abstract class HwndWrapper : DisposableObject
|
||||
{
|
||||
private IntPtr _handle;
|
||||
|
||||
private bool _isHandleCreationAllowed = true;
|
||||
|
||||
private ushort _wndClassAtom;
|
||||
|
||||
private Delegate _wndProc;
|
||||
|
||||
protected ushort WindowClassAtom
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_wndClassAtom == 0) _wndClassAtom = CreateWindowClassCore();
|
||||
return _wndClassAtom;
|
||||
}
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureHandle();
|
||||
return _handle;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual bool IsWindowSubclassed => false;
|
||||
|
||||
protected virtual ushort CreateWindowClassCore() => RegisterClass(Guid.NewGuid().ToString());
|
||||
|
||||
protected virtual void DestroyWindowClassCore()
|
||||
{
|
||||
if (_wndClassAtom != 0)
|
||||
{
|
||||
var moduleHandle = InteropMethods.GetModuleHandle(null);
|
||||
InteropMethods.UnregisterClass(new IntPtr(_wndClassAtom), moduleHandle);
|
||||
_wndClassAtom = 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected ushort RegisterClass(string className)
|
||||
{
|
||||
var wndClass = default(InteropValues.WNDCLASS);
|
||||
wndClass.cbClsExtra = 0;
|
||||
wndClass.cbWndExtra = 0;
|
||||
wndClass.hbrBackground = IntPtr.Zero;
|
||||
wndClass.hCursor = IntPtr.Zero;
|
||||
wndClass.hIcon = IntPtr.Zero;
|
||||
wndClass.lpfnWndProc = _wndProc = new InteropValues.WndProc(WndProc);
|
||||
wndClass.lpszClassName = className;
|
||||
wndClass.lpszMenuName = null;
|
||||
wndClass.style = 0u;
|
||||
return InteropMethods.RegisterClass(ref wndClass);
|
||||
}
|
||||
|
||||
private void SubclassWndProc()
|
||||
{
|
||||
_wndProc = new InteropValues.WndProc(WndProc);
|
||||
InteropMethods.SetWindowLong(_handle, -4, Marshal.GetFunctionPointerForDelegate(_wndProc));
|
||||
}
|
||||
|
||||
protected abstract IntPtr CreateWindowCore();
|
||||
|
||||
protected virtual void DestroyWindowCore()
|
||||
{
|
||||
if (_handle != IntPtr.Zero)
|
||||
{
|
||||
InteropMethods.DestroyWindow(_handle);
|
||||
_handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam) =>
|
||||
InteropMethods.DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
|
||||
public void EnsureHandle()
|
||||
{
|
||||
if (_handle == IntPtr.Zero)
|
||||
{
|
||||
if (!_isHandleCreationAllowed) return;
|
||||
_isHandleCreationAllowed = false;
|
||||
_handle = CreateWindowCore();
|
||||
if (IsWindowSubclassed) SubclassWndProc();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeNativeResources()
|
||||
{
|
||||
_isHandleCreationAllowed = false;
|
||||
DestroyWindowCore();
|
||||
DestroyWindowClassCore();
|
||||
}
|
||||
}
|
||||
}
|
@ -302,6 +302,10 @@
|
||||
|
||||
internal const string WindowWin10 = nameof(WindowWin10);
|
||||
|
||||
internal const string WindowBlur = nameof(WindowBlur);
|
||||
|
||||
internal const string WindowGlow = nameof(WindowGlow);
|
||||
|
||||
internal const string AddTagButtonStyle = nameof(AddTagButtonStyle);
|
||||
|
||||
internal const string RadioGroupItemDefault = nameof(RadioGroupItemDefault);
|
||||
|
@ -41,6 +41,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\RunningBlock.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\GlowWindow.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\DisposableObject.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\DrawerShowMode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\HatchStyle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\HitMode.cs" />
|
||||
@ -48,6 +50,12 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\NotifyIconInfoType.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\StrokePosition.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\TransitionMode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\ChangeScope.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowBitmap.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowBitmapPart.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowDrawingContext.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\GlowWindow\GlowEdge.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\HwndWrapper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\CloseWindowCommand.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\OpenLinkCommand.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Media\Animation\DiscreteGeometryKeyFrame.cs" />
|
||||
@ -70,6 +78,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Number2PercentageConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\RectangleCircularConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\ThicknessSplitConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DependencyObjectExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\FrameworkElementExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\StringExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ValueExtension.cs" />
|
||||
@ -299,6 +308,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ExternDllHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\IconHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ResourceHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\ScreenHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\SecurityHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\SingleOpenHelper.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Helper\TokenizerHelper.cs" />
|
||||
@ -309,20 +319,14 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Hook\KeyboardHook.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Hook\MouseHook.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Hook\SystemMenuHook.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\BitmapHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\BITMAPINFO.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\CommonHandles.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\ExternDll.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\HandleCollector.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\IconHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\ICONINFO.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\NativeMethods.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\NativeValues.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\NOTIFYICONDATA.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\SafeFileMappingHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\UnsafeNativeMethods.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\WNDCLASS.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\WpfSafeHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\BitmapHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\CommonHandles.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\HandleCollector.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\IconHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\InteropMethods.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\InteropValues.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\SafeFileMappingHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\WpfSafeHandle.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\MouseDragElementBehaviorEx.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Pool\IPool!1.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Pool\SimplePool!1.cs" />
|
||||
@ -943,4 +947,7 @@
|
||||
<None Include="$(MSBuildThisFileDirectory)Resources\Effects\ColorComplementEffect.fx" />
|
||||
<None Include="$(MSBuildThisFileDirectory)Resources\Effects\GrayScaleEffect.fx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="$(MSBuildThisFileDirectory)Tools\Interop\Handle\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -18,7 +18,7 @@ namespace HandyControl.Interactivity
|
||||
var hwndSource = (HwndSource)PresentationSource.FromDependencyObject(Application.Current.MainWindow);
|
||||
if (hwndSource != null)
|
||||
{
|
||||
UnsafeNativeMethods.SetForegroundWindow(hwndSource.Handle);
|
||||
InteropMethods.SetForegroundWindow(hwndSource.Handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.3 KiB |
@ -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)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
85
src/Shared/HandyControl_Shared/Tools/Helper/ScreenHelper.cs
Normal file
@ -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<InteropValues.RECT>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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<T>(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;
|
||||
}
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ namespace HandyControl.Tools
|
||||
/// <returns></returns>
|
||||
public static Window GetActiveWindow() => Application.Current.Windows.OfType<Window>().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));
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
@ -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";
|
||||
}
|
||||
}
|
@ -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]
|
@ -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]
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
437
src/Shared/HandyControl_Shared/Tools/Interop/InteropMethods.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
620
src/Shared/HandyControl_Shared/Tools/Interop/InteropValues.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|