using System; using Windows.UI.Xaml.Media; #if WINDOWS_UWP namespace Xamarin.Forms.Platform.UWP #else namespace Xamarin.Forms.Platform.WinRT #endif { internal static class BrushHelpers { /// /// Handles the logic for setting a Xamarin.Forms Color for a Brush /// while caching the original default brush /// /// The target Xamarin.Forms.Color /// The renderer's cache for the default brush /// Delegate for retrieving the Control's current Brush /// Delegate for setting the Control's Brush public static void UpdateColor(Color color, ref Brush defaultbrush, Func getter, Action setter) { if (color.IsDefault) { if (defaultbrush == null) { return; } setter(defaultbrush); return; } if (defaultbrush == null) { defaultbrush = getter(); } setter(color.ToBrush()); } } }