🧡优化拾色器
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
|
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
|
||||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:xf="clr-namespace:XamlFlair;assembly=XamlFlair.WPF"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
@@ -14,8 +15,52 @@
|
|||||||
Background="White"
|
Background="White"
|
||||||
Height="385"
|
Height="385"
|
||||||
Width="228">
|
Width="228">
|
||||||
|
<Grid>
|
||||||
|
<TextBlock Panel.ZIndex="1000" Text="❤❤❤"
|
||||||
|
x:Name="CopySuccess"
|
||||||
|
Visibility="Collapsed"
|
||||||
|
xf:Animations.Primary="{xf:Animate BasedOn={StaticResource FadeInAndSlideFromBottom}, Duration=400, Event=None}"
|
||||||
|
xf:Animations.PrimaryBinding="{Binding CopyAnimation}"
|
||||||
|
Margin="138,300,0,0"
|
||||||
|
/>
|
||||||
|
<Button Height="32"
|
||||||
|
BorderThickness="0" Content="复 制"
|
||||||
|
Panel.ZIndex="999"
|
||||||
|
Margin="122,329,0,0"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Background="#BF8EF6"
|
||||||
|
Click="MyColorPicker_Confirmed"
|
||||||
|
VerticalAlignment="Top" Width="80"
|
||||||
|
>
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button" BasedOn="{StaticResource Btn1}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsPressed" Value="true">
|
||||||
|
<Setter Property="Opacity" Value="1"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
<Button Height="32"
|
||||||
|
BorderThickness="0" Content="关 闭"
|
||||||
|
Panel.ZIndex="999" Margin="26,329,0,0"
|
||||||
|
Background="#EEEEEE"
|
||||||
|
Click="MyColorPicker_Canceled"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top" Width="80"
|
||||||
|
>
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button" BasedOn="{StaticResource Btn1}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<Trigger Property="IsPressed" Value="true">
|
||||||
|
<Setter Property="Opacity" Value="1"/>
|
||||||
|
</Trigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
|
||||||
<Border MouseDown="DragMove"
|
<Border MouseDown="DragMove"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
CornerRadius="8,8,0,0"
|
CornerRadius="8,8,0,0"
|
||||||
@@ -36,14 +81,12 @@
|
|||||||
|
|
||||||
</Button>
|
</Button>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<hc:ColorPicker HorizontalAlignment="Center"
|
<hc:ColorPicker HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
SelectedColorChanged="MyColorPicker_SelectedColorChanged"
|
SelectedColorChanged="MyColorPicker_SelectedColorChanged"
|
||||||
x:Name="MyColorPicker"
|
x:Name="MyColorPicker"
|
||||||
Confirmed="MyColorPicker_Confirmed"
|
|
||||||
Canceled="MyColorPicker_Canceled"
|
|
||||||
ToggleButton.Checked="MyColorPicker_Checked"/>
|
ToggleButton.Checked="MyColorPicker_Checked"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
using GeekDesk.Interface;
|
using GeekDesk.Interface;
|
||||||
|
using GeekDesk.Util;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -14,10 +17,33 @@ namespace GeekDesk.Control.Windows
|
|||||||
public partial class GlobalColorPickerWindow : IWindowCommon
|
public partial class GlobalColorPickerWindow : IWindowCommon
|
||||||
{
|
{
|
||||||
PixelColorPickerWindow colorPickerWindow = null;
|
PixelColorPickerWindow colorPickerWindow = null;
|
||||||
|
|
||||||
|
class PrivateDataContext : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private bool copyAnimation = false;
|
||||||
|
|
||||||
|
public bool CopyAnimation
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
copyAnimation = value;
|
||||||
|
OnPropertyChanged("CopyAnimation");
|
||||||
|
|
||||||
|
}
|
||||||
|
get { return copyAnimation; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
private void OnPropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
}
|
||||||
|
}
|
||||||
public GlobalColorPickerWindow()
|
public GlobalColorPickerWindow()
|
||||||
{
|
{
|
||||||
this.Topmost = true;
|
this.Topmost = true;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.DataContext = new PrivateDataContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||||
@@ -35,14 +61,26 @@ namespace GeekDesk.Control.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void MyColorPicker_Canceled(object sender, EventArgs e)
|
private void MyColorPicker_Canceled(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
MyColorPickerClose();
|
MyColorPickerClose();
|
||||||
}
|
}
|
||||||
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
private void MyColorPicker_Confirmed(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
CopySuccess.Visibility = Visibility.Visible;
|
||||||
|
PrivateDataContext pdc = this.DataContext as PrivateDataContext;
|
||||||
|
pdc.CopyAnimation = true;
|
||||||
|
new Thread(() =>
|
||||||
|
{
|
||||||
|
Thread.Sleep(400);
|
||||||
|
this.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
pdc.CopyAnimation = false;
|
||||||
|
CopySuccess.Visibility = Visibility.Collapsed;
|
||||||
|
});
|
||||||
|
}).Start();
|
||||||
Color c = MyColorPicker.SelectedBrush.Color;
|
Color c = MyColorPicker.SelectedBrush.Color;
|
||||||
Clipboard.SetData(DataFormats.Text, string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.A, c.R, c.G, c.B));
|
Clipboard.SetData(DataFormats.Text, string.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -148,5 +186,28 @@ namespace GeekDesk.Control.Windows
|
|||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICommand _hideCommand;
|
||||||
|
public ICommand HideCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_hideCommand == null)
|
||||||
|
{
|
||||||
|
_hideCommand = new RelayCommand(
|
||||||
|
p =>
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
p =>
|
||||||
|
{
|
||||||
|
//CopySuccess.Visibility = Visibility.Collapsed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return _hideCommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user