Saradomin-Launcher/Saradomin/Views/Controls/MenuPreview.axaml.cs
2022-05-26 22:09:42 +02:00

131 lines
No EOL
4.1 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using PropertyChanged;
namespace Saradomin.Views.Controls
{
[DoNotNotify]
public class MenuPreview : UserControl
{
public static readonly StyledProperty<SolidColorBrush> BackgroundColorProperty = new(
nameof(BackgroundColor),
typeof(MenuPreview),
new StyledPropertyMetadata<SolidColorBrush>(
new(SolidColorBrush.Parse("#5D5447"))
)
);
public static readonly StyledProperty<SolidColorBrush> TitleBarColorProperty = new(
nameof(TitleBarColor),
typeof(MenuPreview),
new(SolidColorBrush.Parse("#000000"))
);
public static readonly StyledProperty<SolidColorBrush> TitleFontColorProperty = new(
nameof(TitleFontColor),
typeof(MenuPreview),
new(SolidColorBrush.Parse("#FFFFFF"))
);
public static readonly StyledProperty<SolidColorBrush> BorderColorProperty = new(
nameof(TitleFontColor),
typeof(MenuPreview),
new(SolidColorBrush.Parse("#FFFFFF"))
);
public static readonly StyledProperty<bool> UseRuneScape3StyleBorderProperty = new(
nameof(UseRuneScape3StyleBorder),
typeof(MenuPreview),
new(false)
);
private static readonly StyledProperty<Thickness> OldStyleBorderThicknessProperty = new(
nameof(OldStyleBorderThickness),
typeof(MenuPreview),
new(Thickness.Parse("1"))
);
private static readonly StyledProperty<Thickness> RuneScape3StyleBorderThicknessProperty = new(
nameof(RuneScape3StyleBorderThickness),
typeof(MenuPreview),
new(Thickness.Parse("0"))
);
public SolidColorBrush BackgroundColor
{
get => GetValue(BackgroundColorProperty);
set => SetValue(BackgroundColorProperty, value);
}
public SolidColorBrush TitleBarColor
{
get => GetValue(TitleBarColorProperty);
set => SetValue(TitleBarColorProperty, value);
}
public SolidColorBrush TitleFontColor
{
get => GetValue(TitleFontColorProperty);
set => SetValue(TitleFontColorProperty, value);
}
public SolidColorBrush BorderColor
{
get => GetValue(BorderColorProperty);
set => SetValue(BorderColorProperty, value);
}
public bool UseRuneScape3StyleBorder
{
get => GetValue(UseRuneScape3StyleBorderProperty);
set => SetValue(UseRuneScape3StyleBorderProperty, value);
}
private Thickness OldStyleBorderThickness
{
get => GetValue(OldStyleBorderThicknessProperty);
set => SetValue(OldStyleBorderThicknessProperty, value);
}
private Thickness RuneScape3StyleBorderThickness
{
get => GetValue(RuneScape3StyleBorderThicknessProperty);
set => SetValue(RuneScape3StyleBorderThicknessProperty, value);
}
public MenuPreview()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
PropertyChanged += OnPropertyChanged;
}
private void OnPropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
switch (e.Property.Name)
{
case nameof(UseRuneScape3StyleBorder):
{
if (UseRuneScape3StyleBorder)
{
OldStyleBorderThickness = new(0);
RuneScape3StyleBorderThickness = new(1);
}
else
{
OldStyleBorderThickness = new(1);
RuneScape3StyleBorderThickness = new(0);
}
break;
}
}
}
}
}