diff --git a/Control/UserControls/Config/ThemeControl.xaml b/Control/UserControls/Config/ThemeControl.xaml
index ecc94a5..dbea9d4 100644
--- a/Control/UserControls/Config/ThemeControl.xaml
+++ b/Control/UserControls/Config/ThemeControl.xaml
@@ -4,42 +4,109 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:cvt="clr-namespace:GeekDesk.Converts"
mc:Ignorable="d"
Background="Transparent"
d:DesignHeight="500" d:DesignWidth="450">
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -49,11 +116,10 @@
-
-
+
-
+
+
+ ValueChanged="BGOpacity_ValueChanged"
+ Maximum="100"
+ Width="350"
+ >
@@ -131,8 +199,8 @@
-
-
+
+
diff --git a/Control/UserControls/Config/ThemeControl.xaml.cs b/Control/UserControls/Config/ThemeControl.xaml.cs
index d718d25..2777a85 100644
--- a/Control/UserControls/Config/ThemeControl.xaml.cs
+++ b/Control/UserControls/Config/ThemeControl.xaml.cs
@@ -18,24 +18,45 @@ 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
+ }
+
///
/// MotionControl.xaml 的交互逻辑
///
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)
+ {
+ GradientBGConf.Visibility = Visibility.Collapsed;
+ ImgBGConf.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ ImgBGConf.Visibility = Visibility.Collapsed;
+ GradientBGConf.Visibility = Visibility.Visible;
+ }
}
///
@@ -64,7 +85,7 @@ namespace GeekDesk.Control.UserControls.Config
LogUtil.WriteErrorLog(ex, "修改背景失败,已重置为默认背景!");
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
}
-
+ BGSettingUtil.BGSetting();
}
@@ -81,12 +102,22 @@ namespace GeekDesk.Control.UserControls.Config
LogUtil.WriteErrorLog(ex, "修改背景失败2,已重置为默认背景!");
HandyControl.Controls.Growl.WarningGlobal("修改背景失败,已重置为默认背景!");
}
-
+ BGSettingUtil.BGSetting();
}
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;
+ }
ColorPanel.Visibility = Visibility.Visible;
}
@@ -107,7 +138,16 @@ namespace GeekDesk.Control.UserControls.Config
private void MyColorPicker_SelectedColorChanged(object sender, HandyControl.Data.FunctionEventArgs e)
{
SolidColorBrush scb = MyColorPicker.SelectedBrush;
- appConfig.TextColor = scb.ToString();
+
+ 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;
+ }
}
///
@@ -178,6 +218,28 @@ namespace GeekDesk.Control.UserControls.Config
ColorPanel.Visibility = Visibility.Collapsed;
}
+ public void BGStyle_Changed(object sender, RoutedEventArgs e)
+ {
+ BGSettingUtil.BGSetting();
+ if (appConfig.BGStyle != BGStyle.GradientBac)
+ {
+ GradientBGConf.Visibility = Visibility.Collapsed;
+ ImgBGConf.Visibility = Visibility.Visible;
+ } else
+ {
+ ImgBGConf.Visibility = Visibility.Collapsed;
+ GradientBGConf.Visibility = Visibility.Visible;
+ }
+ }
+ private void BGOpacity_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ BGSettingUtil.BGSetting();
+ }
+
+ private void Color_TargetUpdated(object sender, DataTransferEventArgs e)
+ {
+ BGSettingUtil.BGSetting();
+ }
}
}
diff --git a/Converts/BGStyleConvert.cs b/Converts/BGStyleConvert.cs
new file mode 100644
index 0000000..c527a23
--- /dev/null
+++ b/Converts/BGStyleConvert.cs
@@ -0,0 +1,29 @@
+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
+{
+ class BGStyleConvert : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (BGStyle)value == (BGStyle)int.Parse(parameter.ToString());
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool isChecked = (bool)value;
+ if (!isChecked)
+ {
+ return null;
+ }
+ return (BGStyle)int.Parse(parameter.ToString());
+ }
+ }
+}
diff --git a/MainWindow.xaml b/MainWindow.xaml
index ce1e33f..ce377d2 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:GeekDesk.Control.UserControls.PannelCard"
+ xmlns:cn="clr-namespace:GeekDesk.Constant"
mc:Ignorable="d"
xmlns:cvt="clr-namespace:GeekDesk.Converts"
x:Name="window"
@@ -33,12 +34,22 @@
+
+
+
+
+
+
+
+
@@ -48,29 +59,15 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 53e1fdd..4d9acb1 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -18,6 +18,7 @@ using System.Collections.ObjectModel;
using NPinyin;
using GeekDesk.ViewModel.Temp;
using System.Threading;
+using DraggAnimatedPanelExample;
namespace GeekDesk
{
@@ -52,6 +53,7 @@ namespace GeekDesk
}
}
+
///
/// 显示搜索框
///
@@ -110,7 +112,6 @@ namespace GeekDesk
///
private void LoadData()
{
- GC.KeepAlive(appData); // 持活
this.DataContext = appData;
if (appData.MenuList.Count == 0)
{
@@ -129,6 +130,7 @@ namespace GeekDesk
///
void Window_Loaded(object sender, RoutedEventArgs e)
{
+ BGSettingUtil.BGSetting();
if (!appData.AppConfig.StartedShowPanel)
{
if (appData.AppConfig.AppAnimation)
diff --git a/Util/BGSettingUtil.cs b/Util/BGSettingUtil.cs
new file mode 100644
index 0000000..2361605
--- /dev/null
+++ b/Util/BGSettingUtil.cs
@@ -0,0 +1,74 @@
+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;
+
+namespace GeekDesk.Util
+{
+ public class BGSettingUtil
+ {
+ private static readonly AppConfig appConfig = MainWindow.appData.AppConfig;
+ public static void BGSetting()
+ {
+ if (appConfig.BGStyle == BGStyle.ImgBac || appConfig.BGStyle == 0)
+ {
+ Image image = new Image
+ {
+ Effect = new BlurEffect()
+ {
+ Radius = appConfig.BlurValue
+ },
+ 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);
+
+ Grid grid = new Grid
+ {
+ ClipToBounds = true
+ };
+ grid.Children.Add(image);
+
+ VisualBrush vb = new VisualBrush
+ {
+ Visual = grid
+ };
+ MainWindow.mainWindow.BGBorder.Background = vb;
+ }
+ else
+ {
+ LinearGradientBrush lgb = new LinearGradientBrush();
+
+ GradientStop gs = new GradientStop
+ {
+ Color = (Color)ColorConverter.ConvertFromString(appConfig.GradientBGParam.Color1),
+ Offset = 0
+ };
+
+ lgb.GradientStops.Add(gs);
+
+ GradientStop gs2 = new GradientStop
+ {
+ Color = (Color)ColorConverter.ConvertFromString(appConfig.GradientBGParam.Color2),
+ Offset = 1
+ };
+ lgb.GradientStops.Add(gs2);
+ MainWindow.mainWindow.BGBorder.Background = lgb;
+ }
+
+ }
+
+ }
+}