added multilang and settings
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CursorLang.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Показывает элемент, только если значение совпадает с параметром.
|
||||
/// Нужен, чтобы настройки курсора и экрана не показывались одновременно.
|
||||
/// </summary>
|
||||
public sealed class EnumToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value?.ToString() == parameter?.ToString() ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
Binding.DoNothing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Цвет в запись вида «#RRGGBB»: альфа не показывается, потому что
|
||||
/// за прозрачность отвечает отдельная настройка.
|
||||
/// </summary>
|
||||
public sealed class ColorToHexConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is Color color ? $"#{color.R:X2}{color.G:X2}{color.B:X2}" : string.Empty;
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
Binding.DoNothing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Цвет в кисть — для образцов палитры в списке.
|
||||
/// </summary>
|
||||
public sealed class ColorToBrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is Color color ? new SolidColorBrush(color) : Brushes.Transparent;
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||
value is SolidColorBrush brush ? brush.Color : Binding.DoNothing;
|
||||
}
|
||||
Reference in New Issue
Block a user