优化拾色器
This commit is contained in:
@@ -99,22 +99,8 @@ namespace GeekDesk.Control.Other
|
|||||||
|
|
||||||
private void MyColorPickerClose(object sender)
|
private void MyColorPickerClose(object sender)
|
||||||
{
|
{
|
||||||
ClickColorPickerToggleButton(sender as HandyControl.Controls.ColorPicker);
|
|
||||||
dialog.Close();
|
dialog.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClickColorPickerToggleButton(HandyControl.Controls.ColorPicker colorPicker)
|
|
||||||
{
|
|
||||||
if (toggleButton != null && toggleButton.IsChecked == true)
|
|
||||||
{
|
|
||||||
const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
|
|
||||||
Type type = colorPicker.GetType();
|
|
||||||
toggleButton.IsChecked = false;
|
|
||||||
MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags);
|
|
||||||
mi.Invoke(colorPicker, new object[] { null, null });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace GeekDesk.Control.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class GlobalColorPickerWindow : IWindowCommon
|
public partial class GlobalColorPickerWindow : IWindowCommon
|
||||||
{
|
{
|
||||||
PixelColorPickerWindow colorPickerWindow;
|
PixelColorPickerWindow colorPickerWindow = null;
|
||||||
public GlobalColorPickerWindow()
|
public GlobalColorPickerWindow()
|
||||||
{
|
{
|
||||||
this.Topmost = true;
|
this.Topmost = true;
|
||||||
@@ -60,10 +60,12 @@ namespace GeekDesk.Control.Windows
|
|||||||
|
|
||||||
|
|
||||||
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
|
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.Hide();
|
this.Hide();
|
||||||
colorPickerWindow = new PixelColorPickerWindow(MyColorPicker);
|
if (colorPickerWindow == null || !colorPickerWindow.Activate())
|
||||||
|
{
|
||||||
|
colorPickerWindow = new PixelColorPickerWindow(MyColorPicker);
|
||||||
|
}
|
||||||
colorPickerWindow.Show();
|
colorPickerWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +75,22 @@ namespace GeekDesk.Control.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static System.Windows.Window window = null;
|
private static System.Windows.Window window = null;
|
||||||
|
|
||||||
|
public static void CreateNoShow()
|
||||||
|
{
|
||||||
|
if (window == null || !window.Activate())
|
||||||
|
{
|
||||||
|
window = new GlobalColorPickerWindow();
|
||||||
|
}
|
||||||
|
window.Hide();
|
||||||
|
GlobalColorPickerWindow thisWindow = (GlobalColorPickerWindow)window;
|
||||||
|
if (thisWindow.colorPickerWindow == null || !thisWindow.colorPickerWindow.Activate())
|
||||||
|
{
|
||||||
|
thisWindow.colorPickerWindow = new PixelColorPickerWindow(thisWindow.MyColorPicker);
|
||||||
|
}
|
||||||
|
thisWindow.colorPickerWindow.Show();
|
||||||
|
}
|
||||||
|
|
||||||
public static void Show()
|
public static void Show()
|
||||||
{
|
{
|
||||||
if (window == null || !window.Activate())
|
if (window == null || !window.Activate())
|
||||||
@@ -83,6 +101,20 @@ namespace GeekDesk.Control.Windows
|
|||||||
Keyboard.Focus(window);
|
Keyboard.Focus(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowOrHide()
|
||||||
|
{
|
||||||
|
if (window == null || !window.Activate())
|
||||||
|
{
|
||||||
|
window = new GlobalColorPickerWindow();
|
||||||
|
window.Show();
|
||||||
|
Keyboard.Focus(window);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
|
||||||
{
|
{
|
||||||
Show();
|
Show();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
xml:lang="zh-CN"
|
xml:lang="zh-CN"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
|
Background="Black"
|
||||||
PreviewMouseMove="Window_PreviewMouseMove"
|
PreviewMouseMove="Window_PreviewMouseMove"
|
||||||
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
MouseLeftButtonDown="Window_MouseLeftButtonDown"
|
||||||
MouseWheel="Window_MouseWheel"
|
MouseWheel="Window_MouseWheel"
|
||||||
@@ -19,11 +20,8 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid x:Name="DesktopBG">
|
<Image x:Name="DesktopBG" RenderOptions.BitmapScalingMode="HighQuality"/>
|
||||||
<Grid.Background>
|
|
||||||
<ImageBrush Stretch="Fill"/>
|
|
||||||
</Grid.Background>
|
|
||||||
</Grid>
|
|
||||||
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Background="Transparent">
|
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Background="Transparent">
|
||||||
<Canvas x:Name="ColorCanvas"
|
<Canvas x:Name="ColorCanvas"
|
||||||
Width="185"
|
Width="185"
|
||||||
@@ -47,6 +45,7 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Width="70"
|
Width="70"
|
||||||
Height="70"
|
Height="70"
|
||||||
|
Background="Black"
|
||||||
BorderBrush="Black"
|
BorderBrush="Black"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Margin="20,0,0,0"
|
Margin="20,0,0,0"
|
||||||
|
|||||||
@@ -66,16 +66,13 @@ namespace GeekDesk.Control.Windows
|
|||||||
bgBitmap.Size
|
bgBitmap.Size
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(
|
BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(
|
||||||
bgBitmap.GetHbitmap(),
|
bgBitmap.GetHbitmap(),
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
Int32Rect.Empty,
|
Int32Rect.Empty,
|
||||||
BitmapSizeOptions.FromEmptyOptions()
|
BitmapSizeOptions.FromEmptyOptions()
|
||||||
);
|
);
|
||||||
ImageBrush ib = (ImageBrush)DesktopBG.Background;
|
DesktopBG.Source = bs;
|
||||||
ib.ImageSource = bs;
|
|
||||||
|
|
||||||
VisualBrush b = (VisualBrush)PixelBG.Fill;
|
VisualBrush b = (VisualBrush)PixelBG.Fill;
|
||||||
b.Visual = DesktopBG;
|
b.Visual = DesktopBG;
|
||||||
Mouse.OverrideCursor = Cursors.Cross;
|
Mouse.OverrideCursor = Cursors.Cross;
|
||||||
@@ -83,10 +80,6 @@ namespace GeekDesk.Control.Windows
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[DllImport("gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
|
|
||||||
public static extern int BitBlt(IntPtr hDC, int x, int y, int nWidth, int nHeight, IntPtr hSrcDC, int xSrc, int ySrc, int dwRop);
|
|
||||||
|
|
||||||
|
|
||||||
public void OnKeyDown(object sender, KeyEventArgs e)
|
public void OnKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Escape)
|
if (e.Key == Key.Escape)
|
||||||
@@ -98,13 +91,13 @@ namespace GeekDesk.Control.Windows
|
|||||||
|
|
||||||
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
Mouse.OverrideCursor = null;
|
||||||
Point pos = e.MouseDevice.GetPosition(DesktopBG);
|
Point pos = e.MouseDevice.GetPosition(DesktopBG);
|
||||||
System.Drawing.Color colorD = bgBitmap.GetPixel((int)pos.X, (int)pos.Y);
|
System.Drawing.Color colorD = bgBitmap.GetPixel((int)pos.X, (int)pos.Y);
|
||||||
colorPicker.SelectedBrush = new SolidColorBrush(Color.FromArgb(colorD.A, colorD.R, colorD.G, colorD.B));
|
colorPicker.SelectedBrush = new SolidColorBrush(Color.FromArgb(colorD.A, colorD.R, colorD.G, colorD.B));
|
||||||
DeleteObject(bgBitmap.GetHbitmap());
|
DeleteObject(bgBitmap.GetHbitmap());
|
||||||
this.Close();
|
this.Close();
|
||||||
ClickColorPickerToggleButton(colorPicker);
|
ClickColorPickerToggleButton(colorPicker);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClickColorPickerToggleButton(ColorPicker colorPicker)
|
public void ClickColorPickerToggleButton(ColorPicker colorPicker)
|
||||||
@@ -121,13 +114,7 @@ namespace GeekDesk.Control.Windows
|
|||||||
mi.Invoke(colorPicker, new object[] { null, null });
|
mi.Invoke(colorPicker, new object[] { null, null });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Window_MouseEnter(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
Mouse.OverrideCursor = Cursors.Cross;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Window_PreviewMouseMove(object sender, MouseEventArgs e)
|
private void Window_PreviewMouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
SetPixelAbout(e);
|
SetPixelAbout(e);
|
||||||
|
|||||||
@@ -145,9 +145,10 @@
|
|||||||
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
<uc:RightCardControl x:Name="RightCard" Grid.Row="1" Grid.Column="1"/>
|
||||||
|
|
||||||
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
|
<hc:NotifyIcon Icon="/Taskbar.ico" Click="NotifyIcon_Click" x:Name="BarIcon"
|
||||||
|
MouseRightButtonDown="BarIcon_MouseRightButtonDown"
|
||||||
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
|
Visibility="{Binding AppConfig.ShowBarIcon, Mode=TwoWay, Converter={StaticResource Boolean2VisibilityConverter}}">
|
||||||
<hc:NotifyIcon.ContextMenu>
|
<hc:NotifyIcon.ContextMenu>
|
||||||
<ContextMenu Width="130">
|
<ContextMenu Width="130" x:Name="TaskbarContextMenu">
|
||||||
<MenuItem Header="打开面板" Click="ShowApp"/>
|
<MenuItem Header="打开面板" Click="ShowApp"/>
|
||||||
<MenuItem Header="拾色器" Click="ColorPicker"/>
|
<MenuItem Header="拾色器" Click="ColorPicker"/>
|
||||||
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
|
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ using System.Windows;
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Threading;
|
||||||
using static GeekDesk.Util.ShowWindowFollowMouse;
|
using static GeekDesk.Util.ShowWindowFollowMouse;
|
||||||
|
|
||||||
namespace GeekDesk
|
namespace GeekDesk
|
||||||
@@ -243,7 +244,7 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
if (MotionControl.hotkeyFinished)
|
if (MotionControl.hotkeyFinished)
|
||||||
{
|
{
|
||||||
ToDoInfoWindow.ShowOrHide();
|
ToDoWindow.ShowOrHide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!first)
|
if (!first)
|
||||||
@@ -273,7 +274,6 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (appData.AppConfig.ColorPickerHotkeyModifiers != 0)
|
if (appData.AppConfig.ColorPickerHotkeyModifiers != 0)
|
||||||
{
|
{
|
||||||
//加载完毕注册热键
|
//加载完毕注册热键
|
||||||
@@ -281,7 +281,7 @@ namespace GeekDesk
|
|||||||
{
|
{
|
||||||
if (MotionControl.hotkeyFinished)
|
if (MotionControl.hotkeyFinished)
|
||||||
{
|
{
|
||||||
GlobalColorPickerWindow.Show();
|
GlobalColorPickerWindow.CreateNoShow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!first)
|
if (!first)
|
||||||
@@ -432,6 +432,7 @@ namespace GeekDesk
|
|||||||
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
if (RunTimeStatus.SEARCH_BOX_SHOW)
|
||||||
{
|
{
|
||||||
mainWindow.HidedSearchBox();
|
mainWindow.HidedSearchBox();
|
||||||
|
|
||||||
Thread t = new Thread(() =>
|
Thread t = new Thread(() =>
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
@@ -682,9 +683,26 @@ namespace GeekDesk
|
|||||||
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
|
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 打开屏幕拾色器
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
private void ColorPicker(object sender, RoutedEventArgs e)
|
private void ColorPicker(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
GlobalColorPickerWindow.Show();
|
TaskbarContextMenu.Visibility = Visibility.Collapsed;
|
||||||
|
App.DoEvents();
|
||||||
|
GlobalColorPickerWindow.CreateNoShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 防止点击拾色器后无法显示菜单的问题
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void BarIcon_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
TaskbarContextMenu.Visibility = Visibility.Visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user