Esempio n. 1
0
        public static Color ToEtoWithAppearance(this NSColor color, bool calibrated = true)
        {
            if (color == null)
            {
                return(Colors.Transparent);
            }
            if (!MacVersion.IsAtLeast(10, 9))
            {
                return(color.ToEto(calibrated));
            }

            // use the current appearance to get the proper RGB values (it can be different than when the application started).
            NSAppearance saved      = NSAppearance.CurrentAppearance;
            var          appearance = NSApplication.SharedApplication.MainWindow?.EffectiveAppearance;

            if (appearance != null)
            {
                NSAppearance.CurrentAppearance = appearance;
            }

            var result = color.ToEto(calibrated);

            NSAppearance.CurrentAppearance = saved;
            return(result);
        }
Esempio n. 2
0
 public static NSColor ToNSUI(this Color color)
 {
     if (color.ControlObject is NSColor nscolor)
     {
         return(nscolor);
     }
     if (color.ControlObject is CGColor cgcolor && MacVersion.IsAtLeast(10, 8))
     {
         return(NSColor.FromCGColor(cgcolor));
     }
     return(NSColor.FromDeviceRgba(color.R, color.G, color.B, color.A));
 }
Esempio n. 3
0
        public static NSColor ToNS(this CGColor color)
        {
            if (color == null)
            {
                return(null);
            }

            if (MacVersion.IsAtLeast(10, 8))
            {
                return(NSColor.FromCGColor(color));
            }

            return(NSColor.FromColorSpace(new NSColorSpace(color.ColorSpace), color.Components));
        }