:fire:增加自定义背景保存
This commit is contained in:
30
Converts/TextToColorConverter.cs
Normal file
30
Converts/TextToColorConverter.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
internal class TextToColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string str = value as string;
|
||||
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(str));
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string str = value as string;
|
||||
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(str));
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Converts/ValueConvert.cs
Normal file
32
Converts/ValueConvert.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace GeekDesk.Converts
|
||||
{
|
||||
internal class ValueConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool) {
|
||||
Dictionary<bool, string> dict = (Dictionary<bool, string>)parameter;
|
||||
bool val = (bool)value;
|
||||
return dict[val];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool)
|
||||
{
|
||||
Dictionary<bool, string> dict = (Dictionary<bool, string>)parameter;
|
||||
bool val = (bool)value;
|
||||
return dict[val];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user