static void UpdateIncrement(this MauiSlider nativeSlider, ISlider slider) { double stepping = Math.Min((slider.Maximum - slider.Minimum) / 1000, 1); nativeSlider.StepFrequency = stepping; nativeSlider.SmallChange = stepping; }
public static void UpdateValue(this MauiSlider nativeSlider, ISlider slider) { if (nativeSlider.Value != slider.Value) { nativeSlider.Value = slider.Value; } }
public static void UpdateMaximumTrackColor(this MauiSlider nativeSlider, ISlider slider, Brush?defaultBackgroundColor) { if (slider.MaximumTrackColor.IsDefault()) { nativeSlider.BorderBrush = defaultBackgroundColor; } else { nativeSlider.BorderBrush = slider.MaximumTrackColor.ToNative(); } }
public static void UpdateMinimumTrackColor(this MauiSlider nativeSlider, ISlider slider, Brush?defaultForegroundColor) { if (slider.MinimumTrackColor.IsDefault()) { nativeSlider.Foreground = defaultForegroundColor; } else { nativeSlider.Foreground = slider.MinimumTrackColor.ToNative(); } }
public static void UpdateThumbColor(this MauiSlider nativeSlider, ISlider slider, Brush?defaultThumbColor) { var thumb = nativeSlider?.Thumb; if (thumb == null || slider?.ThumbColor == null || nativeSlider == null) { return; } nativeSlider.ThumbColorOver = slider.ThumbColor.ToNative(); BrushHelpers.UpdateColor(slider.ThumbColor, ref defaultThumbColor, () => thumb.Background, brush => thumb.Background = brush); }
public static async Task UpdateThumbImageSourceAsync(this MauiSlider nativeSlider, ISlider slider, IImageSourceServiceProvider?provider) { var thumbImageSource = slider.ThumbImageSource; if (thumbImageSource == null) { nativeSlider.ThumbImageSource = null; return; } if (provider != null && thumbImageSource != null) { var service = provider.GetRequiredImageSourceService(thumbImageSource); var nativeThumbImageSource = await service.GetImageSourceAsync(thumbImageSource); nativeSlider.ThumbImageSource = nativeThumbImageSource?.Value; } }
static void SwapThumbs(MauiSlider slider) { if (slider.Thumb == null || slider.ImageThumb == null) { return; } if (slider.ThumbImageSource != null) { slider.Thumb.Visibility = UI.Xaml.Visibility.Collapsed; slider.ImageThumb.Visibility = UI.Xaml.Visibility.Visible; } else { slider.Thumb.Visibility = UI.Xaml.Visibility.Visible; slider.ImageThumb.Visibility = UI.Xaml.Visibility.Collapsed; } }
public static void UpdateMaximum(this MauiSlider nativeSlider, ISlider slider) { nativeSlider.Maximum = slider.Maximum; nativeSlider.UpdateIncrement(slider); }