예제 #1
0
        static void UpdateIncrement(this MauiSlider nativeSlider, ISlider slider)
        {
            double stepping = Math.Min((slider.Maximum - slider.Minimum) / 1000, 1);

            nativeSlider.StepFrequency = stepping;
            nativeSlider.SmallChange   = stepping;
        }
예제 #2
0
 public static void UpdateValue(this MauiSlider nativeSlider, ISlider slider)
 {
     if (nativeSlider.Value != slider.Value)
     {
         nativeSlider.Value = slider.Value;
     }
 }
예제 #3
0
 public static void UpdateMaximumTrackColor(this MauiSlider nativeSlider, ISlider slider, Brush?defaultBackgroundColor)
 {
     if (slider.MaximumTrackColor.IsDefault())
     {
         nativeSlider.Background = defaultBackgroundColor;
     }
     else
     {
         nativeSlider.Background = slider.MaximumTrackColor.ToNative();
     }
 }
예제 #4
0
        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;
            }
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
 public static void UpdateMaximum(this MauiSlider nativeSlider, ISlider slider)
 {
     nativeSlider.Maximum = slider.Maximum;
     nativeSlider.UpdateIncrement(slider);
 }