Пример #1
0
 /// <summary>
 /// Transforms every single part of a geomtry-based drawing.
 /// </summary>
 /// <param name="drawing"></param>
 /// <param name="theme"></param>
 private static void TransformParts(Media.Drawing drawing, IconTheme theme)
 {
     if (drawing is GeometryDrawing gd && gd.Brush is SolidColorBrush s)
     {
         var hsl      = s.Color.ToHslColor();
         var newL     = TransformLuminosity(hsl, theme.BackgroundLuminosity);
         var newColor = new HslColor(hsl.Hue, hsl.Saturation, newL, hsl.Alpha).ToColor();
         s.Color = newColor;
     }
Пример #2
0
        /// <summary>
        /// This method transforms colors of a geometry-based drawing to a desired theme.
        /// </summary>
        /// <param name="drawing">The input drawing</param>
        /// <param name="theme">The desired theme</param>
        /// <param name="checkLuminosity">If check uminosity is on, a dark drawing only can be converted to a light one, this is specially used
        /// when you don't want your dark icon reveted to light when called twice</param>
        /// <returns>A new drawing with converted colors</returns>
        public static Media.Drawing TransformDrawing(Media.Drawing drawing, IconTheme theme, bool checkLuminosity = true)
        {
            var isDark = ThemeController.GetIsDark(drawing);

            if (checkLuminosity)
            {
                if (isDark == IsDark(theme.BackgroundLuminosity))
                {
                    return(drawing);
                }
            }
            var newDrawing = drawing.CloneCurrentValue();

            TransformParts(newDrawing, theme);
            ThemeController.SetIsDark(newDrawing, !isDark);
            return(newDrawing);
        }