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

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

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