completed the branch

This commit is contained in:
NaBian committed 2019-08-13 23:36:13 +08:00
1 parent 86c58476c6
commit d25ff966c2
17 files changed
+152 -18

No files matched your search

@@ -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);
}
}
@@ -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;
@@ -31,6 +31,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\RunningBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\CloseWindowCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interactivity\Commands\OpenLinkCommand.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\BorderCircularClipConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\Number2PercentageConverter.cs" />
@@ -763,6 +764,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\Sprite.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Themes\Styles\StepBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -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;
}
}
@@ -156,5 +156,10 @@ namespace HandyControl.Interactivity
/// 前置主窗口
/// </summary>
public static PushMainWindow2TopCommand PushMainWindow2Top { get; } = new PushMainWindow2TopCommand();
/// <summary>
/// 关闭窗口
/// </summary>
public static CloseWindowCommand CloseWindow { get; } = new CloseWindowCommand();
}
}
@@ -11,6 +11,8 @@
</ResourceDictionary.MergedDictionaries>
<Style TargetType="controls:GrowlWindow">
<Setter Property="controls:WindowAttach.IgnoreAltF4" Value="True"/>
<Setter Property="controls:WindowAttach.ShowInTaskManager" Value="False"/>
<Setter Property="Width" Value="340"/>
<Setter Property="MaxWidth" Value="340"/>
<Setter Property="Background" Value="Transparent"/>
@@ -71,6 +71,7 @@
<ResourceDictionary Source="Magnifier.xaml"/>
<ResourceDictionary Source="ToggleBlock.xaml"/>
<ResourceDictionary Source="RunningBlock.xaml"/>
<ResourceDictionary Source="Sprite.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>