diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml
new file mode 100644
index 00000000..8495d6ec
--- /dev/null
+++ b/.github/workflows/nuget.yml
@@ -0,0 +1,16 @@
+name: Nuget
+
+on:
+ push:
+ branches: [ master ]
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@2.0.
+ - name: Build the Docker image
+ run: docker build -f Dockerfile -t HandyOrg/hcbuild .
+ - name: Run the Docker image
+ run: docker run --rm HandyOrg/hcbuild --version
diff --git a/README.md b/README.md
index 2faaf251..b9245ba3 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@
[https://handyorg.github.io/handycontrol/](https://handyorg.github.io/handycontrol/)
### 赞助
-如果您觉得HandyControl还不错,并且刚好有些闲钱,那么可以选择以下两种方式来赞助:
+如果您觉得HandyControl还不错,并且刚好有些闲钱,那么可以选择以下两种方式来赞助(记得入群联系我们呀~~):
* [以HandyControl的名义为慈善事业做贡献](http://www.chinacharityfederation.org/ConfirmDonation/0.html?zhijie=3)
@@ -27,32 +27,35 @@
## Contributors
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
## Backers
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
## Special thanks to
diff --git a/src/HandyControl.sln b/src/HandyControl.sln
index 1154962f..45fa85fc 100644
--- a/src/HandyControl.sln
+++ b/src/HandyControl.sln
@@ -34,7 +34,9 @@ Global
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{32204503-2ef0-4681-ae13-aa1feb6c658a}*SharedItemsImports = 4
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{9a7b52e6-94bb-4e7e-bb6a-7cf6761b79a7}*SharedItemsImports = 4
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{aac11083-faca-405d-9197-5c1212d65656}*SharedItemsImports = 13
+ Shared\HandyControl_Shared\HandyControl_Shared.projitems*{be4a567d-b6e0-413e-8f64-e1a53b4f9366}*SharedItemsImports = 5
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{c4694269-c9b8-45d5-87f8-d0088c532510}*SharedItemsImports = 13
+ Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d7107690-8592-4f9f-9379-9b82c1c15d2a}*SharedItemsImports = 5
Shared\HandyControlDemo_Shared\HandyControlDemo_Shared.projitems*{d8ae88f8-c36b-4d10-a7f9-22ffcfba5231}*SharedItemsImports = 4
Shared\HandyControl_Shared\HandyControl_Shared.projitems*{dc966e3d-bcff-4652-98cf-070e5494749a}*SharedItemsImports = 4
EndGlobalSection
@@ -104,57 +106,37 @@ Global
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Core31|Any CPU.ActiveCfg = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Core31|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net40|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net40|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net45|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net45|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net462|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net462|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net47|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net47|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net48|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Debug-Net48|Any CPU.Build.0 = Debug-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core30|Any CPU.ActiveCfg = Release-Core30|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core30|Any CPU.Build.0 = Release-Core30|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core31|Any CPU.ActiveCfg = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Core31|Any CPU.Build.0 = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net40|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net40|Any CPU.Build.0 = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net45|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net45|Any CPU.Build.0 = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net462|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net462|Any CPU.Build.0 = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net47|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net47|Any CPU.Build.0 = Release-Core31|Any CPU
{BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net48|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {BE4A567D-B6E0-413E-8F64-E1A53B4F9366}.Release-Net48|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core30|Any CPU.ActiveCfg = Debug-Core30|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core30|Any CPU.Build.0 = Debug-Core30|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core31|Any CPU.ActiveCfg = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Core31|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net40|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net40|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net45|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net45|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net462|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net462|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net47|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net47|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net48|Any CPU.ActiveCfg = Debug-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Debug-Net48|Any CPU.Build.0 = Debug-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core30|Any CPU.ActiveCfg = Release-Core30|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core30|Any CPU.Build.0 = Release-Core30|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core31|Any CPU.ActiveCfg = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Core31|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net40|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net40|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net45|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net45|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net462|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net462|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net47|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net47|Any CPU.Build.0 = Release-Core31|Any CPU
{D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net48|Any CPU.ActiveCfg = Release-Core31|Any CPU
- {D7107690-8592-4F9F-9379-9B82C1C15D2A}.Release-Net48|Any CPU.Build.0 = Release-Core31|Any CPU
{32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Core30|Any CPU.ActiveCfg = Debug|Any CPU
{32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Core31|Any CPU.ActiveCfg = Debug|Any CPU
{32204503-2EF0-4681-AE13-AA1FEB6C658A}.Debug-Net40|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
index 05d65336..1eb7fa4f 100644
--- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs
@@ -71,6 +71,8 @@ namespace HandyControlDemo
}
ConfigHelper.Instance.SetSystemVersionInfo(CommonHelper.GetSystemVersionInfo());
+ ConfigHelper.Instance.SetWindowDefaultStyle();
+ ConfigHelper.Instance.SetNavigationWindowDefaultStyle();
ServicePointManager.SecurityProtocol = (SecurityProtocolType)(SslProtocols)0x00000C00;
}
diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
index bcc0bcbd..456917df 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
+++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.cs
@@ -46,5 +46,7 @@
public static readonly string NavigationWindow = nameof(NavigationWindow);
+ public static readonly string DialogContainer = nameof(DialogContainer);
+
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
index 76cbb2b3..9c53e44f 100644
--- a/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
+++ b/src/Shared/HandyControlDemo_Shared/Data/MessageToken.tt
@@ -25,7 +25,8 @@ var messageList = new List
"QQGroupView",
"GlowWindow",
"NativeCommonWindow",
- "NavigationWindow"
+ "NavigationWindow",
+ "DialogContainer"
};
#>
namespace HandyControlDemo.Data
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
index e3078682..5fcf9206 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
@@ -1725,6 +1725,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 文本对话框(控件中) 的本地化字符串。
+ ///
+ public static string TextDialogInControl {
+ get {
+ return ResourceManager.GetString("TextDialogInControl", resourceCulture);
+ }
+ }
+
///
/// 查找类似 文本对话框,带计时器 的本地化字符串。
///
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
index 97bad55c..63f989ac 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
@@ -744,4 +744,7 @@
Screenshot
+
+ TextDialog(In control)
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
index b1d3c4fe..e3bb5ced 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fa.resx
@@ -744,4 +744,7 @@
Screenshot
+
+ TextDialog(In control)
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
index 3c22a942..c24dda27 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.fr.resx
@@ -744,4 +744,7 @@
Screenshot
+
+ TextDialog(In control)
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx
index 88562ce8..70c29806 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.ko-KR.resx
@@ -744,4 +744,7 @@
Screenshot
+
+ TextDialog(In control)
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
index f4e63998..736038d0 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
@@ -744,4 +744,7 @@
截图
+
+ 文本对话框(控件中)
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml
index c8973990..7a2522b9 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/DialogDemoCtl.xaml
@@ -3,16 +3,23 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:data="clr-namespace:HandyControlDemo.Data"
+ hc:Dialog.Token="{x:Static data:MessageToken.DialogContainer}"
Background="{DynamicResource RegionBrush}"
- MinWidth="300"
+ MinWidth="500"
DataContext="{Binding DialogDemo,Source={StaticResource Locator}}">
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml
index dbce1495..0c230a0b 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/StepBarDemoCtl.xaml
@@ -18,7 +18,7 @@
-
+
diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs
index e3c1a08e..f223cd5a 100644
--- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs
@@ -29,12 +29,19 @@ namespace HandyControlDemo.ViewModel
#endif
}
- public RelayCommand ShowTextCmd => new Lazy(() =>
- new RelayCommand(ShowText)).Value;
+ public RelayCommand ShowTextCmd => new Lazy>(() =>
+ new RelayCommand(ShowText)).Value;
- private void ShowText()
+ private void ShowText(FrameworkElement element)
{
- Dialog.Show(new TextDialog());
+ if (element == null)
+ {
+ Dialog.Show(new TextDialog());
+ }
+ else
+ {
+ Dialog.Show(new TextDialog(), MessageToken.DialogContainer);
+ }
}
#if netle40
diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs
index 8c2032c1..49d03a53 100644
--- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs
+++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs
@@ -16,6 +16,18 @@ namespace HandyControlDemo.ViewModel
{
public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList();
+ private int _stepIndex;
+
+ public int StepIndex
+ {
+ get => _stepIndex;
+#if netle40
+ set => Set(nameof(StepIndex), ref _stepIndex, value);
+#else
+ set => Set(ref _stepIndex, value);
+#endif
+ }
+
///
/// 下一步
///
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs
new file mode 100644
index 00000000..5d6cd18f
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/MenuTopLineAttach.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using HandyControl.Tools;
+using HandyControl.Tools.Interop;
+
+namespace HandyControl.Controls
+{
+ public class MenuTopLineAttach
+ {
+ public static readonly DependencyProperty PopupProperty = DependencyProperty.RegisterAttached(
+ "Popup", typeof(Popup), typeof(MenuTopLineAttach), new PropertyMetadata(default(Popup), OnPopupChanged));
+
+ private static void OnPopupChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var topLine = (FrameworkElement) d;
+
+ if (e.NewValue is Popup popup)
+ {
+ if (popup.TemplatedParent is MenuItem menuItem)
+ {
+ SetTopLine(menuItem, topLine);
+ menuItem.Loaded += MenuItem_Loaded;
+ }
+ }
+ }
+
+ private static void MenuItem_Loaded(object sender, RoutedEventArgs e)
+ {
+ var menuItem = (FrameworkElement)sender;
+ menuItem.Unloaded += MenuItem_Unloaded;
+ var topLine = GetTopLine(menuItem);
+ var popup = GetPopup(topLine);
+ if (popup != null)
+ {
+ popup.Opened += Popup_Opened;
+ }
+ }
+
+ private static void MenuItem_Unloaded(object sender, RoutedEventArgs e)
+ {
+ var menuItem = (FrameworkElement)sender;
+ menuItem.Unloaded -= MenuItem_Unloaded;
+ var topLine = GetTopLine(menuItem);
+ var popup = GetPopup(topLine);
+ if (popup != null)
+ {
+ popup.Opened -= Popup_Opened;
+ }
+ }
+
+ private static void Popup_Opened(object sender, EventArgs e)
+ {
+ var popup = (Popup) sender;
+ if (popup.TemplatedParent is MenuItem menuItem)
+ {
+ var topLine = GetTopLine(menuItem);
+ if (topLine == null) return;
+
+ topLine.HorizontalAlignment = HorizontalAlignment.Left;
+ topLine.Width = menuItem.ActualWidth;
+ topLine.Margin = new Thickness();
+
+ var positionLeftTop = menuItem.PointToScreen(new Point());
+ var positionRightBottom = menuItem.PointToScreen(new Point(menuItem.ActualWidth, menuItem.ActualHeight));
+ ScreenHelper.FindMonitorRectsFromPoint(InteropMethods.GetCursorPos(), out _, out var workAreaRect);
+ var panel = VisualHelper.GetParent(topLine);
+
+ if (positionLeftTop.X < 0)
+ {
+
+ topLine.Margin = new Thickness(positionLeftTop.X - panel.Margin.Left, 0, 0, 0);
+ }
+ else if (positionLeftTop.X + panel.ActualWidth > workAreaRect.Right)
+ {
+ var overflowWidth = positionRightBottom.X - workAreaRect.Right;
+ if (overflowWidth > 0)
+ {
+ topLine.Width -= overflowWidth + panel.Margin.Right;
+ }
+ topLine.HorizontalAlignment = HorizontalAlignment.Left;
+ topLine.Margin = new Thickness(positionLeftTop.X + panel.ActualWidth - workAreaRect.Right + panel.Margin.Right, 0, 0, 0);
+ }
+
+ if (positionRightBottom.Y > workAreaRect.Bottom)
+ {
+ topLine.Width = 0;
+ topLine.HorizontalAlignment = HorizontalAlignment.Stretch;
+ topLine.Margin = new Thickness();
+ }
+ }
+ }
+
+ public static void SetPopup(DependencyObject element, Popup value)
+ => element.SetValue(PopupProperty, value);
+
+ public static Popup GetPopup(DependencyObject element)
+ => (Popup) element.GetValue(PopupProperty);
+
+ internal static readonly DependencyProperty TopLineProperty = DependencyProperty.RegisterAttached(
+ "TopLine", typeof(FrameworkElement), typeof(MenuTopLineAttach), new PropertyMetadata(default(FrameworkElement)));
+
+ internal static void SetTopLine(DependencyObject element, FrameworkElement value)
+ => element.SetValue(TopLineProperty, value);
+
+ internal static FrameworkElement GetTopLine(DependencyObject element)
+ => (FrameworkElement) element.GetValue(TopLineProperty);
+ }
+}
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
index dd6a8db5..848b2327 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
@@ -80,7 +80,10 @@ namespace HandyControl.Controls
{
if (d is System.Windows.Window window)
{
- if ((bool)e.NewValue)
+ var v = (bool) e.NewValue;
+ window.SetCurrentValue(System.Windows.Window.ShowInTaskbarProperty, v);
+
+ if (v)
{
window.SourceInitialized -= Window_SourceInitialized;
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
index 18427620..717f0731 100644
--- a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
@@ -4,9 +4,11 @@ using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using HandyControl.Data;
+using HandyControl.Tools.Extension;
namespace HandyControl.Controls
{
@@ -27,7 +29,7 @@ namespace HandyControl.Controls
///
/// 最大显示数量的一半
///
- private const int MaxShowCountHalf = 7;
+ private const int MaxShowCountHalf = 3;
///
/// 页码
@@ -55,7 +57,7 @@ namespace HandyControl.Controls
private static void OnPageIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (CoverFlow)d;
- ctl.UpdateIndex((int)e.NewValue, (int)e.OldValue);
+ ctl.UpdateIndex((int)e.NewValue);
}
///
@@ -72,13 +74,15 @@ namespace HandyControl.Controls
///
/// 当前在显示范围内的项
///
- private readonly Dictionary _itemShowList = new Dictionary();
+ private readonly Dictionary _itemShowDic = new Dictionary();
///
/// 相机
///
private ProjectionCamera _camera;
+ private Point3DAnimation _point3DAnimation;
+
///
/// 3d画布
///
@@ -127,7 +131,7 @@ namespace HandyControl.Controls
if (_viewport3D != null)
{
_viewport3D.Children.Clear();
- _itemShowList.Clear();
+ _itemShowDic.Clear();
_viewport3D.MouseLeftButtonDown -= Viewport3D_MouseLeftButtonDown;
}
@@ -148,7 +152,9 @@ namespace HandyControl.Controls
PageIndex = _jumpToIndex;
_jumpToIndex = -1;
}
- _camera.Position = new Point3D(CoverFlowItem.Interval * PageIndex, _camera.Position.Y, _camera.Position.Z);
+
+ _point3DAnimation = new Point3DAnimation(new Point3D(CoverFlowItem.Interval * PageIndex, _camera.Position.Y, _camera.Position.Z), new Duration(TimeSpan.FromMilliseconds(200)));
+ _camera.BeginAnimation(ProjectionCamera.PositionProperty, _point3DAnimation);
}
///
@@ -204,24 +210,17 @@ namespace HandyControl.Controls
///
private void Remove(int pos)
{
- if (!_itemShowList.TryGetValue(pos, out var item)) return;
+ if (!_itemShowDic.TryGetValue(pos, out var item)) return;
_visualParent.Children.Remove(item);
- _itemShowList.Remove(pos);
+ _itemShowDic.Remove(pos);
}
- ///
- /// 移动项到指定的位置
- ///
- ///
- ///
- private void Move(int index, bool animated) => _itemShowList[index].Move(PageIndex, animated);
-
private void Viewport3D_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var result = (RayMeshGeometry3DHitTestResult)VisualTreeHelper.HitTest(_viewport3D, e.GetPosition(_viewport3D));
if (result != null)
{
- foreach (var item in _itemShowList.Values)
+ foreach (var item in _itemShowDic.Values)
{
if (item.HitTest(result.MeshHit))
{
@@ -236,35 +235,25 @@ namespace HandyControl.Controls
/// 更新项的位置
///
///
- ///
- private void UpdateIndex(int newIndex, int oldIndex)
+ private void UpdateIndex(int newIndex)
{
- var animate = Math.Abs(newIndex - oldIndex) < MaxShowCountHalf;
UpdateShowRange();
- if (newIndex > oldIndex)
+ _itemShowDic.Do(item =>
{
- if (oldIndex < _firstShowIndex)
+ if (item.Value.Index < _firstShowIndex || item.Value.Index > _lastShowIndex)
{
- oldIndex = _firstShowIndex;
+ Remove(item.Value.Index);
}
- for (var i = oldIndex; i <= newIndex; i++)
+ else
{
- Move(i, animate);
+ item.Value.Move(PageIndex);
}
- }
- else
- {
- if (oldIndex > _lastShowIndex)
- {
- oldIndex = _lastShowIndex;
- }
- for (var i = oldIndex; i >= newIndex; i--)
- {
- Move(i, animate);
- }
- }
- _camera.Position = new Point3D(CoverFlowItem.Interval * newIndex, _camera.Position.Y,
- _camera.Position.Z);
+ });
+
+ _point3DAnimation = new Point3DAnimation(new Point3D(CoverFlowItem.Interval * newIndex, _camera.Position.Y,
+ _camera.Position.Z), new Duration(TimeSpan.FromMilliseconds(200)));
+
+ _camera.BeginAnimation(ProjectionCamera.PositionProperty, _point3DAnimation);
}
///
@@ -275,27 +264,12 @@ namespace HandyControl.Controls
var newFirstShowIndex = Math.Max(PageIndex - MaxShowCountHalf, 0);
var newLastShowIndex = Math.Min(PageIndex + MaxShowCountHalf, _contentDic.Count - 1);
- if (_firstShowIndex < newFirstShowIndex)
- {
- for (var i = _firstShowIndex; i < newFirstShowIndex; i++)
- {
- Remove(i);
- }
- }
- else if (newLastShowIndex < _lastShowIndex)
- {
- for (var i = newLastShowIndex; i < _lastShowIndex; i++)
- {
- Remove(i);
- }
- }
-
for (var i = newFirstShowIndex; i <= newLastShowIndex; i++)
{
- if (!_itemShowList.ContainsKey(i))
+ if (!_itemShowDic.ContainsKey(i))
{
var cover = CreateCoverFlowItem(i, _contentDic[i]);
- _itemShowList[i] = cover;
+ _itemShowDic[i] = cover;
_visualParent.Children.Add(cover);
}
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs
index b678f343..485a17be 100644
--- a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlowItem.cs
@@ -124,23 +124,14 @@ namespace HandyControl.Controls
///
/// 移动
///
- internal void Move(int currentIndex, bool animated)
+ internal void Move(int currentIndex)
{
- if (animated || _rotation3D.HasAnimatedProperties)
- {
- _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty,
- AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed));
- _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty,
- AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed));
- _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty,
- AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed));
- }
- else
- {
- _rotation3D.Angle = GetAngleByPos(currentIndex);
- _transform3D.OffsetX = GetXByPos(currentIndex);
- _transform3D.OffsetZ = GetZByPos(currentIndex);
- }
+ _rotation3D.BeginAnimation(AxisAngleRotation3D.AngleProperty,
+ AnimationHelper.CreateAnimation(GetAngleByPos(currentIndex), AnimationSpeed));
+ _transform3D.BeginAnimation(TranslateTransform3D.OffsetXProperty,
+ AnimationHelper.CreateAnimation(GetXByPos(currentIndex), AnimationSpeed));
+ _transform3D.BeginAnimation(TranslateTransform3D.OffsetZProperty,
+ AnimationHelper.CreateAnimation(GetZByPos(currentIndex), AnimationSpeed));
}
///
diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs b/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs
index 7f2fc50a..31c93d2e 100644
--- a/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Other/Dialog.cs
@@ -16,14 +16,14 @@ namespace HandyControl.Controls
private Adorner _container;
- private static readonly Dictionary WindowDic = new Dictionary();
+ private static readonly Dictionary ContainerDic = new Dictionary();
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsClosed
{
- get => (bool) GetValue(IsClosedProperty);
+ get => (bool)GetValue(IsClosedProperty);
internal set => SetValue(IsClosedProperty, value);
}
@@ -32,15 +32,15 @@ namespace HandyControl.Controls
private static void OnTokenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
- if (d is System.Windows.Window window)
+ if (d is FrameworkElement element)
{
if (e.NewValue == null)
{
- Unregister(window);
+ Unregister(element);
}
else
{
- Register(e.NewValue.ToString(), window);
+ Register(e.NewValue.ToString(), element);
}
}
}
@@ -49,39 +49,39 @@ namespace HandyControl.Controls
=> element.SetValue(TokenProperty, value);
public static string GetToken(DependencyObject element)
- => (string) element.GetValue(TokenProperty);
+ => (string)element.GetValue(TokenProperty);
public Dialog()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Close, (s, e) => Close()));
}
- public static void Register(string token, System.Windows.Window window)
+ public static void Register(string token, FrameworkElement element)
{
- if (string.IsNullOrEmpty(token) || window == null) return;
- WindowDic[token] = window;
+ if (string.IsNullOrEmpty(token) || element == null) return;
+ ContainerDic[token] = element;
}
- public static void Unregister(string token, System.Windows.Window window)
+ public static void Unregister(string token, FrameworkElement element)
{
- if (string.IsNullOrEmpty(token) || window == null) return;
+ if (string.IsNullOrEmpty(token) || element == null) return;
- if (WindowDic.ContainsKey(token))
+ if (ContainerDic.ContainsKey(token))
{
- if (ReferenceEquals(WindowDic[token], window))
+ if (ReferenceEquals(ContainerDic[token], element))
{
- WindowDic.Remove(token);
+ ContainerDic.Remove(token);
}
}
}
- public static void Unregister(System.Windows.Window window)
+ public static void Unregister(FrameworkElement element)
{
- if (window == null) return;
- var first = WindowDic.FirstOrDefault(item => ReferenceEquals(window, item.Value));
+ if (element == null) return;
+ var first = ContainerDic.FirstOrDefault(item => ReferenceEquals(element, item.Value));
if (!string.IsNullOrEmpty(first.Key))
{
- WindowDic.Remove(first.Key);
+ ContainerDic.Remove(first.Key);
}
}
@@ -89,9 +89,9 @@ namespace HandyControl.Controls
{
if (string.IsNullOrEmpty(token)) return;
- if (WindowDic.ContainsKey(token))
+ if (ContainerDic.ContainsKey(token))
{
- WindowDic.Remove(token);
+ ContainerDic.Remove(token);
}
}
@@ -105,20 +105,20 @@ namespace HandyControl.Controls
Content = content
};
- System.Windows.Window window;
+ FrameworkElement element;
if (string.IsNullOrEmpty(token))
{
- window = WindowHelper.GetActiveWindow();
+ element = WindowHelper.GetActiveWindow();
}
else
{
- WindowDic.TryGetValue(token, out window);
+ ContainerDic.TryGetValue(token, out element);
}
- if (window != null)
+ if (element != null)
{
- var decorator = VisualHelper.GetChild(window);
+ var decorator = VisualHelper.GetChild(element);
if (decorator != null)
{
if (decorator.Child != null)
@@ -148,17 +148,17 @@ namespace HandyControl.Controls
{
Close(WindowHelper.GetActiveWindow());
}
- else if (WindowDic.TryGetValue(_token, out var window))
+ else if (ContainerDic.TryGetValue(_token, out var element))
{
- Close(window);
+ Close(element);
}
}
- private void Close(System.Windows.Window window)
+ private void Close(DependencyObject element)
{
- if (window != null)
+ if (element != null)
{
- var decorator = VisualHelper.GetChild(window);
+ var decorator = VisualHelper.GetChild(element);
if (decorator != null)
{
if (decorator.Child != null)
diff --git a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
index 5e3bdb13..7b73fd0e 100644
--- a/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Screenshot/ScreenshotWindow.cs
@@ -7,6 +7,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using HandyControl.Data;
using HandyControl.Tools;
+using HandyControl.Tools.Extension;
using HandyControl.Tools.Interop;
namespace HandyControl.Controls
@@ -17,13 +18,19 @@ namespace HandyControl.Controls
[TemplatePart(Name = ElementMaskAreaRight, Type = typeof(FrameworkElement))]
[TemplatePart(Name = ElementMaskAreaBottom, Type = typeof(FrameworkElement))]
[TemplatePart(Name = ElementTargetArea, Type = typeof(InkCanvas))]
- [TemplatePart(Name = ElementTextSize, Type = typeof(TextBlock))]
+ [TemplatePart(Name = ElementMagnifier, Type = typeof(FrameworkElement))]
public class ScreenshotWindow : System.Windows.Window
{
#region fields
private readonly Screenshot _screenshot;
+ private VisualBrush _visualPreview;
+
+ private Size _viewboxSize;
+
+ private BitmapSource _imageSource;
+
#region const
private const int IntervalLength = 1;
@@ -52,6 +59,8 @@ namespace HandyControl.Controls
private readonly int[] _flagArr = new int[4];
+ private bool _isOut;
+
private bool _canDrag;
private bool _receiveMoveMsg = true;
@@ -60,7 +69,7 @@ namespace HandyControl.Controls
private Point _pointFixed;
- private Point _pointFloating;
+ private InteropValues.POINT _pointFloating;
private bool _saveScreenshot;
@@ -82,7 +91,7 @@ namespace HandyControl.Controls
internal FrameworkElement TargetArea { get; set; }
- internal TextBlock TextSize { get; set; }
+ private FrameworkElement _magnifier;
#endregion
@@ -100,7 +109,7 @@ namespace HandyControl.Controls
private const string ElementTargetArea = "PART_TargetArea";
- private const string ElementTextSize = "PART_TextSize";
+ private const string ElementMagnifier = "PART_Magnifier";
#endregion
@@ -124,6 +133,53 @@ namespace HandyControl.Controls
internal set => SetValue(IsSelectingProperty, value);
}
+ public static readonly DependencyProperty SizeProperty = DependencyProperty.Register(
+ "Size", typeof(Size), typeof(ScreenshotWindow), new PropertyMetadata(default(Size)));
+
+ public Size Size
+ {
+ get => (Size) GetValue(SizeProperty);
+ internal set => SetValue(SizeProperty, value);
+ }
+
+ public static readonly DependencyProperty SizeStrProperty = DependencyProperty.Register(
+ "SizeStr", typeof(string), typeof(ScreenshotWindow), new PropertyMetadata(default(string)));
+
+ public string SizeStr
+ {
+ get => (string) GetValue(SizeStrProperty);
+ internal set => SetValue(SizeStrProperty, value);
+ }
+
+ public static readonly DependencyProperty PixelColorProperty = DependencyProperty.Register(
+ "PixelColor", typeof(Color), typeof(ScreenshotWindow), new PropertyMetadata(default(Color)));
+
+ public Color PixelColor
+ {
+ get => (Color) GetValue(PixelColorProperty);
+ internal set => SetValue(PixelColorProperty, value);
+ }
+
+ public static readonly DependencyProperty PixelColorStrProperty = DependencyProperty.Register(
+ "PixelColorStr", typeof(string), typeof(ScreenshotWindow), new PropertyMetadata(default(string)));
+
+ public string PixelColorStr
+ {
+ get => (string) GetValue(PixelColorStrProperty);
+ internal set => SetValue(PixelColorStrProperty, value);
+ }
+
+ public static readonly DependencyPropertyKey PreviewBrushPropertyKey = DependencyProperty.RegisterReadOnly(
+ "PreviewBrush", typeof(Brush), typeof(ScreenshotWindow), new PropertyMetadata(default(Brush)));
+
+ public static readonly DependencyProperty PreviewBrushProperty = PreviewBrushPropertyKey.DependencyProperty;
+
+ public Brush PreviewBrush
+ {
+ get => (Brush) GetValue(PreviewBrushProperty);
+ set => SetValue(PreviewBrushProperty, value);
+ }
+
#endregion
public ScreenshotWindow(Screenshot screenshot)
@@ -149,7 +205,19 @@ namespace HandyControl.Controls
MaskAreaRight = GetTemplateChild(ElementMaskAreaRight) as FrameworkElement;
MaskAreaBottom = GetTemplateChild(ElementMaskAreaBottom) as FrameworkElement;
TargetArea = GetTemplateChild(ElementTargetArea) as FrameworkElement;
- TextSize = GetTemplateChild(ElementTextSize) as TextBlock;
+ _magnifier = GetTemplateChild(ElementMagnifier) as FrameworkElement;
+
+ if (_magnifier != null)
+ {
+ _viewboxSize = new Size(29, 21);
+ }
+
+ _visualPreview = new VisualBrush(Canvas)
+ {
+ ViewboxUnits = BrushMappingMode.Absolute
+ };
+ SetValue(PreviewBrushPropertyKey, _visualPreview);
+ _magnifier.Show();
}
protected override void OnPreviewKeyDown(KeyEventArgs e)
@@ -190,6 +258,8 @@ namespace HandyControl.Controls
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) => _mousePointOld = e.GetPosition(this);
+ protected override void OnPreviewMouseLeftButtonUp(MouseButtonEventArgs e) => _magnifier.Collapse();
+
protected override void OnPreviewMouseDoubleClick(MouseButtonEventArgs e)
{
_saveScreenshot = true;
@@ -210,6 +280,7 @@ namespace HandyControl.Controls
if (IsDrawing)
{
+ if (_isOut) return;
var rect = _targetWindowRect;
if (_canDrag)
@@ -221,28 +292,37 @@ namespace HandyControl.Controls
}
else
{
+ var magnifierPos = new InteropValues.POINT((int) newPoint.X, (int) newPoint.Y);
+
if (_flagArr[0] > 0)
{
_pointFloating.X += offsetX * _flagArr[0];
+ magnifierPos.X = _pointFloating.X;
}
else if (_flagArr[2] > 0)
{
_pointFloating.X += offsetX * _flagArr[2];
+ magnifierPos.X = _pointFloating.X - 1;
}
if (_flagArr[1] > 0)
{
_pointFloating.Y += offsetY * _flagArr[1];
+ magnifierPos.Y = _pointFloating.Y;
}
else if (_flagArr[3] > 0)
{
_pointFloating.Y += offsetY * _flagArr[3];
+ magnifierPos.Y = _pointFloating.Y - 1;
}
rect.Left = (int)Math.Min(_pointFixed.X, _pointFloating.X);
rect.Top = (int)Math.Min(_pointFixed.Y, _pointFloating.Y);
rect.Right = (int)Math.Max(_pointFixed.X, _pointFloating.X);
rect.Bottom = (int)Math.Max(_pointFixed.Y, _pointFloating.Y);
+
+ _magnifier.Show();
+ MoveMagnifier(magnifierPos);
}
MoveTargetArea(rect);
@@ -279,10 +359,17 @@ namespace HandyControl.Controls
private void ScreenshotWindow_Loaded(object sender, RoutedEventArgs e)
{
- Canvas.Background = new ImageBrush(GetDesktopSnapshot());
+ _imageSource = GetDesktopSnapshot();
+ var image = new Image
+ {
+ Source = _imageSource
+ };
+ RenderOptions.SetBitmapScalingMode(image, BitmapScalingMode.NearestNeighbor);
+ Canvas.Children.Add(image);
StartHooks();
InteropMethods.GetCursorPos(out var point);
- MoveElement2Point(point);
+ MoveElement(point);
+ MoveMagnifier(point);
}
private void UpdateStatus(Point point)
@@ -295,6 +382,7 @@ namespace HandyControl.Controls
var downAbs = Math.Abs(point.Y - _targetWindowRect.Height);
_canDrag = false;
+ _isOut = false;
_flagArr[0] = 0;
_flagArr[1] = 0;
_flagArr[2] = 0;
@@ -309,7 +397,7 @@ namespace HandyControl.Controls
// left
cursor = Cursors.SizeWE;
_pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
- _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Bottom);
_flagArr[0] = 1;
}
else
@@ -317,7 +405,7 @@ namespace HandyControl.Controls
//left bottom
cursor = Cursors.SizeNESW;
_pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
- _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Bottom);
_flagArr[0] = 1;
_flagArr[3] = 1;
}
@@ -327,7 +415,7 @@ namespace HandyControl.Controls
// left top
cursor = Cursors.SizeNWSE;
_pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
- _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Top);
_flagArr[0] = 1;
_flagArr[1] = 1;
}
@@ -348,6 +436,7 @@ namespace HandyControl.Controls
{
//out
cursor = Cursors.Arrow;
+ _isOut = true;
}
}
else
@@ -355,7 +444,7 @@ namespace HandyControl.Controls
//bottom
cursor = Cursors.SizeNS;
_pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
- _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Bottom);
_flagArr[3] = 1;
}
}
@@ -364,7 +453,7 @@ namespace HandyControl.Controls
//top
cursor = Cursors.SizeNS;
_pointFixed = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
- _pointFloating = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Left, _targetWindowRect.Top);
_flagArr[1] = 1;
}
}
@@ -377,7 +466,7 @@ namespace HandyControl.Controls
//right
cursor = Cursors.SizeWE;
_pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
- _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Top);
_flagArr[2] = 1;
}
else
@@ -385,7 +474,7 @@ namespace HandyControl.Controls
//right bottom
cursor = Cursors.SizeNWSE;
_pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Top);
- _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Bottom);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Bottom);
_flagArr[2] = 1;
_flagArr[3] = 1;
}
@@ -395,7 +484,7 @@ namespace HandyControl.Controls
// right top
cursor = Cursors.SizeNESW;
_pointFixed = new Point(_targetWindowRect.Left, _targetWindowRect.Bottom);
- _pointFloating = new Point(_targetWindowRect.Right, _targetWindowRect.Top);
+ _pointFloating = new InteropValues.POINT(_targetWindowRect.Right, _targetWindowRect.Top);
_flagArr[1] = 1;
_flagArr[2] = 1;
}
@@ -404,6 +493,7 @@ namespace HandyControl.Controls
{
//out
cursor = Cursors.Arrow;
+ _isOut = true;
}
TargetArea.Cursor = cursor;
@@ -426,33 +516,35 @@ namespace HandyControl.Controls
switch (e.MessageType)
{
case MouseHookMessageType.MouseMove:
- MoveElement2Point(e.Point);
+ MoveElement(e.Point);
+ MoveMagnifier(e.Point);
break;
case MouseHookMessageType.LeftButtonDown:
_receiveMoveMsg = false;
_mousePointOld = new Point(e.Point.X, e.Point.Y);
InteropMethods.EnableWindow(_screenshotWindowHandle, true);
break;
+ case MouseHookMessageType.RightButtonDown:
+ if (!IsDrawing) Close();
+ break;
case MouseHookMessageType.LeftButtonUp:
StopHooks();
IsSelecting = false;
IsDrawing = true;
+ _magnifier.Collapse();
break;
}
}
private void SaveScreenshot()
{
- if (Canvas.Background is ImageBrush imageBrush && imageBrush.ImageSource is BitmapSource bitmapSource)
- {
- var cb = new CroppedBitmap(bitmapSource, new Int32Rect(_targetWindowRect.Left, _targetWindowRect.Top, _targetWindowRect.Width, _targetWindowRect.Height));
- _screenshot.OnSnapped(cb);
- }
+ var cb = new CroppedBitmap(_imageSource, new Int32Rect(_targetWindowRect.Left, _targetWindowRect.Top, _targetWindowRect.Width, _targetWindowRect.Height));
+ _screenshot.OnSnapped(cb);
Close();
}
- private ImageSource GetDesktopSnapshot()
+ private BitmapSource GetDesktopSnapshot()
{
_desktopWindowHandle = InteropMethods.GetDesktopWindow();
var hdcSrc = InteropMethods.GetWindowDC(_desktopWindowHandle);
@@ -471,7 +563,7 @@ namespace HandyControl.Controls
return Imaging.CreateBitmapSourceFromHBitmap(bitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
}
- private void MoveElement2Point(InteropValues.POINT point)
+ private void MoveElement(InteropValues.POINT point)
{
if (!_receiveMoveMsg) return;
@@ -544,7 +636,8 @@ namespace HandyControl.Controls
TargetArea.Margin = new Thickness(left, top, 0, 0);
_targetWindowRect = new InteropValues.RECT(left, top, left + width, top + height);
- TextSize.Text = $"{_targetWindowRect.Width} x {_targetWindowRect.Height}";
+ Size = _targetWindowRect.Size;
+ SizeStr = $"{_targetWindowRect.Width} x {_targetWindowRect.Height}";
MoveMaskArea();
}
@@ -566,5 +659,11 @@ namespace HandyControl.Controls
MaskAreaBottom.Width = TargetArea.Width;
MaskAreaBottom.Height = _desktopWindowRect.Height - TargetArea.Height - TargetArea.Margin.Top;
}
+
+ private void MoveMagnifier(InteropValues.POINT point)
+ {
+ _magnifier.Margin = new Thickness(point.X + 4, point.Y + 26, 0, 0);
+ _visualPreview.Viewbox = new Rect(new Point(point.X - _viewboxSize.Width / 2 + 0.5, point.Y - _viewboxSize.Height / 2 + 0.5), _viewboxSize);
+ }
}
}
diff --git a/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs b/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs
index 4a085542..e4f7396c 100644
--- a/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs
+++ b/src/Shared/HandyControl_Shared/Controls/StepBar/StepBar.cs
@@ -18,6 +18,8 @@ namespace HandyControl.Controls
{
private ProgressBar _progressBarBack;
+ private int _oriStepIndex = -1;
+
#region Constants
private const string ElementProgressBarBack = "PART_ProgressBarBack";
@@ -46,19 +48,14 @@ namespace HandyControl.Controls
}
}
- if (StepIndex < count)
+ if (_oriStepIndex > 0)
{
- for (var i = 0; i < StepIndex; i++)
- {
- if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepBarItem)
- {
- stepBarItem.Status = StepStatus.Complete;
- }
- }
- if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem item)
- {
- item.Status = StepStatus.UnderWay;
- }
+ StepIndex = _oriStepIndex;
+ _oriStepIndex = -1;
+ }
+ else
+ {
+ OnStepIndexChanged(StepIndex);
}
}
}
@@ -85,12 +82,64 @@ namespace HandyControl.Controls
}
public static readonly DependencyProperty StepIndexProperty = DependencyProperty.Register(
- "StepIndex", typeof(int), typeof(StepBar), new PropertyMetadata(ValueBoxes.Int0Box));
+ "StepIndex", typeof(int), typeof(StepBar), new FrameworkPropertyMetadata(ValueBoxes.Int0Box,
+ FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnStepIndexChanged, CoerceStepIndex));
+
+ private static object CoerceStepIndex(DependencyObject d, object basevalue)
+ {
+ var ctl = (StepBar)d;
+ var stepIndex = (int) basevalue;
+ if (ctl.Items.Count == 0 && stepIndex > 0)
+ {
+ ctl._oriStepIndex = stepIndex;
+ return ValueBoxes.Int0Box;
+ }
+
+ return stepIndex < 0
+ ? ValueBoxes.Int0Box
+ : stepIndex >= ctl.Items.Count
+ ? ctl.Items.Count == 0 ? 0 : ctl.Items.Count - 1
+ : basevalue;
+ }
+
+ private static void OnStepIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var ctl = (StepBar) d;
+ ctl.OnStepIndexChanged((int)e.NewValue);
+ }
+
+ private void OnStepIndexChanged(int stepIndex)
+ {
+ for (var i = 0; i < stepIndex; i++)
+ {
+ if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepItemFinished)
+ {
+ stepItemFinished.Status = StepStatus.Complete;
+ }
+ }
+
+ for (var i = stepIndex + 1; i < Items.Count; i++)
+ {
+ if (ItemContainerGenerator.ContainerFromIndex(i) is StepBarItem stepItemFinished)
+ {
+ stepItemFinished.Status = StepStatus.Waiting;
+ }
+ }
+
+ if (ItemContainerGenerator.ContainerFromIndex(stepIndex) is StepBarItem stepItemSelected)
+ stepItemSelected.Status = StepStatus.UnderWay;
+ _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(stepIndex));
+
+ RaiseEvent(new FunctionEventArgs(StepChangedEvent, this)
+ {
+ Info = stepIndex
+ });
+ }
public int StepIndex
{
- get => (int)GetValue(StepIndexProperty);
- protected set => SetValue(StepIndexProperty, value);
+ get => (int)GetValue(StepIndexProperty);
+ set => SetValue(StepIndexProperty, value);
}
public static readonly DependencyProperty DockProperty = DependencyProperty.Register(
@@ -128,42 +177,8 @@ namespace HandyControl.Controls
}
}
- public void Next()
- {
- StepIndex++;
- if (StepIndex >= Items.Count)
- {
- StepIndex = Items.Count - 1;
- return;
- }
- RaiseEvent(new FunctionEventArgs(StepChangedEvent, this)
- {
- Info = StepIndex
- });
- if (ItemContainerGenerator.ContainerFromIndex(StepIndex - 1) is StepBarItem stepItemFinished)
- stepItemFinished.Status = StepStatus.Complete;
- if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected)
- stepItemSelected.Status = StepStatus.UnderWay;
- _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
- }
+ public void Next() => StepIndex++;
- public void Prev()
- {
- StepIndex--;
- if (StepIndex < 0)
- {
- StepIndex = 0;
- return;
- }
- RaiseEvent(new FunctionEventArgs(StepChangedEvent, this)
- {
- Info = StepIndex
- });
- if (ItemContainerGenerator.ContainerFromIndex(StepIndex + 1) is StepBarItem stepItemWaiting)
- stepItemWaiting.Status = StepStatus.Waiting;
- if (ItemContainerGenerator.ContainerFromIndex(StepIndex) is StepBarItem stepItemSelected)
- stepItemSelected.Status = StepStatus.UnderWay;
- _progressBarBack?.BeginAnimation(RangeBase.ValueProperty, AnimationHelper.CreateAnimation(StepIndex));
- }
+ public void Prev() => StepIndex--;
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs
index c001fb30..c0aa5600 100644
--- a/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs
+++ b/src/Shared/HandyControl_Shared/Controls/TabControl/TabItem.cs
@@ -251,6 +251,8 @@ namespace HandyControl.Controls
protected override void OnMouseRightButtonDown(MouseButtonEventArgs e)
{
base.OnMouseRightButtonDown(e);
+
+ if (VisualTreeHelper.HitTest(this, e.GetPosition(this)) == null) return;
IsSelected = true;
Focus();
}
@@ -293,6 +295,7 @@ namespace HandyControl.Controls
{
base.OnMouseLeftButtonDown(e);
+ if (VisualTreeHelper.HitTest(this, e.GetPosition(this)) == null) return;
var parent = TabControlParent;
if (parent == null) return;
diff --git a/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs b/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs
index 038480de..abc6a971 100644
--- a/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Text/OutlineText.cs
@@ -155,24 +155,31 @@ namespace HandyControl.Controls
protected override void OnRender(DrawingContext drawingContext)
{
- EnsureGeometry();
-
- drawingContext.DrawGeometry(Fill, null, _textGeometry);
-
- if (StrokePosition == StrokePosition.Outside)
+ if (StrokeThickness > 0)
{
- drawingContext.PushClip(_clipGeometry);
+ EnsureGeometry();
+
+ drawingContext.DrawGeometry(Fill, null, _textGeometry);
+
+ if (StrokePosition == StrokePosition.Outside)
+ {
+ drawingContext.PushClip(_clipGeometry);
+ }
+ else if (StrokePosition == StrokePosition.Inside)
+ {
+ drawingContext.PushClip(_textGeometry);
+ }
+
+ drawingContext.DrawGeometry(null, _pen, _textGeometry);
+
+ if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside)
+ {
+ drawingContext.Pop();
+ }
}
- else if (StrokePosition == StrokePosition.Inside)
+ else
{
- drawingContext.PushClip(_textGeometry);
- }
-
- drawingContext.DrawGeometry(null, _pen, _textGeometry);
-
- if (StrokePosition == StrokePosition.Outside || StrokePosition == StrokePosition.Inside)
- {
- drawingContext.Pop();
+ drawingContext.DrawText(_formattedText, new Point());
}
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs
new file mode 100644
index 00000000..84830748
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Controls/Text/SimpleText.cs
@@ -0,0 +1,203 @@
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Documents;
+using System.Windows.Media;
+using HandyControl.Data;
+
+namespace HandyControl.Controls
+{
+ public class SimpleText : FrameworkElement
+ {
+ private FormattedText _formattedText;
+
+ static SimpleText()
+ {
+ SnapsToDevicePixelsProperty.OverrideMetadata(typeof(SimpleText), new FrameworkPropertyMetadata(ValueBoxes.TrueBox));
+ UseLayoutRoundingProperty.OverrideMetadata(typeof(SimpleText), new FrameworkPropertyMetadata(ValueBoxes.TrueBox));
+ }
+
+ public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
+ "Text", typeof(string), typeof(SimpleText), new FrameworkPropertyMetadata(
+ string.Empty,
+ FrameworkPropertyMetadataOptions.AffectsMeasure |
+ FrameworkPropertyMetadataOptions.AffectsRender, OnFormattedTextInvalidated));
+
+ public string Text
+ {
+ get => (string)GetValue(TextProperty);
+ set => SetValue(TextProperty, value);
+ }
+
+ public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register(
+ "TextAlignment", typeof(TextAlignment), typeof(SimpleText),
+ new PropertyMetadata(default(TextAlignment), OnFormattedTextUpdated));
+
+ public TextAlignment TextAlignment
+ {
+ get => (TextAlignment)GetValue(TextAlignmentProperty);
+ set => SetValue(TextAlignmentProperty, value);
+ }
+
+ public static readonly DependencyProperty TextTrimmingProperty = DependencyProperty.Register(
+ "TextTrimming", typeof(TextTrimming), typeof(SimpleText),
+ new PropertyMetadata(default(TextTrimming), OnFormattedTextInvalidated));
+
+ public TextTrimming TextTrimming
+ {
+ get => (TextTrimming)GetValue(TextTrimmingProperty);
+ set => SetValue(TextTrimmingProperty, value);
+ }
+
+ public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register(
+ "TextWrapping", typeof(TextWrapping), typeof(SimpleText),
+ new PropertyMetadata(TextWrapping.NoWrap, OnFormattedTextInvalidated));
+
+ public TextWrapping TextWrapping
+ {
+ get => (TextWrapping)GetValue(TextWrappingProperty);
+ set => SetValue(TextWrappingProperty, value);
+ }
+
+ public static readonly DependencyProperty ForegroundProperty = DependencyProperty.Register(
+ "Foreground", typeof(Brush), typeof(SimpleText), new PropertyMetadata(Brushes.Black, OnFormattedTextUpdated));
+
+ public Brush Foreground
+ {
+ get => (Brush) GetValue(ForegroundProperty);
+ set => SetValue(ForegroundProperty, value);
+ }
+
+ public static readonly DependencyProperty FontFamilyProperty = TextElement.FontFamilyProperty.AddOwner(
+ typeof(SimpleText),
+ new FrameworkPropertyMetadata(OnFormattedTextUpdated));
+
+ public FontFamily FontFamily
+ {
+ get => (FontFamily)GetValue(FontFamilyProperty);
+ set => SetValue(FontFamilyProperty, value);
+ }
+
+ public static readonly DependencyProperty FontSizeProperty = TextElement.FontSizeProperty.AddOwner(
+ typeof(SimpleText),
+ new FrameworkPropertyMetadata(OnFormattedTextUpdated));
+
+ [TypeConverter(typeof(FontSizeConverter))]
+ public double FontSize
+ {
+ get => (double)GetValue(FontSizeProperty);
+ set => SetValue(FontSizeProperty, value);
+ }
+
+ public static readonly DependencyProperty FontStretchProperty = TextElement.FontStretchProperty.AddOwner(
+ typeof(SimpleText),
+ new FrameworkPropertyMetadata(OnFormattedTextUpdated));
+
+ public FontStretch FontStretch
+ {
+ get => (FontStretch)GetValue(FontStretchProperty);
+ set => SetValue(FontStretchProperty, value);
+ }
+
+ public static readonly DependencyProperty FontStyleProperty = TextElement.FontStyleProperty.AddOwner(
+ typeof(SimpleText),
+ new FrameworkPropertyMetadata(OnFormattedTextUpdated));
+
+ public FontStyle FontStyle
+ {
+ get => (FontStyle)GetValue(FontStyleProperty);
+ set => SetValue(FontStyleProperty, value);
+ }
+
+ public static readonly DependencyProperty FontWeightProperty = TextElement.FontWeightProperty.AddOwner(
+ typeof(SimpleText),
+ new FrameworkPropertyMetadata(OnFormattedTextUpdated));
+
+ public FontWeight FontWeight
+ {
+ get => (FontWeight)GetValue(FontWeightProperty);
+ set => SetValue(FontWeightProperty, value);
+ }
+
+ protected override void OnRender(DrawingContext drawingContext) => drawingContext.DrawText(_formattedText, new Point());
+
+ private void EnsureFormattedText()
+ {
+ if (_formattedText != null || Text == null)
+ {
+ return;
+ }
+
+#if netle45
+ _formattedText = new FormattedText(
+ Text,
+ CultureInfo.CurrentUICulture,
+ FlowDirection,
+ new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),
+ FontSize, Foreground);
+#else
+ var source = PresentationSource.FromVisual(this);
+ var dpi = 1.0;
+ if (source?.CompositionTarget != null)
+ {
+ dpi = 96.0 * source.CompositionTarget.TransformToDevice.M11 / 96.0;
+ }
+ _formattedText = new FormattedText(
+ Text,
+ CultureInfo.CurrentUICulture,
+ FlowDirection,
+ new Typeface(FontFamily, FontStyle, FontWeight, FontStretch),
+ FontSize, Foreground, dpi);
+#endif
+
+ UpdateFormattedText();
+ }
+
+ private void UpdateFormattedText()
+ {
+ if (_formattedText == null)
+ {
+ return;
+ }
+
+ _formattedText.MaxLineCount = TextWrapping == TextWrapping.NoWrap ? 1 : int.MaxValue;
+ _formattedText.TextAlignment = TextAlignment;
+ _formattedText.Trimming = TextTrimming;
+
+ _formattedText.SetFontSize(FontSize);
+ _formattedText.SetFontStyle(FontStyle);
+ _formattedText.SetFontWeight(FontWeight);
+ _formattedText.SetFontFamily(FontFamily);
+ _formattedText.SetFontStretch(FontStretch);
+ }
+
+ private static void OnFormattedTextUpdated(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var outlinedTextBlock = (SimpleText)d;
+ outlinedTextBlock.UpdateFormattedText();
+
+ outlinedTextBlock.InvalidateMeasure();
+ outlinedTextBlock.InvalidateVisual();
+ }
+
+ private static void OnFormattedTextInvalidated(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var outlinedTextBlock = (SimpleText)d;
+ outlinedTextBlock._formattedText = null;
+
+ outlinedTextBlock.InvalidateMeasure();
+ outlinedTextBlock.InvalidateVisual();
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ EnsureFormattedText();
+
+ _formattedText.MaxTextWidth = Math.Min(3579139, availableSize.Width);
+ _formattedText.MaxTextHeight = Math.Max(0.0001d, availableSize.Height);
+
+ return new Size(_formattedText.Width, _formattedText.Height);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs
index 5d190fb6..932e79c8 100644
--- a/src/Shared/HandyControl_Shared/Controls/Window/Window.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Window/Window.cs
@@ -304,7 +304,7 @@ namespace HandyControl.Controls
_tempNonClientAreaHeight = NonClientAreaHeight;
NonClientAreaHeight += 8;
}
- else if (WindowState == WindowState.Normal)
+ else
{
BorderThickness = _actualBorderThickness;
NonClientAreaHeight = _tempNonClientAreaHeight;
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index a78fba08..cf7a8042 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -17,6 +17,7 @@
+
@@ -44,6 +45,7 @@
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml
index 367c0b7f..85f1d0e6 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/ContextMenuBaseStyle.xaml
@@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
+
@@ -11,7 +12,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
index bd7b0652..d9d3be29 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml
@@ -3,6 +3,7 @@
xmlns:controls="clr-namespace:HandyControl.Controls">
+
@@ -64,13 +65,13 @@
-
+
-
+
@@ -166,7 +167,7 @@
-
+
@@ -184,7 +185,7 @@
-
+
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml
index 9b3a0bfd..27a4b5f6 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Screenshot.xaml
@@ -88,10 +88,12 @@
-
+
+
+
@@ -112,7 +114,24 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
index b8872602..a6bbd3e7 100644
--- a/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Converter/TreeViewItemMarginConverter.cs
@@ -8,7 +8,6 @@ namespace HandyControl.Tools.Converter
{
public class TreeViewItemMarginConverter: IValueConverter
{
-
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var left = 0.0;
diff --git a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
index 81f22d93..7d242bec 100644
--- a/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Extension/UIElementExtension.cs
@@ -9,37 +9,25 @@ namespace HandyControl.Tools.Extension
/// 显示元素
///
///
- public static void Show(this UIElement element)
- {
- element.Visibility = Visibility.Visible;
- }
+ public static void Show(this UIElement element) => element.Visibility = Visibility.Visible;
///
/// 显示元素
///
///
///
- public static void Show(this UIElement element, bool show)
- {
- element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
- }
+ public static void Show(this UIElement element, bool show) => element.Visibility = show ? Visibility.Visible : Visibility.Collapsed;
///
/// 不现实元素,但保留空间
///
///
- public static void Hide(this UIElement element)
- {
- element.Visibility = Visibility.Hidden;
- }
+ public static void Hide(this UIElement element) => element.Visibility = Visibility.Hidden;
///
/// 不显示元素,且不保留空间
///
///
- public static void Collapse(this UIElement element)
- {
- element.Visibility = Visibility.Collapsed;
- }
+ public static void Collapse(this UIElement element) => element.Visibility = Visibility.Collapsed;
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
index b6351478..84a088e1 100644
--- a/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
+++ b/src/Shared/HandyControl_Shared/Tools/Helper/VisualHelper.cs
@@ -20,12 +20,10 @@ namespace HandyControl.Tools
.FirstOrDefault(group => string.CompareOrdinal(groupName, group.Name) == 0);
}
- internal static FrameworkElement GetImplementationRoot(DependencyObject d)
- {
- return 1 == VisualTreeHelper.GetChildrenCount(d)
+ internal static FrameworkElement GetImplementationRoot(DependencyObject d) =>
+ 1 == VisualTreeHelper.GetChildrenCount(d)
? VisualTreeHelper.GetChild(d, 0) as FrameworkElement
: null;
- }
public static T GetChild(DependencyObject d) where T : DependencyObject
{
@@ -42,16 +40,19 @@ namespace HandyControl.Tools
return default;
}
- public static IntPtr GetHandle(this Visual visual)
- {
- return (PresentationSource.FromVisual(visual) as HwndSource)?.Handle ?? IntPtr.Zero;
- }
+ public static T GetParent(DependencyObject d) where T : DependencyObject =>
+ d switch
+ {
+ null => default,
+ T t => t,
+ Window _ => null,
+ _ => GetParent(VisualTreeHelper.GetParent(d))
+ };
- internal static void HitTestVisibleElements(Visual visual, HitTestResultCallback resultCallback,
- HitTestParameters parameters)
- {
+ public static IntPtr GetHandle(this Visual visual) => (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)
{