private async void OnBackColorChoose(Windows.UI.Xaml.Media.Brush brush) { backColorPicker.HideFlyout(); string hex = UIHelper.GetHexColor(brush); await ChangeBackColor(hex); }
public void SetForeground(Windows.UI.Xaml.Media.Brush brush) { if (_currentInputWidget != null) { _currentInputWidget.Foreground = brush.ToWpfBrush(); } }
public static System.Windows.Media.Brush?ToWpfBrush(this Windows.UI.Xaml.Media.Brush brush) { if (brush is Windows.UI.Xaml.Media.SolidColorBrush solidBrush) { return(new System.Windows.Media.SolidColorBrush(solidBrush.Color.ToWpfColor()) { Opacity = solidBrush.Opacity }); } else if (brush is Windows.UI.Xaml.Media.LinearGradientBrush gradientBrush) { return(new System.Windows.Media.LinearGradientBrush(gradientBrush.GradientStops.ToWpfGradientStopCollection(), gradientBrush.StartPoint.ToWpfPoint(), gradientBrush.EndPoint.ToWpfPoint()) { MappingMode = gradientBrush.MappingMode.ToWpfBrushMappingMode(), Transform = gradientBrush.Transform.ToWpfTransform(), RelativeTransform = gradientBrush.RelativeTransform.ToWpfTransform(), }); } else if (brush is Windows.UI.Xaml.Media.ImageBrush imageBrush) { return(new System.Windows.Media.ImageBrush(imageBrush.ImageSource.ToWpfImageSource()) { AlignmentX = imageBrush.AlignmentX.ToWpfAlignmentX(), AlignmentY = imageBrush.AlignmentY.ToWpfAlignmentY(), Opacity = imageBrush.Opacity, Stretch = imageBrush.Stretch.ToWpfStretch(), Transform = imageBrush.Transform.ToWpfTransform(), RelativeTransform = imageBrush.RelativeTransform.ToWpfTransform(), }); } // TODO: Support more brushes. return(null); }
public object Convert(object value, Type targetType, object parameter, string language) { var color = (Color)value; var defaultColorKey = (string)parameter; WBrush defaultBrush = defaultColorKey != null ? (WBrush)Windows.UI.Xaml.Application.Current.Resources[defaultColorKey] : new WSolidColorBrush(Colors.Transparent); return(color == Color.Default ? defaultBrush : color.ToBrush()); }
public Cell(int index, Windows.UI.Xaml.Media.Brush foregroundBrush, GameProcessor gameProcessor, char mark) { m_index = index; m_mark = mark; m_gameProcessor = new WeakReference(gameProcessor); ForegroundBrush = foregroundBrush; m_selectCommand = new DelegateCommand(new ExecuteDelegate(Select), null); }
void ControlOnLoaded(object sender, RoutedEventArgs routedEventArgs) { WireUpFormsVsm(); // The defaults from the control template won't be available // right away; we have to wait until after the template has been applied _defaultBrush = Control.Foreground; UpdateFont(); UpdateTextColor(); }
public Windows.UI.Xaml.Media.Brush toBrush() { var r = (byte)getRedInt(); var g = (byte)getGreenInt(); var b = (byte)getBlueInt(); var a = (byte)getAlphaInt(); Windows.UI.Xaml.Media.Brush v = null; v = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Color.FromArgb(a, r, g, b)); return(v); }
void UpdateSelectedTabColors() { // Retrieve all tab header textblocks var allTabHeaderTextBlocks = Control.GetDescendantsByName <WTextBlock>(TabBarHeaderTextBlockName).ToArray(); if (allTabHeaderTextBlocks.Length != Control.Items.Count) { return; } // Loop through all pages in the Pivot control foreach (Page page in Control.Items) { // Fetch just the textblock for the current page var tabBarTextBlock = allTabHeaderTextBlocks[Control.Items.IndexOf(page)]; // Apply selected or unselected style to the current textblock if (page == Element.CurrentPage) { if (_defaultSelectedColor == null) { _defaultSelectedColor = tabBarTextBlock.Foreground; } if (Element.IsSet(TabbedPage.SelectedTabColorProperty) && Element.SelectedTabColor != Color.Default) { tabBarTextBlock.Foreground = Element.SelectedTabColor.ToBrush(); } else { tabBarTextBlock.Foreground = _defaultSelectedColor; } } else { if (_defaultUnselectedColor == null) { _defaultUnselectedColor = tabBarTextBlock.Foreground; } if (Element.IsSet(TabbedPage.SelectedTabColorProperty) && Element.UnselectedTabColor != Color.Default) { tabBarTextBlock.Foreground = Element.UnselectedTabColor.ToBrush(); } else { tabBarTextBlock.Foreground = _defaultUnselectedColor; } } } }
public static void UpdateBrush(Brush brush, ref WBrush defaultbrush, Func <WBrush> getter, Action <WBrush> setter) { if (Brush.IsNullOrEmpty(brush)) { if (defaultbrush == null) { return; } setter(defaultbrush); return; } if (defaultbrush == null) { defaultbrush = getter(); } setter(brush.ToBrush()); }
/// <summary> /// Handles the logic for setting a Xamarin.Forms Color for a Brush /// while caching the original default brush /// </summary> /// <param name="color">The target Xamarin.Forms.Color</param> /// <param name="defaultbrush">The renderer's cache for the default brush</param> /// <param name="getter">Delegate for retrieving the Control's current Brush</param> /// <param name="setter">Delegate for setting the Control's Brush</param> public static void UpdateColor(Color color, ref WBrush defaultbrush, Func <WBrush> getter, Action <WBrush> setter) { if (color.IsDefault) { if (defaultbrush == null) { return; } setter(defaultbrush); return; } if (defaultbrush == null) { defaultbrush = getter(); } setter(color.ToBrush()); }
internal void RefreshFlyoutBackdrop() { var dismissLayer = ((WRectangle)GetTemplateChild("LightDismissLayer")); if (dismissLayer == null) { return; } if (_defaultBrush == null) { _defaultBrush = dismissLayer.Fill; } if (Brush.IsNullOrEmpty(_flyoutBackdrop)) { dismissLayer.Fill = _defaultBrush; } else { dismissLayer.Fill = _flyoutPlatformBrush ?? _defaultBrush; } }
protected override void OnElementChanged(ElementChangedEventArgs <Forms9Patch.Label> e) { base.OnElementChanged(e); if (e.OldElement != null) { e.OldElement.RendererSizeForWidthAndFontSize -= LabelF9PSize; } if (e.NewElement != null) { if (Control == null) { var nativeControl = new TextBlock(); _defaultNativeFontSize = nativeControl.FontSize; _defaultForeground = nativeControl.Foreground; SetNativeControl(nativeControl); } e.NewElement.RendererSizeForWidthAndFontSize += LabelF9PSize; UpdateColor(Control); UpdateHorizontalAlign(Control); Control.UpdateLineBreakMode(e.NewElement); } }
void UpdateThumbColor() { if (Control == null) { return; } var grid = Control.GetFirstDescendant <WGrid>(); if (grid == null) { return; } var groups = WVisualStateManager.GetVisualStateGroups(grid); foreach (var group in groups) { if (group.Name != ToggleSwitchCommonStates) { continue; } foreach (var state in group.States) { if (state.Name != ToggleSwitchPointerOver) { continue; } foreach (var timeline in state.Storyboard.Children.OfType <ObjectAnimationUsingKeyFrames>()) { var property = Storyboard.GetTargetProperty(timeline); var target = Storyboard.GetTargetName(timeline); if ((target == ToggleSwitchKnobOn) && (property == ToggleSwitchFillMode)) { var frame = timeline.KeyFrames.FirstOrDefault(); if (frame != null) { if (_originalThumbOnBrush == null) { if (frame.Value is Windows.UI.Color color) { _originalOnColorBrush = new WSolidColorBrush(color); } if (frame.Value is WBrush brush) { _originalThumbOnBrush = brush; } } if (!Element.ThumbColor.IsDefault) { var brush = Element.ThumbColor.ToBrush(); brush.Opacity = _originalThumbOnBrush.Opacity; frame.Value = brush; } else { frame.Value = _originalThumbOnBrush; } } break; } } } } if (grid.FindName(ToggleSwitchKnobOn) is WEllipse thumb) { if (_originalThumbOnBrush == null) { _originalThumbOnBrush = thumb.Fill; } if (!Element.ThumbColor.IsDefault) { thumb.Fill = Element.ThumbColor.ToBrush(); } else { thumb.Fill = _originalThumbOnBrush; } } }
void UpdateButtonBackgroundColor(Color value) { Windows.UI.Xaml.Media.Brush brush = value.ToBrush(); Minus.Background = brush; Plus.Background = brush; }
public Cell(int index, Windows.UI.Xaml.Media.Brush foregroundBrush, GameProcessor gameProcessor) : this(index, foregroundBrush, gameProcessor, '\0') { }
/// <summary> /// Initializes a new instance of the <see cref="Brush"/> class, a /// Wpf-enabled wrapper for <see cref="Windows.UI.Xaml.Media.Brush"/> /// </summary> public Brush(Windows.UI.Xaml.Media.Brush instance) { // REVIEW: Guard for NULL UwpInstance = instance; }
void UpdateOnColor() { if (Control == null) { return; } var grid = Control.GetFirstDescendant <WGrid>(); if (grid == null) { return; } var groups = WVisualStateManager.GetVisualStateGroups(grid); foreach (var group in groups) { if (group.Name != ToggleSwitchCommonStates) { continue; } foreach (var state in group.States) { if (state.Name != ToggleSwitchPointerOver) { continue; } foreach (var timeline in state.Storyboard.Children.OfType <ObjectAnimationUsingKeyFrames>()) { var property = Storyboard.GetTargetProperty(timeline); var target = Storyboard.GetTargetName(timeline); if (target == ToggleSwitchKnobBounds && property == ToggleSwitchFillMode) { var frame = timeline.KeyFrames.FirstOrDefault(); if (frame != null) { if (_originalOnHoverColor == null) { if (frame.Value is WColor color) { _originalOnHoverColor = color; } if (frame.Value is SolidColorBrush solidColorBrush) { _originalOnHoverColor = solidColorBrush; } } if (!Element.OnColor.IsDefault) { frame.Value = new WSolidColorBrush(Element.OnColor.ToWindowsColor()) { Opacity = _originalOnHoverColor is WSolidColorBrush originalOnHoverBrush ? originalOnHoverBrush.Opacity : 1 }; } else { frame.Value = _originalOnHoverColor; } } break; } } } } var rect = Control.GetDescendantsByName <WRectangle>(ToggleSwitchKnobBounds).FirstOrDefault(); if (rect != null) { if (_originalOnColorBrush == null) { _originalOnColorBrush = rect.Fill; } if (!Element.OnColor.IsDefault) { rect.Fill = new WSolidColorBrush(Element.OnColor.ToWindowsColor()); } else { rect.Fill = _originalOnColorBrush; } } }
public static bool IsOpaqueSolidColorBrush(this Windows.UI.Xaml.Media.Brush brush) { return(default(bool)); }
public static bool IsEqualTo(this Windows.UI.Xaml.Media.Brush brush, Windows.UI.Xaml.Media.Brush otherBrush) { return(default(bool)); }