Beispiel #1
0
        public static void UpdateCancelButtonColor(this AutoSuggestBox nativeControl, ISearchBar searchBar, MauiCancelButton?cancelButton, Brush?defaultDeleteButtonBackgroundColorBrush, Brush?defaultDeleteButtonForegroundColorBrush)
        {
            if (cancelButton == null || !cancelButton.IsReady)
            {
                return;
            }

            Color cancelColor = searchBar.CancelButtonColor;

            BrushHelpers.UpdateColor(cancelColor, ref defaultDeleteButtonForegroundColorBrush,
                                     () => cancelButton.ForegroundBrush, brush => cancelButton.ForegroundBrush = brush);

            if (cancelColor == null)
            {
                BrushHelpers.UpdateColor(null, ref defaultDeleteButtonBackgroundColorBrush,
                                         () => cancelButton.BackgroundBrush, brush => cancelButton.BackgroundBrush = brush);
            }
            else
            {
                // Determine whether the background should be black or white (in order to make the foreground color visible)
                var bcolor = cancelColor.ToWindowsColor().GetContrastingColor().ToColor();
                BrushHelpers.UpdateColor(bcolor, ref defaultDeleteButtonBackgroundColorBrush,
                                         () => cancelButton.BackgroundBrush, brush => cancelButton.BackgroundBrush = brush);
            }
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public static void UpdateTextColor(this AutoSuggestBox nativeControl, ISearchBar searchBar, Brush?defaultTextColorBrush, Brush?defaultTextColorFocusBrush, MauiSearchTextBox?queryTextBox)
        {
            if (queryTextBox == null)
            {
                return;
            }

            Color textColor = searchBar.TextColor;

            BrushHelpers.UpdateColor(textColor, ref defaultTextColorBrush,
                                     () => queryTextBox.Foreground, brush => queryTextBox.Foreground = brush);

            BrushHelpers.UpdateColor(textColor, ref defaultTextColorFocusBrush,
                                     () => queryTextBox.ForegroundFocusBrush, brush => queryTextBox.ForegroundFocusBrush = brush);
        }
        public static void UpdatePlaceholderColor(this AutoSuggestBox platformControl, ISearchBar searchBar, Brush?defaultPlaceholderColorBrush, Brush?defaultPlaceholderColorFocusBrush, MauiSearchTextBox?queryTextBox)
        {
            if (queryTextBox == null)
            {
                return;
            }

            Color placeholderColor = searchBar.PlaceholderColor;

            BrushHelpers.UpdateColor(placeholderColor, ref defaultPlaceholderColorBrush,
                                     () => queryTextBox.PlaceholderForegroundBrush, brush => queryTextBox.PlaceholderForegroundBrush = brush);

            BrushHelpers.UpdateColor(placeholderColor, ref defaultPlaceholderColorFocusBrush,
                                     () => queryTextBox.PlaceholderForegroundFocusBrush, brush => queryTextBox.PlaceholderForegroundFocusBrush = brush);
        }