代码清理/拾色器功能/部分程序优化

This commit is contained in:
liufei
2022-05-20 15:39:52 +08:00
parent 5cfaf9a37d
commit d01a27b827
83 changed files with 1320 additions and 627 deletions

View File

@@ -5,18 +5,8 @@ using GeekDesk.ViewModel;
using HandyControl.Controls;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Other
{

View File

@@ -1,13 +1,9 @@
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Configuration;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.Other

View File

@@ -1,11 +1,8 @@
using GeekDesk.Util;
using GeekDesk.ViewModel;
using GeekDesk.ViewModel.Temp;
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.Other

View File

@@ -3,7 +3,6 @@ using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;

View File

@@ -4,7 +4,6 @@ using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
@@ -89,12 +88,13 @@ namespace GeekDesk.Control.Other
info.BitmapImage = ImageUtil.GetBitmapIconByPath(ofd.FileName);
CommonCode.SaveAppData(MainWindow.appData);
}
} catch (Exception ex)
}
catch (Exception ex)
{
HandyControl.Controls.Growl.WarningGlobal("修改图标失败,已重置为默认图标!");
LogUtil.WriteErrorLog(ex, "修改图标失败!");
}
}
}
}

View File

@@ -0,0 +1,30 @@
<Border x:Class="GeekDesk.Control.Other.MyColorPickerDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="4"
>
<Grid>
<StackPanel>
<Grid Width="750"
Height="550"
Panel.ZIndex="0"
MouseDown="DragMove"
>
<Grid.Background>
<SolidColorBrush Color="Black" Opacity="0.01"/>
</Grid.Background>
</Grid>
<hc:ColorPicker x:Name="MyColorPicker"
Panel.ZIndex="99"
Margin="0,-500,0,0"
Confirmed="MyColorPicker_Confirmed"
Canceled="MyColorPicker_Canceled"
ToggleButton.Checked="MyColorPicker_Checked"
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>
</StackPanel>
</Grid>
</Border>

View File

@@ -0,0 +1,120 @@
using GeekDesk.Control.Windows;
using GeekDesk.ViewModel;
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
namespace GeekDesk.Control.Other
{
public enum ColorType
{
COLOR_1 = 1,
COLOR_2 = 2,
TEXT_COLOR = 3
}
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class MyColorPickerDialog
{
public static ColorType COLOR_TYPE = new ColorType();
private static AppConfig appConfig = MainWindow.appData.AppConfig;
public static HandyControl.Controls.Dialog dialog;
private System.Windows.Controls.Primitives.ToggleButton toggleButton = null;
private static ColorType colorType;
public MyColorPickerDialog(string strType, string token)
{
InitializeComponent();
switch (strType)
{
case "Color1":
colorType = ColorType.COLOR_1; break;
case "Color2":
colorType = ColorType.COLOR_2; break;
default:
colorType = ColorType.TEXT_COLOR; break;
}
dialog = HandyControl.Controls.Dialog.Show(this, token);
}
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyColorPicker_Canceled(object sender, EventArgs e)
{
MyColorPickerClose(sender);
}
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
MyColorPickerClose(sender);
}
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
SolidColorBrush scb = MyColorPicker.SelectedBrush;
switch (colorType)
{
case ColorType.COLOR_1:
appConfig.GradientBGParam.Color1 = scb.ToString(); break;
case ColorType.COLOR_2:
appConfig.GradientBGParam.Color2 = scb.ToString(); break;
default:
appConfig.TextColor = scb.ToString(); break;
}
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Window.GetWindow(this).DragMove();
}
}
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
{
toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton;
PixelColorPickerWindow colorPickerWindow = new PixelColorPickerWindow(MyColorPicker);
colorPickerWindow.Show();
}
private void MyColorPickerClose(object sender)
{
ClickColorPickerToggleButton(sender as HandyControl.Controls.ColorPicker);
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 });
}
}
}
}

View File

@@ -1,20 +1,9 @@
using System;
using GeekDesk.Constant;
using GeekDesk.Util;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GeekDesk.Util;
using GeekDesk.Constant;
namespace GeekDesk.Control.UserControls.Config
{

View File

@@ -4,10 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:viewmodel="clr-namespace:GeekDesk.ViewModel"
d:DataContext="{d:DesignInstance Type=viewmodel:AppConfig}"
xmlns:cst="clr-namespace:GeekDesk.Constant"
Background="Transparent"
d:DesignHeight="300" d:DesignWidth="450">
d:DesignHeight="400" d:DesignWidth="450">
<UserControl.Resources>
<cvt:HideTypeConvert x:Key="HideTypeConvert"/>
@@ -109,30 +112,74 @@
<TextBlock Text="热键设置" VerticalAlignment="Center"/>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<TextBlock Text="主面板:" VerticalAlignment="Center" Width="55"/>
<TextBlock Text="主面板:" VerticalAlignment="Center" Margin="0,5,0,0" Width="55"/>
<hc:TextBox HorizontalAlignment="Left"
Tag="Main"
Tag="{x:Static cst:HotKeyType.Main}"
VerticalAlignment="Top"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
Width="200"
Width="170"
Text="{Binding HotkeyStr}"
KeyDown="HotKeyDown"
KeyUp="HotKeyUp"
/>
<CheckBox Content="启用"
Click="EnableHotKey_Click"
Tag="{x:Static cst:HotKeyType.Main}"
IsChecked="{Binding EnableAppHotKey}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<TextBlock Text="新建待办:" Width="55"/>
<TextBlock Text="新建待办:" Margin="0,5,0,0" Width="55"/>
<hc:TextBox HorizontalAlignment="Left"
Tag="ToDo"
Tag="{x:Static cst:HotKeyType.ToDo}"
VerticalAlignment="Top"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
Width="200"
Width="170"
Text="{Binding ToDoHotkeyStr}"
KeyDown="HotKeyDown"
KeyUp="HotKeyUp"
/>
<CheckBox Content="启用"
Click="EnableHotKey_Click"
Tag="{x:Static cst:HotKeyType.ToDo}"
IsChecked="{Binding EnableTodoHotKey}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
<hc:UniformSpacingPanel Spacing="10" Margin="10,5,0,0" Grid.ColumnSpan="4">
<TextBlock Text="拾色器:" Margin="0,5,0,0" Width="55"/>
<hc:TextBox HorizontalAlignment="Left"
Tag="{x:Static cst:HotKeyType.ColorPicker}"
VerticalAlignment="Top"
IsReadOnly="True"
IsReadOnlyCaretVisible="True"
Width="170"
Text="{Binding ColorPickerHotkeyStr}"
KeyDown="HotKeyDown"
KeyUp="HotKeyUp"
/>
<CheckBox Content="启用"
Tag="{x:Static cst:HotKeyType.ColorPicker}"
Click="EnableHotKey_Click"
IsChecked="{Binding EnableColorPickerHotKey}">
<CheckBox.Background>
<LinearGradientBrush EndPoint="1,0" StartPoint="0,0">
<GradientStop Color="#FF9EA3A6"/>
</LinearGradientBrush>
</CheckBox.Background>
</CheckBox>
</hc:UniformSpacingPanel>
</StackPanel>
</Grid>

View File

@@ -1,26 +1,12 @@
using GeekDesk.Constant;
using GeekDesk.Control.Windows;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Data;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static GeekDesk.Util.GlobalHotKey;
namespace GeekDesk.Control.UserControls.Config
@@ -48,7 +34,7 @@ namespace GeekDesk.Control.UserControls.Config
/// <param name="e"></param>
private void HotKeyDown(object sender, KeyEventArgs e)
{
string tag = (sender as TextBox).Tag.ToString();
HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag;
Key downKey = e.Key;
if (downKey == Key.System)
@@ -56,47 +42,59 @@ namespace GeekDesk.Control.UserControls.Config
downKey = e.SystemKey;
}
bool main = false;
if ("Main".Equals(tag))
{
main = true;
}
if (!CheckIsEnable(hkType)) return;
if (prevKeyTemp == Key.None || prevKeyTemp != downKey)
{
if (hotkeyFinished)
{
if (main)
switch (hkType)
{
appConfig.Hotkey = 0;
appConfig.HotkeyStr = "";
appConfig.HotkeyModifiers = 0;
}
else
{
appConfig.ToDoHotkey = 0;
appConfig.ToDoHotkeyStr = "";
appConfig.ToDoHotkeyModifiers = 0;
case HotKeyType.Main:
appConfig.Hotkey = 0;
appConfig.HotkeyStr = "";
appConfig.HotkeyModifiers = 0;
break;
case HotKeyType.ToDo:
appConfig.ToDoHotkey = 0;
appConfig.ToDoHotkeyStr = "";
appConfig.ToDoHotkeyModifiers = 0;
break;
case HotKeyType.ColorPicker:
appConfig.ColorPickerHotkey = 0;
appConfig.ColorPickerHotkeyStr = "";
appConfig.ColorPickerHotkeyModifiers = 0;
break;
}
hotkeyFinished = false;
}
//首次按下按键
if ((main && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0))
|| (!main && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0)))
if ((HotKeyType.Main == hkType && (appConfig.HotkeyStr == null || appConfig.HotkeyStr.Length == 0))
|| (HotKeyType.ToDo == hkType && (appConfig.ToDoHotkeyStr == null || appConfig.ToDoHotkeyStr.Length == 0))
|| (HotKeyType.ColorPicker == hkType && (appConfig.ColorPickerHotkeyStr == null || appConfig.ColorPickerHotkeyStr.Length == 0))
)
{
if (CheckModifierKeys(downKey))
{
//辅助键
if (main)
switch (hkType)
{
appConfig.HotkeyStr = GetKeyName(downKey);
appConfig.HotkeyModifiers = GetModifierKeys(downKey);
}
else
{
appConfig.ToDoHotkeyStr = GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey);
case HotKeyType.Main:
appConfig.HotkeyStr = GetKeyName(downKey);
appConfig.HotkeyModifiers = GetModifierKeys(downKey);
break;
case HotKeyType.ToDo:
appConfig.ToDoHotkeyStr = GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers = GetModifierKeys(downKey);
break;
case HotKeyType.ColorPicker:
appConfig.ColorPickerHotkeyStr = GetKeyName(downKey);
appConfig.ColorPickerHotkeyModifiers = GetModifierKeys(downKey);
break;
}
prevKeyTemp = downKey;
keysTemp.Add(e);
}
@@ -109,30 +107,41 @@ namespace GeekDesk.Control.UserControls.Config
|| (downKey >= Key.F1 && downKey <= Key.F12)
|| (downKey >= Key.D0 && downKey <= Key.D9)))
{
if (main)
switch (hkType)
{
appConfig.Hotkey = downKey;
appConfig.HotkeyStr += downKey.ToString();
}
else
{
appConfig.ToDoHotkey = downKey;
appConfig.ToDoHotkeyStr += downKey.ToString();
case HotKeyType.Main:
appConfig.Hotkey = downKey;
appConfig.HotkeyStr += downKey.ToString();
break;
case HotKeyType.ToDo:
appConfig.ToDoHotkey = downKey;
appConfig.ToDoHotkeyStr += downKey.ToString();
break;
case HotKeyType.ColorPicker:
appConfig.ColorPickerHotkey = downKey;
appConfig.ColorPickerHotkeyStr += downKey.ToString();
break;
}
prevKeyTemp = downKey;
keysTemp.Add(e);
}
else if (CheckModifierKeys(downKey))
{
if (main)
switch (hkType)
{
appConfig.HotkeyStr += GetKeyName(downKey);
appConfig.HotkeyModifiers |= GetModifierKeys(downKey);
}
else
{
appConfig.ToDoHotkeyStr += GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey);
case HotKeyType.Main:
appConfig.HotkeyStr += GetKeyName(downKey);
appConfig.HotkeyModifiers |= GetModifierKeys(downKey);
break;
case HotKeyType.ToDo:
appConfig.ToDoHotkeyStr += GetKeyName(downKey);
appConfig.ToDoHotkeyModifiers |= GetModifierKeys(downKey);
break;
case HotKeyType.ColorPicker:
appConfig.ColorPickerHotkeyStr += GetKeyName(downKey);
appConfig.ColorPickerHotkeyModifiers |= GetModifierKeys(downKey);
break;
}
prevKeyTemp = downKey;
@@ -194,12 +203,10 @@ namespace GeekDesk.Control.UserControls.Config
[MethodImpl(MethodImplOptions.Synchronized)]
private void HotKeyUp(object sender, KeyEventArgs e)
{
string tag = (sender as TextBox).Tag.ToString();
bool main = false;
if ("Main".Equals(tag))
{
main = true;
}
HotKeyType hkType = (HotKeyType)(sender as TextBox).Tag;
if (!CheckIsEnable(hkType)) return;
lock (this)
{
bool allKeyUp = true;
@@ -218,30 +225,52 @@ namespace GeekDesk.Control.UserControls.Config
prevKeyTemp = Key.None;
hotkeyFinished = true;
if (main)
switch (hkType)
{
if (MainWindow.hotKeyId != -1)
{
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]);
GlobalHotKey.Dispose(MainWindow.hotKeyId);
}
MainWindow.RegisterHotKey(false);
case HotKeyType.Main:
if (MainWindow.hotKeyId != -1)
{
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.mainWindow).Handle, Hotkey.keymap[MainWindow.hotKeyId]);
GlobalHotKey.Dispose(MainWindow.hotKeyId);
}
MainWindow.RegisterHotKey(false);
break;
case HotKeyType.ToDo:
if (MainWindow.toDoHotKeyId != -1)
{
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]);
GlobalHotKey.Dispose(MainWindow.toDoHotKeyId);
}
MainWindow.RegisterCreateToDoHotKey(false);
break;
case HotKeyType.ColorPicker:
if (MainWindow.colorPickerHotKeyId != -1)
{
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]);
GlobalHotKey.Dispose(MainWindow.colorPickerHotKeyId);
}
MainWindow.RegisterColorPickerHotKey(false);
break;
}
else
{
if (MainWindow.toDoHotKeyId != -1)
{
//Hotkey.UnRegist(new WindowInteropHelper(MainWindow.toDoInfoWindow).Handle, Hotkey.keymap[MainWindow.toDoHotKeyId]);
GlobalHotKey.Dispose(MainWindow.toDoHotKeyId);
}
MainWindow.RegisterCreateToDoHotKey(false);
}
}
}
}
private bool CheckIsEnable(HotKeyType hkType)
{
switch (hkType)
{
case HotKeyType.Main:
return true == appConfig.EnableAppHotKey;
case HotKeyType.ToDo:
return true == appConfig.EnableTodoHotKey;
case HotKeyType.ColorPicker:
return true == appConfig.EnableColorPickerHotKey;
}
return false;
}
/// <summary>
/// 移动窗口
/// </summary>
@@ -295,5 +324,29 @@ namespace GeekDesk.Control.UserControls.Config
}
}
/// <summary>
/// 启用热键
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void EnableHotKey_Click(object sender, RoutedEventArgs e)
{
HotKeyType hkType = (HotKeyType)(sender as CheckBox).Tag;
switch (hkType)
{
case HotKeyType.Main:
if (true == appConfig.EnableAppHotKey)
MainWindow.RegisterHotKey(false);
break;
case HotKeyType.ToDo:
if (true == appConfig.EnableTodoHotKey)
MainWindow.RegisterCreateToDoHotKey(false);
break;
case HotKeyType.ColorPicker:
if (true == appConfig.EnableColorPickerHotKey)
MainWindow.RegisterColorPickerHotKey(false);
break;
}
}
}
}

View File

@@ -1,20 +1,9 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Config
{

View File

@@ -18,7 +18,7 @@
<cvt:Visibility2BooleanConverter x:Key="Visibility2BooleanConverter"/>
</UserControl.Resources>
<Grid>
<Grid MouseDown="DragMove" Background="Transparent">
<Grid Background="Transparent">
<StackPanel Margin="20" >
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
<TextBlock Text="背景风格" VerticalAlignment="Center"/>
@@ -228,10 +228,10 @@
<SolidColorBrush Color="AliceBlue" Opacity="0.01"/>
</StackPanel.Background>-->
<hc:ColorPicker Name="MyColorPicker"
<!--<hc:ColorPicker Name="MyColorPicker"
Canceled="MyColorPicker_Canceled"
Confirmed="MyColorPicker_Confirmed"
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>
SelectedColorChanged="MyColorPicker_SelectedColorChanged"/>-->
<!--</StackPanel>-->
</Grid>

View File

@@ -1,53 +1,28 @@
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Control.Windows;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace GeekDesk.Control.UserControls.Config
{
enum ColorType
{
COLOR_1 = 1,
COLOR_2 = 2,
TEXT_COLOR = 3
}
/// <summary>
/// MotionControl.xaml 的交互逻辑
/// </summary>
public partial class ThemeControl : System.Windows.Controls.UserControl
{
private static ColorType colorType;
private static AppConfig appConfig = MainWindow.appData.AppConfig;
private System.Windows.Controls.Primitives.ToggleButton toggleButton = null;
public ThemeControl()
{
InitializeComponent();
if (appConfig.BGStyle != BGStyle.GradientBac)
{
@@ -111,60 +86,9 @@ namespace GeekDesk.Control.UserControls.Config
private void ColorButton_Click(object sender, RoutedEventArgs e)
{
string tag = (sender as Button).Tag.ToString();
switch (tag)
{
case "Color1":
colorType = ColorType.COLOR_1;break;
case "Color2":
colorType = ColorType.COLOR_2;break;
default:
colorType = ColorType.TEXT_COLOR;break;
}
MyColorPicker.Visibility = Visibility.Visible;
new ColorPickerWindow().Show();
new MyColorPickerDialog(tag, "ConfigWindowDialog");
}
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyColorPicker_Canceled(object sender, EventArgs e)
{
MyColorPickerClose(sender);
}
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
MyColorPickerClose(sender);
}
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
SolidColorBrush scb = MyColorPicker.SelectedBrush;
switch (colorType)
{
case ColorType.COLOR_1:
appConfig.GradientBGParam.Color1 = scb.ToString();break;
case ColorType.COLOR_2:
appConfig.GradientBGParam.Color2 = scb.ToString(); break;
default:
appConfig.TextColor = scb.ToString();break;
}
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
Window.GetWindow(this).DragMove();
}
}
private void PreviewSlider_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
@@ -174,6 +98,7 @@ namespace GeekDesk.Control.UserControls.Config
};
System.Threading.ThreadStart ts = new System.Threading.ThreadStart(cbu.CheckButtonUp);
System.Threading.Thread t = new System.Threading.Thread(ts);
t.IsBackground = true;
t.Start();
}
@@ -201,25 +126,6 @@ namespace GeekDesk.Control.UserControls.Config
}
}
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
{
toggleButton = e.OriginalSource as System.Windows.Controls.Primitives.ToggleButton;
}
private void MyColorPickerClose(object sender)
{
if (toggleButton != null && toggleButton.IsChecked == true)
{
HandyControl.Controls.ColorPicker cp = sender as HandyControl.Controls.ColorPicker;
const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Type type = cp.GetType();
toggleButton.IsChecked = false;
MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags);
mi.Invoke(cp, new object[] { null, null });
}
MyColorPicker.Visibility = Visibility.Collapsed;
}
public void BGStyle_Changed(object sender, RoutedEventArgs e)
{
@@ -228,7 +134,8 @@ namespace GeekDesk.Control.UserControls.Config
{
GradientBGConf.Visibility = Visibility.Collapsed;
ImgBGConf.Visibility = Visibility.Visible;
} else
}
else
{
ImgBGConf.Visibility = Visibility.Collapsed;
GradientBGConf.Visibility = Visibility.Visible;
@@ -248,7 +155,7 @@ namespace GeekDesk.Control.UserControls.Config
private void SysBG_Click(object sender, RoutedEventArgs e)
{
GradientBGDialog gbg = new GradientBGDialog();
gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "SysBGDialog");
gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "ConfigWindowDialog");
}
}
}

View File

@@ -1,18 +1,4 @@
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls;
namespace GeekDesk.Control.UserControls.IconFont
{

View File

@@ -1,7 +1,6 @@
using DraggAnimatedPanelExample;
using GeekDesk.Constant;
using GeekDesk.Control.Windows;
using GeekDesk.MyThread;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
@@ -10,10 +9,8 @@ using System.Collections.ObjectModel;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
namespace GeekDesk.Control.UserControls.PannelCard
{
@@ -33,7 +30,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
public LeftCardControl()
{
InitializeComponent();
this.Loaded += (s, e) =>
{
@@ -44,7 +41,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
private void SetMenuListBoxItemEvent()
{
{
int size = MenuListBox.Items.Count;
for (int i = 0; i < size; i++)
{
@@ -87,7 +84,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
}
}
DelegateCommand<int[]> _swap;
DelegateCommand<int[]> _swap;
public DelegateCommand<int[]> SwapCommand
{
@@ -333,7 +330,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
if (appData.AppConfig.HoverMenu && !IS_EDIT)
{
new Thread(() =>
Thread t = new Thread(() =>
{
Thread.Sleep(200);
this.Dispatcher.Invoke(() =>
@@ -345,7 +342,9 @@ namespace GeekDesk.Control.UserControls.PannelCard
MenuListBox.SelectedIndex = index;
}
});
}).Start();
});
t.IsBackground = true;
t.Start();
}
}
@@ -356,7 +355,8 @@ namespace GeekDesk.Control.UserControls.PannelCard
/// <param name="e"></param>
private void ListBoxItem_MouseDown(object sender, MouseButtonEventArgs e)
{
if (RunTimeStatus.SEARCH_BOX_SHOW) {
if (RunTimeStatus.SEARCH_BOX_SHOW)
{
MainWindow.mainWindow.HidedSearchBox();
}
}

View File

@@ -176,7 +176,7 @@
VirtualizingPanel.IsContainerVirtualizable="True"
>
<UniformGrid x:Name="VerticalUFG">
<hc:TransitioningContentControl TransitionMode="Fade">
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
<ListBox ItemsSource="{Binding Source={StaticResource SearchIconList},Path=IconList}"
BorderThickness="0"
Padding="0,10,0,0"

View File

@@ -9,13 +9,11 @@ using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.UserControls.PannelCard
{
@@ -422,12 +420,31 @@ namespace GeekDesk.Control.UserControls.PannelCard
double height = appData.AppConfig.ImageHeight;
width += width * 0.15;
height += height * 0.15;
ImgStoryBoard(sender, (int)width, (int)height, 1, true);
Thread t = new Thread(() =>
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
ImgStoryBoard(sender, (int)width, (int)height, 1, true);
}));
});
t.IsBackground = true;
t.Start();
}
private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
{
ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 220);
Thread t = new Thread(() =>
{
this.Dispatcher.BeginInvoke(new Action(() =>
{
ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260);
}));
});
t.IsBackground = true;
t.Start();
}
@@ -491,6 +508,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
{
ThreadStart ts = new ThreadStart(crs.Remove);
System.Threading.Thread t = new System.Threading.Thread(ts);
t.IsBackground = true;
t.Start();
}
else

View File

@@ -1,20 +1,8 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.SystemItem
{
@@ -47,7 +35,8 @@ namespace GeekDesk.Control.UserControls.SystemItem
};
iconInfo.Content_NoWrite = iconInfo.Name_NoWrite
+ "\n使用次数:" + iconInfo.Count;
} else
}
else
{
//startupMenu or Store
iconInfo = CommonCode.GetIconInfoByPath(thisInfo.LnkPath_NoWrite);

View File

@@ -3,19 +3,10 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace GeekDesk.Control.UserControls.Backlog
{

View File

@@ -24,7 +24,7 @@
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
<Grid hc:Dialog.Token="SysBGDialog">
<Grid hc:Dialog.Token="ConfigWindowDialog">
<hc:DialogContainer Margin="10">
<Border Style="{StaticResource BorderBG}">
<Grid Background="Transparent">
@@ -110,7 +110,7 @@
</hc:Card>
<hc:ScrollViewer Grid.Row="0" Grid.Column="1" BorderThickness="0" Margin="0,5,1,5">
<UniformGrid x:Name="UFG">
<hc:TransitioningContentControl TransitionMode="Fade">
<hc:TransitioningContentControl TransitionMode="Left2RightWithFade">
<hc:Card x:Name="RightCard" BorderThickness="0" MouseDown="DragMove">
<hc:Card.Background>
<SolidColorBrush Opacity="0"/>

View File

@@ -1,13 +1,7 @@

using GeekDesk.Constant;
using GeekDesk.Control.UserControls;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
@@ -44,8 +38,8 @@ namespace GeekDesk.Control.Windows
this.mainWindow = mainWindow;
}
/// <summary>
/// 点击关闭按钮

View File

@@ -0,0 +1,49 @@
<Window x:Class="GeekDesk.Control.Windows.GlobalColorPickerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
xmlns:hc="https://handyorg.github.io/handycontrol"
WindowStyle="None"
AllowsTransparency="True"
Background="Transparent"
KeyDown="OnKeyDown"
>
<Border CornerRadius="8"
Background="White"
Height="385"
Width="228">
<StackPanel>
<Border MouseDown="DragMove"
VerticalAlignment="Top"
CornerRadius="8,8,0,0"
Height="20"
Background="White"
>
<Button Width="18" Height="18"
hc:IconElement.Geometry="{StaticResource ErrorGeometry}"
Padding="0"
Background="Transparent"
Opacity="0.6"
Margin="0,0,5,0"
Click="Button_Click"
HorizontalAlignment="Right"
MouseEnter="Button_MouseEnter"
MouseLeave="Button_MouseLeave"
VerticalAlignment="Center">
</Button>
</Border>
<hc:ColorPicker HorizontalAlignment="Center"
VerticalAlignment="Bottom"
SelectedColorChanged="MyColorPicker_SelectedColorChanged"
x:Name="MyColorPicker"
Confirmed="MyColorPicker_Confirmed"
Canceled="MyColorPicker_Canceled"
ToggleButton.Checked="MyColorPicker_Checked"/>
</StackPanel>
</Border>
</Window>

View File

@@ -0,0 +1,108 @@
using GeekDesk.Interface;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// GlobalColorPickerWindow.xaml 的交互逻辑
/// </summary>
public partial class GlobalColorPickerWindow : IWindowCommon
{
PixelColorPickerWindow colorPickerWindow;
public GlobalColorPickerWindow()
{
this.Topmost = true;
InitializeComponent();
}
public void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void MyColorPicker_Canceled(object sender, EventArgs e)
{
MyColorPickerClose();
}
private void MyColorPicker_Confirmed(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
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));
}
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
private void MyColorPicker_Checked(object sender, RoutedEventArgs e)
{
this.Hide();
colorPickerWindow = new PixelColorPickerWindow(MyColorPicker);
colorPickerWindow.Show();
}
private void MyColorPickerClose()
{
this.Close();
}
private static System.Windows.Window window = null;
public static void Show()
{
if (window == null || !window.Activate())
{
window = new GlobalColorPickerWindow();
}
window.Show();
Keyboard.Focus(window);
}
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs<Color> e)
{
Show();
}
private void Button_MouseEnter(object sender, MouseEventArgs e)
{
Button btn = sender as Button;
btn.Opacity = 1;
}
private void Button_MouseLeave(object sender, MouseEventArgs e)
{
Button btn = sender as Button;
btn.Opacity = 0.6;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}

View File

@@ -0,0 +1,90 @@
<Window
x:Class="GeekDesk.Control.Windows.PixelColorPickerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xml:lang="zh-CN"
WindowStyle="None"
AllowsTransparency="True"
PreviewMouseMove="Window_PreviewMouseMove"
MouseLeftButtonDown="Window_MouseLeftButtonDown"
MouseWheel="Window_MouseWheel"
>
<Window.Resources>
<Style x:Key="TextKey" TargetType="TextBlock">
<Setter Property="FontSize" Value="12"/>
</Style>
<Style x:Key="TextValue" TargetType="TextBlock">
<Setter Property="FontSize" Value="12"/>
<Setter Property="Margin" Value="10,0,0,0"/>
</Style>
</Window.Resources>
<Grid>
<Grid x:Name="DesktopBG">
<Grid.Background>
<ImageBrush Stretch="Fill"/>
</Grid.Background>
</Grid>
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Background="Transparent">
<Canvas x:Name="ColorCanvas"
Width="185"
Height="160">
<Border Background="White"
CornerRadius="5"
>
<Grid>
<WrapPanel HorizontalAlignment="Center" Height="70" Margin="0,5,0,80">
<Border Width="70" Height="70"
BorderBrush="Black"
BorderThickness="1">
<Rectangle x:Name="PixelColor" StrokeThickness="0">
<Rectangle.Fill>
<SolidColorBrush />
</Rectangle.Fill>
</Rectangle>
</Border>
<Border x:Name="Pixel"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="70"
Height="70"
BorderBrush="Black"
BorderThickness="1"
Margin="20,0,0,0"
>
<Grid>
<Rectangle x:Name="PixelBG" StrokeThickness="0">
<Rectangle.Fill>
<VisualBrush ViewboxUnits="Absolute" Viewbox="0,0,20,20"
ViewportUnits="RelativeToBoundingBox" Viewport="0,0,1,1">
</VisualBrush>
</Rectangle.Fill>
</Rectangle>
<Border HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="6" Height="6"
BorderBrush="White" BorderThickness="0.6">
<Border Width="4.5" Height="4.5" BorderBrush="Black" BorderThickness="0.6"/>
</Border>
</Grid>
</Border>
</WrapPanel>
<WrapPanel HorizontalAlignment="Center" Height="80" Margin="0,85,0,5">
<StackPanel Width="100" Height="80">
<TextBlock Text="RGB:" Style="{StaticResource TextKey}"/>
<TextBlock x:Name="PixelColor_RGB" Style="{StaticResource TextValue}"/>
<TextBlock Text="HTML:" Margin="0,5,0,0" Style="{StaticResource TextKey}"/>
<TextBlock x:Name="PixelColor_HTML" Style="{StaticResource TextValue}"/>
</StackPanel>
<StackPanel Width="65" Height="80" Margin="10,0,0,0">
<TextBlock x:Name="Pixel_XY" TextAlignment="Right"/>
</StackPanel>
</WrapPanel>
</Grid>
</Border>
</Canvas>
</Canvas>
</Grid>
</Window>

View File

@@ -0,0 +1,208 @@
using GeekDesk.Interface;
using GeekDesk.Util;
using HandyControl.Controls;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// ColorPickerWindow.xaml 的交互逻辑
/// </summary>
public partial class PixelColorPickerWindow : IWindowCommon
{
private static int PIXEL_REC_LENGTH = 20;
private static readonly int MIN_LENGTH = 10;
private static readonly int MAX_LENGTH = 50;
private static System.Drawing.Bitmap bgBitmap;
private readonly ColorPicker colorPicker;
public PixelColorPickerWindow(ColorPicker colorPicker)
{
InitializeComponent();
this.colorPicker = colorPicker;
ColorPickerWindow_Init();
}
private void ColorPickerWindow_Init()
{
this.WindowState = WindowState.Normal;//还原窗口(非最小化和最大化)
this.Width = SystemParameters.VirtualScreenWidth;
this.Height = SystemParameters.VirtualScreenHeight;
this.Left = SystemParameters.VirtualScreenLeft;
this.Top = SystemParameters.VirtualScreenTop;
DesktopBG.Width = this.Width;
DesktopBG.Height = this.Height;
this.Topmost = true;
bgBitmap = new System.Drawing.Bitmap(
(int)SystemParameters.VirtualScreenWidth,
(int)SystemParameters.VirtualScreenHeight,
System.Drawing.Imaging.PixelFormat.Format32bppArgb
);
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bgBitmap))
{
g.CopyFromScreen(
0,
0,
0,
0,
bgBitmap.Size
);
}
BitmapSource bs = Imaging.CreateBitmapSourceFromHBitmap(
bgBitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions()
);
ImageBrush ib = (ImageBrush)DesktopBG.Background;
ib.ImageSource = bs;
VisualBrush b = (VisualBrush)PixelBG.Fill;
b.Visual = DesktopBG;
Mouse.OverrideCursor = Cursors.Cross;
SetPixelAbout(null);
}
[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)
{
if (e.Key == Key.Escape)
{
this.DataContext = null;
this.Close();
}
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Point pos = e.MouseDevice.GetPosition(DesktopBG);
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));
DeleteObject(bgBitmap.GetHbitmap());
this.Close();
ClickColorPickerToggleButton(colorPicker);
}
public void ClickColorPickerToggleButton(ColorPicker colorPicker)
{
const BindingFlags InstanceBindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
Type type = colorPicker.GetType();
FieldInfo fi = type.GetField("_toggleButtonDropper", InstanceBindFlags);
ToggleButton tb = (ToggleButton)fi.GetValue(colorPicker);
if (tb != null && tb.IsChecked == true)
{
tb.IsChecked = false;
MethodInfo mi = type.GetMethod("ToggleButtonDropper_Click", InstanceBindFlags);
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)
{
SetPixelAbout(e);
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr onj);
private void SetPixelAbout(MouseEventArgs e)
{
VisualBrush b = (VisualBrush)PixelBG.Fill;
Point pos;
if (e == null)
{
pos = MouseUtil.GetMousePosition();
}
else
{
pos = e.MouseDevice.GetPosition(DesktopBG);
}
Rect viewBox = b.Viewbox;
viewBox.Width = PIXEL_REC_LENGTH;
viewBox.Height = PIXEL_REC_LENGTH;
viewBox.X = pos.X - PIXEL_REC_LENGTH / 2;
viewBox.Y = pos.Y - PIXEL_REC_LENGTH / 2;
b.Viewbox = viewBox;
double x = pos.X + 10;
double y = pos.Y + 10;
if (x + ColorCanvas.Width > SystemParameters.VirtualScreenWidth)
{
x = pos.X - ColorCanvas.Width - 10;
}
if (y + ColorCanvas.Height > SystemParameters.VirtualScreenHeight)
{
y = pos.Y - ColorCanvas.Height - 10;
}
Canvas.SetLeft(ColorCanvas, x);
Canvas.SetTop(ColorCanvas, y);
System.Drawing.Color dColor = bgBitmap.GetPixel((int)pos.X, (int)pos.Y);
PixelColor_HTML.Text = "#" + dColor.Name.ToUpper();
PixelColor_RGB.Text = dColor.R + "," + dColor.G + "," + dColor.B;
Pixel_XY.Text = pos.X + "*" + pos.Y;
SolidColorBrush scb = (SolidColorBrush)PixelColor.Fill;
scb.Color = Color.FromArgb(dColor.A, dColor.R, dColor.G, dColor.B);
}
/// <summary>
/// 滚轮控制缩放区域
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Window_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Delta < 0 && PIXEL_REC_LENGTH < MAX_LENGTH)
{
//缩小
PIXEL_REC_LENGTH += 5;
}
else if (e.Delta > 0 && PIXEL_REC_LENGTH > MIN_LENGTH)
{
//放大
PIXEL_REC_LENGTH -= 5;
}
SetPixelAbout(e);
}
}
}

View File

@@ -1,5 +1,4 @@
using GeekDesk.Constant;
using GeekDesk.Control.Other;
using GeekDesk.Interface;
using GeekDesk.Util;
using GeekDesk.ViewModel;
@@ -8,13 +7,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Resources;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using static GeekDesk.Util.ShowWindowFollowMouse;
@@ -85,7 +81,8 @@ namespace GeekDesk.Control.Windows
IsBackground = true
};
t.Start();
} else
}
else
{
StartMenuLoading.Visibility = Visibility.Collapsed;
vm.IconInfos = startMenuIcons;
@@ -109,7 +106,8 @@ namespace GeekDesk.Control.Windows
vm.IconInfos = null;
systemIcons = GetSysteIconInfos();
vm.IconInfos = systemIcons;
} else
}
else
{
vm.IconInfos = systemIcons;
}
@@ -142,7 +140,7 @@ namespace GeekDesk.Control.Windows
}
StartMenuLoading.Visibility = Visibility.Collapsed;
}));
}
/// <summary>
@@ -161,7 +159,8 @@ namespace GeekDesk.Control.Windows
if (filePaths == null || filePaths.Length == 0)
{
dirPaths.CopyTo(paths, 0);
} else
}
else
{
dirPaths.CopyTo(paths, filePaths.Length - 1);
}
@@ -195,7 +194,7 @@ namespace GeekDesk.Control.Windows
//foreach(FileSystemInfo fi in fileInfoArr)
//{
// string path = fi.FullName;
//}
}

View File

@@ -5,18 +5,9 @@ using GeekDesk.ViewModel;
using HandyControl.Controls;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{
@@ -42,7 +33,8 @@ namespace GeekDesk.Control.Windows
DateTime time = DateTime.Now.AddMinutes(10);
ExeTime.SelectedDateTime = time;
SetTimePanel.Visibility = Visibility.Visible;
this.DataContext = new ToDoInfo {
this.DataContext = new ToDoInfo
{
ExeTime = time.ToString("yyyy-MM-dd HH:mm:ss")
};
}
@@ -97,7 +89,8 @@ namespace GeekDesk.Control.Windows
{
Growl.Warning("任务标题不能为空!");
return;
} else
}
else
{
if (SetTimePanel.Visibility == Visibility.Visible)
{
@@ -117,7 +110,9 @@ namespace GeekDesk.Control.Windows
return;
}
execTime = ExeTime.Text;
} else {
}
else
{
execType = TodoTaskExecType.CRON;
if (Cron.Text.Trim() == "")
{
@@ -128,7 +123,8 @@ namespace GeekDesk.Control.Windows
{
bool isValid = CronExpression.IsValidExpression(Cron.Text);
if (!isValid) throw new Exception();
} catch (Exception)
}
catch (Exception)
{
Growl.Warning("请输入正确的Cron表达式!");
return;
@@ -155,7 +151,8 @@ namespace GeekDesk.Control.Windows
if (appData.HiToDoList.Contains(tdi))
{
appData.HiToDoList.Remove(tdi);
} else if (appData.ToDoList.Contains(tdi))
}
else if (appData.ToDoList.Contains(tdi))
{
appData.ToDoList.Remove(tdi);
}
@@ -175,7 +172,8 @@ namespace GeekDesk.Control.Windows
int h = minutes / 60;
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + h + " 小时零 " + m + " 分钟后提醒您!");
} else
}
else
{
Growl.SuccessGlobal("设置待办任务成功, 系统将在 " + minutes + " 分钟后提醒您!");
}
@@ -202,7 +200,8 @@ namespace GeekDesk.Control.Windows
{
window = new ToDoInfoWindow();
window.Show();
} else
}
else
{
window.Close();
}

View File

@@ -2,20 +2,8 @@
using GeekDesk.Interface;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{

View File

@@ -4,20 +4,10 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{
@@ -42,7 +32,7 @@ namespace GeekDesk.Control.Windows
{
}
}
/// <summary>
@@ -68,7 +58,7 @@ namespace GeekDesk.Control.Windows
githubUrl = StringUtil.IsEmpty(jo["githubUrl"]) ? ConfigurationManager.AppSettings["GitHubUrl"] : jo["githubUrl"].ToString();
giteeUrl = StringUtil.IsEmpty(jo["giteeUrl"]) ? ConfigurationManager.AppSettings["GiteeUrl"] : jo["giteeUrl"].ToString();
string msg = "";
for (int i=0; i<ja.Count; i++)
for (int i = 0; i < ja.Count; i++)
{
msg += "• " + ja[i].ToString() + "\n";
}