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

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

@@ -2,6 +2,8 @@
<configuration>
<configSections>
<section name="SystemIcons" type="System.Configuration.DictionarySectionHandler" />
<section name="SystemBGs" type="System.Collections.ObjectModel.ObservableCollection" />
<section name="GradientBGParam" type="GeekDesk.ViewModel.GradientBGParam" />
</configSections>
<SystemIcons>
<add key="Calculator" value="计算器" />
@@ -16,6 +18,9 @@
<add key="CMD" value="命令行" />
<add key="Services" value="服务" />
</SystemIcons>
<SystemBGs>
<GradientBGParam Color1="#FCCF31" Color2="#F55555" Name="诸神黄昏"/>
</SystemBGs>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>

View File

@@ -1,12 +1,7 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using Microsoft.Win32;
using System;
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Threading;
namespace GeekDesk
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// <summary>
/// 背景风格
/// </summary>
namespace GeekDesk.Constant

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
{

10
Constant/HotKeyType.cs Normal file
View File

@@ -0,0 +1,10 @@
namespace GeekDesk.Constant
{
public enum HotKeyType
{
Main = 0, //主窗口
ToDo = 1, //待办任务
ColorPicker = 2 //拾色器
}
}

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// <summary>
/// 图标应用启动方式
/// </summary>
namespace GeekDesk.Constant

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
namespace GeekDesk.Constant
{
public enum IconType
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
namespace GeekDesk.Constant
{
internal class RunTimeStatus
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Constant
namespace GeekDesk.Constant
{
public enum TodoTaskExecType
{

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/// <summary>
/// <summary>
/// 更新源
/// </summary>
namespace GeekDesk.Constant

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";
}

View File

@@ -1,10 +1,6 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

View File

@@ -1,15 +1,11 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
{
public class HideTypeConvert : IValueConverter
public class HideTypeConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

View File

@@ -1,15 +1,10 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
{
public class MenuInfoConvert : IValueConverter
public class MenuInfoConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
@@ -17,7 +12,8 @@ namespace GeekDesk.Converts
if (menuIndex == -1)
{
return "";
} else
}
else
{
string type = parameter.ToString();
if ("1".Equals(type))

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts

View File

@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace GeekDesk.Converts
@@ -18,7 +13,8 @@ namespace GeekDesk.Converts
{
double menuLeftWidth = double.Parse(value.ToString());
return MainWindow.mainWindow.Width - menuLeftWidth;
} else
}
else
{
double menuLeftWidth = double.Parse(value.ToString());
return (MainWindow.mainWindow.Width - menuLeftWidth) / 2;

View File

@@ -1,10 +1,6 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts

View File

@@ -1,10 +1,5 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
@@ -17,7 +12,8 @@ namespace GeekDesk.Converts
if (parameter == null)
{
return value.ToString();
} else
}
else
{
string val = value.ToString();
string param = parameter.ToString();

View File

@@ -1,15 +1,11 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts
{
public class TodoTaskExecConvert : IValueConverter
public class TodoTaskExecConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{

View File

@@ -1,10 +1,6 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace GeekDesk.Converts

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
@@ -16,7 +12,8 @@ namespace GeekDesk.Converts
if ((Visibility)value == Visibility.Visible)
{
return true;
} else
}
else
{
return false;
}
@@ -27,7 +24,8 @@ namespace GeekDesk.Converts
if ((bool)value)
{
return Visibility.Visible;
} else
}
else
{
return Visibility.Collapsed;
}

View File

@@ -15,6 +15,21 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -127,12 +142,14 @@
<Compile Include="Command\DelegateCommandBase.cs" />
<Compile Include="Constant\AppHideType.cs" />
<Compile Include="Constant\Constants.cs" />
<Compile Include="Constant\HotKeyType.cs" />
<Compile Include="Constant\IconType.cs" />
<Compile Include="Constant\CommonEnum.cs" />
<Compile Include="Constant\IconStartType.cs" />
<Compile Include="Constant\RunTimeStatus.cs" />
<Compile Include="Constant\SortType.cs" />
<Compile Include="Constant\TodoTaskExecType.cs" />
<Compile Include="Constant\BGStyle.cs" />
<Compile Include="Constant\UpdateType.cs" />
<Compile Include="Control\Other\BacklogNotificatin.xaml.cs">
<DependentUpon>BacklogNotificatin.xaml</DependentUpon>
@@ -140,6 +157,12 @@
<Compile Include="Control\Other\CustomIconUrlDialog.xaml.cs">
<DependentUpon>CustomIconUrlDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\GradientBGDialog.xaml.cs">
<DependentUpon>GradientBGDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\MyColorPickerDialog.xaml.cs">
<DependentUpon>MyColorPickerDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Other\IconInfoUrlDialog.xaml.cs">
<DependentUpon>IconInfoUrlDialog.xaml</DependentUpon>
</Compile>
@@ -155,6 +178,12 @@
<Compile Include="Control\UserControls\IconFont\IconPannel.xaml.cs">
<DependentUpon>IconPannel.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\GlobalColorPickerWindow.xaml.cs">
<DependentUpon>GlobalColorPickerWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\PixelColorPickerWindow.xaml.cs">
<DependentUpon>PixelColorPickerWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Control\Windows\SystemItemWindow.xaml.cs">
<DependentUpon>SystemItemWindow.xaml</DependentUpon>
</Compile>
@@ -191,6 +220,7 @@
<Compile Include="Control\Windows\UpdateWindow.xaml.cs">
<DependentUpon>UpdateWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Converts\StringAppendConvert.cs" />
<Compile Include="Converts\DoubleToGridLength.cs" />
<Compile Include="Converts\MenuInfoConvert.cs" />
<Compile Include="Converts\SearchResWidth.cs" />
@@ -198,7 +228,9 @@
<Compile Include="Converts\TodoTaskExecConvert.cs" />
<Compile Include="Converts\IntToCornerRadius.cs" />
<Compile Include="Converts\OpcityConvert.cs" />
<Compile Include="Converts\BGStyleConvert.cs" />
<Compile Include="Converts\UpdateTypeConvert.cs" />
<Compile Include="Converts\Visibility2BooleanConverter.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.cs" />
<Compile Include="DraggAnimatedPanel\DraggAnimatedPanel.Drag.cs" />
<Compile Include="Converts\HideTypeConvert.cs" />
@@ -208,6 +240,8 @@
<Compile Include="MyThread\DispatcherBuild.cs" />
<Compile Include="MyThread\UpdateThread.cs" />
<Compile Include="Util\AeroGlassHelper.cs" />
<Compile Include="Util\BGSettingUtil.cs" />
<Compile Include="Util\ColorUtil.cs" />
<Compile Include="Util\GlobalHotKey.cs" />
<Compile Include="Util\CommonCode.cs" />
<Compile Include="Util\FileIcon.cs" />
@@ -225,6 +259,9 @@
<Compile Include="Util\SvgToGeometry.cs" />
<Compile Include="ViewModel\AppConfig.cs" />
<Compile Include="ViewModel\AppData.cs" />
<Compile Include="ViewModel\GradientBGParam.cs" />
<Compile Include="ViewModel\CPDataContext.cs" />
<Compile Include="ViewModel\Temp\GradientBGParamList.cs" />
<Compile Include="ViewModel\Temp\SearchIconList.cs" />
<Compile Include="ViewModel\ToDoInfo.cs" />
<Compile Include="ViewModel\IconfontInfo.cs" />
@@ -238,6 +275,14 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\GradientBGDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\MyColorPickerDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Control\Other\IconInfoUrlDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -258,6 +303,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\GlobalColorPickerWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\PixelColorPickerWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Control\Windows\SystemItemWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -402,5 +455,17 @@
<Resource Include="Resource\Image\SystemIcon\RecycleBin.png" />
<Resource Include="Resource\Image\SystemIcon\Registry.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

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

Microsoft Visual Studio Solution File, Format Version 12.00
# Blend for Visual Studio Version 16
VisualStudioVersion = 16.0.30907.101
# Visual Studio Version 17
VisualStudioVersion = 17.1.32319.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeekDesk", "GeekDesk.csproj", "{B4983CEC-2281-413C-8ECF-92EE0E40A713}"
EndProject

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Input;
namespace GeekDesk.Interface
{

View File

@@ -60,7 +60,7 @@
Focusable="True"
>
<hc:DialogContainer Focusable="True">
<!-- -1是为了解决圆角白线的问题-->
<Border x:Name="BGBorder"
CornerRadius="{Binding AppConfig.PannelCornerRadius, Mode=TwoWay, Converter={StaticResource IntToCornerRadius}}"
BorderThickness="0"
@@ -149,6 +149,7 @@
<hc:NotifyIcon.ContextMenu>
<ContextMenu Width="130">
<MenuItem Header="打开面板" Click="ShowApp"/>
<MenuItem Header="拾色器" Click="ColorPicker"/>
<MenuItem Header="隐藏图标" Click="CloseBarIcon"/>
<MenuItem Header="待办" Click="BacklogMenuClick"/>
<MenuItem Header="程序目录" Click="OpenThisDir"/>

View File

@@ -2,23 +2,21 @@
using GeekDesk.Control.UserControls.Config;
using GeekDesk.Control.Windows;
using GeekDesk.Interface;
using GeekDesk.Task;
using GeekDesk.MyThread;
using GeekDesk.Task;
using GeekDesk.Util;
using GeekDesk.ViewModel;
using GeekDesk.ViewModel.Temp;
using NPinyin;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using static GeekDesk.Util.ShowWindowFollowMouse;
using System.Collections.ObjectModel;
using NPinyin;
using GeekDesk.ViewModel.Temp;
using System.Threading;
using DraggAnimatedPanelExample;
namespace GeekDesk
{
@@ -33,6 +31,7 @@ namespace GeekDesk
public static ToDoInfoWindow toDoInfoWindow;
public static int hotKeyId = -1;
public static int toDoHotKeyId = -1;
public static int colorPickerHotKeyId = -1;
public static MainWindow mainWindow;
public MainWindow()
{
@@ -153,8 +152,19 @@ namespace GeekDesk
BarIcon.Text = Constants.MY_NAME;
//注册热键
RegisterHotKey(true);
RegisterCreateToDoHotKey(true);
if (true == appData.AppConfig.EnableAppHotKey)
{
RegisterHotKey(true);
}
if (true == appData.AppConfig.EnableTodoHotKey)
{
RegisterCreateToDoHotKey(true);
}
if (true == appData.AppConfig.EnableColorPickerHotKey)
{
RegisterColorPickerHotKey(true);
}
//注册自启动
if (!appData.AppConfig.SelfStartUped && !Constants.DEV)
@@ -196,10 +206,10 @@ namespace GeekDesk
}
}
});
}
if (!first)
{
HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
if (!first)
{
HandyControl.Controls.Growl.Success("GeekDesk快捷键注册成功(" + appData.AppConfig.HotkeyStr + ")!", "HotKeyGrowl");
}
}
}
catch (Exception)
@@ -236,11 +246,12 @@ namespace GeekDesk
ToDoInfoWindow.ShowOrHide();
}
});
if (!first)
{
HandyControl.Controls.Growl.Success("新建待办任务快捷键注册成功(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl");
}
}
if (!first)
{
HandyControl.Controls.Growl.Success("新建待办任务快捷键注册成功(" + appData.AppConfig.ToDoHotkeyStr + ")!", "HotKeyGrowl");
}
}
catch (Exception)
{
@@ -255,6 +266,43 @@ namespace GeekDesk
}
}
/// <summary>
/// 注册新建待办的热键
/// </summary>
public static void RegisterColorPickerHotKey(bool first)
{
try
{
if (appData.AppConfig.ColorPickerHotkeyModifiers != 0)
{
//加载完毕注册热键
colorPickerHotKeyId = GlobalHotKey.RegisterHotKey(appData.AppConfig.ColorPickerHotkeyModifiers, appData.AppConfig.ColorPickerHotkey, () =>
{
if (MotionControl.hotkeyFinished)
{
GlobalColorPickerWindow.Show();
}
});
if (!first)
{
HandyControl.Controls.Growl.Success("拾色器快捷键注册成功(" + appData.AppConfig.ColorPickerHotkeyStr + ")!", "HotKeyGrowl");
}
}
}
catch (Exception)
{
if (first)
{
HandyControl.Controls.Growl.WarningGlobal("拾色器快捷键已被其它程序占用(" + appData.AppConfig.ColorPickerHotkeyStr + ")!");
}
else
{
HandyControl.Controls.Growl.Warning("拾色器快捷键已被其它程序占用(" + appData.AppConfig.ColorPickerHotkeyStr + ")!", "HotKeyGrowl");
}
}
}
/// <summary>
/// 重置窗体大小 写入缓存
@@ -384,24 +432,27 @@ namespace GeekDesk
if (RunTimeStatus.SEARCH_BOX_SHOW)
{
mainWindow.HidedSearchBox();
new Thread(() =>
Thread t = new Thread(() =>
{
Thread.Sleep(100);
App.Current.Dispatcher.BeginInvoke(new Action(() =>
{
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}));
}).Start();
});
t.IsBackground = true;
t.Start();
}
else
{
FadeStoryBoard(0, (int)CommonEnum.WINDOW_ANIMATION_TIME, Visibility.Collapsed);
}
} else
}
else
{
ShowApp();
}
}
/// <summary>
@@ -630,5 +681,10 @@ namespace GeekDesk
//防止延迟贴边隐藏
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
}
private void ColorPicker(object sender, RoutedEventArgs e)
{
GlobalColorPickerWindow.Show();
}
}
}

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Threading;
namespace GeekDesk.MyThread
@@ -25,6 +20,7 @@ namespace GeekDesk.MyThread
manualResetEvent.Set();
Dispatcher.Run();
});
thread.IsBackground = true;
thread.Start();
manualResetEvent.WaitOne();
manualResetEvent.Dispose();

View File

@@ -2,11 +2,6 @@
using GeekDesk.ViewModel;
using Gma.System.MouseKeyHook;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
@@ -50,7 +45,7 @@ namespace GeekDesk.MyThread
if (MotionControl.hotkeyFinished)
{
App.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Render, new Action(() =>
{
{
if (MainWindow.mainWindow.Visibility == Visibility.Collapsed || MainWindow.mainWindow.Opacity == 0)
{
MainWindow.ShowApp();

View File

@@ -4,13 +4,8 @@ using GeekDesk.Util;
using GeekDesk.ViewModel;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk.MyThread
{
@@ -59,7 +54,8 @@ namespace GeekDesk.MyThread
}));
}
}
} catch (Exception ex)
}
catch (Exception ex)
{
LogUtil.WriteErrorLog(ex, "获取更新失败!");
}

View File

@@ -1,16 +1,11 @@
using GeekDesk.Control;
using GeekDesk.Control.Other;
using GeekDesk.Control.Other;
using GeekDesk.ViewModel;
using HandyControl.Controls;
using HandyControl.Data;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
namespace GeekDesk.Task

View File

@@ -1,13 +1,8 @@
using GeekDesk.Constant;
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.Media;
using System.Windows.Media.Effects;
@@ -29,9 +24,9 @@ namespace GeekDesk.Util
Margin = new Thickness(-30),
Source = appConfig.BitmapImage,
Opacity = (double)(Math.Round((decimal)(appConfig.BgOpacity / 100.00), 2))
};
};
//binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
//image.SetBinding(Image.OpacityProperty, binding);
@@ -67,7 +62,7 @@ namespace GeekDesk.Util
lgb.GradientStops.Add(gs2);
MainWindow.mainWindow.BGBorder.Background = lgb;
}
}
}

15
Util/ColorUtil.cs Normal file
View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
public class ColorUtil
{
}
}

View File

@@ -1,5 +1,4 @@
using IWshRuntimeLibrary;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
@@ -21,17 +20,17 @@ namespace GeekDesk.Util
return list;
}
[DllImport("User32.dll")]
public static extern int PrivateExtractIcons(
string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp
int nIconIndex, //从第几个图标开始获取
int cxIcon, //获取图标的尺寸x
int cyIcon, //获取图标的尺寸y
IntPtr[] phicon, //获取到的图标指针数组
int[] piconid, //图标对应的资源编号
int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用
int flags //标志默认0就可以具体可以看LoadImage函数
);
[DllImport("User32.dll")]
public static extern int PrivateExtractIcons(
string lpszFile, //文件名可以是exe,dll,ico,cur,ani,bmp
int nIconIndex, //从第几个图标开始获取
int cxIcon, //获取图标的尺寸x
int cyIcon, //获取图标的尺寸y
IntPtr[] phicon, //获取到的图标指针数组
int[] piconid, //图标对应的资源编号
int nIcons, //指定获取的图标数量,仅当文件类型为.exe 和 .dll时候可用
int flags //标志默认0就可以具体可以看LoadImage函数
);
public static BitmapImage GetBitmapImage(string filePath)

View File

@@ -1,11 +1,8 @@
using IWshRuntimeLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace GeekDesk.Util
{

View File

@@ -53,7 +53,8 @@ namespace GeekDesk.Util
UnregisterHotKey(handleTemp[id].Handle, id);
GlobalHotKey.handleTemp[id].Dispose();
GlobalHotKey.handleTemp.Remove(id);
} catch
}
catch
{
//nothing
}
@@ -75,7 +76,7 @@ namespace GeekDesk.Util
{
CreateHandle(new CreateParams());
this.callback += callback;
}
}
private static readonly int WM_HOTKEY = 0x0312;
protected override void WndProc(ref Message m)
@@ -94,4 +95,4 @@ namespace GeekDesk.Util
}
}
}

View File

@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
namespace GeekDesk.Util
{

View File

@@ -1,12 +1,9 @@
using GeekDesk.Constant;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;

View File

@@ -1,10 +1,7 @@
using GeekDesk.Constant;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{
@@ -48,27 +45,30 @@ namespace GeekDesk.Util
fs.Write(buffer, 0, buffer.Length);
}
}
} catch
}
catch
{
}
}
public static void WriteLog(string msg)
{
try {
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
try
{
fs.Seek(0, SeekOrigin.End);
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
fs.Write(buffer, 0, buffer.Length);
using (FileStream fs = File.Open(Constants.LOG_FILE_PATH, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(0, SeekOrigin.End);
byte[] buffer = Encoding.Default.GetBytes("-------------------------------------------------------\r\n");
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n" );
fs.Write(buffer, 0, buffer.Length);
buffer = Encoding.Default.GetBytes(DateTime.Now.ToString() + msg + "\r\n");
fs.Write(buffer, 0, buffer.Length);
}
}
} catch { }
catch { }
}

View File

@@ -1,9 +1,8 @@
using System;
using System.Windows.Forms;
using GeekDesk.Constant;
using System;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Media.Animation;
using GeekDesk.Constant;
namespace GeekDesk.Util
{
@@ -71,7 +70,7 @@ namespace GeekDesk.Util
#region
private static void HideWindow(object o, EventArgs e)
{
if (window.Visibility != Visibility.Visible
if (window.Visibility != Visibility.Visible
|| RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW) return;
double screenLeft = SystemParameters.VirtualScreenLeft;
@@ -302,12 +301,14 @@ namespace GeekDesk.Util
public static void WaitHide(int waitTime)
{
new System.Threading.Thread(()=>
System.Threading.Thread t = new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(waitTime);
//修改状态为false 继续执行贴边隐藏
RunTimeStatus.MARGIN_HIDE_AND_OTHER_SHOW = false;
}).Start();
});
t.IsBackground = true;
t.Start();
}

View File

@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace GeekDesk.Util

View File

@@ -1,9 +1,5 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
{

View File

@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Security.Permissions;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
namespace GeekDesk.Util
{
@@ -1166,7 +1164,7 @@ namespace GeekDesk.Util
Int32 ParseDisplayName(
IntPtr hwnd,
IntPtr pbc,
[MarshalAs(UnmanagedType.LPWStr)]
[MarshalAs(UnmanagedType.LPWStr)]
string pszDisplayName,
ref uint pchEaten,
out IntPtr ppidl,
@@ -1261,7 +1259,7 @@ namespace GeekDesk.Util
Int32 SetNameOf(
IntPtr hwnd,
IntPtr pidl,
[MarshalAs(UnmanagedType.LPWStr)]
[MarshalAs(UnmanagedType.LPWStr)]
string pszName,
SHGNO uFlags,
out IntPtr ppidlOut);

View File

@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.Util
namespace GeekDesk.Util
{
public class StringUtil
public class StringUtil
{

View File

@@ -4,10 +4,8 @@ using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml;

View File

@@ -48,7 +48,12 @@ namespace GeekDesk.ViewModel
private string toDoHotkeyStr = "Ctrl + Shift + Q"; //待办任务快捷键
private HotkeyModifiers toDoHotkeyModifiers; //待办任务快捷键
private Key toDoHotkey = Key.E; //待办任务快捷键
private Key toDoHotkey = Key.Q; //待办任务快捷键
private string colorPickerHotkeyStr = ""; //拾色器快捷键
private HotkeyModifiers colorPickerHotkeyModifiers; //拾色器快捷键
private Key colorPickerHotkey; //拾色器快捷键
private string customIconUrl; //自定义图标url
private string customIconJsonUrl; //自定义图标json信息url
@@ -81,9 +86,55 @@ namespace GeekDesk.ViewModel
private GradientBGParam gradientBGParam = null; //渐变背景参数
private bool? enableAppHotKey = true; //可能为null
private bool? enableTodoHotKey = true; //可能为null
private bool enableColorPickerHotKey; //新增 默认为false 不需要考虑null值
#region GetSet
public bool EnableColorPickerHotKey
{
get
{
return enableColorPickerHotKey;
}
set
{
enableColorPickerHotKey = value;
OnPropertyChanged("EnableColorPickerHotKey");
}
}
public bool? EnableAppHotKey
{
get
{
if (enableAppHotKey == null) enableAppHotKey = true;
return enableAppHotKey;
}
set
{
enableAppHotKey = value;
OnPropertyChanged("EnableAppHotKey");
}
}
public bool? EnableTodoHotKey
{
get
{
if (enableTodoHotKey == null) enableTodoHotKey = true;
return enableTodoHotKey;
}
set
{
enableTodoHotKey = value;
OnPropertyChanged("EnableTodoHotKey");
}
}
public Visibility TitleLogoVisible
{
get
@@ -375,6 +426,47 @@ namespace GeekDesk.ViewModel
}
}
public Key ColorPickerHotkey
{
get
{
return colorPickerHotkey;
}
set
{
colorPickerHotkey = value;
OnPropertyChanged("ColorPickerHotkey");
}
}
public HotkeyModifiers ColorPickerHotkeyModifiers
{
get
{
return colorPickerHotkeyModifiers;
}
set
{
colorPickerHotkeyModifiers = value;
OnPropertyChanged("ColorPickerHotkeyModifiers");
}
}
public string ColorPickerHotkeyStr
{
get
{
return colorPickerHotkeyStr;
}
set
{
colorPickerHotkeyStr = value;
OnPropertyChanged("ColorPickerHotkeyStr");
}
}
public Key ToDoHotkey
{
get
@@ -382,7 +474,7 @@ namespace GeekDesk.ViewModel
//兼容老版本
if (toDoHotkey == Key.None)
{
toDoHotkey = Key.Q;
toDoHotkey = Key.E;
}
return toDoHotkey;
}

View File

@@ -1,6 +1,5 @@
using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;

View File

@@ -0,0 +1,93 @@
using System.ComponentModel;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace GeekDesk.ViewModel
{
public class CPDataContext : INotifyPropertyChanged
{
private BitmapSource pixelIMG;
private System.Drawing.Color pixelColor_D;
public Color pixelColor;
private string colorHtml;
private string colorRGB;
private string pixelXY;
public BitmapSource PixelIMG
{
set
{
pixelIMG = value;
OnPropertyChanged("PixelIMG");
}
get { return pixelIMG; }
}
public System.Drawing.Color PixelColor_D
{
set
{
pixelColor_D = value;
ColorHtml = pixelColor_D.Name.ToUpper().Substring(2);
ColorRGB = pixelColor_D.R + "," + pixelColor_D.G + "," + pixelColor_D.B;
PixelColor = Color.FromArgb(pixelColor_D.A, pixelColor_D.R, pixelColor_D.G, pixelColor_D.B);
}
get { return pixelColor_D; }
}
public Color PixelColor
{
set
{
pixelColor = value;
OnPropertyChanged("PixelColor");
}
get { return pixelColor; }
}
public string ColorRGB
{
set
{
colorRGB = value;
OnPropertyChanged("ColorRGB");
}
get { return colorRGB; }
}
public string ColorHtml
{
set
{
colorHtml = value;
OnPropertyChanged("ColorHtml");
}
get { return colorHtml; }
}
public string PixelXY
{
set
{
pixelXY = value;
OnPropertyChanged("PixelXY");
}
get { return pixelXY; }
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@@ -1,10 +1,6 @@
using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{
@@ -19,7 +15,8 @@ namespace GeekDesk.ViewModel
public GradientBGParam() { }
public GradientBGParam(string name, string color1, string color2) {
public GradientBGParam(string name, string color1, string color2)
{
this.name = name;
this.color1 = color1;
this.color2 = color2;

View File

@@ -1,11 +1,7 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using Newtonsoft.Json;
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Text;
using System.Windows.Media.Imaging;
/// <summary>

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
namespace GeekDesk.ViewModel
{
public class IconfontInfo
{

View File

@@ -11,7 +11,7 @@ namespace GeekDesk.ViewModel
[Serializable]
public class MenuInfo : INotifyPropertyChanged
{
private string menuName;
private string menuId;
@@ -65,7 +65,7 @@ namespace GeekDesk.ViewModel
set
{
menuName = value;
OnPropertyChanged("MenuName");
OnPropertyChanged("MenuName");
}
}
@@ -94,7 +94,8 @@ namespace GeekDesk.ViewModel
if (menuEdit == Visibility.Visible)
{
NotMenuEdit = Visibility.Collapsed;
} else
}
else
{
NotMenuEdit = Visibility.Visible;
}

View File

@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
namespace GeekDesk.ViewModel.Temp
{
@@ -37,6 +31,6 @@ namespace GeekDesk.ViewModel.Temp
gradientBGParams = value;
}
}
}
}

View File

@@ -1,11 +1,7 @@
using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GeekDesk.ViewModel
{