增加系统预设渐变背景
This commit is contained in:
58
Control/Other/GradientBGDialog.xaml
Normal file
58
Control/Other/GradientBGDialog.xaml
Normal file
@@ -0,0 +1,58 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.GradientBGDialog"
|
||||
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"
|
||||
Width="600"
|
||||
Height="400"
|
||||
Style="{StaticResource BorderBG}"
|
||||
>
|
||||
<hc:TransitioningContentControl TransitionMode="Fade">
|
||||
<Grid>
|
||||
<ListBox x:Name="GradientBGs"
|
||||
ItemsSource="{Binding}"
|
||||
Background="Transparent"
|
||||
Margin="20,20,20,50"
|
||||
BorderThickness="0"
|
||||
>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="Margin" Value="10"/>
|
||||
<Setter Property="Effect" Value="{StaticResource EffectShadow2}"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Background="Transparent"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border CornerRadius="4" Width="100" Height="100"
|
||||
MouseLeftButtonDown="BGBorder_MouseLeftButtonDown"
|
||||
Tag="{Binding}">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush>
|
||||
<GradientStop Offset="0" Color="{Binding Color1}"/>
|
||||
<GradientStop Offset="1" Color="{Binding Color2}"/>
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<Border Width="100" Height="30" VerticalAlignment="Bottom">
|
||||
<Border.Background>
|
||||
<SolidColorBrush Color="Gray" Opacity="0.4"/>
|
||||
</Border.Background>
|
||||
<TextBlock Text="{Binding Name}" TextAlignment="Center" VerticalAlignment="Center" FontSize="17" FontWeight="Bold" Foreground="White"/>
|
||||
</Border>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<hc:UniformSpacingPanel Spacing="10" Grid.ColumnSpan="4">
|
||||
<Button Content="关闭" Style="{StaticResource Btn1}" Click="Close_Click" HorizontalAlignment="Stretch" Margin="524,360,-524,10" VerticalAlignment="Stretch"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Grid>
|
||||
|
||||
</hc:TransitioningContentControl>
|
||||
</Border>
|
||||
38
Control/Other/GradientBGDialog.xaml.cs
Normal file
38
Control/Other/GradientBGDialog.xaml.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// TextDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class GradientBGDialog
|
||||
{
|
||||
public HandyControl.Controls.Dialog dialog;
|
||||
|
||||
public GradientBGDialog()
|
||||
{
|
||||
this.DataContext = GradientBGParamList.GradientBGParams;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
private void BGBorder_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
GradientBGParam bgParam = (sender as Border).Tag as GradientBGParam;
|
||||
MainWindow.appData.AppConfig.GradientBGParam = bgParam;
|
||||
BGSettingUtil.BGSetting();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
</hc:UniformSpacingPanel>
|
||||
|
||||
<UniformGrid x:Name="ImgBGConf">
|
||||
<hc:TransitioningContentControl TransitionMode="Bottom2TopWithFade"
|
||||
<hc:TransitioningContentControl TransitionMode="Fade"
|
||||
Height="130">
|
||||
<StackPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
@@ -65,7 +65,7 @@
|
||||
</UniformGrid>
|
||||
|
||||
<UniformGrid x:Name="GradientBGConf">
|
||||
<hc:TransitioningContentControl TransitionMode="Bottom2TopWithFade"
|
||||
<hc:TransitioningContentControl TransitionMode="Fade"
|
||||
Height="130">
|
||||
<StackPanel>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,10,0,0" Grid.ColumnSpan="4">
|
||||
@@ -98,6 +98,7 @@
|
||||
hc:Poptip.IsOpen="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
|
||||
hc:Poptip.Content="{Binding GradientBGParam.Name, Converter={StaticResource StringAppendConvert}, ConverterParameter=当前设置: \{\}}"
|
||||
hc:Poptip.Placement="Top"
|
||||
Click="SysBG_Click"
|
||||
/>
|
||||
</StackPanel>
|
||||
</hc:TransitioningContentControl>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Control.Other;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
@@ -241,5 +242,11 @@ namespace GeekDesk.Control.UserControls.Config
|
||||
{
|
||||
BGSettingUtil.BGSetting();
|
||||
}
|
||||
|
||||
private void SysBG_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GradientBGDialog gbg = new GradientBGDialog();
|
||||
gbg.dialog = HandyControl.Controls.Dialog.Show(gbg, "SysBGDialog");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
<DropShadowEffect BlurRadius="20" Direction="-90" Color="Gray"
|
||||
RenderingBias="Quality" ShadowDepth="2"/>
|
||||
</Grid.Effect>
|
||||
<Grid hc:Dialog.Token="SysBGDialog">
|
||||
<hc:DialogContainer Margin="10">
|
||||
<Border Style="{StaticResource BorderBG}">
|
||||
<Grid Background="Transparent">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -107,16 +109,23 @@
|
||||
</hc:SideMenu>
|
||||
</hc:Card>
|
||||
<hc:ScrollViewer Grid.Row="0" Grid.Column="1" BorderThickness="0" Margin="0,5,1,5">
|
||||
<hc:Card x:Name="RightCard" Height="480" BorderThickness="0" MouseDown="DragMove">
|
||||
<UniformGrid x:Name="UFG">
|
||||
<hc:TransitioningContentControl TransitionMode="Fade">
|
||||
<hc:Card x:Name="RightCard" BorderThickness="0" MouseDown="DragMove">
|
||||
<hc:Card.Background>
|
||||
<SolidColorBrush Opacity="0"/>
|
||||
</hc:Card.Background>
|
||||
</hc:Card>
|
||||
</hc:TransitioningContentControl>
|
||||
</UniformGrid>
|
||||
</hc:ScrollViewer>
|
||||
|
||||
<Button Width="22" Height="22" Click="Close_Button_Click" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</hc:DialogContainer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</hc:Window>
|
||||
@@ -8,7 +8,9 @@ using GeekDesk.ViewModel;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace GeekDesk.Control.Windows
|
||||
@@ -22,6 +24,14 @@ namespace GeekDesk.Control.Windows
|
||||
private static readonly ThemeControl theme = new ThemeControl();
|
||||
private static readonly MotionControl motion = new MotionControl();
|
||||
private static readonly OtherControl other = new OtherControl();
|
||||
private static List<UserControl> ucList = new List<UserControl>();
|
||||
static ConfigWindow()
|
||||
{
|
||||
ucList.Add(about);
|
||||
ucList.Add(theme);
|
||||
ucList.Add(motion);
|
||||
ucList.Add(other);
|
||||
}
|
||||
public MainWindow mainWindow;
|
||||
|
||||
private ConfigWindow(AppConfig appConfig, MainWindow mainWindow)
|
||||
@@ -53,16 +63,24 @@ namespace GeekDesk.Control.Windows
|
||||
switch (smi.Tag.ToString())
|
||||
{
|
||||
case "Motion":
|
||||
UFG.Visibility = Visibility.Collapsed;
|
||||
RightCard.Content = motion;
|
||||
UFG.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "Theme":
|
||||
UFG.Visibility = Visibility.Collapsed;
|
||||
RightCard.Content = theme;
|
||||
UFG.Visibility = Visibility.Visible;
|
||||
break;
|
||||
case "Other":
|
||||
UFG.Visibility = Visibility.Collapsed;
|
||||
RightCard.Content = other;
|
||||
UFG.Visibility = Visibility.Visible;
|
||||
break;
|
||||
default:
|
||||
UFG.Visibility = Visibility.Collapsed;
|
||||
RightCard.Content = about;
|
||||
UFG.Visibility = Visibility.Visible;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
33
Converts/StringAppendConvert.cs
Normal file
33
Converts/StringAppendConvert.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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 StringAppendConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null) return null;
|
||||
if (parameter == null)
|
||||
{
|
||||
return value.ToString();
|
||||
} else
|
||||
{
|
||||
string val = value.ToString();
|
||||
string param = parameter.ToString();
|
||||
return param.Replace("{}", val);
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,10 +34,6 @@
|
||||
<cvt:OpcityConvert x:Key="OpcityConvert"/>
|
||||
<cvt:IntToCornerRadius x:Key="IntToCornerRadius"/>
|
||||
<cvt:DoubleToGridLength x:Key="DoubleToGridLength"/>
|
||||
<cvt:ArrToBitmapImageConvert x:Key="ArrToBitmapImageConvert"/>
|
||||
<cvt:VisualBrushConvert x:Key="VisualBrushConvert"/>
|
||||
|
||||
|
||||
<Style x:Key="BorderBacStyle" TargetType="Border">
|
||||
|
||||
</Style>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -75,8 +76,42 @@ namespace GeekDesk.ViewModel
|
||||
|
||||
private bool hoverMenu = false; //悬停切换菜单 默认关闭
|
||||
|
||||
private BGStyle bgStyle = BGStyle.ImgBac; //背景风格
|
||||
|
||||
private GradientBGParam gradientBGParam = null; //渐变背景参数
|
||||
|
||||
#region GetSet
|
||||
|
||||
public GradientBGParam GradientBGParam
|
||||
{
|
||||
get
|
||||
{
|
||||
if (gradientBGParam == null)
|
||||
{
|
||||
gradientBGParam = GradientBGParamList.GradientBGParams[0];
|
||||
}
|
||||
return gradientBGParam;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientBGParam = value;
|
||||
OnPropertyChanged("GradientBGParam");
|
||||
}
|
||||
}
|
||||
|
||||
public BGStyle BGStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return bgStyle;
|
||||
}
|
||||
set
|
||||
{
|
||||
bgStyle = value;
|
||||
OnPropertyChanged("BGStyle");
|
||||
}
|
||||
}
|
||||
|
||||
public bool HoverMenu
|
||||
{
|
||||
get
|
||||
|
||||
79
ViewModel/GradientBGParam.cs
Normal file
79
ViewModel/GradientBGParam.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
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
|
||||
{
|
||||
[Serializable]
|
||||
public class GradientBGParam : INotifyPropertyChanged
|
||||
{
|
||||
private string color1;
|
||||
|
||||
private string color2;
|
||||
|
||||
private string name;
|
||||
|
||||
public GradientBGParam() { }
|
||||
|
||||
public GradientBGParam(string name, string color1, string color2) {
|
||||
this.name = name;
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string Color1
|
||||
{
|
||||
get
|
||||
{
|
||||
return color1;
|
||||
}
|
||||
set
|
||||
{
|
||||
color1 = value;
|
||||
OnPropertyChanged("Color1");
|
||||
}
|
||||
}
|
||||
|
||||
public string Color2
|
||||
{
|
||||
get
|
||||
{
|
||||
return color2;
|
||||
}
|
||||
set
|
||||
{
|
||||
color2 = value;
|
||||
OnPropertyChanged("Color2");
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return name;
|
||||
}
|
||||
set
|
||||
{
|
||||
name = value;
|
||||
OnPropertyChanged("Name");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[field: NonSerializedAttribute()]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
CommonCode.SaveAppData(MainWindow.appData);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
42
ViewModel/Temp/GradientBGParamList.cs
Normal file
42
ViewModel/Temp/GradientBGParamList.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GeekDesk.ViewModel.Temp
|
||||
{
|
||||
public class GradientBGParamList
|
||||
{
|
||||
|
||||
|
||||
private static ObservableCollection<GradientBGParam> gradientBGParams;
|
||||
|
||||
static GradientBGParamList()
|
||||
{
|
||||
//gradientBGParams = (ObservableCollection<GradientBGParam>)ConfigurationManager.GetSection("SystemBGs")
|
||||
gradientBGParams = new ObservableCollection<GradientBGParam>
|
||||
{
|
||||
new GradientBGParam("诸神黄昏", "#FCCF31", "#F55555"),
|
||||
new GradientBGParam ("森林之友", "#EBF7E3", "#A8E4C0"),
|
||||
new GradientBGParam("魅惑妖术", "#FFDDE1", "#EE9CA7"),
|
||||
new GradientBGParam("魅惑妖术", "#D2F6FF", "#91B0E4")
|
||||
};
|
||||
}
|
||||
|
||||
public static ObservableCollection<GradientBGParam> GradientBGParams
|
||||
{
|
||||
get
|
||||
{
|
||||
return gradientBGParams;
|
||||
}
|
||||
set
|
||||
{
|
||||
gradientBGParams = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user