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

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