diff --git a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
index 50700677..984abb9a 100644
--- a/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
+++ b/src/Shared/HandyControlDemo_Shared/HandyControlDemo_Shared.projitems
@@ -328,6 +328,7 @@
+
@@ -339,6 +340,9 @@
AboutWindow.xaml
+
+ AppSprite.xaml
+
BlurWindow.xaml
@@ -787,6 +791,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
index 628ef134..43270cfc 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.Designer.cs
@@ -987,6 +987,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
+ ///
+ /// 查找类似 打开精灵 的本地化字符串。
+ ///
+ public static string OpenSprite {
+ get {
+ return ResourceManager.GetString("OpenSprite", resourceCulture);
+ }
+ }
+
///
/// 查找类似 轮廓文本 的本地化字符串。
///
diff --git a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
index a9276065..3efb365c 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.en.resx
@@ -648,4 +648,7 @@
Sprite
+
+ Open sprite
+
\ 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 452d92b9..6b168ea6 100644
--- a/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
+++ b/src/Shared/HandyControlDemo_Shared/Properties/Langs/Lang.resx
@@ -648,4 +648,7 @@
精灵
+
+ 打开精灵
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
index 8bcccf6a..49a0d290 100644
--- a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
+++ b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Styles/Style.xaml
@@ -94,4 +94,8 @@
+
+
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml
index e023b10b..282b15b0 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/SpriteDemoCtl.xaml
@@ -1,7 +1,12 @@
-
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml
new file mode 100644
index 00000000..4f135524
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs
new file mode 100644
index 00000000..b0cba5f3
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/AppSprite.xaml.cs
@@ -0,0 +1,10 @@
+namespace HandyControlDemo.UserControl
+{
+ public partial class AppSprite
+ {
+ public AppSprite()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs
new file mode 100644
index 00000000..46d154ab
--- /dev/null
+++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs
@@ -0,0 +1,18 @@
+using System;
+using GalaSoft.MvvmLight;
+using HandyControl.Controls;
+using HandyControlDemo.UserControl;
+#if netle40
+using GalaSoft.MvvmLight.Command;
+#else
+using GalaSoft.MvvmLight.CommandWpf;
+# endif
+
+namespace HandyControlDemo
+{
+ public class SpriteDemoViewModel : ViewModelBase
+ {
+ public RelayCommand OpenCmd => new Lazy(() =>
+ new RelayCommand(()=> Sprite.Show(new AppSprite()))).Value;
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs
index 94eeca7a..a623d046 100644
--- a/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs
+++ b/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs
@@ -39,6 +39,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
+ SimpleIoc.Default.Register();
}
public static ViewModelLocator Instance => new Lazy(() =>
@@ -90,6 +91,8 @@ namespace HandyControlDemo.ViewModel
public CardDemoViewModel CardDemo => new CardDemoViewModel(ServiceLocator.Current.GetInstance());
+ public SpriteDemoViewModel SpriteDemo => ServiceLocator.Current.GetInstance();
+
#endregion
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
index fb600659..911f6fec 100644
--- a/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Attach/WindowAttach.cs
@@ -1,6 +1,9 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Input;
+using System.Windows.Interop;
using HandyControl.Data;
+using HandyControl.Tools.Interop;
namespace HandyControl.Controls
{
@@ -21,7 +24,7 @@ namespace HandyControl.Controls
{
if ((bool)e.NewValue)
{
- ctl.MouseLeftButtonDown += DragElement_MouseLeftButtonDown; ;
+ ctl.MouseLeftButtonDown += DragElement_MouseLeftButtonDown;
}
else
{
@@ -69,5 +72,40 @@ namespace HandyControl.Controls
public static bool GetIgnoreAltF4(DependencyObject element)
=> (bool) element.GetValue(IgnoreAltF4Property);
+
+ public static readonly DependencyProperty ShowInTaskManagerProperty = DependencyProperty.RegisterAttached(
+ "ShowInTaskManager", typeof(bool), typeof(WindowAttach), new PropertyMetadata(ValueBoxes.TrueBox, OnShowInTaskManagerChanged));
+
+ private static void OnShowInTaskManagerChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is System.Windows.Window window)
+ {
+ if ((bool)e.NewValue)
+ {
+ window.SourceInitialized -= Window_SourceInitialized;
+ }
+ else
+ {
+ window.SourceInitialized += Window_SourceInitialized;
+ }
+ }
+ }
+
+ private static void Window_SourceInitialized(object sender, EventArgs e)
+ {
+ if (sender is System.Windows.Window window)
+ {
+ var _ = new WindowInteropHelper(window)
+ {
+ Owner = NativeMethods.GetDesktopWindow()
+ };
+ }
+ }
+
+ public static void SetShowInTaskManager(DependencyObject element, bool value)
+ => element.SetValue(ShowInTaskManagerProperty, value);
+
+ public static bool GetShowInTaskManager(DependencyObject element)
+ => (bool) element.GetValue(ShowInTaskManagerProperty);
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Controls/Growl/GrowlWindow.cs b/src/Shared/HandyControl_Shared/Controls/Growl/GrowlWindow.cs
index a341abbc..38c75cd5 100644
--- a/src/Shared/HandyControl_Shared/Controls/Growl/GrowlWindow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Growl/GrowlWindow.cs
@@ -1,8 +1,5 @@
-using System;
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
-using System.Windows.Interop;
-using HandyControl.Tools.Interop;
namespace HandyControl.Controls
{
@@ -26,16 +23,6 @@ namespace HandyControl.Controls
GrowlPanel = GetTemplateChild(ElementGrowPanel) as Panel;
}
- protected override void OnSourceInitialized(EventArgs e)
- {
- base.OnSourceInitialized(e);
-
- var _ = new WindowInteropHelper(this)
- {
- Owner = NativeMethods.GetDesktopWindow()
- };
- }
-
public void Init()
{
var desktopWorkingArea = SystemParameters.WorkArea;
diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
index 1b95259b..09c934eb 100644
--- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
+++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems
@@ -31,6 +31,7 @@
+
@@ -763,6 +764,10 @@
Designer
MSBuild:Compile
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
diff --git a/src/Shared/HandyControl_Shared/Interactivity/Commands/CloseWindowCommand.cs b/src/Shared/HandyControl_Shared/Interactivity/Commands/CloseWindowCommand.cs
new file mode 100644
index 00000000..392abeab
--- /dev/null
+++ b/src/Shared/HandyControl_Shared/Interactivity/Commands/CloseWindowCommand.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Windows;
+using System.Windows.Input;
+
+namespace HandyControl.Interactivity
+{
+ public class CloseWindowCommand : ICommand
+ {
+ public bool CanExecute(object parameter) => true;
+
+ public void Execute(object parameter)
+ {
+ if (parameter is DependencyObject dependencyObject)
+ {
+ if (Window.GetWindow(dependencyObject) is Window window)
+ {
+ window.Close();
+ }
+ }
+ }
+
+ public event EventHandler CanExecuteChanged;
+ }
+}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs b/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
index ab66b196..07c58353 100644
--- a/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
+++ b/src/Shared/HandyControl_Shared/Interactivity/Commands/ControlCommands.cs
@@ -156,5 +156,10 @@ namespace HandyControl.Interactivity
/// 前置主窗口
///
public static PushMainWindow2TopCommand PushMainWindow2Top { get; } = new PushMainWindow2TopCommand();
+
+ ///
+ /// 关闭窗口
+ ///
+ public static CloseWindowCommand CloseWindow { get; } = new CloseWindowCommand();
}
}
\ No newline at end of file
diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Growl.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Growl.xaml
index 9fd38d69..f54f7525 100644
--- a/src/Shared/HandyControl_Shared/Themes/Styles/Growl.xaml
+++ b/src/Shared/HandyControl_Shared/Themes/Styles/Growl.xaml
@@ -11,6 +11,8 @@