Пример #1
0
        public static UNColor FromRgba(nfloat red, nfloat green, nfloat blue, nfloat alpha)
        {
#if __IOS__
            return(UNColor.FromRGBA(red, green, blue, alpha));
#else
            return(UNColor.FromRgba(red, green, blue, alpha));
#endif
        }
        NativeColor ToNativeColor(Color color)
        {
#if __IOS__
            return(NativeColor.FromRGBA(
                       color.Red,
                       color.Green,
                       color.Blue,
                       color.Alpha));
#elif MONOMAC
            return(NativeColor.FromDeviceRgba(
                       color.RedValue,
                       color.GreenValue,
                       color.BlueValue,
                       color.AlphaValue));
#endif
        }
        void SetUnderline()
        {
#if __IOS__
            var color = NativeColor.FromRGBA(
                underlineColor.Red,
                underlineColor.Green,
                underlineColor.Blue,
                underlineColor.Alpha);
            attrs.UnderlineColor = color;
            attrs.UnderlineStyle = underlineStyle == UnderlineStyle.None ?
                                   NSUnderlineStyle.None : NSUnderlineStyle.Single;
#elif MONOMAC
            attrs.Dictionary.SetValue(AppKit.NSStringAttributeKey.UnderlineColor, ToNativeColor(underlineColor));
            var ns = underlineStyle == UnderlineStyle.None ? 0 :
                     (underlineStyle == UnderlineStyle.Single ? 0x1 : 0x9);
            attrs.Dictionary.SetValue(AppKit.NSStringAttributeKey.UnderlineStyle, NSNumber.FromInt32(ns));
#endif
        }
        INativeObject ToNativeColor(Color color)
        {
            if (UseCGColor)
            {
                return(new CGColor(
                           color.RedValue,
                           color.GreenValue,
                           color.BlueValue,
                           color.AlphaValue));
            }
#if __IOS__
            return(NativeColor.FromRGBA(
                       color.Red,
                       color.Green,
                       color.Blue,
                       color.Alpha));
#elif MONOMAC
            return(NativeColor.FromDeviceRgba(
                       color.RedValue,
                       color.GreenValue,
                       color.BlueValue,
                       color.AlphaValue));
#endif
        }