:fire:增加自定义背景保存
This commit is contained in:
34
Control/Other/BGNmaeDialog.xaml
Normal file
34
Control/Other/BGNmaeDialog.xaml
Normal file
@@ -0,0 +1,34 @@
|
||||
<Border x:Class="GeekDesk.Control.Other.BGNmaeDialog"
|
||||
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"
|
||||
xmlns:cvt="clr-namespace:GeekDesk.Converts"
|
||||
CornerRadius="4"
|
||||
Width="350"
|
||||
Height="160"
|
||||
Style="{StaticResource BorderBG}"
|
||||
>
|
||||
<Border.Resources>
|
||||
<Style x:Key="LeftTB" TargetType="TextBlock" BasedOn="{StaticResource TextBlockBaseStyle}">
|
||||
<Setter Property="Width" Value="75"/>
|
||||
<Setter Property="TextAlignment" Value="Left"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Margin" Value="5,8,0,0"/>
|
||||
<Setter Property="FontSize" Value="14"/>
|
||||
</Style>
|
||||
<cvt:StringAppendConvert x:Key="StringAppendConvert"/>
|
||||
</Border.Resources>
|
||||
<hc:SimplePanel Margin="10" VerticalAlignment="Center">
|
||||
<StackPanel>
|
||||
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top"/>
|
||||
<hc:UniformSpacingPanel Spacing="10" Margin="0,15,0,0">
|
||||
<TextBlock Text="起个名字吧:" Style="{StaticResource LeftTB}"/>
|
||||
<TextBox x:Name="BGName" Style="{StaticResource MyTextBoxStyle}" Text="{Binding Name, Mode=OneWay}" Width="230" FontSize="14"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
<hc:UniformSpacingPanel Margin="0,25,0,0" Spacing="10" Grid.ColumnSpan="4">
|
||||
<Button Content="保存" Style="{StaticResource MyBtnStyle}" Click="Save" Margin="265,10,0,0"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
</hc:SimplePanel>
|
||||
</Border>
|
||||
42
Control/Other/BGNmaeDialog.xaml.cs
Normal file
42
Control/Other/BGNmaeDialog.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
|
||||
namespace GeekDesk.Control.Other
|
||||
{
|
||||
/// <summary>
|
||||
/// TextDialog.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class BGNmaeDialog
|
||||
{
|
||||
public HandyControl.Controls.Dialog dialog;
|
||||
|
||||
public BGNmaeDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Save(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GradientBGParam bg = new GradientBGParam();
|
||||
bg.Id = Guid.NewGuid().ToString();
|
||||
bg.Name = BGName.Text;
|
||||
bg.Color1 = MainWindow.appData.AppConfig.GradientBGParam.Color1;
|
||||
bg.Color2 = MainWindow.appData.AppConfig.GradientBGParam.Color2;
|
||||
MainWindow.appData.AppConfig.CustomBGParams.Add(bg);
|
||||
MainWindow.appData.AppConfig.CustomBGParams = DeepCopyUtil.DeepCopy(MainWindow.appData.AppConfig.CustomBGParams);
|
||||
dialog.Close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,27 @@
|
||||
Width="600"
|
||||
Height="400"
|
||||
Margin="0,-620,0,0">
|
||||
|
||||
<Border Style="{StaticResource BorderBG}">
|
||||
<Grid>
|
||||
<TextBlock Text="提示: 右键点击可以删除自定义的背景颜色哦" Foreground="Gray" HorizontalAlignment="Center" Margin="0,5,0,0"/>
|
||||
|
||||
<ListBox x:Name="GradientBGs"
|
||||
ItemsSource="{Binding}"
|
||||
Background="Transparent"
|
||||
Margin="20,20,20,50"
|
||||
BorderThickness="0"
|
||||
>
|
||||
ItemsSource="{Binding}"
|
||||
Background="Transparent"
|
||||
Margin="20,20,20,50"
|
||||
BorderThickness="0"
|
||||
>
|
||||
<ListBox.Resources>
|
||||
<ContextMenu x:Key="CMDialog" Width="200">
|
||||
<MenuItem Header="删除" Click="Delete" Tag="{Binding}"/>
|
||||
</ContextMenu>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="ContextMenu" Value="{StaticResource CMDialog}"/>
|
||||
<Setter Property="Margin" Value="10"/>
|
||||
<Setter Property="Effect" Value="{StaticResource EffectShadow2}"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemsPanel>
|
||||
@@ -40,6 +48,7 @@
|
||||
<WrapPanel Background="Transparent"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border CornerRadius="4" Width="100" Height="100"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using GeekDesk.ViewModel.Temp;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
@@ -16,7 +18,13 @@ namespace GeekDesk.Control.Other
|
||||
|
||||
public GradientBGDialog()
|
||||
{
|
||||
this.DataContext = GradientBGParamList.GradientBGParams;
|
||||
ObservableCollection<GradientBGParam> bgArr = DeepCopyUtil.DeepCopy(GradientBGParamList.GradientBGParams);
|
||||
foreach(var bg in MainWindow.appData.AppConfig.CustomBGParams)
|
||||
{
|
||||
bgArr.Add(bg);
|
||||
}
|
||||
|
||||
this.DataContext = DeepCopyUtil.DeepCopy(bgArr);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
@@ -45,8 +53,38 @@ namespace GeekDesk.Control.Other
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void Delete(object sender, RoutedEventArgs e)
|
||||
{
|
||||
HandyControl.Controls.Growl.Ask("确认删除吗?", isConfirmed =>
|
||||
{
|
||||
if (isConfirmed)
|
||||
{
|
||||
GradientBGParam bg = (GradientBGParam)(((MenuItem)sender).Tag);
|
||||
ObservableCollection<GradientBGParam> bgArr = (ObservableCollection<GradientBGParam>)this.DataContext;
|
||||
bgArr.Remove(bg);
|
||||
MainWindow.appData.AppConfig.CustomBGParams.Remove(bg);
|
||||
for (int i = MainWindow.appData.AppConfig.CustomBGParams.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var cbg = MainWindow.appData.AppConfig.CustomBGParams[i];
|
||||
if (cbg.Id == null)
|
||||
{
|
||||
if (cbg.Color1.Equals(bg.Color1) && cbg.Color2.Equals(bg.Color2))
|
||||
{
|
||||
MainWindow.appData.AppConfig.CustomBGParams.RemoveAt(i);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (cbg.Id.Equals(bg.Id))
|
||||
{
|
||||
MainWindow.appData.AppConfig.CustomBGParams.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
MainWindow.appData.AppConfig.CustomBGParams = DeepCopyUtil.DeepCopy(MainWindow.appData.AppConfig.CustomBGParams);
|
||||
}
|
||||
return true;
|
||||
}, "ConfigWindowAskGrowl");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user