コード例 #1
0
        Color GetNativeTextColor(ButtonHandler buttonHandler)
        {
            int    currentTextColorInt = GetNativeButton(buttonHandler).CurrentTextColor;
            AColor currentTextColor    = new AColor(currentTextColorInt);

            return(currentTextColor.ToColor());
        }
コード例 #2
0
        Color GetNativeTextColor(EntryHandler entryHandler)
        {
            int    currentTextColorInt = GetNativeEntry(entryHandler).CurrentTextColor;
            AColor currentTextColor    = new AColor(currentTextColorInt);

            return(currentTextColor.ToColor());
        }
コード例 #3
0
            void DrawBackground(ACanvas canvas, int width, int height, float cornerRadius, bool pressed)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (var path = new Path())
                        using (Path.Direction direction = Path.Direction.Cw)
                            using (Paint.Style style = Paint.Style.Fill)
                                using (var rect = new RectF(
                                           _bounds + _boundsDiff + _contentBounds,
                                           _bounds + _boundsDiff + _contentBounds,
                                           width - (_bounds + _boundsDiff + _contentBounds),
                                           height - (_bounds + _boundsDiff + _contentBounds)))
                                {
                                    float rx = _convertToPixels(cornerRadius);
                                    float ry = _convertToPixels(cornerRadius);
                                    path.AddRoundRect(rect, rx, ry, direction);

                                    global::Android.Graphics.Color color = _frame.BackgroundColor.ToAndroid();


                                    paint.SetStyle(style);
                                    paint.Color = color;

                                    canvas.DrawPath(path, paint);
                                }
            }
コード例 #4
0
        void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed)
        {
            using (Paint paint = new Paint {
                AntiAlias = true
            })
                using (Path.Direction direction = Path.Direction.Cw)
                    using (Paint.Style style = Paint.Style.Fill)
                    {
                        Path path = new Path();

                        using (RectF rect = new RectF(0, 0, width, height))
                        {
                            float topLeft     = this._convertToPixels(cornerRadius.TopLeft);
                            float topRight    = this._convertToPixels(cornerRadius.TopRight);
                            float bottomRight = this._convertToPixels(cornerRadius.BottomRight);
                            float bottomLeft  = this._convertToPixels(cornerRadius.BottomLeft);

                            if (!this._corneredContentView.HasShadow)
                            {
                                path.AddRoundRect(rect, new float[] { topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft }, direction);
                            }
                            else
                            {
                                path.AddRoundRect(rect, new float[] { topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft }, direction);
                            }
                        }

                        global::Android.Graphics.Color color = this._corneredContentView.BackgroundColor.ToAndroid();
                        paint.SetStyle(style);
                        paint.Color = color;

                        canvas.DrawPath(path, paint);
                    }
        }
コード例 #5
0
ファイル: AndroidBitmap.cs プロジェクト: saizant/MonoAGS
        public IBitmap ApplyArea(IArea area)
        {
            //todo: performance can be improved by only creating a bitmap the size of the area, and not the entire background.
            //This will require to change the rendering as well to offset the location
            byte   zero   = (byte)0;
            Bitmap output = Bitmap.CreateBitmap(Width, Height, Bitmap.Config.Argb8888);

            using (FastBitmap inBmp = new FastBitmap(_bitmap))
            {
                using (FastBitmap outBmp = new FastBitmap(output, true))
                {
                    for (int y = 0; y < Height; y++)
                    {
                        int bitmapY = Height - y - 1;
                        for (int x = 0; x < Width; x++)
                        {
                            global::Android.Graphics.Color color = inBmp.GetPixel(x, bitmapY);
                            byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero;
                            outBmp.SetPixel(x, bitmapY, new global::Android.Graphics.Color(color.R, color.G, color.B, alpha));
                        }
                    }
                }
            }

            return(new AndroidBitmap(output, _graphics));
        }
コード例 #6
0
        static void n_SetSomeColor_I(IntPtr jnienv, IntPtr native__this, int native_newvalue)
        {
            var __this   = global::Java.Lang.Object.GetObject <global::Xamarin.Test.SomeObject> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
            var newvalue = new global::Android.Graphics.Color(native_newvalue);

            __this.SomeColor = newvalue;
        }
コード例 #7
0
            void DrawBackground(ACanvas canvas, int width, int height, float cornerRadius, bool pressed)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (var path = new APath())
                        using (APath.Direction direction = APath.Direction.Cw)
                            using (Paint.Style style = Paint.Style.Fill)
                                using (var rect = new RectF(0, 0, width, height))
                                {
                                    float rx = _convertToPixels(cornerRadius);
                                    float ry = _convertToPixels(cornerRadius);
                                    path.AddRoundRect(rect, rx, ry, direction);

                                    paint.SetStyle(style);

                                    if (!Brush.IsNullOrEmpty(_frame.Background))
                                    {
                                        Brush background = _frame.Background;
                                        paint.UpdateBackground(background, height, width);
                                    }
                                    else
                                    {
                                        global::Android.Graphics.Color color = _frame.BackgroundColor.ToAndroid();
                                        paint.Color = color;
                                    }

                                    canvas.DrawPath(path, paint);
                                }
            }
コード例 #8
0
        private static Color ToXamarinColor(int color)
        {
            var androidColor = new global::Android.Graphics.Color(color);

            return(new Color(androidColor.R * OneOver255, androidColor.G * OneOver255, androidColor.B * OneOver255,
                             androidColor.A * OneOver255));
        }
コード例 #9
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);

            global::Xamarin.Auth.CustomTabsConfiguration.ActionLabel                = null;
            global::Xamarin.Auth.CustomTabsConfiguration.MenuItemTitle              = null;
            global::Xamarin.Auth.CustomTabsConfiguration.AreAnimationsUsed          = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsShowTitleUsed            = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsUrlBarHidingUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsCloseButtonIconUsed      = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionButtonUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionBarToolbarIconUsed = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsDefaultShareMenuItemUsed = false;

            global::Android.Graphics.Color color_xamarin_blue;
            color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);
            global::Xamarin.Auth.CustomTabsConfiguration.ToolbarColor = color_xamarin_blue;

            MobileCenter.Start("b24cccf0-0f70-42cd-b94e-a6c61dbe9add", typeof(Analytics), typeof(Crashes));

            LoadApplication(new App());
        }
コード例 #10
0
        public static Bitmap AssertColorAtPoint(this AView view, AColor expectedColor, int x, int y)
        {
            var bitmap = view.ToBitmap();

            Assert.Equal(bitmap.ColorAtPoint(x, y), expectedColor);

            return(bitmap);
        }
コード例 #11
0
 public override void SetTitleColor(global::Android.Graphics.Color textColor)
 {
     if (id_setTitleColor_I == IntPtr.Zero)
     {
         id_setTitleColor_I = JNIEnv.GetMethodID(class_ref, "setTitleColor", "(I)V");
     }
     JNIEnv.CallVoidMethod(Handle, id_setTitleColor_I, new JValue(textColor.ToArgb()));
 }
コード例 #12
0
 public void SetBackgroundColor([global::Android.Runtime.GeneratedEnum] global::Android.Graphics.Color color)
 {
     if (id_setBackgroundColor_I == IntPtr.Zero)
     {
         id_setBackgroundColor_I = JNIEnv.GetMethodID(class_ref, "setBackgroundColor", "(I)V");
     }
     JNIEnv.CallVoidMethod(Handle, id_setBackgroundColor_I, new JValue(color.ToArgb()));
 }
コード例 #13
0
 public PlatformColor(byte r, byte g, byte b)
 {
     Color = new global::UIKit.UIColor(
         (float)(r / 255.0),
         (float)(g / 255.0),
         (float)(b / 255.0),
         1f
         );
 }
コード例 #14
0
        public static Color AsColor(this global::Android.Graphics.Color target)
        {
            var r = (int)target.R;
            var g = (int)target.G;
            var b = (int)target.B;
            var a = (int)target.A;

            return(new Color(r, g, b, a));
        }
コード例 #15
0
        public static Color ToColor(this global::Android.Graphics.Color color)
        {
            var r = color.R / 255f;
            var g = color.G / 255f;
            var b = color.B / 255f;
            var a = color.A / 255f;

            return(new Color(r, g, b, a));
        }
コード例 #16
0
        //=================================================================

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //=================================================================
            //  switching between
            //      embbedded browsers (WebView)
            //  and
            //      Native UI ([Chrome] Custom Tabs)
            //  read the docs about pros and cons
            test_native_ui = true;
            //=================================================================

            ListAdapter = new ArrayAdapter <String>(this, global::Android.Resource.Layout.SimpleListItem1, provider_list);

            // Step 2.2 Customizing the UI - Native UI [OPTIONAL]
            // [Chrome] Custom Tabs WarmUp and prefetch
            custom_tab_activity_helper = new global::Android.Support.CustomTabs.Chromium.SharedUtilities.CustomTabActivityHelper();

            //-----------------------------------------------------------------------------------------------
            // Xamarin.Auth initialization

            // User-Agent tweaks for Embedded WebViews (UIWebView and WKWebView)
            global::Xamarin.Auth.WebViewConfiguration.Android.UserAgent = "moljac++";

            // Xamarin.Auth CustomTabs Initialization/Customisation
            global::Xamarin.Auth.CustomTabsConfiguration.ActionLabel                = null;
            global::Xamarin.Auth.CustomTabsConfiguration.MenuItemTitle              = null;
            global::Xamarin.Auth.CustomTabsConfiguration.AreAnimationsUsed          = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsShowTitleUsed            = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsUrlBarHidingUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsCloseButtonIconUsed      = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionButtonUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionBarToolbarIconUsed = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsDefaultShareMenuItemUsed = false;

            global::Android.Graphics.Color color_xamarin_blue;
            color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);
            global::Xamarin.Auth.CustomTabsConfiguration.ToolbarColor = color_xamarin_blue;


            // ActivityFlags for tweaking closing of CustomTabs
            // please report findings!
            global::Xamarin.Auth.CustomTabsConfiguration.
            ActivityFlags =
                global::Android.Content.ActivityFlags.NoHistory
                |
                global::Android.Content.ActivityFlags.SingleTop
                |
                global::Android.Content.ActivityFlags.NewTask
            ;

            global::Xamarin.Auth.CustomTabsConfiguration.IsWarmUpUsed   = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsPrefetchUsed = true;
            //-----------------------------------------------------------------------------------------------
            return;
        }
コード例 #17
0
        public RectBorder(Int32 width, global::Android.Graphics.Color BorderColor, global::Android.Graphics.Color backcolor)
        {
            this._backcolor = backcolor;

            // border color
            this._paint             = new global::Android.Graphics.Paint();
            this._paint.Color       = BorderColor;
            this._paint.StrokeWidth = width;
            this._paint.SetStyle(global::Android.Graphics.Paint.Style.Stroke);
        }
コード例 #18
0
		public RectBorder (Int32 width, global::Android.Graphics.Color BorderColor, global::Android.Graphics.Color backcolor)
		{
			this._backcolor = backcolor;

			// border color
			this._paint = new global::Android.Graphics.Paint();
			this._paint.Color = BorderColor;
			this._paint.StrokeWidth = width;
			this._paint.SetStyle (global::Android.Graphics.Paint.Style.Stroke);
		}
コード例 #19
0
 public SpinnerAdapter(Activity context, IList <string> items,
                       string Title, float FSize, global::Android.Graphics.Color backcolor, global::Android.Graphics.Color selectedColor) : base()
 {
     this._Items             = items;
     this._Context           = context;
     this._Title             = Title;
     this._FontSize          = FSize;
     this._SelectedBackColor = backcolor;
     this._SelectedTextColor = selectedColor;
     this._NoSelectedColor   = false;
 }
コード例 #20
0
        protected void InitializeNativeUICustomTabs()
        {
            // Step 2.2 Customizing the UI - Native UI [OPTIONAL]
            // [Chrome] Custom Tabs WarmUp and prefetch
            custom_tab_activity_helper = new global::Android.Support.CustomTabs.Chromium.SharedUtilities.CustomTabActivityHelper();

            //-----------------------------------------------------------------------------------------------
            // Xamarin.Auth initialization

            // User-Agent tweaks for Embedded WebViews (UIWebView and WKWebView)
            global::Xamarin.Auth.WebViewConfiguration.Android.UserAgent = "moljac++";

            //................................................................
            // Xamarin.Auth CustomTabs Initialization/Customisation
            // Note this API is still under development and subject to changes!

            // CustomTabs closing Toast message (null to turn it of, otherwise define it here)
            global::Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = null;
            //global::Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = "Closing? Let us know";

            global::Xamarin.Auth.CustomTabsConfiguration.ActionLabel                = null;
            global::Xamarin.Auth.CustomTabsConfiguration.MenuItemTitle              = null;
            global::Xamarin.Auth.CustomTabsConfiguration.AreAnimationsUsed          = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsShowTitleUsed            = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsUrlBarHidingUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsCloseButtonIconUsed      = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionButtonUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionBarToolbarIconUsed = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsDefaultShareMenuItemUsed = false;

            global::Android.Graphics.Color color_xamarin_blue;
            color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);
            global::Xamarin.Auth.CustomTabsConfiguration.ToolbarColor = color_xamarin_blue;
            //................................................................


            // ActivityFlags for tweaking closing of CustomTabs
            // please report findings!
            global::Xamarin.Auth.CustomTabsConfiguration.
            ActivityFlags =
                global::Android.Content.ActivityFlags.NoHistory
                |
                global::Android.Content.ActivityFlags.SingleTop
                |
                global::Android.Content.ActivityFlags.NewTask
            ;

            global::Xamarin.Auth.CustomTabsConfiguration.IsWarmUpUsed   = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsPrefetchUsed = true;
            //-----------------------------------------------------------------------------------------------

            return;
        }
コード例 #21
0
        static CustomTabsConfiguration()
        {
            color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);

            CustomTabsClosingMessage =
                "If CustomTabs Login Screen does not close automatically"
                + System.Environment.NewLine +
                "close CustomTabs by navigating back to the app."
            ;

            return;
        }
コード例 #22
0
        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            //-----------------------------------------------------------------------------------------------
            // Xamarin.Auth initialization

            // Presenters Initialization
            global::Xamarin.Auth.Presenters.XamarinAndroid.AuthenticationConfiguration.Init(this, bundle);

            // User-Agent tweaks for Embedded WebViews
            global::Xamarin.Auth.WebViewConfiguration.Android.UserAgent = "moljac++";

            // Xamarin.Auth CustomTabs Initialization/Customisation
            global::Xamarin.Auth.CustomTabsConfiguration.ActionLabel                = null;
            global::Xamarin.Auth.CustomTabsConfiguration.MenuItemTitle              = null;
            global::Xamarin.Auth.CustomTabsConfiguration.AreAnimationsUsed          = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsShowTitleUsed            = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsUrlBarHidingUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsCloseButtonIconUsed      = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionButtonUsed         = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsActionBarToolbarIconUsed = false;
            global::Xamarin.Auth.CustomTabsConfiguration.IsDefaultShareMenuItemUsed = false;

            global::Android.Graphics.Color color_xamarin_blue;
            color_xamarin_blue = new global::Android.Graphics.Color(0x34, 0x98, 0xdb);
            global::Xamarin.Auth.CustomTabsConfiguration.ToolbarColor = color_xamarin_blue;


            // ActivityFlags for tweaking closing of CustomTabs
            // please report findings!
            global::Xamarin.Auth.CustomTabsConfiguration.
            ActivityFlags =
                global::Android.Content.ActivityFlags.NoHistory
                |
                global::Android.Content.ActivityFlags.SingleTop
                |
                global::Android.Content.ActivityFlags.NewTask
            ;

            global::Xamarin.Auth.CustomTabsConfiguration.IsWarmUpUsed   = true;
            global::Xamarin.Auth.CustomTabsConfiguration.IsPrefetchUsed = true;



            //-----------------------------------------------------------------------------------------------
            LoadApplication(new App());
        }
コード例 #23
0
        public void SetColor(Color c)
        {
            if (!Color.AreEqual(c, _lastColor))
            {
                _lastColor = c;

                var ac = new global::Android.Graphics.Color(c.Red, c.Green, c.Blue, c.Alpha);

                _paints.Stroke.Color = ac;
                _paints.Fill.Color   = ac;
                _paints.Text.Color   = ac;
            }
        }
コード例 #24
0
        protected override Dialog OnCreateDialog(int id)
        {
            Console.WriteLine("Opening Color Dialog (" + id + ")");

            AlertDialog.Builder builder  = new AlertDialog.Builder(this);
            LayoutInflater      inflater = LayoutInflater.FromContext(this);

            ViewGroup layout = (ViewGroup)inflater.Inflate(Resource.Layout.ColorDialogView, null);

            builder.SetView(layout);

            var colorPicker = layout.FindViewById <ColorPicker> (Resource.Id.color_picker);

            SVBar sv = layout.FindViewById <SVBar> (Resource.Id.sv_bar);
            var   cb = layout.FindViewById <CheckBox> (Resource.Id.chk_random);

            sv.HorizontalOrientation = false;
            sv.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.SetBackgroundColor(global::Android.Graphics.Color.Transparent);
            colorPicker.addSVBar(sv);
            colorPicker.ColorChanged += (s, c) => {
                global::Android.Graphics.Color cd = new global::Android.Graphics.Color((int)Util.MakePastel(c));
                layout.SetBackgroundColor(cd);
                sv.SetBackgroundColor(cd);
                colorPicker.SetBackgroundColor(cd);
            };

            AlertDialog d = builder.Create();

            d.KeyPress += (sender, e) => {
                Console.WriteLine(e.KeyCode + " " + e.Handled);
                d.Dismiss();
            };
            d.SetButton("add", (sender, e) => {
                Console.WriteLine(e.Which);
                if (cb.Checked)
                {
                    ViewModel.AddColor(new Color(0, 1, 0, 1, 0, 1));
                }
                else
                {
                    ViewModel.AddColor(colorPicker.CurrentColor);
                }
            });
            d.SetButton2("cancel", (sender, e) => {
                Console.WriteLine(e.Which);
                d.Dismiss();
            });
            return(d);
        }
コード例 #25
0
        Color GetNativeTextColor(SearchBarHandler searchBarHandler)
        {
            var searchView = GetNativeSearchBar(searchBarHandler);
            var editText   = searchView.GetChildrenOfType <EditText>().FirstOrDefault();

            if (editText != null)
            {
                int    currentTextColorInt = editText.CurrentTextColor;
                AColor currentTextColor    = new AColor(currentTextColorInt);
                return(currentTextColor.ToColor());
            }

            return(Colors.Transparent);
        }
コード例 #26
0
        void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (Path.Direction direction = Path.Direction.Cw)
                    using (Paint.Style style = Paint.Style.Fill)
                    {
                        var path = new Path();

                        if (_pancake.Sides != 4)
                        {
                            path = DrawingExtensions.CreatePolygonPath(width, height, _pancake.Sides, _pancake.CornerRadius.TopLeft, _pancake.OffsetAngle);
                        }
                        else
                        {
                            float topLeft     = _convertToPixels(cornerRadius.TopLeft);
                            float topRight    = _convertToPixels(cornerRadius.TopRight);
                            float bottomRight = _convertToPixels(cornerRadius.BottomRight);
                            float bottomLeft  = _convertToPixels(cornerRadius.BottomLeft);

                            path = DrawingExtensions.CreateRoundedRectPath(width, height, topLeft, topRight, bottomRight, bottomLeft);
                        }

                        if (_pancake.BackgroundGradientStops != null && _pancake.BackgroundGradientStops.Any())
                        {
                            // A range of colors is given. Let's add them.
                            var orderedStops = _pancake.BackgroundGradientStops.OrderBy(x => x.Offset).ToList();
                            var colors       = orderedStops.Select(x => x.Color.ToAndroid().ToArgb()).ToArray();
                            var locations    = orderedStops.Select(x => x.Offset).ToArray();

                            var shader = new LinearGradient((float)(canvas.Width * _pancake.BackgroundGradientStartPoint.X),
                                                            (float)(canvas.Height * _pancake.BackgroundGradientStartPoint.Y),
                                                            (float)(canvas.Width * _pancake.BackgroundGradientEndPoint.X),
                                                            (float)(canvas.Height * _pancake.BackgroundGradientEndPoint.Y),
                                                            colors, locations, Shader.TileMode.Clamp);

                            paint.SetShader(shader);
                        }
                        else
                        {
                            global::Android.Graphics.Color color = _pancake.BackgroundColor.ToAndroid();
                            paint.SetStyle(style);
                            paint.Color = color;
                        }

                        canvas.DrawPath(path, paint);
                    }
        }
コード例 #27
0
        public Style GetStyle(int style)
        {
            var result = new Style(typeof(Label));

            double fontSize   = 0;
            string fontFamily = null;

            global::Android.Graphics.Color defaultColor = global::Android.Graphics.Color.Argb(0, 0, 0, 0);
            global::Android.Graphics.Color androidColor = defaultColor;

            var context = System.Maui.Maui.ApplicationContext;

            using (var value = new TypedValue())
            {
                if (context.Theme.ResolveAttribute(style, value, true))
                {
                    var styleattrs = new[] { global::Android.Resource.Attribute.TextSize, global::Android.Resource.Attribute.FontFamily, global::Android.Resource.Attribute.TextColor };
                    using (TypedArray array = context.ObtainStyledAttributes(value.ResourceId, styleattrs))
                    {
                        fontSize     = context.FromPixels(array.GetDimensionPixelSize(0, -1));
                        fontFamily   = array.GetString(1);
                        androidColor = array.GetColor(2, defaultColor);
                    }
                }
            }

            if (fontSize > 0)
            {
                result.Setters.Add(new Setter {
                    Property = Label.FontSizeProperty, Value = fontSize
                });
            }

            if (!string.IsNullOrEmpty(fontFamily))
            {
                result.Setters.Add(new Setter {
                    Property = Label.FontFamilyProperty, Value = fontFamily
                });
            }

            if (androidColor != defaultColor)
            {
                result.Setters.Add(new Setter {
                    Property = Label.TextColorProperty, Value = Color.FromRgba(androidColor.R, androidColor.G, androidColor.B, androidColor.A)
                });
            }

            return(result);
        }
コード例 #28
0
        private void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (var path = PolygonUitls.RegularPolygonPath(width, height, _polygonFrame.Sides, _polygonFrame.CornerRadius, 0, _polygonFrame.OffsetAngle))
                    using (Paint.Style style = Paint.Style.Fill)
                    {
                        global::Android.Graphics.Color color = _polygonFrame.BackgroundColor.ToAndroid();
                        paint.SetStyle(style);
                        paint.Color = color;

                        canvas.DrawPath(path, paint);
                    }
        }
コード例 #29
0
        public static global::Android.Graphics.Color AsColorMultiplyAlpha(this Color target, float alpha)
        {
            var r = (int)(target.Red * 255f);
            var g = (int)(target.Green * 255f);
            var b = (int)(target.Blue * 255f);
            var a = (int)(target.Alpha * alpha * 255f);

            if (a > 255)
            {
                a = 255;
            }

            var color = new global::Android.Graphics.Color(r, g, b, a);

            return(color);
        }
コード例 #30
0
            void DrawBackground(ACanvas canvas, Path path, bool pressed)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (Path.Direction direction = Path.Direction.Cw)
                        using (Paint.Style style = Paint.Style.Fill)
                        {
                            global::Android.Graphics.Color color = _frame.InnerBackground.ToAndroid();

                            paint.SetStyle(style);
                            paint.Color = color;

                            canvas.DrawPath(path, paint);
                        }
            }
コード例 #31
0
ファイル: AndroidBitmap.cs プロジェクト: tzachshabtay/MonoAGS
		public void MakeTransparent(AGS.API.Color color)
		{
			global::Android.Graphics.Color c = new global::Android.Graphics.Color(color.R, color.G, color.B, color.A);
			global::Android.Graphics.Color transparent = global::Android.Graphics.Color.Transparent;
			using (FastBitmap fastBitmap = new FastBitmap (_bitmap))
			{
				for (int x = 0; x < _bitmap.Width; x++)
				{
					for (int y = 0; y < _bitmap.Height; y++)
					{
						if (fastBitmap.GetPixel(x, y) == c)
							fastBitmap.SetPixel(x, y, c);
					}
				}
			}
		}
コード例 #32
0
        void DrawBackground(ACanvas canvas, int width, int height, CornerRadius cornerRadius, bool pressed)
        {
            using (var paint = new Paint {
                AntiAlias = true
            })
                using (var path = new Path())
                    using (Path.Direction direction = Path.Direction.Cw)
                        using (Paint.Style style = Paint.Style.Fill)
                            using (var rect = new RectF(0, 0, width, height))
                            {
                                float topLeft     = _convertToPixels(cornerRadius.TopLeft);
                                float topRight    = _convertToPixels(cornerRadius.TopRight);
                                float bottomRight = _convertToPixels(cornerRadius.BottomRight);
                                float bottomLeft  = _convertToPixels(cornerRadius.BottomLeft);

                                if (!_pancake.HasShadow)
                                {
                                    path.AddRoundRect(rect, new float[] { topLeft, topLeft, topRight, topRight, bottomRight, bottomRight, bottomLeft, bottomLeft }, direction);
                                }
                                else
                                {
                                    path.AddRoundRect(rect, new float[] { topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft, topLeft }, direction);
                                }

                                if (_pancake.BackgroundGradientStartColor != default(Xamarin.Forms.Color) && _pancake.BackgroundGradientEndColor != default(Xamarin.Forms.Color))
                                {
                                    var angle = _pancake.BackgroundGradientAngle / 360.0;

                                    // Calculate the new positions based on angle between 0-360.
                                    var a = width * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.75) / 2)), 2);
                                    var b = height * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.0) / 2)), 2);
                                    var c = width * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.25) / 2)), 2);
                                    var d = height * Math.Pow(Math.Sin(2 * Math.PI * ((angle + 0.5) / 2)), 2);

                                    var shader = new LinearGradient(width - (float)a, (float)b, width - (float)c, (float)d, _pancake.BackgroundGradientStartColor.ToAndroid(), _pancake.BackgroundGradientEndColor.ToAndroid(), Shader.TileMode.Clamp);
                                    paint.SetShader(shader);
                                }
                                else
                                {
                                    global::Android.Graphics.Color color = _pancake.BackgroundColor.ToAndroid();
                                    paint.SetStyle(style);
                                    paint.Color = color;
                                }

                                canvas.DrawPath(path, paint);
                            }
        }