| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- 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;
- }
- }
- }
|