Пример #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);
            }
        }
Пример #2
0
        public static void UpdatePlaceholderColor(this MauiTextBox textBox, IPlaceholder placeholder, Brush?defaultPlaceholderColorBrush, Brush?defaultPlaceholderColorFocusBrush)
        {
            Color placeholderColor = placeholder.PlaceholderColor;

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

            BrushHelpers.UpdateColor(placeholderColor, ref defaultPlaceholderColorFocusBrush,
                                     () => textBox.PlaceholderForegroundFocusBrush, brush => textBox.PlaceholderForegroundFocusBrush = brush);
        }
Пример #3
0
        public static void UpdateTextColor(this AutoSuggestBox nativeControl, ISearchBar searchBar, Brush?defaultTextColorBrush, Brush?defaultTextColorFocusBrush, MauiTextBox?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);
        }