static System.Drawing.Color XamarinColorToDrawingColor(Color xamarinColor)
        {
            var mediaColor = xamarinColor.ToGtkColor();

            return(System.Drawing.Color.FromArgb(GetColorInByte(mediaColor.Red), GetColorInByte(mediaColor.Green),
                                                 GetColorInByte(mediaColor.Blue)));
Ejemplo n.º 2
0
 public static void SetTextColor(this TextBlock textBlock, Color color)
 {
     textBlock.Foreground = new SolidColorBrush(color.ToNative());
 }
Ejemplo n.º 3
0
 public static void SetTextColor(this UIButton button, Color color)
 {
     button.SetTitleColor(color.ToNative(), UIControlState.Normal);
 }
Ejemplo n.º 4
0
 public static global::Windows.UI.Color ToWinColor(this 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)));
 }
Ejemplo n.º 5
0
        public static void ApplyBadge(this BottomNavigationItemView bottomNavigationView, XColor color, string text,
                                      XColor textColor)
        {
            if (!bottomNavigationView.GetChildrenOfType <BadgeFrameLayout>().Any())
            {
                bottomNavigationView.SetClipChildren(false);
                bottomNavigationView.SetClipToPadding(false);

                ImageView imageView = bottomNavigationView.GetChildrenOfType <ImageView>().Single();
                bottomNavigationView.RemoveView(imageView);

                FrameLayout badgeContainerFrameLayout = new FrameLayout(bottomNavigationView.Context)
                {
                    LayoutParameters = new FrameLayout.LayoutParams(LP.WrapContent, LP.WrapContent)
                    {
                        Gravity = GravityFlags.CenterHorizontal
                    }
                };

                badgeContainerFrameLayout.AddView(imageView);

                BadgeFrameLayout badgeContainer = CreateBadgeContainer(bottomNavigationView.Context);
                badgeContainer.TopMargin += 12;

                badgeContainer.Visibility = !string.IsNullOrEmpty(text) ? ViewStates.Visible : ViewStates.Invisible;

                badgeContainer.Background = CreateBadgeBackground(bottomNavigationView.Context, color);
                badgeContainer.AddView(CreateBadgeText(bottomNavigationView.Context, text, textColor));

                badgeContainerFrameLayout.AddView(badgeContainer);

                bottomNavigationView.AddView(badgeContainerFrameLayout);
            }
            else
            {
                BadgeFrameLayout badgeContainer = bottomNavigationView.GetChildrenOfType <BadgeFrameLayout>().Single();
                badgeContainer.Visibility = !string.IsNullOrEmpty(text) ? ViewStates.Visible : ViewStates.Invisible;

                ((PaintDrawable)badgeContainer.Background).Paint.Color = color.IsDefault ? XColor.FromRgb(255, 59, 48).ToAndroid() : color.ToAndroid();

                TextView textView = (TextView)badgeContainer.GetChildAt(0);
                textView.Text = text;
                textView.SetTextColor(textColor.IsDefault ? XColor.White.ToAndroid() : textColor.ToAndroid());
            }
        }
Ejemplo n.º 6
0
 public static Windows.UI.Xaml.Media.Brush ToBrush(this Xamarin.Forms.Color color)
 {
     return(new Windows.UI.Xaml.Media.SolidColorBrush(color.ToWindowsColor()));
 }
 public static Brush ToBrush(this Xamarin.Forms.Color color)
 {
     return(new SolidColorBrush(color.ToWindowsColor()));
 }
 public static Color Convert(Xamarin.Forms.Color xamarinColor)
 {
     return(Color.FromArgb(DoubleToByte(xamarinColor.A), DoubleToByte(xamarinColor.R), DoubleToByte(xamarinColor.G), DoubleToByte(xamarinColor.B)));
 }
Ejemplo n.º 9
0
 public PopupButton(Xamarin.Forms.Color buttonColour, Xamarin.Forms.Color buttonTextColour, string buttonText)
 {
     ButtonColour     = buttonColour;
     ButtonTextColour = buttonTextColour;
     ButtonText       = buttonText;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Convert Xamarin.Forms.Color to Mapsui.Style.Color
 /// </summary>
 /// <param name="color">Color in Xamarin.Forms.Color format </param>
 /// <returns>Color in Mapsui.Styles.Color format</returns>
 public static Styles.Color ToMapsui(this Xamarin.Forms.Color color)
 {
     return(new Styles.Color((int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255), (int)(color.A * 255)));
 }
Ejemplo n.º 11
0
 Color XFColorToWinColor(Xamarin.Forms.Color xfColor)
 {
     return(Color.FromArgb((byte)(xfColor.A * 255), (byte)(xfColor.R * 255), (byte)(xfColor.G * 255), (byte)(xfColor.B * 255)));
 }
Ejemplo n.º 12
0
        /// <summary>
        /// WARNING!  Calling this will cause a crash IF target version of APP is not set to Windows10 FallCreatorsUpdate (10.0.16299.0) or greater
        /// </summary>
        /// <param name="textBlock"></param>
        /// <param name="color"></param>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        public static void ApplyBackgroundColor(this Windows.UI.Xaml.Controls.TextBlock textBlock, Xamarin.Forms.Color color, int startIndex = 0, int length = -1)
        {
            if (TextHeghLighterPresent)
            {
                if (length < 0)
                {
                    if (startIndex != 0)
                    {
                        return;
                    }
                    length  = textBlock.Text.Length;
                    length += textBlock.Inlines.Count;
                }

                var highlighter = new TextHighlighter
                {
                    Background = new Windows.UI.Xaml.Media.SolidColorBrush(color.ToWindowsColor()),
                    //Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(metaFont.TextColor.ToWindowsColor()),
                };
                highlighter.Ranges.Add(new Windows.UI.Xaml.Documents.TextRange
                {
                    StartIndex = startIndex,
                    Length     = length
                });
                textBlock.TextHighlighters.Add(highlighter);
            }
        }
Ejemplo n.º 13
0
 public static Color ToUwp(this Xamarin.Forms.Color color) => Color.FromArgb((byte)(color.A * 255),
                                                                             (byte)(color.R * 255),
                                                                             (byte)(color.G * 255),
                                                                             (byte)(color.B * 255));
Ejemplo n.º 14
0
 /// <summary>
 /// To the color of the UI.
 /// </summary>
 /// <param name="color">The color.</param>
 /// <returns></returns>
 public static Color ToUIColor(this Xamarin.Forms.Color color) => Color.FromArgb((Byte)(color.A * Byte.MaxValue), (Byte)(color.R * Byte.MaxValue), (Byte)(color.G * Byte.MaxValue), (Byte)(color.B * Byte.MaxValue));
Ejemplo n.º 15
0
 public static Color ToLiteColor(this Xamarin.Forms.Color color)
 {
     return(new Color((float)color.R, (float)color.G, (float)color.B, (float)color.A));
 }
Ejemplo n.º 16
0
 public void SetColor(Xamarin.Forms.Color color)
 {
     //Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
     //Window.SetStatusBarColor(Color.Red);
 }
Ejemplo n.º 17
0
 public static void UpdateBorderColor(this Border nativeControl, Xamarin.Forms.Color backgroundColor)
 {
     nativeControl.Background = backgroundColor.ToBrush();
 }
 public object ProvideValue(IServiceProvider serviceProvider)
 {
     return(Color.FromRgb(Red, Green, Blue));
 }
Ejemplo n.º 19
0
 public static Color ToMediaColor(this Xamarin.Forms.Color color)
 {
     return(Color.FromArgb((byte)(color.A * 255), (byte)(color.R * 255), (byte)(color.G * 255), (byte)(color.B * 255)));
 }
Ejemplo n.º 20
0
 private Color(Xamarin.Forms.Color color)
 {
     this.xamarinColor = color;
 }
Ejemplo n.º 21
0
 public static XamColor FromSystemDrawingColor(SysColor color)
 {
     return(XamColor.FromRgba((int)color.R, (int)color.G, (int)color.B, (int)color.A));
 }
Ejemplo n.º 22
0
 public static Windows.UI.Color ToUWPColor(this Color color)
 {
     return((Windows.UI.Color)XamlBindingHelper.ConvertValue(typeof(Windows.UI.Color), color.ToArgbHexString()));
 }
Ejemplo n.º 23
0
        public static void ApplyBadge(this TabLayout.TabView tabView, XColor color, string text,
                                      XColor textColor)
        {
            if (!tabView.GetChildrenOfType <BadgeFrameLayout>().Any())
            {
                tabView.SetClipChildren(false);
                tabView.SetClipToPadding(false);

                TextView tabTextView = tabView.GetChildrenOfType <TextView>().Single();
                tabView.RemoveView(tabTextView);

                FrameLayout badgeContainerFrameLayout = new FrameLayout(tabView.Context)
                {
                    LayoutParameters = new FrameLayout.LayoutParams(LP.WrapContent, LP.WrapContent)
                };

                badgeContainerFrameLayout.AddView(tabTextView);

                BadgeFrameLayout badgeContainer = CreateBadgeContainer(tabView.Context);
                badgeContainer.Visibility = !string.IsNullOrEmpty(text) ? ViewStates.Visible : ViewStates.Invisible;

                badgeContainer.Background = CreateBadgeBackground(tabView.Context, color);
                badgeContainer.AddView(CreateBadgeText(tabView.Context, text, textColor));

                badgeContainerFrameLayout.AddView(badgeContainer);

                tabView.AddView(badgeContainerFrameLayout);
            }
            else
            {
                BadgeFrameLayout badgeContainer = tabView.GetChildrenOfType <BadgeFrameLayout>().Single();
                badgeContainer.Visibility = !string.IsNullOrEmpty(text) ? ViewStates.Visible : ViewStates.Invisible;

                ((PaintDrawable)badgeContainer.Background).Paint.Color = color.IsDefault ? XColor.FromRgb(255, 59, 48).ToAndroid() : color.ToAndroid();

                TextView textView = (TextView)badgeContainer.GetChildAt(0);
                textView.Text = text;
                textView.SetTextColor(textColor.IsDefault ? XColor.White.ToAndroid() : textColor.ToAndroid());
            }
        }
Ejemplo n.º 24
0
        public static string ToArgbHexString(this Color color)
        {
            var colorAsHex = $"#{(int)(color.A * 255):X2}{(int)(color.R * 255):X2}{(int)(color.G * 255):X2}{(int)(color.B * 255):X2}";

            return(colorAsHex);
        }
Ejemplo n.º 25
0
        public static void ApplyTinyBadge(this BottomNavigationItemView bottomNavigationView, XColor textColor)
        {
            if (!bottomNavigationView.GetChildrenOfType <BadgeFrameLayout>().Any())
            {
                bottomNavigationView.SetClipChildren(false);
                bottomNavigationView.SetClipToPadding(false);

                ImageView imageView = bottomNavigationView.GetChildrenOfType <ImageView>().Single();
                bottomNavigationView.RemoveView(imageView);

                FrameLayout badgeContainerFrameLayout = new FrameLayout(bottomNavigationView.Context)
                {
                    LayoutParameters = new FrameLayout.LayoutParams(LP.WrapContent, LP.WrapContent)
                    {
                        Gravity = GravityFlags.CenterHorizontal
                    }
                };

                badgeContainerFrameLayout.AddView(imageView);

                BadgeFrameLayout badgeContainer = CreateBadgeContainer(bottomNavigationView.Context);
                badgeContainer.TopMargin += 16;
                badgeContainer.Visibility = ViewStates.Visible;
                badgeContainer.Background = CreateBadgeBackground(bottomNavigationView.Context, XColor.Transparent);
                badgeContainer.AddView(CreateBadgeText(bottomNavigationView.Context, "●", textColor, 20));

                badgeContainerFrameLayout.AddView(badgeContainer);

                bottomNavigationView.AddView(badgeContainerFrameLayout);
            }
            else
            {
                BadgeFrameLayout badgeContainer = bottomNavigationView.GetChildrenOfType <BadgeFrameLayout>().Single();
                badgeContainer.Visibility = ViewStates.Visible;

                ((PaintDrawable)badgeContainer.Background).Paint.Color = textColor.IsDefault ? XColor.FromRgb(255, 59, 48).ToAndroid() : textColor.ToAndroid();
            }
        }
Ejemplo n.º 26
0
 public static Bitmap AssertContainsColor(this AView view, Xamarin.Forms.Color expectedColor) =>
 AssertContainsColor(view, expectedColor.ToNative());
Ejemplo n.º 27
0
 public static void SetTextColor(this UILabel label, Color color)
 {
     label.TextColor = color.ToNative();
 }
Ejemplo n.º 28
0
 public static Dictionary <string, string> GetColorStringMap(Xamarin.Forms.Color color) => GetColorStringMap(color.ToHex());
Ejemplo n.º 29
0
 public static void SetTextColor(this TextView label, Color color)
 {
     label.SetTextColor(color.ToNative());
 }
Ejemplo n.º 30
0
 public static AK.Color ToAKColor(this Xamarin.Forms.Color color)
 {
     return(Color.FromArgb((int)(255 * color.A), (int)(255 * color.R), (int)(255 * color.G), (int)(255 * color.B)));
 }