From 61be135c8cbb5fe11ebf6484ed6e2e77ef27b421 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 22 May 2023 12:52:30 +0200 Subject: [PATCH] Don't expose protected fields. --- .../ColorSlider/ColorSlider.cs | 6 ++-- src/Avalonia.Controls/Slider.cs | 28 ++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs index a6d9ca459f..31ac18100e 100644 --- a/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs +++ b/src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs @@ -98,10 +98,10 @@ namespace Avalonia.Controls.Primitives int pixelWidth; int pixelHeight; - if (base._track != null) + if (base.Track != null) { - pixelWidth = Convert.ToInt32(base._track.Bounds.Width * scale); - pixelHeight = Convert.ToInt32(base._track.Bounds.Height * scale); + pixelWidth = Convert.ToInt32(base.Track.Bounds.Width * scale); + pixelHeight = Convert.ToInt32(base.Track.Bounds.Height * scale); } else { diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs index b0dff5be79..de3c4023bd 100644 --- a/src/Avalonia.Controls/Slider.cs +++ b/src/Avalonia.Controls/Slider.cs @@ -86,10 +86,10 @@ namespace Avalonia.Controls TickBar.TicksProperty.AddOwner(); // Slider required parts - protected bool _isDragging; - protected Track? _track; - protected Button? _decreaseButton; - protected Button? _increaseButton; + private bool _isDragging; + private Track? _track; + private Button? _decreaseButton; + private Button? _increaseButton; private IDisposable? _decreaseButtonPressDispose; private IDisposable? _decreaseButtonReleaseDispose; private IDisposable? _increaseButtonSubscription; @@ -181,6 +181,26 @@ namespace Avalonia.Controls set { SetValue(TickPlacementProperty, value); } } + /// + /// Gets a value indicating whether the is currently being dragged. + /// + protected bool IsDragging => _isDragging; + + /// + /// Gets the part of the . + /// + protected Track? Track => _track; + + /// + /// Gets the that decreases the value. + /// + protected Button? DecreaseButton => _decreaseButton; + + /// + /// Gets the that increases the value. + /// + protected Button? IncreaseButton => _increaseButton; + /// protected override void OnApplyTemplate(TemplateAppliedEventArgs e) {