A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

90 lines
3.0 KiB

using Avalonia.Controls;
using Avalonia.Media;
namespace ControlCatalog.Pages
{
public partial class CommandBarCustomizationPage : UserControl
{
public CommandBarCustomizationPage()
{
InitializeComponent();
}
private void OnBgPresetChanged(object? sender, SelectionChangedEventArgs e)
{
if (LiveBar == null)
return;
switch (BgPresetCombo.SelectedIndex)
{
case 1:
LiveBar.Background = new SolidColorBrush(Color.Parse("#0078D4"));
break;
case 2:
LiveBar.Background = new SolidColorBrush(Color.Parse("#1C1C1E"));
break;
case 3:
LiveBar.Background = new LinearGradientBrush
{
StartPoint = new Avalonia.RelativePoint(0, 0, Avalonia.RelativeUnit.Relative),
EndPoint = new Avalonia.RelativePoint(1, 0, Avalonia.RelativeUnit.Relative),
GradientStops =
{
new GradientStop(Color.Parse("#3F51B5"), 0),
new GradientStop(Color.Parse("#E91E63"), 1)
}
};
break;
case 4:
LiveBar.Background = Brushes.Transparent;
break;
default:
LiveBar.ClearValue(BackgroundProperty);
break;
}
}
private void OnFgChanged(object? sender, SelectionChangedEventArgs e)
{
if (LiveBar == null)
return;
switch (FgCombo.SelectedIndex)
{
case 1:
LiveBar.Foreground = Brushes.White;
break;
case 2:
LiveBar.Foreground = Brushes.Black;
break;
default:
LiveBar.ClearValue(ForegroundProperty);
break;
}
}
private void OnRadiusChanged(object? sender, Avalonia.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
if (LiveBar == null)
return;
var r = (int)RadiusSlider.Value;
LiveBar.CornerRadius = new Avalonia.CornerRadius(r);
RadiusLabel.Text = $"{r}";
}
private void OnBorderChanged(object? sender, Avalonia.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
if (LiveBar == null)
return;
var t = (int)BorderSlider.Value;
LiveBar.BorderThickness = new Avalonia.Thickness(t);
BorderLabel.Text = $"{t}";
if (t > 0)
LiveBar.BorderBrush = Brushes.Gray;
else
LiveBar.BorderBrush = null;
}
}
}