public CustomTypefaceSpan(String family, Typeface type, Android.Graphics.Color color)
            : base(family)
        {

            newType = type;
            fontColor = color;
        }
		public HorizontalMenuLabel (Activity activity) : base (activity)
		{
			defaultTextColor = TextColor;
			Gravity = GravityFlags.Center;
			TextColor = CustomColors.DarkColor;
			TextSize = Sizes.GetRealSize (9);
		}
		public Color mapColor(Color pColor) {
			int mappedColor = this.mColorMappings.Get(pColor);
			if(mappedColor == 0) {
				return pColor;
			} else {
				return new Color (mappedColor);
			}
		}
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     _whiteColor = Resources.GetColor(Android.Resource.Color.White);
     _whiteColorWithOpacity = this.GetColorWithOpacity(Resource.Color.white, Resource.Color.button_shadow_gray);
     var grayColor = Resources.GetColor(Resource.Color.button_shadow_gray);
     _grayColorFilter = new LightingColorFilter(grayColor, grayColor);
 }
 public void SetColor(Color color)
 {
     this.color = color;
     backgroundPaint.Color = color;
     foregroundPaint.Color = color;
     Invalidate();
     RequestLayout();
 }
        public CountSpan(int count, Context context, Color textColor, int textSize, int maxWidth)
            : base(new TextView(context), maxWidth)
        {
            TextView v = (TextView)View;
            v.SetTextColor(textColor);

            v.SetTextSize(ComplexUnitType.Px, textSize);
            SetCount(count);
        }
 public KenBurnsDrawable(Color defaultColor)
 {
     this.defaultColor = defaultColor;
     this.paint = new Paint
     {
         AntiAlias = false,
         FilterBitmap = false
     };
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="ChartSurface"/> class.
		/// </summary>
		/// <param name="context">The context.</param>
		/// <param name="chart">The chart.</param>
		/// <param name="color">The color.</param>
		/// <param name="colors">The colors.</param>
		public ChartSurface(Context context, Chart chart, AndroidColor color, AndroidColor[] colors)
			: base(context)
		{
			SetWillNotDraw(false);

			Chart = chart;
			Paint = new Paint() { Color = color, StrokeWidth = 2 };
			Colors = colors;
		}
		public MvxCircleImageView(Context context, IAttributeSet attrs, int defStyle) : base (context, attrs) {
			TypedArray a = context.ObtainStyledAttributes(attrs, Resource.Styleable.CircleImageView, defStyle, 0);

			_borderWidth = a.GetDimensionPixelSize (Resource.Styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH);
			mBorderColor = a.GetColor (Resource.Styleable.CircleImageView_border_color, DEFAULT_BORDER_COLOR);

			a.Recycle ();

			Init();			
		}
 public CustomTypefaceSpan(Icon icon, Typeface type, float iconSizePx, float iconSizeRatio, int iconColor,
     bool rotate)
 {
     _rotate = rotate;
     _icon = icon.Character.ToString();
     _typeface = type;
     _iconSizePx = iconSizePx;
     _iconSizeRatio = iconSizeRatio;
     _iconColor = new Color(iconColor);
     _rotationStartTime = DateTimeHelpers.CurrentUnixTimeMillis();
 }
        public static IMenuItem SetEnabled(this IMenuItem item, bool enabled, Context context, int iconId, Color disabledColor)
        {
            var resIcon = context.Resources.GetDrawable(iconId);

            if (!enabled)
                resIcon.Mutate().SetColorFilter(disabledColor, PorterDuff.Mode.SrcIn);

            item.SetEnabled(enabled);
            item.SetIcon(resIcon);

            return item;
        }
Exemple #12
0
		public BaseCellView(Context context, Cell cell) : base(context)
		{
			_cell = cell;
			SetMinimumWidth((int)context.ToPixels(25));
			SetMinimumHeight((int)context.ToPixels(25));
			Orientation = Orientation.Horizontal;

			var padding = (int)context.FromPixels(8);
			SetPadding(padding, padding, padding, padding);

			_imageView = new ImageView(context);
			var imageParams = new LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent)
			{
				Width = (int)context.ToPixels(60),
				Height = (int)context.ToPixels(60),
				RightMargin = 0,
				Gravity = GravityFlags.Center
			};
			using (imageParams)
				AddView(_imageView, imageParams);

			var textLayout = new LinearLayout(context) { Orientation = Orientation.Vertical };

			_mainText = new TextView(context);
			_mainText.SetSingleLine(true);
			_mainText.Ellipsize = TextUtils.TruncateAt.End;
			_mainText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
			_mainText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall);

			using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
				textLayout.AddView(_mainText, lp);

			_detailText = new TextView(context);
			_detailText.SetSingleLine(true);
			_detailText.Ellipsize = TextUtils.TruncateAt.End;
			_detailText.SetPadding((int)context.ToPixels(15), padding, padding, padding);
			_detailText.Visibility = ViewStates.Gone;
			_detailText.SetTextAppearanceCompat(context, global::Android.Resource.Style.TextAppearanceSmall);

			using (var lp = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent))
				textLayout.AddView(_detailText, lp);

			var layoutParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent) { Width = 0, Weight = 1, Gravity = GravityFlags.Center };

			using (layoutParams)
				AddView(textLayout, layoutParams);

			SetMinimumHeight((int)context.ToPixels(DefaultMinHeight));
			_androidDefaultTextColor = Color.FromUint((uint)_mainText.CurrentTextColor);
		}
Exemple #13
0
        public ClingDrawer(Resources resources, Color showcaseColor)
        {
            this.showcaseColor = showcaseColor;

            PorterDuffXfermode mBlender = new PorterDuffXfermode(PorterDuff.Mode.Clear);
            mEraser = new Paint();
            mEraser.Color = Color.White;
            mEraser.Alpha = 0;
            mEraser.SetXfermode(mBlender);
            mEraser.AntiAlias = true;

            mShowcaseDrawable = resources.GetDrawable(Resource.Drawable.cling_bleached);
            mShowcaseDrawable.SetColorFilter(showcaseColor, PorterDuff.Mode.Multiply);
        }
		public static SpannableString ToAttributed(this FormattedString formattedString, Font defaultFont, Color defaultForegroundColor, TextView view)
		{
			if (formattedString == null)
				return null;

			var builder = new StringBuilder();
			foreach (Span span in formattedString.Spans)
			{
				if (span.Text == null)
					continue;

				builder.Append(span.Text);
			}

			var spannable = new SpannableString(builder.ToString());

			var c = 0;
			foreach (Span span in formattedString.Spans)
			{
				if (span.Text == null)
					continue;

				int start = c;
				int end = start + span.Text.Length;
				c = end;

				if (span.ForegroundColor != Color.Default)
				{
					spannable.SetSpan(new ForegroundColorSpan(span.ForegroundColor.ToAndroid()), start, end, SpanTypes.InclusiveExclusive);
				}
				else if (defaultForegroundColor != Color.Default)
				{
					spannable.SetSpan(new ForegroundColorSpan(defaultForegroundColor.ToAndroid()), start, end, SpanTypes.InclusiveExclusive);
				}

				if (span.BackgroundColor != Color.Default)
				{
					spannable.SetSpan(new BackgroundColorSpan(span.BackgroundColor.ToAndroid()), start, end, SpanTypes.InclusiveExclusive);
				}

				if (!span.IsDefault())
#pragma warning disable 618 // We will need to update this when .Font goes away
					spannable.SetSpan(new FontSpan(span.Font, view), start, end, SpanTypes.InclusiveInclusive);
#pragma warning restore 618
				else if (defaultFont != Font.Default)
					spannable.SetSpan(new FontSpan(defaultFont, view), start, end, SpanTypes.InclusiveInclusive);
			}
			return spannable;
		}
        static void SetNumberPickerTextColor(NumberPicker numberPicker, Color color)
        {
            try
            {
                int count = numberPicker.ChildCount;
                for (int i = 0; i < count; i++)
                {
                    View child = numberPicker.GetChildAt(i);
                    if (child is EditText)
                    {
                        try
                        {
                            Field selectorWheelPaintField = numberPicker.Class
                                .GetDeclaredField("mSelectorWheelPaint");
                            selectorWheelPaintField.Accessible = true;
                            ((Paint)selectorWheelPaintField.Get(numberPicker)).Color = color;

                            Field selectionDivider = numberPicker.Class.GetDeclaredField("mSelectionDivider");
                            selectionDivider.Accessible = true;
                            selectionDivider.Set(numberPicker, numberPicker.Context.Resources.GetDrawable(Resource.Drawable.numberpicker_selection_divider));
                            
                            ((EditText)child).SetTextColor(color);
                        }
                        catch (NoSuchFieldException e)
                        {
                            Log.Debug("setNumberPickerTextColor", e.Message);
                        }
                        catch (IllegalAccessException e)
                        {
                            Log.Debug("setNumberPickerTextColor", e.Message);
                        }
                        catch (Resources.NotFoundException e)
                        {
                            Log.Debug("setNumberPickerTextColor", e.Message);
                        }
                    }
                }

                numberPicker.Invalidate();
            }
            catch
            {

            }
        }
Exemple #16
0
 public ButtonUI(ButtonUI buttonUI)
 {
     StrokeShade = buttonUI.StrokeShade;
     FillShade = buttonUI.FillShade;
     StrokeColor = buttonUI.StrokeColor;
     FillColor = buttonUI.FillColor;
     IsTextStroked = buttonUI.IsTextStroked;
     IsSquared = buttonUI.IsSquared;
     Typeface = buttonUI.Typeface;
     Gravity = buttonUI.Gravity;
     Shape = buttonUI.Shape;
     Padding = buttonUI.Padding;
     TextSizeRatio = buttonUI.TextSizeRatio;
     StrokeBorderWidthRatio = buttonUI.StrokeBorderWidthRatio;
     StrokeTextWidthRatio = buttonUI.StrokeTextWidthRatio;
     StrokeBorderWidth = buttonUI.StrokeBorderWidth;
     StrokeTextWidth = buttonUI.StrokeTextWidth;
     _textSize = buttonUI._textSize;
     _radiusIn = buttonUI._radiusIn;
     _radiusOut = buttonUI._radiusOut;
 }
 public void SetFillColor (Color fillColor)
 {
     _paintFill.Color = fillColor;
     Invalidate ();
 }
Exemple #18
0
		public void SetMainTextColor(Color color)
		{
			Color defaultColorToSet = _defaultMainTextColor == Color.Default ? _androidDefaultTextColor : _defaultMainTextColor;

			_mainTextColor = color;
			_mainText.SetTextColor(color.ToAndroid(defaultColorToSet));
		}
Exemple #19
0
    public void CreateNotification(string contentText, int teaType, int infusionNum)
    {
        //Get context using CurrentActivity plugin
        var context = (MainActivity)CrossCurrentActivity.Current.Activity;

        //Get appropriate suffix for the infusion number

        string infusion = infusionNum.ToString();
        bool   forceTh  = false;

        if (infusionNum > 9 && infusionNum < 21)
        {
            forceTh = true;
        }

        char lastChar = infusion[infusion.Length - 1];

        if (forceTh == true)
        {
            infusion += "th";
        }
        else if (lastChar == '1')
        {
            infusion += "st";
        }
        else if (lastChar == '2')
        {
            infusion += "nd";
        }
        else if (lastChar == '3')
        {
            infusion += "rd";
        }
        else
        {
            infusion += "th";
        }

        //Get tea type colour

        string teaName = "tea";

        if (!string.IsNullOrEmpty(contentText))
        {
            teaName = contentText.ToLower().Trim();
        }

        Android.Graphics.Color notiColour = Android.Graphics.Color.Black;
        bool isColorized = false;

        if (teaType > -1)
        {
            isColorized = true;
            notiColour  = Android.Graphics.Color.ParseColor(MainActivity.teaColorsHex[teaType]);
        }

        // Create the PendingIntent
        var intent = context.PackageManager.GetLaunchIntentForPackage(context.PackageName);

        intent.AddFlags(ActivityFlags.ClearTop);
        var pendingIntent = PendingIntent.GetActivity(context, 0, intent, PendingIntentFlags.UpdateCurrent);

        //Build the notification:
        var builder = new NotificationCompat.Builder(context, MainActivity.CHANNEL_ID)
                      .SetAutoCancel(true)                             // Dismiss the notification from the notification area when the user clicks on it
                      .SetContentIntent(pendingIntent)                 // Start up this activity when the user clicks the intent.
                      .SetContentTitle("Timer Complete")               // Set the title
                      .SetSmallIcon(Resource.Drawable.ic_notification) // This is the icon to display
                      .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                      .SetColor(notiColour)
                      .SetColorized(isColorized)
                      .SetContentText($"Your {infusion} infusion of {teaName} is ready!"); // the message to display.

        // Finally, publish the notification:
        var notificationManager = NotificationManagerCompat.From(context);

        notificationManager.Notify(MainActivity.NOTIFICATION_ID, builder.Build());

        builder.Dispose();
    }
 static ReportsHeaderCellViewHolder()
 {
     totalTimeText          = Application.Context.SafeGetColor(Resource.Color.totalTimeText);
     disabledReportFeature  = Application.Context.SafeGetColor(Resource.Color.disabledReportFeature);
     billablePercentageText = Application.Context.SafeGetColor(Resource.Color.billablePercentageText);
 }
Exemple #21
0
		public void SetDefaultMainTextColor(Color defaultColor)
		{
			_defaultMainTextColor = defaultColor;
			if (_mainTextColor == Color.Default)
				_mainText.SetTextColor(defaultColor.ToAndroid());
		}
 internal static PlatformColor WithAlpha(this PlatformColor color, double alpha) =>
 new PlatformColor(color.R, color.G, color.B, (byte)(alpha * 255));
 public static Bitmap AssertColorAtBottomRight(this Bitmap bitmap, AColor expectedColor)
 {
     return(bitmap.AssertColorAtPoint(expectedColor, bitmap.Width - 1, 0));
 }
Exemple #24
0
 public SplitDrawable(AColor color, int topSize, int bottomSize)
 {
     Color      = color;
     BottomSize = bottomSize;
     TopSize    = topSize;
 }
Exemple #25
0
 private void UpdateProperties(ColorSwitch SwitchElement)
 {
     TintColor  = SwitchElement.TintColor.ToAndroid();
     ThumbColor = SwitchElement.ThumbColor.ToAndroid();
 }
Exemple #26
0
 public static Color ToEto(this ag.Color color)
 {
     return(Color.FromArgb(color.R, color.G, color.B, color.A));
 }
			public void SetUiEnable (bool enable)
			{
				if(remoteSettings.SendVehicleDataToMailbox){
					sliderLabel.Text = "Slider:";
				}
				else{
					sliderLabel.Text = "Motor:";
				}
				sensor1.Enabled = enable;
				sensor2.Enabled = enable;
				sensor3.Enabled = enable;
				sensor4.Enabled = enable;
				seekBar.Enabled = enable;
				circle.Enabled = enable;
				Android.Graphics.Color color = new Android.Graphics.Color (0x99, 0x99, 0x99);
				if (!enable) {
					circle.SetImageResource(Resource.Drawable.aniGray);
					circleAnimation.Stop();
				} 
				else 
				{
					color =	new Android.Graphics.Color (0xf2, 0x61, 0x00);
					circle.SetImageResource(Resource.Drawable.animation);
					circleAnimation = (AnimationDrawable) circle.Drawable;
					circleAnimation.Start();
					if(remoteSettings.SensorValueToSpeech){
						sensor1.Enabled = true;
						sensor2.Enabled = true;
						sensor3.Enabled = true;
						sensor4.Enabled = true;
					}
					else{
						sensor1.Enabled = false;
						sensor2.Enabled = false;
						sensor3.Enabled = false;
						sensor4.Enabled = false;
					}
				}
				angleText.SetTextColor(color);
				speedText.SetTextColor(color);
				sliderText.SetTextColor(color);
				angleLabel.SetTextColor(color);
				speedLabel.SetTextColor(color);
				sliderLabel.SetTextColor(color);
			}
Exemple #28
0
 public void SetOverlayColor(Android.Graphics.Color color)
 {
     _mOverlayColor = color;
 }
Exemple #29
0
        public static Drawable GenerateBackgroundWithShadow(RoundedCornerStackLayout control, Android.Views.View child, Android.Graphics.Color backgroundColor,
                                                            Android.Graphics.Color shadowColor,
                                                            int elevation,
                                                            GravityFlags shadowGravity)
        {
            var radii = GetRadii(control);

            int DY;

            switch (shadowGravity)
            {
            case GravityFlags.Center:
                DY = 0;
                break;

            case GravityFlags.Top:
                DY = -1 * elevation / 3;
                break;

            default:
            case GravityFlags.Bottom:
                DY = elevation / 3;
                break;
            }

            var shapeDrawable = new ShapeDrawable();

            shapeDrawable.Paint.Color = backgroundColor;
            shapeDrawable.Paint.SetShadowLayer(elevation, 0, DY, shadowColor);

            child.SetLayerType(LayerType.Software, shapeDrawable.Paint);

            shapeDrawable.Shape = new RoundRectShape(radii, null, null);

            var drawable = new LayerDrawable(new Drawable[] { shapeDrawable });

            drawable.SetLayerInset(0, elevation, elevation, elevation, elevation);

            child.Background = drawable;
            return(drawable);
        }
 public void SetBackgroundColor(Color color)
 {
     ((IMapView)this).SetBackgroundColor(color);
 }
        public static (PlatformColor FocusedColor, PlatformColor UnFocusedColor) GetUnderlineColor(Color textColor)
        {
            PlatformColor color = GetEntryTextColor(textColor);

            return(color, WithAlpha(color, kFilledTextFieldIndicatorLineAlpha));
        }
        public void BindItem(vwOutletListViewModel listItem, ViewGroup parent)
        {
            HPLabel.Text     = "( HP )";
            RemarkLabel.Text = "Remark:";

            CustomerName.Text = listItem.getCustomerName();

            if (listItem.getP01Code() != "")
            {
                Project01.Text = listItem.getP01Code();
                Project01.SetBackgroundColor(GetColorFromHexValue(listItem.getP01Color()));
                Project01.SetOnClickListener(this);
            }
            else
            {
                Project01.Text = "";
                Project01.SetBackgroundColor(Android.Graphics.Color.Transparent);
                Project01.SetOnClickListener(null);
            }

            if (listItem.getP02Code() != "")
            {
                Project02.Text = listItem.getP02Code();
                Project02.SetBackgroundColor(GetColorFromHexValue(listItem.getP02Color()));
                Project02.SetOnClickListener(this);
            }
            else
            {
                Project02.Text = "";
                Project02.SetBackgroundColor(Android.Graphics.Color.Transparent);
                Project02.SetOnClickListener(null);
            }

            if (listItem.getP03Code() != "")
            {
                Project03.Text = listItem.getP03Code();
                Project03.SetBackgroundColor(GetColorFromHexValue(listItem.getP03Color()));
                Project03.SetOnClickListener(this);
            }
            else
            {
                Project03.Text = "";
                Project03.SetBackgroundColor(Android.Graphics.Color.Transparent);
                Project03.SetOnClickListener(null);
            }

            CustomerID.Text     = listItem.getCustomerID();
            FISSalesTarget.Text = listItem.getFISSales() + "/" + listItem.getFISTarget();
            FISPer.Text         = listItem.getFISPer() + "%";
            FISBal.Text         = "B: " + listItem.getFISBal();
            FISMr.Text          = "MR: " + listItem.getFISMr();
            FISMrPer.Text       = listItem.getFISMr() + "%";
            HPSalesTarget.Text  = listItem.getHPSales() + "/" + listItem.getHPTarget();
            HPPer.Text          = listItem.getHPPer() + "%";
            HPBal.Text          = "B: " + listItem.getHPBal();
            HPMr.Text           = "MR: " + listItem.getHPMr();
            HPMrPer.Text        = listItem.getHPMr() + "%";
            Remark.Text         = listItem.getRemark();

            if (listItem.Selected)
            {
                Android.Graphics.Color bgColor = new Android.Graphics.Color(ContextCompat.GetColor(this.outletListFragment.Context, Resource.Color.color_light_grey_background));
                ListItemFrame.SetBackgroundColor(bgColor);
            }
            else
            {
                ListItemFrame.SetBackgroundColor(Android.Graphics.Color.White);
            }
        }
 public FilledButtonData(int id, Color color)
     : this(id, (int)color)
 {
 }
        // State list from material-components-android
        // https://github.com/material-components/material-components-android/blob/3637c23078afc909e42833fd1c5fd47bb3271b5f/lib/java/com/google/android/material/button/res/color/mtrl_btn_bg_color_selector.xml
        public static ColorStateList CreateButtonBackgroundColors(PlatformColor primary)
        {
            var colors = new int[] { primary, primary.WithAlpha(0.12) };

            return(new ColorStateList(ButtonStates, colors));
        }
        void DrawPlot(Canvas canvas, GraphOptions options, IEnumerable <GraphData> items, int xSelect)
        {
            var density = Resources.DisplayMetrics.Density;

            var backgroundColor        = options.BackgroundColor.ToAndroid();
            var bandsColor             = options.BandColor.ToAndroid();
            var lineShadowColor        = options.LineShadowColor.ToAndroid();
            var lineColor              = options.LineColor.ToAndroid();
            var markerTextShadowColor  = options.MarkerTextShadowColor.ToAndroid();
            var markerTextColor        = options.MarkerTextColor.ToAndroid();
            var xAxisLabelOffset       = options.XAxisLabelOffset * density;
            var yAxisLabelOffset       = options.YAxisLabelOffset * density;
            var sectionHeight          = options.SectionHeight;
            var lineStrokeWidth        = options.LineStrokeWidth * density;
            var axisStrokeWidth        = options.AxisStrokeWidth * density;
            var markerTextSize         = options.MarkerTextSize * density;
            var markerTextOffset       = options.MarkerTextOffset * density;
            var markerShadowTextOffset = options.MarkerShadowTextOffset * density;
            var markerDefaultRadius    = options.MarkerDefaultRadius * density;
            var markerSelectedRadius   = options.MarkerSelectedRadius * density;
            var labelTextSize          = options.LabelTextSize * density;
            var sectionCount           = 4;

            /*****************************************
            *
            *  PART 1 - Draw background and bands
            *
            *****************************************/

            // Draws background
            paint.Color = Color.ParseColor("#2CBCEB");
            canvas.DrawRect(new Rect(0, 0, this.Width, this.Height), paint);

            // Set text size to measure text
            paint.TextSize = labelTextSize;

            var ceilingValue = Math.Ceiling(items.Max(i => i.Y) / 50.0) * 50.0;

            // Computes plot boundaries
            // - Left: left padding + maximum text lenght + 2dp
            // - Bottom: bottom padding + text size
            var plotBoundaries = new PlotBoundaries
            {
                Left   = options.Padding.Left * density + paint.MeasureText(ceilingValue.ToString()) + yAxisLabelOffset,
                Right  = this.Width - options.Padding.Right * density,
                Top    = options.Padding.Top * density,
                Bottom = this.Height - options.Padding.Bottom * density - paint.TextSize - xAxisLabelOffset
            };
            var plotWidth  = plotBoundaries.Right - plotBoundaries.Left;
            var plotHeight = plotBoundaries.Bottom - plotBoundaries.Top;

            var verticalSection = new Section
            {
                Width = plotWidth / items.Count(),
                Count = items.Count()
            };
            var horizontalSection = new Section
            {
                Max   = (float)ceilingValue,
                Count = sectionCount,
                Width = plotHeight / sectionCount
            };

            // Special function not present in the tutorial
            // Darken plot if xSelect within boundaries
            if (plotBoundaries.Left <= xSelect && xSelect <= plotBoundaries.Right)
            {
                Darken(ref backgroundColor);
                Darken(ref bandsColor);
                Darken(ref lineShadowColor);
                Darken(ref lineColor);
            }

            // Draws horizontal bands
            paint.Reset();
            paint.Color = bandsColor;
            for (int i = horizontalSection.Count - 1; i >= 0; i = i - 2)
            {
                var y = plotBoundaries.Bottom - horizontalSection.Width * i;

                canvas.DrawRect(
                    left: plotBoundaries.Left,
                    top: y - horizontalSection.Width,
                    right: plotBoundaries.Right,
                    bottom: y,
                    paint: paint);
            }

            /*****************************************
            *
            *  PART 2 - Draw axis and labels
            *
            *****************************************/

            // Draws X and Y axis lines
            paint.Reset();
            paint.StrokeWidth = axisStrokeWidth;
            paint.Color       = lineColor;
            canvas.DrawLine(
                plotBoundaries.Left,
                plotBoundaries.Bottom,
                plotBoundaries.Right,
                plotBoundaries.Bottom,
                paint);
            canvas.DrawLine(
                plotBoundaries.Left,
                plotBoundaries.Top,
                plotBoundaries.Left,
                plotBoundaries.Bottom,
                paint);


            //// Calculates all the data coordinates
            var points = new List <Tuple <float, float, string, double, bool> >();

            foreach (var l in items.Select((l, index) => Tuple.Create(l.X, l.Y, index)))
            {
                var x = verticalSection.Width * (l.Item3 + 0.5f) + plotBoundaries.Left;
                var y = (float)l.Item2 * plotHeight / horizontalSection.Max;

                points.Add(
                    Tuple.Create(
                        x,
                        plotBoundaries.Bottom - y,
                        l.Item1,
                        l.Item2,
                        plotBoundaries.Left + l.Item3 * verticalSection.Width <= xSelect &&
                        xSelect < plotBoundaries.Left + (l.Item3 + 1) * verticalSection.Width
                        ));
            }

            // Draws X axis labels
            paint.Reset();
            paint.TextAlign = Paint.Align.Center;
            paint.TextSize  = labelTextSize;
            foreach (var p in points)
            {
                if (p.Item5)
                {
                    paint.Color = markerTextColor;

                    canvas.DrawText(
                        text: p.Item3,
                        x: p.Item1,
                        y: plotBoundaries.Bottom + paint.TextSize + xAxisLabelOffset,
                        paint: paint);
                }
                else
                {
                    paint.Color = lineColor;

                    canvas.DrawText(
                        text: p.Item3,
                        x: p.Item1,
                        y: plotBoundaries.Bottom + paint.TextSize + xAxisLabelOffset,
                        paint: paint);
                }
            }

            // Draw Y axis labels
            // The 1.5f * density on y is a hack to get the label aligned vertically.
            // It will need adjustements if the font size changes.
            paint.Reset();
            paint.TextAlign = Paint.Align.Right;
            paint.TextSize  = labelTextSize;
            paint.Color     = lineColor;
            for (int i = 0; i < horizontalSection.Count; i++)
            {
                var y = plotBoundaries.Bottom - horizontalSection.Width * i;

                canvas.DrawText(
                    text: (i * sectionHeight).ToString(),
                    x: plotBoundaries.Left - yAxisLabelOffset,
                    y: y - (paint.Ascent() / 2f + 1.5f * density),
                    paint: paint);
            }


            /*****************************************
            *
            *  PART 3 - Draw lines and markers
            *
            *****************************************/

            // Draws line shadow
            paint.Reset();
            paint.StrokeWidth = lineStrokeWidth;
            paint.Color       = lineShadowColor;
            for (int i = 0; i < points.Count; i++)
            {
                if (i < points.Count - 1)
                {
                    canvas.DrawLine(
                        points[i].Item1,
                        points[i].Item2 + 2f * density,
                        points[i + 1].Item1,
                        points[i + 1].Item2 + 2f * density,
                        paint);
                }

                canvas.DrawCircle(
                    cx: points[i].Item1,
                    cy: points[i].Item2 + 2f * density,
                    radius: markerDefaultRadius,
                    paint: paint);
            }

            //// Draws main line
            paint.Reset();
            paint.StrokeWidth = lineStrokeWidth;
            paint.Color       = lineColor;
            for (int i = 0; i < points.Count; i++)
            {
                if (i < points.Count - 1)
                {
                    canvas.DrawLine(
                        points[i].Item1,
                        points[i].Item2,
                        points[i + 1].Item1,
                        points[i + 1].Item2,
                        paint);
                }

                canvas.DrawCircle(
                    cx: points[i].Item1,
                    cy: points[i].Item2,
                    radius: markerDefaultRadius,
                    paint: paint);
            }


            /*****************************************
            *
            *  PLUS - Draw text
            *
            *****************************************/

            // Draws markers
            paint.Reset();
            for (int i = 0; i < points.Count; i++)
            {
                if (points[i].Item5)
                {
                    paint.Color = markerTextShadowColor;
                    canvas.DrawCircle(
                        cx: points[i].Item1,
                        cy: points[i].Item2 + 2f * density,
                        radius: markerSelectedRadius,
                        paint: paint);
                }

                if (points[i].Item5)
                {
                    paint.Color = markerTextColor;
                    canvas.DrawCircle(
                        cx: points[i].Item1,
                        cy: points[i].Item2,
                        radius: markerSelectedRadius,
                        paint: paint);
                }
            }

            // Draws marker text shadow
            // Draws marker text
            paint.Reset();
            paint.TextAlign = Paint.Align.Center;
            paint.TextSize  = markerTextSize;
            paint.SetTypeface(Typeface.Create(Typeface.Default, TypefaceStyle.Bold));
            paint.Color = markerTextShadowColor;
            for (int i = 0; i < points.Count; i++)
            {
                var text = points[i].Item4.ToString();

                if (points[i].Item5)
                {
                    paint.Color = markerTextShadowColor;

                    // Prevent markers from being drawn out of Y axis
                    var position = points[i].Item2 - markerTextOffset - paint.TextSize < 0 ? -1 : 1;

                    canvas.DrawText(
                        text: text,
                        x: points[i].Item1,
                        y: points[i].Item2 - markerShadowTextOffset * position,
                        paint: paint);

                    paint.Color = markerTextColor;

                    canvas.DrawText(
                        text: text,
                        x: points[i].Item1,
                        y: points[i].Item2 - markerTextOffset * position,
                        paint: paint);
                }
            }
        }
Exemple #36
0
        private GradientDrawable CreateShapeDrawable(float cornerRadius, int borderWidth, Color backgroundColor, Color borderColor)
        {
            GradientDrawable shapeDrawable;

            if (_button.ButtonType != MaterialButtonType.Text)
            {
                shapeDrawable = _withIcon ? MaterialHelper.GetDrawableCopyFromResource <GradientDrawable>(Resource.Drawable.drawable_shape_with_icon)
                                          : MaterialHelper.GetDrawableCopyFromResource <GradientDrawable>(Resource.Drawable.drawable_shape);
            }
            else
            {
                shapeDrawable = MaterialHelper.GetDrawableCopyFromResource <GradientDrawable>(Resource.Drawable.drawable_shape_text);
            }

            shapeDrawable.SetCornerRadius(cornerRadius);
            shapeDrawable.SetColor(backgroundColor);
            shapeDrawable.SetStroke(borderWidth, borderColor);

            return(shapeDrawable);
        }
 public static Bitmap AssertColorAtTopLeft(this Bitmap bitmap, AColor expectedColor)
 {
     return(bitmap.AssertColorAtPoint(expectedColor, 0, bitmap.Height - 1));
 }
Exemple #38
0
 private void UpdateDisabledColor(Xamarin.Forms.Color disabledColor)
 {
     _disabledColor = disabledColor.IsDefault ? _normalColor.GetDisabledColor() : disabledColor.ToAndroid();
 }
 public void setColor(Color color)
 {
     Color.ColorToHSV(color, colorHSV);
 }
Exemple #40
0
 private void UpdatePressedColor(Xamarin.Forms.Color pressedColor)
 {
     if (pressedColor.IsDefault)
     {
         _pressedColor = _normalColor.IsColorDark() ? Color.ParseColor("#52FFFFFF") : Color.ParseColor("#52000000");
     }
     else
     {
         _pressedColor = pressedColor.ToAndroid();
     }
 }
Exemple #41
0
		public void SetDetailTextColor(Color color)
		{
			if (_detailTextColor == color)
				return;

			if (_defaultDetailColor == Color.Default)
				_defaultDetailColor = Color.FromUint((uint)_detailText.CurrentTextColor);

			_detailTextColor = color;
			_detailText.SetTextColor(color.ToAndroid(_defaultDetailColor));
		}
        // State list from material-components-android
        // https://github.com/material-components/material-components-android/blob/3637c23078afc909e42833fd1c5fd47bb3271b5f/lib/java/com/google/android/material/button/res/color/mtrl_btn_text_color_selector.xml
        public static ColorStateList CreateButtonTextColors(PlatformColor primary, PlatformColor text, PlatformColor disabledText)
        {
            var colors = new int[] { text, disabledText, primary.WithAlpha(0.38) };

            return(new ColorStateList(ButtonTextStates, colors));
        }
Exemple #43
0
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            if (_path == null)
            {
                return;
            }

            AMatrix transformMatrix = CreateMatrix();

            _path.Transform(transformMatrix);
            transformMatrix.MapRect(_pathFillBounds);
            transformMatrix.MapRect(_pathStrokeBounds);

            if (_fill != null)
            {
                _drawable.Paint.SetStyle(Paint.Style.Fill);

                if (_fill is GradientBrush fillGradientBrush)
                {
                    if (fillGradientBrush is LinearGradientBrush linearGradientBrush)
                    {
                        _fillShader = CreateLinearGradient(linearGradientBrush, _pathFillBounds);
                    }

                    if (fillGradientBrush is RadialGradientBrush radialGradientBrush)
                    {
                        _fillShader = CreateRadialGradient(radialGradientBrush, _pathFillBounds);
                    }

                    _drawable.Paint.SetShader(_fillShader);
                }
                else
                {
                    AColor fillColor = Color.Default.ToAndroid();

                    if (_fill is SolidColorBrush solidColorBrush && solidColorBrush.Color != Color.Default)
                    {
                        fillColor = solidColorBrush.Color.ToAndroid();
                    }

                    _drawable.Paint.Color = fillColor;
                }

                _drawable.Draw(canvas);
                _drawable.Paint.SetShader(null);
            }

            if (_stroke != null)
            {
                _drawable.Paint.SetStyle(Paint.Style.Stroke);

                if (_stroke is GradientBrush strokeGradientBrush)
                {
                    UpdatePathStrokeBounds();

                    if (strokeGradientBrush is LinearGradientBrush linearGradientBrush)
                    {
                        _strokeShader = CreateLinearGradient(linearGradientBrush, _pathStrokeBounds);
                    }

                    if (strokeGradientBrush is RadialGradientBrush radialGradientBrush)
                    {
                        _strokeShader = CreateRadialGradient(radialGradientBrush, _pathStrokeBounds);
                    }

                    _drawable.Paint.SetShader(_strokeShader);
                }
                else
                {
                    AColor strokeColor = Color.Default.ToAndroid();

                    if (_stroke is SolidColorBrush solidColorBrush && solidColorBrush.Color != Color.Default)
                    {
                        strokeColor = solidColorBrush.Color.ToAndroid();
                    }

                    _drawable.Paint.Color = strokeColor;
                }

                _drawable.Draw(canvas);
                _drawable.Paint.SetShader(null);
            }

            AMatrix inverseTransformMatrix = new AMatrix();

            transformMatrix.Invert(inverseTransformMatrix);
            _path.Transform(inverseTransformMatrix);
            inverseTransformMatrix.MapRect(_pathFillBounds);
            inverseTransformMatrix.MapRect(_pathStrokeBounds);
        }
 public static Color ToColor(this Android.Graphics.Color androidColor)
 {
     return(Color.FromArgb(androidColor.ToArgb()));
 }
 public void SetPageColor (Color pageColor)
 {
     _paintPageFill.Color = pageColor;
     Invalidate ();
 }
        private void Initilize(Context context, IAttributeSet attrs)
        {
            rectF = new RectF();
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(
                    attrs,
                    Resource.Styleable.CircleProgressBar,
                    0, 0);

            //Reading values from the XML layout
            try
            {
                strokeWidth = typedArray.GetDimension(Resource.Styleable.CircleProgressBar_progressBarThickness, strokeWidth);
                progress = typedArray.GetFloat(Resource.Styleable.CircleProgressBar_progress, progress);
                color = typedArray.GetColor(Resource.Styleable.CircleProgressBar_progressbarColor, color);
                min = typedArray.GetInt(Resource.Styleable.CircleProgressBar_min, min);
                max = typedArray.GetInt(Resource.Styleable.CircleProgressBar_max, max);
            }
            finally
            {
                typedArray.Recycle();
            }

            backgroundPaint = new Paint();
            backgroundPaint.AntiAlias = true;
            backgroundPaint.Color = color;
            backgroundPaint.SetStyle(Paint.Style.Stroke);
            backgroundPaint.StrokeWidth = strokeWidth;

            foregroundPaint = new Paint();
            foregroundPaint.AntiAlias = true;
            foregroundPaint.Color = color;
            foregroundPaint.SetStyle(Paint.Style.Stroke);
            foregroundPaint.StrokeWidth = strokeWidth;
        }
 public void SetStrokeColor (Color strokeColor)
 {
     _paintStroke.Color = strokeColor;
     Invalidate ();
 }
        public static ColorStateList CreateEntryUnderlineColors(PlatformColor focusedColor, PlatformColor unfocusedColor)
        {
            var colors = new int[] { focusedColor, unfocusedColor };

            return(new ColorStateList(EntryUnderlineStates, colors));
        }
Exemple #49
0
		/// <summary>
		/// Color transition method.
		/// </summary>
		private Color Evaluate (float fraction, Color startValue, Color endValue)
		{
			int startInt = (int)startValue;
			int startA = (startInt >> 24) & 0xff;
			int startR = (startInt >> 16) & 0xff;
			int startG = (startInt >> 8) & 0xff;
			int startB = startInt & 0xff;

			int endInt = (int)endValue;
			int endA = (endInt >> 24) & 0xff;
			int endR = (endInt >> 16) & 0xff;
			int endG = (endInt >> 8) & 0xff;
			int endB = endInt & 0xff;

			return new Color (
				(startA + (int)(fraction * (endA - startA))),
				(startR + (int)(fraction * (endR - startR))),
				(startG + (int)(fraction * (endG - startG))),
				(startB + (int)(fraction * (endB - startB))));
		}
 public static Bitmap AssertColorAtCenter(this Bitmap bitmap, AColor expectedColor)
 {
     return(bitmap.AssertColorAtPoint(expectedColor, bitmap.Width / 2, bitmap.Height / 2));
 }
        internal static void ApplyProgressBarColors(this AProgressBar progressBar, PlatformColor progressColor, PlatformColor backgroundColor, PorterDuff.Mode mode)
        {
            if ((int)Forms.SdkInt == 21 && progressBar.ProgressDrawable is ALayerDrawable progressDrawable)
            {
                progressBar.ProgressTintList           = ColorStateList.ValueOf(progressColor);
                progressBar.ProgressBackgroundTintList = ColorStateList.ValueOf(backgroundColor);
                progressBar.ProgressBackgroundTintMode = mode;

                if (progressDrawable.GetDrawable(0) is AGradientDrawable layer0)
                {
                    layer0.SetColor(backgroundColor);
                }

                if (progressDrawable.GetDrawable(1) is AScaleDrawable layer1)
                {
                    layer1.SetColorFilter(progressColor, FilterMode.SrcIn);
                }

                if (progressDrawable.GetDrawable(2) is AScaleDrawable layer2)
                {
                    layer2.SetColorFilter(progressColor, FilterMode.SrcIn);
                }
            }
            else if (Forms.IsLollipopOrNewer)
            {
                progressBar.ProgressTintList           = ColorStateList.ValueOf(progressColor);
                progressBar.ProgressBackgroundTintList = ColorStateList.ValueOf(backgroundColor);
                progressBar.ProgressBackgroundTintMode = mode;
            }
            else
            {
                (progressBar.Indeterminate ? progressBar.IndeterminateDrawable :
                 progressBar.ProgressDrawable).SetColorFilter(progressColor, FilterMode.SrcIn);
            }
        }
 public static Bitmap AssertColorAtBottomLeft(this Bitmap bitmap, AColor expectedColor)
 {
     return(bitmap.AssertColorAtPoint(expectedColor, 0, 0));
 }
Exemple #53
0
            void DrawRect(ACanvas canvas, int width, int height, float cornerRadius, float strokeWidth, Android.Graphics.Color color, Paint.Style style)
            {
                using (var paint = new Paint {
                    AntiAlias = true
                })
                    using (var path = new Path())
                        using (Path.Direction direction = Path.Direction.Cw)
                            using (style)
                                using (var rect = new RectF(0, 0, width, height))
                                {
                                    cornerRadius -= strokeWidth / 2;

                                    float rx = Forms.Context.ToPixels(cornerRadius);
                                    float ry = Forms.Context.ToPixels(cornerRadius);
                                    path.AddRoundRect(rect, rx, ry, direction);

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

                                    canvas.DrawPath(path, paint);
                                }
            }
 // Make color darker by altering the third HSV value
 void Darken(ref Color color)
 {
     Color.ColorToHSV(color, tempHSV);
     tempHSV[2] *= .5f;
     color       = Color.HSVToColor(tempHSV);
 }
 protected override void OnTitleChanged(ICharSequence title, Color color)
 {
     base.OnTitleChanged(title, color);
     this.AppCompatDelegate.SetTitle(title);
 }
        public static Bitmap AssertColorAtTopRight(this AView view, AColor expectedColor)
        {
            var bitmap = view.ToBitmap();

            return(bitmap.AssertColorAtTopRight(expectedColor));
        }
Exemple #57
0
        /// <summary>
        /// Sets the color of the action bar.
        /// </summary>
        /// <param name="color">Color.</param>
        protected void SetActionBarColor(Color color)
        {
            Resources res = this.Resources;
            var maskDrawable = res.GetDrawable(Resource.Drawable.actionbar_icon_mask) as BitmapDrawable;
            if (maskDrawable == null)
            {
                return;
            }

            var maskBitmap = maskDrawable.Bitmap;
            int width = maskBitmap.Width;
            int height = maskBitmap.Height;

            var outBitmap = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            Canvas canvas = new Canvas(outBitmap);
            canvas.DrawBitmap(maskBitmap, 0, 0, null);

            var maskedPaint = new Paint();
            maskedPaint.Color = color;
            maskedPaint.SetXfermode(new PorterDuffXfermode(PorterDuff.Mode.SrcAtop));

            canvas.DrawRect(0, 0, width, height, maskedPaint);
            var outDrawable = new BitmapDrawable(res, outBitmap);
            SupportActionBar.SetIcon(outDrawable);
        }
 public static string CreateColorAtPointError(this Bitmap bitmap, AColor expectedColor, int x, int y)
 {
     return(CreateColorError(bitmap, $"Expected {expectedColor} at point {x},{y} in renderered view."));
 }
Exemple #59
0
 public SplitDrawable(AColor color, int topSize, int bottomSize)
 {
     _color      = color;
     _bottomSize = bottomSize;
     _topSize    = topSize;
 }
        public static ColorStateList CreateEntryFilledPlaceholderColors(PlatformColor inlineColor, PlatformColor floatingColor)
        {
            int[][] States =
            {
                new []     { global::Android.Resource.Attribute.StateEnabled, global::Android.Resource.Attribute.StatePressed },
                new int[0] {
                }
            };

            var colors = new int[] { floatingColor, inlineColor };

            return(new ColorStateList(States, colors));
        }