public static Color ToUwp(this global::Xamarin.Forms.Color color) { return(Color.FromArgb((byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255))); }
global::Windows.UI.Color ToWindowsColor(global::Xamarin.Forms.Color color) { return(global::Windows.UI.Color.FromArgb((byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255))); }
public void SetColor(global::Xamarin.Forms.Color color) { drawable.Paint.SetARGB((int)(255 * color.A), (int)(255 * color.R), (int)(255 * color.G), (int)(255 * color.B)); Invalidate(); }
internal static NSAttributedString ToAttributed(this Span span, Element owner, global::Xamarin.Forms.Color defaultForegroundColor) { if (span == null) { return(null); } #if __MOBILE__ UIFont targetFont; if (span.IsDefault()) { targetFont = ((IFontElement)owner).ToUIFont(); } else { targetFont = span.ToUIFont(); } var fgcolor = span.ForegroundColor; if (fgcolor.IsDefault) { fgcolor = defaultForegroundColor; } if (fgcolor.IsDefault) { fgcolor = global::Xamarin.Forms.Color.Black; // as defined by apple docs } return(new NSAttributedString(span.Text, targetFont, fgcolor.ToUIColor(), span.BackgroundColor.ToUIColor())); #else NSFont targetFont; if (span.IsDefault()) { targetFont = ((IFontElement)owner).ToNSFont(); } else { targetFont = span.ToNSFont(); } var fgcolor = span.ForegroundColor; if (fgcolor.IsDefault) { fgcolor = defaultForegroundColor; } if (fgcolor.IsDefault) { fgcolor = Color.Black; // as defined by apple docs } return(new NSAttributedString(span.Text, targetFont, fgcolor.ToNSColor(), span.BackgroundColor.ToNSColor())); #endif }
internal static NSAttributedString ToAttributed(this FormattedString formattedString, Element owner, global::Xamarin.Forms.Color defaultForegroundColor) { if (formattedString == null) { return(null); } var attributed = new NSMutableAttributedString(); foreach (var span in formattedString.Spans) { if (span.Text == null) { continue; } attributed.Append(span.ToAttributed(owner, defaultForegroundColor)); } return(attributed); }
/// <summary> /// Converts from <see cref="T:Color"/> to <see cref="T:OxyColor"/>. /// </summary> /// <param name="c">The color to convert.</param> /// <returns>The converted color.</returns> public static OxyColor ToOxyColor(this global::Xamarin.Forms.Color c) { return(OxyColor.FromArgb((byte)(c.A * 255), (byte)(c.R * 255), (byte)(c.G * 255), (byte)(c.B * 255))); }
/// <summary> /// Parse a Xamarin.Forms.Color to a OKHOSTING.UI.Thickness. /// <para xml:lang="es"> /// Parsea un Xamarin.Forms.Color a un OKHOSTING.UI.Thickness. /// </para> /// </summary> /// <param name="color">Color.</param> public virtual Color Parse(global::Xamarin.Forms.Color color) { return(new Color((int)color.A, (int)color.R, (int)color.G, (int)color.B)); }