Esempio n. 1
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            if (Borders != null)
            {
                Android.Graphics.Paint paint = new Android.Graphics.Paint();
                paint.Color = Color.Black;
                paint.SetStyle(Android.Graphics.Paint.Style.Stroke);

                int Height = this.Height;
                int Width  = this.Width;
                if (Borders.Top > 0)
                {
                    paint.StrokeWidth = Borders.Top * 2;
                    canvas.DrawLine(0, 0, Width, 0, paint);
                }
                if (Borders.Bottom > 0)
                {
                    paint.StrokeWidth = Borders.Bottom * 2;
                    canvas.DrawLine(0, Height, Width, Height, paint);
                }
                if (Borders.Left > 0)
                {
                    paint.StrokeWidth = Borders.Left * 2;
                    canvas.DrawLine(0, 0, 0, Height, paint);
                }
                if (Borders.Right > 0)
                {
                    paint.StrokeWidth = Borders.Right * 2;
                    canvas.DrawLine(Width, 0, Width, Height, paint);
                }
                paint.Dispose();
            }
        }
			public void draw(Canvas canvas) {
			
			pathA.getPointOnLine(parameter, coordsA);
			pathB.getPointOnLine(parameter, coordsB);
			if (rounded) insetPointsForRoundCaps();
			canvas.DrawLine(coordsA[0], coordsA[1], coordsB[0], coordsB[1], linePaint);
			}
Esempio n. 3
0
        public void Draw(Android.Graphics.Canvas canvas)
        {
            switch (Group)
            {
            case PlaneGroup.Bed:
                paint.Color = new Color(20, 84, 140);
                break;

            case PlaneGroup.Group1:
                paint.Color = new Color(243, 111, 99);
                break;

            case PlaneGroup.Group2:
                paint.Color = new Color(80, 176, 174);
                break;

            case PlaneGroup.Group3:
                paint.Color = new Color(241, 192, 89);
                break;

            case PlaneGroup.Group4:
                paint.Color = new Color(16, 150, 117);
                break;

            case PlaneGroup.Group5:
                paint.Color = new Color(156, 27, 49);
                break;
            }

            canvas.DrawLine(X1, Y1, X2, Y2, paint);
        }
Esempio n. 4
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            Paint White = new Paint();

            White.Color = Color.White;

            float min = 100;
            float max = 0;

            if (vals != null)
            {
                float xOffset = (float)Width / (float)(vals.Length - 1);

                for (int i = 0; i < vals.Length; i++)
                {
                    if (min > vals[i])
                    {
                        min = vals[i];
                    }

                    if (max < vals[i])
                    {
                        max = vals[i];
                    }
                }

                max++;

                for (int i = 1; i < vals.Length; i++)
                {
                    float startX = xOffset * (i - 1);
                    float stopX  = xOffset * i;

                    float startY = Height / ((max - min) / (max - vals[i - 1]));
                    float stopY  = Height / ((max - min) / (max - vals[i]));

                    //        canvas.DrawRect(startX-5f,startY+5f,startX+5f,startY-5f,White);
                    canvas.DrawLine(startX, startY, stopX, stopY, White);
                }
            }
            else
            {
                canvas.DrawLine(0, Height / 2, Width, Height / 2, White);
            }
        }
 protected override bool DrawChild(Canvas canvas, Android.Views.View child, long drawingTime)
 {
     bool isInvalidated = base.DrawChild(canvas, child, drawingTime);
     //Draw a bottom border
     int bottom = child.Bottom - 1;
     canvas.DrawLine(child.Left, bottom, child.Right - 2, bottom, _dividerPaint);
     return isInvalidated;
 }
Esempio n. 6
0
        protected override void DispatchDraw(Canvas canvas)
        {
            base.DispatchDraw(canvas);
            var row = (ViewGroup) GetChildAt(1);
            int top = row.Top;
            int bottom = Bottom;

            //Left side border.
            int left = row.GetChildAt(0).Left + Left;
            canvas.DrawLine(left + _floatFudge, top, left + _floatFudge, bottom, _dividerPaint);

            //Each cell's right-side border.
            for (int c = 0; c < 7; c++) {
                float x = left + row.GetChildAt(c).Right - _floatFudge;
                canvas.DrawLine(x, top, x, bottom, _dividerPaint);
            }
        }
Esempio n. 7
0
 internal void Draw(Canvas canvas)
 {
     canvas.DrawCircle(_cells.Last().X, _cells.Last().Y, 3, this);
     for (int p = _cells.Count - 1; p > 0; p--)
     {
         canvas.DrawLine(_cells[p].X, _cells[p].Y, _cells[p - 1].X, _cells[p - 1].Y, this);
     }
 }
Esempio n. 8
0
        public static Bitmap CreateBitmap()
        {
            var bitmap = Bitmap.CreateBitmap(200, 200, Bitmap.Config.Argb4444);
            var canvas = new Canvas(bitmap);
            canvas.DrawLine(0, 0, 100, 100, new Paint { Color = new Color(255, 0, 0) });
            return bitmap;

        }
Esempio n. 9
0
        public override void OnDrawOver(Canvas cValue, RecyclerView parent, RecyclerView.State state)
        {
            var childCount = parent.ChildCount;
            for (int i = 0; i < childCount; i++) {
                var child = parent.GetChildAt (i);
                if (child.Visibility != Android.Views.ViewStates.Visible)
                    continue;

                var left = child.Left;
                var right = child.Right;
                var top = child.Top + child.PaddingTop + child.TranslationY;
                var bottom = child.Bottom;

                cValue.DrawLine (left + .5f, top, left + .5f, bottom, lightPaint);
                cValue.DrawLine (right - .5f, top, right - .5f, bottom, darkPaint);
            }
        }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);
            Paint pnt = new Paint();

            pnt.Color       = separatorColor;
            pnt.StrokeWidth = 5;

            canvas.DrawLine(0, 0, this.ScreenWidth, 0, pnt);
        }
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            //Clean(canvas);
            //清空画布
            if (circles != null && circles.Count == 4)
            {
                circles[0].Draw(canvas);
                circles[1].Draw(canvas);
                circles[2].Draw(canvas);
                circles[3].Draw(canvas);

                canvas.DrawLine(circles[0].Current_X, circles[0].Current_Y, circles[1].Current_X, circles[1].Current_Y, line);
                canvas.DrawLine(circles[1].Current_X, circles[1].Current_Y, circles[3].Current_X, circles[3].Current_Y, line);
                canvas.DrawLine(circles[2].Current_X, circles[2].Current_Y, circles[3].Current_X, circles[3].Current_Y, line);
                canvas.DrawLine(circles[2].Current_X, circles[2].Current_Y, circles[0].Current_X, circles[0].Current_Y, line);
            }

            base.OnDraw(canvas);
        }
Esempio n. 12
0
            protected override void OnDraw(Android.Graphics.Canvas canvas)
            {
                int   ancho     = canvas.Width;
                int   alto      = canvas.Height;
                Paint colorLine = new Paint();

                colorLine.Color       = Android.Graphics.Color.ParseColor("#673AB7");
                colorLine.StrokeWidth = 4;
                canvas.DrawLine(70, 0, 70, alto, colorLine);
                canvas.DrawLine(73, 0, 73, alto, colorLine);

                int cantLineas = alto / 90;

                for (int i = 0; i < cantLineas; i++)
                {
                    canvas.DrawLine(0, i * 90 + 90, ancho, i * 90 + 90, colorLine);
                }

                base.OnDraw(canvas);
            }
Esempio n. 13
0
		public static void parse(SVGProperties pSVGProperties, Canvas pCanvas, SVGPaint pSVGPaint) {
			float x1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X1, 0f);
			float x2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_X2, 0f);
			float y1 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y1, 0f);
			float y2 = pSVGProperties.getFloatAttribute(SVGConstants.ATTRIBUTE_Y2, 0f);
			if (pSVGPaint.setStroke(pSVGProperties)) {
				pSVGPaint.ensureComputedBoundsInclude(x1, y1);
				pSVGPaint.ensureComputedBoundsInclude(x2, y2);
				pCanvas.DrawLine(x1, y1, x2, y2, pSVGPaint.getPaint());
			}
		}
Esempio n. 14
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            Paint Black = new Paint();

            Black.Color       = Color.Black;
            Black.StrokeWidth = 10;

            canvas.DrawLine(0, Height, Width, Height, Black);
        }
		protected override void OnDraw (Canvas canvas)
		{
			int count = LineCount;

			for (int i = 0; i < count; i++) {
				int baseline = GetLineBounds (i, rect);

				canvas.DrawLine (rect.Left, baseline + 1, rect.Right, baseline + 1, paint);
			}

			base.OnDraw (canvas);
		}
Esempio n. 16
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            int height          = Height;
            int childCount      = ChildCount;
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, _dividerHeight), 1f) * height);

            SlidingTabLayout.ITabColorizer tabColorizer = _customTabColorizer != null ? _customTabColorizer: _defaultTabColorizer;

            // Thick colored underline below the current selection
            if (childCount > 0)
            {
                View selectedTitle = GetChildAt(_selectedPosition);
                int  left          = selectedTitle.Left;
                int  right         = selectedTitle.Right;
                int  color         = tabColorizer.GetIndicatorColor(_selectedPosition);

                if (_selectionOffset > 0f && _selectedPosition < (ChildCount - 1))
                {
                    int nextColor = tabColorizer.GetIndicatorColor(_selectedPosition + 1);
                    if (color != nextColor)
                    {
                        color = BlendColors(nextColor, color, _selectionOffset);
                    }

                    // Draw the selection partway between the tabs
                    View nextTitle = GetChildAt(_selectedPosition + 1);
                    left  = (int)(_selectionOffset * nextTitle.Left + (1.0f - _selectionOffset) * left);
                    right = (int)(_selectionOffset * nextTitle.Right + (1.0f - _selectionOffset) * right);
                }

                _selectedIndicatorPaint.Color = Color.LightSkyBlue;


                canvas.DrawRect(left, height - _selectedIndicatorThickness, right,
                                height, _selectedIndicatorPaint);
            }

            // Thin underline along the entire bottom edge
            canvas.DrawRect(0, height - _bottomBorderThickness, Width, height, _bottomBorderPaint);

            // Vertical separators between the titles
            int separatorTop = (height - dividerHeightPx) / 2;

            for (int i = 0; i < childCount - 1; i++)
            {
                View child = GetChildAt(i);
                _dividerPaint.Color = Color.Gray;
                canvas.DrawLine(child.Right, separatorTop, child.Right,
                                separatorTop + dividerHeightPx, _dividerPaint);
            }
        }
        public override void Draw(Canvas canvas)
        {
            Rect rectangle = new Rect();
            GetDrawingRect(rectangle);

            Paint paint = new Paint();
            paint.AntiAlias = true;
            paint.Color = Color.Gray;
            paint.SetStyle(Paint.Style.Stroke);
            canvas.DrawLine(rectangle.Left, rectangle.Bottom - 2, rectangle.Right, rectangle.Bottom, paint);

            paint.Dispose();

            base.Draw(canvas);
        }
 protected override void DrawRightThumb(Android.Graphics.Canvas p0, float x1, float y1, float x2, float y2)
 {
     float density = Context.Resources.DisplayMetrics.Density;
     Paint paint = new Paint();
     paint.AntiAlias = true;
     RectF rounderRectF = new RectF(x2 - (1.66f * density), y2 - (3.33f * density), x2 + (16.66f * density), y2 + (16.66f * density));
     paint.Color = (Color.ParseColor("#5f6872"));
     p0.DrawRoundRect(rounderRectF, 7, 7, paint);
     Path path = new Path();
     path.MoveTo(x2, y2 - (16.66f * density));
     path.LineTo(x2, y2);
     path.LineTo(x2 + (16.66f * density), y2 - (2 * density));
     path.Close();
     p0.DrawPath(path, paint);
     paint.StrokeWidth = (3.33f * density);
     p0.DrawLine(x1, y1, x2, y2, paint);
     SetRightThumbBounds(new RectF(x2 - 25, y1 - 25, x2 + 25, y2 + 25));
 }
Esempio n. 19
0
            protected override void OnDraw (Canvas canvas)
            {
                base.OnDraw (canvas);

                var width = canvas.Width;
                var height = canvas.Height;

                // Background
                int backgroundWidth = width - leftBorderWidth;
                rect.Set (leftBorderWidth, 0, width, height);
                canvas.DrawRect (rect, backgroundPaint);

                // Left border
                rect.Set (0, 0, leftBorderWidth, height);
                canvas.DrawRect (rect, borderPaint);

                for (int i = 0; i < xLabels.Length; i++) {
                    // X-axis line
                    var lineRight = (int) ((backgroundWidth - rightPadding) / (float)xLabels.Length * (i + 1));
                    canvas.DrawLine (
                        leftBorderWidth + lineRight,
                        topPadding,
                        leftBorderWidth + lineRight,
                        height - bottomPadding,
                        linePaint
                    );

                    // X-axis label
                    var label = xLabels [i];
                    xLabelPaint.GetTextBounds (label, 0, label.Length, rect);
                    canvas.DrawText (
                        label,
                        leftBorderWidth + lineRight - rect.Width () / 2f,
                        height - bottomPadding / 2f + rect.Height () / 2f,
                        xLabelPaint
                    );
                }
            }
Esempio n. 20
0
        private void DrawDebugInfo(Canvas canvas, View child)
        {
            if (!DebugDraw)
            {
                return;
            }

            var childPaint = CreatePaint(new Color(255, 255, 0, 255));
            var layoutPaint = CreatePaint(new Color(0, 255, 0, 255));
            var newLinePaint = CreatePaint(new Color(255, 0, 0, 255));

            var lp = (LayoutParams)child.LayoutParameters;

            if (lp.HorizontalSpacing > 0)
            {
                float x = child.Right;
                var y = child.Top + child.Height / 2.0f;
                canvas.DrawLine(x, y, x + lp.HorizontalSpacing, y, childPaint);
                canvas.DrawLine(x + lp.HorizontalSpacing - 4.0f, y - 4.0f, x + lp.HorizontalSpacing, y, childPaint);
                canvas.DrawLine(x + lp.HorizontalSpacing - 4.0f, y + 4.0f, x + lp.HorizontalSpacing, y, childPaint);
            }
            else
                if (HorizontalSpacing > 0)
                {
                    float x = child.Right;
                    var y = child.Top + child.Height / 2.0f;
                    canvas.DrawLine(x, y, x + HorizontalSpacing, y, layoutPaint);
                    canvas.DrawLine(x + HorizontalSpacing - 4.0f, y - 4.0f, x + HorizontalSpacing, y, layoutPaint);
                    canvas.DrawLine(x + HorizontalSpacing - 4.0f, y + 4.0f, x + HorizontalSpacing, y, layoutPaint);
                }

            if (lp.VerticalSpacing > 0)
            {
                var x = child.Left + child.Width / 2.0f;
                float y = child.Bottom;
                canvas.DrawLine(x, y, x, y + lp.VerticalSpacing, childPaint);
                canvas.DrawLine(x - 4.0f, y + lp.VerticalSpacing - 4.0f, x, y + lp.VerticalSpacing, childPaint);
                canvas.DrawLine(x + 4.0f, y + lp.VerticalSpacing - 4.0f, x, y + lp.VerticalSpacing, childPaint);
            }
            else if (VerticalSpacing > 0)
            {
                var x = child.Left + child.Width / 2.0f;
                float y = child.Bottom;
                canvas.DrawLine(x, y, x, y + VerticalSpacing, layoutPaint);
                canvas.DrawLine(x - 4.0f, y + VerticalSpacing - 4.0f, x, y + VerticalSpacing, layoutPaint);
                canvas.DrawLine(x + 4.0f, y + VerticalSpacing - 4.0f, x, y + VerticalSpacing, layoutPaint);
            }

            if (lp.NewLine)
            {
                if (Orientation == Horizontal)
                {
                    float x = child.Left;
                    var y = child.Top + child.Height / 2.0f;
                    canvas.DrawLine(x, y - 6.0f, x, y + 6.0f, newLinePaint);
                }
                else
                {
                    var x = child.Left + child.Width / 2.0f;
                    float y = child.Top;
                    canvas.DrawLine(x - 6.0f, y, x + 6.0f, y, newLinePaint);
                }
            }
        }
Esempio n. 21
0
        protected override void OnCreate(Bundle bundle)
        {
            //Set Display/Interactions/Counter Vars
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Main);
            Button clear = FindViewById<Button> (Resource.Id.ClearButton);
            Button save = FindViewById<Button> (Resource.Id.SaveButton);
            int CountX = -7, CountY = -7;
            var IV = FindViewById<ImageView> (Resource.Id.DisplayView);
            float x1=0, y1=0, x2=0, y2=0;
            Bitmap BM = Bitmap.CreateBitmap (760, 800, Bitmap.Config.Argb8888);

            //Set up Paint
            var P = new Paint();
            P.Color = Color.White;
            P.StrokeWidth = 15;
            Canvas C = new Canvas(BM);

            //Draw on Bitmap When Touched
            IV.Touch += (s, e) => {
                if (e.Event.Action == MotionEventActions.Down)
                {
                    x1 = e.Event.GetX();
                    y1 = e.Event.GetY();
                    x2 = e.Event.GetX();
                    y2 = e.Event.GetY();
                    Console.WriteLine ("Touched at X:"+x1+" Y:"+y1);
                    BM.SetPixel ((int)x1, (int)y1, Color.White);
                    IV.SetImageBitmap (BM);
                }
                if (e.Event.Action == MotionEventActions.Move)
                {
                    x1 = e.Event.GetX();
                    y1 = e.Event.GetY();
                    while(CountY<=7){
                        while(CountX<=7){
                            BM.SetPixel ((int)x1+CountX, (int)y1+CountY, Color.White);
                            CountX++;
                        }
                        CountX=-7;
                        CountY++;
                    }
                    Console.WriteLine ("Touched at X:"+x1+" Y:"+y1);
                    C.DrawLine(x1, y1, x2, y2, P);
                    IV.SetImageBitmap(BM);
                    x2 = x1;
                    y2 = y1;
                }
            };

            //Clear
            clear.Click += delegate {
                C.DrawARGB(255,0,0,0);
                IV.SetImageBitmap (BM);
            };

            //Save
            save.Click += delegate {
                ExportBitmapAsPNG(BM);
            };
        }
Esempio n. 22
0
        protected override void OnDraw(Canvas canvas)
        {
            int height = Height;
            int tabCount = ChildCount;
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height); // wielkosc robaczka w pixelach
            SlidingTabScrollView.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer; //sprawdza kolor jesli nie jest ustalony z gory zmienia sie na podstawowy

            // zmiana koloru pod aktualnym "oknem"  
            if (tabCount > 0) {
                View selectedTitle = GetChildAt(mSelectedPosition);
                int left = selectedTitle.Left;
                int right = selectedTitle.Right;
                int color = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1)) //sprawdza pozycje jesli jestesmy na ostatniej zak³adce nie pojdzie nigdzie dalej
                {
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
                    if (color!=nextColor)
                    {
                        color = blendColor(nextColor, color, mSelectionOffset);
                    }

                    View nextTitle = GetChildAt(mSelectedPosition + 1);
                    left = (int)(mSelectionOffset * nextTitle.Left + (1.0f - mSelectionOffset) * left);
                    right = (int)(mSelectionOffset * nextTitle.Right + (1.0f - mSelectionOffset) * right); // miejsca przeciec zak³adek przez robaczka                  
                }
                mSelectedIndicatorPaint.Color = GetColorFromIntiger(color);

                canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);

                //create vertical dividers between tabs

                int separatorTop = (height - dividerHeightPx) / 2;
                for (int i = 0; i < ChildCount; i++)
                {
                    View child = GetChildAt(i);
                    mDividerPaint.Color = GetColorFromIntiger(tabColorizer.GetDividerColor(i));
                    canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
                }
                canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
            }

        }
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            if(null == _viewPager) return;

            var count = _viewPager.Adapter.Count;
            if(count == 0) return;

            if(_currentPage >= count)
            {
                CurrentItem = count - 1;
                return;
            }

            var lineWidthAndGap = LineWidth + GapWidth;
            var indicatorWidth = (count * lineWidthAndGap) - GapWidth;

            var verticalOffset = PaddingTop + ((Height - PaddingTop - PaddingBottom) / 2.0f);
            float horizontalOffset = PaddingLeft;
            if(_centered)
                horizontalOffset += ((Width - PaddingLeft - PaddingRight) / 2.0f) - (indicatorWidth / 2.0f);

            //Draw stroked circles
            for(var i = 0; i < count; i++)
            {
                var dx1 = horizontalOffset + (i * lineWidthAndGap);
                var dx2 = dx1 + LineWidth;
                canvas.DrawLine(dx1, verticalOffset, dx2, verticalOffset, (i == _currentPage) ? _paintSelected : _paintUnSelected);
            }
        }
Esempio n. 24
0
		protected override void OnDraw(Canvas ca)  {

			if (fullImage == null || shouldUpdate) {

				fullImage = Bitmap.CreateBitmap (Width, Height, Bitmap.Config.Argb8888);
				Canvas canvas = new Canvas(fullImage);
				canvas.DrawColor(Color.Transparent);
				//NinePatchDrawable popup = (NinePatchDrawable)this.Resources.GetDrawable (Android.Resource.Drawable.AlertDarkFrame);

				float maxValue = 0;
				float padding = 7;
				int selectPadding = 4;
				float bottomPadding = 40;
				float usableHeight;
				if (showBarText) {
					this.p.TextSize = 40;
					this.p.GetTextBounds(unit, 0, 1, r3);
					usableHeight = Height - bottomPadding - Math.Abs(r3.Top - r3.Bottom) - 26;
				} else {
					usableHeight = Height - bottomPadding;
				}

				p.Color = Color.Black;
				p.StrokeWidth = 2;
				p.Alpha = 50;
				p.AntiAlias = true;

				canvas.DrawLine(0, Height - bottomPadding + 10, Width, Height - bottomPadding + 10, p);

				float barWidth = (Width - (padding * 2) * points.Count) / points.Count;

				foreach (Bar po in points) {
					maxValue += po.getValue();
				}

				r = new Rect();

				path.Reset();

				int count = 0;
				foreach (Bar po in points) {

					if(po.getStackedBar()){
						List<BarStackSegment> values = new List<BarStackSegment>(po.getStackedValues());
						int prevValue = 0;
						foreach (BarStackSegment value in values) {
							value.Value += prevValue;
							prevValue += value.Value;
						}
						//Collections.Reverse(values);

						foreach (BarStackSegment value in values) {
							r.Set((int) ((padding * 2) * count + padding + barWidth * count), (int) ((Height - bottomPadding - (usableHeight * (value.Value / maxValue)))), (int) ((padding * 2) * count + padding + barWidth * (count + 1)), (int) ((Height - bottomPadding)));
							path.AddRect(new RectF(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding), Path.Direction.Cw);
							po.setPath(path);
							po.setRegion(new Region(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding));
							this.p.Color = value.Color;
							this.p.Alpha = 255;
							canvas.DrawRect (r, this.p);
						}
					}else {
						r.Set((int) ((padding * 2) * count + padding + barWidth * count), (int) (Height - bottomPadding - (usableHeight * (po.getValue() / maxValue))), (int) ((padding * 2) * count + padding + barWidth * (count + 1)), (int) (Height - bottomPadding));
						path.AddRect(new RectF(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding), Path.Direction.Cw);
						po.setPath(path);
						po.setRegion(new Region(r.Left - selectPadding, r.Top - selectPadding, r.Right + selectPadding, r.Bottom + selectPadding));
						this.p.Color = po.getColor ();
						this.p.Alpha=255;
						canvas.DrawRect(r, this.p);
					}

					this.p.TextSize = 20;
					canvas.DrawText(po.getName(), (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(po.getName()) / 2)), Height - 5, this.p);
					if (showBarText) {
						this.p.TextSize=40;
						this.p.Color=Color.White;
						this.p.GetTextBounds (unit + po.getValue (), 0, 1, r2);
//						if (popup != null)
//							popup.SetBounds((int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)) - 14, r.Top + (r2.Top - r2.Bottom) - 26, (int) (((r.Left + r.Right) / 2) + (this.p.MeasureText(unit + po.getValue()) / 2)) + 14, r.Top);
//						popup.Draw(canvas);
						if (isAppended())
							canvas.DrawText(po.getValue() + unit, (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)), r.Top - 20, this.p);
						else
							canvas.DrawText(unit + po.getValue(), (int) (((r.Left + r.Right) / 2) - (this.p.MeasureText(unit + po.getValue()) / 2)), r.Top - 20, this.p);
					}
					if (indexSelected == count && listener != null) {
						this.p.Color = Color.ParseColor ("#33B5E5");
						this.p.Alpha = 100;
						canvas.DrawPath (po.getPath (), this.p);
						this.p.Alpha = 255;
					}
					count++;
				}
				shouldUpdate = false;
			}
			ca.DrawBitmap(fullImage, 0, 0, null);
		}
Esempio n. 25
0
 private void drawLine(Canvas canvas, Paint paint, ResultPoint a, ResultPoint b)
 {
     canvas.DrawLine(a.X, a.Y, b.X, b.Y, paint);
 }
Esempio n. 26
0
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);
            if (!this.IsInEditMode)
            {
                //draw the dragable joystick
                canvas.DrawBitmap(BitmapFactory.DecodeResource(Resources, Resource.Drawable.joystick), _touchingPoint.X, _touchingPoint.Y, null);
            }
            //for debugging in edit mode
            else
            {
                Paint innerCirclePaint = new Paint();
                innerCirclePaint.SetARGB(255, 255, 255, 255);
                innerCirclePaint.AntiAlias = true;

                innerCirclePaint.SetStyle(Paint.Style.Fill);
                canvas.DrawLine(0, 0, 60, 50, innerCirclePaint);
            }
        }
Esempio n. 27
0
        protected override void OnDraw(Canvas canvas)
        {
            int height = Height;
            int tabCount = ChildCount;
            int dividerHeightPx = (int)(Math.Min(Math.Max(0f, mDividerHeight), 1f) * height);
            SlidingTabScrollView1.TabColorizer tabColorizer = mCustomTabColorizer != null ? mCustomTabColorizer : mDefaultTabColorizer;

            //Thick colored underline below the current selection
            if (tabCount > 0)
            {
                View selectedTitle = GetChildAt(mSelectedPosition);
                int left = selectedTitle.Left;
                int right = selectedTitle.Right;
                int color = tabColorizer.GetIndicatorColor(mSelectedPosition);

                if (mSelectionOffset > 0f && mSelectedPosition < (tabCount - 1))
                {
                    int nextColor = tabColorizer.GetIndicatorColor(mSelectedPosition + 1);
                    if (color != nextColor)
                    {
                        color = blendColor(nextColor, color, mSelectionOffset);
                    }

                    View nextTitle = GetChildAt(mSelectedPosition + 1);
                    left = (int)(mSelectionOffset * nextTitle.Left + (1.0f - mSelectionOffset) * left);
                    right = (int)(mSelectionOffset * nextTitle.Right + (1.0f - mSelectionOffset) * right);
                }

                mSelectedIndicatorPaint.Color = GetColorFromInteger(color);

                canvas.DrawRect(left, height - mSelectedIndicatorThickness, right, height, mSelectedIndicatorPaint);

                //Creat vertical dividers between tabs
                int separatorTop = (height - dividerHeightPx) / 2;
                for (int i = 0; i < ChildCount; i++)
                {
                    View child = GetChildAt(i);
                    mDividerPaint.Color = GetColorFromInteger(tabColorizer.GetDividerColor(i));
                    canvas.DrawLine(child.Right, separatorTop, child.Right, separatorTop + dividerHeightPx, mDividerPaint);
                }

                canvas.DrawRect(0, height - mBottomBorderThickness, Width, height, mBottomBorderPaint);
            }
        }
Esempio n. 28
0
        protected override void OnDraw(Canvas canvas)
        {
            if (!parmsSet)
                return;
            float border = 20;
            float horstart = border * 2;
            float height = Height;
            float width = Width - 1;
            float max = getMax();
            float min = getMin();
            float diff = max - min;
            float graphheight = height - (2 * border);
            float graphwidth = width - (2 * border);

            paint.TextAlign = Paint.Align.Left;
            int vers = verlabels.Length - 1;
            for (int i = 0; i < verlabels.Length; i++) {
                paint.Color = Color.DarkGray;
                float y = ((graphheight / vers) * i) + border;
                canvas.DrawLine(horstart, y, width, y, paint);
                paint.Color = Color.White;
                canvas.DrawText(verlabels[i], 0, y, paint);
            }
            int hors = horlabels.Length - 1;
            for (int i = 0; i < horlabels.Length; i++) {
                paint.Color = Color.DarkGray;
                float x = ((graphwidth / hors) * i) + horstart;
                canvas.DrawLine(x, height - border, x, border, paint);
                paint.TextAlign = Paint.Align.Center;
                if (i == horlabels.Length - 1)
                    paint.TextAlign = Paint.Align.Right;
                if (i == 0)
                    paint.TextAlign = Paint.Align.Left;
                paint.Color = Color.White;
                canvas.DrawText(horlabels[i], x, height - 4, paint);
            }

            paint.TextAlign = Paint.Align.Center;
            canvas.DrawText(title, (graphwidth / 2) + horstart, border - 4, paint);

            if (max != min) {
                paint.Color = Color.LightGray;
                if (type == BAR) {
                    float datalength = values.Length;
                    float colwidth = (width - (2 * border)) / datalength;
                    for (int i = 0; i < values.Length; i++) {
                        float val = values[i] - min;
                        float rat = val / diff;
                        float h = graphheight * rat;
                        canvas.DrawRect((i * colwidth) + horstart, (border - h) + graphheight, ((i * colwidth) + horstart) + (colwidth - 1), height - (border - 1), paint);
                    }
                } else {
                    float datalength = values.Length;
                    float colwidth = (width - (2 * border)) / datalength;
                    float halfcol = colwidth / 2;
                    float lasth = 0;
                    for (int i = 0; i < values.Length; i++) {
                        float val = values[i] - min;
                        float rat = val / diff;
                        float h = graphheight * rat;
                        if (i > 0)
                            canvas.DrawLine(((i - 1) * colwidth) + (horstart + 1) + halfcol, (border - lasth) + graphheight, (i * colwidth) + (horstart + 1) + halfcol, (border - h) + graphheight, paint);
                        lasth = h;
                    }
                }
            }
        }
Esempio n. 29
0
			void DrawHands(Canvas canvas, Rect bounds)
			{
				var width = bounds.Width();
				var height = bounds.Height();
				var centerX = width / 2.0f;
				var centerY = height / 2.0f;

				calendar.TimeInMillis = Java.Lang.JavaSystem.CurrentTimeMillis();
				var hour = calendar.Get(CalendarField.Hour);
				var minute = calendar.Get(CalendarField.Minute);
				var second = calendar.Get(CalendarField.Second);

				var secRot = second / 30f * (float)Math.PI;
				var minutes = minute;
				var minRot = minutes / 30f * (float)Math.PI;
				var hrRot = ((hour + (minutes / 60f)) / 6f) * (float)Math.PI;

				var secLength = centerX - 20;
				var minLength = centerX - 40;
				var hrLength = centerX - 80;

				if (!IsInAmbientMode)
				{
					var secX = (float)Math.Sin(secRot) * secLength;
					var secY = (float)-Math.Cos(secRot) * secLength;
					canvas.DrawLine(centerX, centerY, centerX + secX, centerY + secY, secondPaint);
				}

				var minX = (float)Math.Sin(minRot) * minLength;
				var minY = (float)-Math.Cos(minRot) * minLength;
				canvas.DrawLine(centerX, centerY, centerX + minX, centerY + minY, minutePaint);

				var hrX = (float)Math.Sin(hrRot) * hrLength;
				var hrY = (float)-Math.Cos(hrRot) * hrLength;
				canvas.DrawLine(centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);
			}
Esempio n. 30
0
        void HandleScanResult(ZXing.Result result)
        {
            string msg = "";

            if (result != null && !string.IsNullOrEmpty(result.Text))
                msg = "Found Barcode: " + result.Text;
            else
                msg = "Scanning Canceled!";

            this.RunOnUiThread(() => {
                Toast.MakeText(this, msg, ToastLength.Short).Show();
                hideImage.Visibility = ViewStates.Visible;
                previewImage.Visibility = ViewStates.Visible;
                Bitmap resultBitmap = result.CaptureImage as Bitmap;
                Bitmap canvasMap = resultBitmap.Copy(resultBitmap.GetConfig(), true);
                Canvas newCanvas = new Canvas(canvasMap);
                Paint thePaint = new Paint(PaintFlags.AntiAlias);

                thePaint.Color = Color.Red;
                thePaint.StrokeWidth = 2;
                newCanvas.DrawLine(result.ResultPoints[0].X, result.ResultPoints[0].Y, result.ResultPoints[1].X, result.ResultPoints[1].Y, thePaint);
                thePaint.Color = Color.Green;
                newCanvas.DrawLine(result.ResultPoints[1].X, result.ResultPoints[1].Y, result.ResultPoints[2].X, result.ResultPoints[2].Y, thePaint);
                thePaint.Color = Color.Blue;
                newCanvas.DrawLine(result.ResultPoints[2].X, result.ResultPoints[2].Y, result.ResultPoints[3].X, result.ResultPoints[3].Y, thePaint);
                thePaint.Color = Color.Yellow;
                newCanvas.DrawLine(result.ResultPoints[3].X, result.ResultPoints[3].Y, result.ResultPoints[0].X, result.ResultPoints[0].Y, thePaint);
                previewImage.SetImageBitmap(canvasMap);
            });
        }
        private void DrawLine(Canvas canvas, int canvasWidth, float startX, float startY, float stopX, float stopY, int currentIndexColor)
        {
            _paint.Color = _colors[currentIndexColor];

            if (!_mirrorMode)
            {
                canvas.DrawLine(startX, startY, stopX, stopY, _paint);
            }
            else
            {
                if (_reversed)
                {
                    canvas.DrawLine(canvasWidth + startX, startY, canvasWidth + stopX, stopY, _paint);
                    canvas.DrawLine(canvasWidth - startX, startY, canvasWidth - stopX, stopY, _paint);
                }
                else
                {
                    canvas.DrawLine(startX, startY, stopX, stopY, _paint);
                    canvas.DrawLine(canvasWidth * 2 - startX, startY, canvasWidth * 2 - stopX, stopY, _paint);
                }
            }

            canvas.Save();
        }
Esempio n. 32
0
        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);

            try
            {
                // 3000 -|
                //       |
                // 2000 -|
                //       |
                //    0 ---------------------------
                //         Tu We Th Fr Sa Su Mo Avg
                //  # Breakf  # Lunch  # Dinner  # Snack


                /*
                 * string[] yaxis = { "3.000", "2.250", "1.500", "750", "0" };
                 * string[] xaxis = { "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "Today", "Avg" };
                 * string[] legend = { "Breakfast", "Lunch", "Dinner", Property };//"Snack" };
                 * Single[][] values = new Single[4][];
                 * values [0] = new Single[]{ 0.1F, 0.13F, 0.2F, 0.03F, 0.12F, 0.13F, 0.12F, 0.03F };
                 * values [1] = new Single[]{ .3F, .2F, .3F, .2F, .3F, .2F, .3F, .2F };
                 * values [2] = new Single[]{ .2F, .3F, .2F, .3F, .2F, .3F, .2F, .3F };
                 * values [3] = new Single[]{ .3F, .2F, .3F, .2F, .3F, .2F, .3F, .2F };
                 */
                string[]   yaxis;
                string[]   xaxis = new string[8];
                string[]   legend;
                Single[][] values;

                Single goalBar;// = 0.7F;


                // calculate data
                Single goal = UserSettings.Current.GetGoal(property);

                Amount Goal;

                if (Single.IsNaN(goal) || goal == 0)
                {
                    Goal = Amount.Zero;
                }
                else
                {
                    Goal = Amount.FromProperty(goal, property);
                }

                Amount Max = Goal;

                HashSet <Period> UsedPeriods = new HashSet <Period>();

                int firstdate = -1;

                // query values
                for (int i = 0; i < 7; i++)
                {
                    DateTime date = DateTime.Now.Date.AddDays(-6 + i);

                    int    j = 0;
                    Amount amount;
                    Amount total = Amount.Zero;
                    foreach (Period p in PeriodList.All)
                    {
                        amount = Cache.GetPeriodPropertyValue(date, p, property);
                        total += amount;
                        if (!amount.IsZero && !UsedPeriods.Contains(p))
                        {
                            UsedPeriods.Add(p);
                        }
                        j++;
                    }

                    if (!total.IsZero && firstdate == -1)
                    {
                        firstdate = i;
                    }

                    if (i == 6)
                    {
                        xaxis[i] = AppResources.Today;
                    }
                    else if (i >= firstdate)
                    {
                        xaxis[i] = date.ToString("ddd");
                    }
                    else
                    {
                        xaxis[i] = "";
                    }

                    if (Max < total)
                    {
                        Max = total;
                    }
                }

                xaxis[7] = "";

                // determine legend periods
                List <Period> DisplayPeriods = new List <Period>(); // in order
                foreach (Period p in PeriodList.All)
                {
                    if (UsedPeriods.Contains(p))
                    {
                        DisplayPeriods.Add(p);
                    }
                }

                goalBar = Top(Goal, Max);

                yaxis = new string[] {
                    Max.ValueString(),
                    (Max * .75).ValueString(),
                    (Max * .5).ValueString(),
                    (Max * .25).ValueString(),
                    "0"
                };

                legend = new string[DisplayPeriods.Count];
                values = new float[DisplayPeriods.Count][];

                for (int j = 0; j < DisplayPeriods.Count; j++)
                {
                    Single sum = 0;
                    legend[j] = Strings.FromEnum(DisplayPeriods[j]);
                    values[j] = new float[8];

                    for (int i = 0; i < 7; i++)
                    {
                        DateTime date   = DateTime.Now.Date.AddDays(-6 + i);
                        Amount   amount = Cache.GetPeriodPropertyValue(date, DisplayPeriods[j], property);

                        values[j][i] = Top(amount, Max);
                        sum         += values[j][i];
                    }
                    values[j][7] = (sum / (7 - firstdate));
                }

                /*
                 * Color[] colors = {
                 *  Color.Rgb (200, 150, 0),
                 *  Color.Rgb (239, 179, 0),
                 *  Color.Rgb (255, 202, 105),
                 *  Color.Rgb (255, 221, 173)
                 * };
                 */

                Color[] colors; // = {					Resources.GetColor(Resource.Color.bar_color),					Resources.GetColor(Resource.Color.baralternate_color)				};

                int dcnt = DisplayPeriods.Count;

                colors = new Color[dcnt];
                for (float i = 0; i < dcnt; i++)
                {
                    Color refcolor = this.property.Color;// Resources.GetColor (Resource.Color.baralternate_color);
                    colors[(int)i] = new Color(MakeColor(refcolor.R, i / dcnt), MakeColor(refcolor.G, i / dcnt), MakeColor(refcolor.B, i / dcnt));
                }
                // start drawing

                Paint paint = new Paint();
                paint.Color    = Color.Black;
                paint.TextSize = Resources.GetDimensionPixelSize(Resource.Dimension.graphtextsize);

                Paint faintpaint = new Paint();
                faintpaint.Color = Color.Rgb(230, 230, 230);                                         // Color.LightGray;

                int middlemargin = Resources.GetDimensionPixelSize(Resource.Dimension.graphpadding); //10; // margin inbetween drawing regions only

                Rect   ylargest;
                Rect   xlargest;
                Rect   llargest;
                Rect[] ybounds = GetTextBounds(yaxis, paint, out ylargest);
                Rect[] xbounds = GetTextBounds(xaxis, paint, out xlargest);
                Rect[] lbounds = GetTextBounds(legend, paint, out llargest);

                // if labels are rotated 45 degrees; height = sqrt((label width + labelhieght)^2/2)
                //int xaxisheight = Math.Sqrt (((xlargest.Width + xlargest.Height) ^ 2) / 2);
                int xaxisheight = xlargest.Height();

                Rect bounds     = canvas.ClipBounds;
                Rect legendrect = new Rect(ylargest.Width() + middlemargin, bounds.Height() - llargest.Height(), bounds.Width() - middlemargin, bounds.Height() - middlemargin);
                Rect plotrect   = new Rect(ylargest.Width() + middlemargin, ylargest.Height(), bounds.Width(), legendrect.Top - xaxisheight - (int)(middlemargin * 1.5) - ylargest.Height() / 2);
                Rect yaxisrect  = new Rect(0, 0, ylargest.Width(), plotrect.Height() + llargest.Height());
                Rect xaxisrect  = new Rect(plotrect.Left, plotrect.Bottom + middlemargin, plotrect.Right, legendrect.Top - (int)(middlemargin * 1.5));

                // draw avg background
                canvas.DrawRect(plotrect.Left + plotrect.Width() * (xaxis.Length - 1) / xaxis.Length, plotrect.Top, plotrect.Right, plotrect.Bottom, faintpaint);

                // canvas.DrawRect (legendrect, faintpaint);
                // canvas.DrawRect (xaxisrect, faintpaint);

                // y axis
                for (int i = 0; i < yaxis.Length; i++)
                {
                    // draw y axis text
                    Single y = plotrect.Top + plotrect.Height() * i / (yaxis.Length - 1);
                    canvas.DrawText(yaxis[i], yaxisrect.Right - ybounds[i].Width(), y + ybounds[i].Height() / 2, paint);
                    // draw notch
                    canvas.DrawLine(yaxisrect.Right + middlemargin / 2, y, plotrect.Left, y, paint);

                    // draw horizontal line
                    canvas.DrawLine(plotrect.Left, y, plotrect.Right, y, (i == yaxis.Length - 1) ? paint : faintpaint);
                }
                canvas.DrawLine(plotrect.Left, plotrect.Top, plotrect.Left, plotrect.Bottom + middlemargin / 2, paint);

                // x axis
                for (int i = 0; i < xaxis.Length; i++)
                {
                    // draw x axis text
                    Single x = xaxisrect.Left + plotrect.Width() * (i + 0.5F) / xaxis.Length;
                    canvas.DrawText(xaxis[i], x - xbounds[i].Width() / 2, xaxisrect.Bottom, paint);
                    // draw notch
                    x = xaxisrect.Right - plotrect.Width() * i / xaxis.Length - 1;
                    canvas.DrawLine(x, plotrect.Bottom, x, plotrect.Bottom + middlemargin / 2, paint);
                }

                // legend
                int cubesize = middlemargin;
                int legendw  = (cubesize + middlemargin * 2) * legend.Length;
                for (int i = 0; i < legend.Length; i++)
                {
                    legendw += lbounds[i].Right;
                }

                legendrect.Left += (legendrect.Width() - legendw) / 2;

                Paint colorPaint = new Paint();
                int   dx         = 0;
                for (int i = 0; i < legend.Length; i++)
                {
                    // cube
                    colorPaint.Color = colors[i % colors.Length];
                    Single x = legendrect.Left + dx; // legendrect.Width () * i / legend.Length;
                    Single y = legendrect.Top + legendrect.Height() / 2;
                    canvas.DrawRect(x, y - (int)(cubesize / 2.5), x + cubesize, y + (int)(cubesize / 1.5), colorPaint);
                    // legend text
                    canvas.DrawText(legend[i], x + cubesize + middlemargin / 2, y + (int)(cubesize / 1.5), paint);
                    dx += cubesize + middlemargin * 2 + lbounds[i].Right;
                }
                dateOfValues.Clear();
                int      barwidth = middlemargin * 2;
                Single[] bottoms  = new Single[xaxis.Length];
                for (int i = 0; i < values.Length; i++)
                {
                    colorPaint.Color = colors[i % colors.Length];

                    for (int j = 0; j < values[i].Length; j++)
                    {
                        DateTime date = DateTime.Now.Date.AddDays(-6 + j);

                        if (i == 0)
                        {
                            bottoms[j] = plotrect.Bottom;
                        }

                        Single x       = plotrect.Left + plotrect.Width() * (j + 0.5F) / xaxis.Length;
                        Single h       = plotrect.Height() * values[i][j];
                        var    dLeft   = x - barwidth / 2;
                        var    dTop    = bottoms[j] - h;
                        var    dRight  = x + barwidth / 2;
                        var    dBottom = bottoms[j];
                        if (dateOfValues.Count < 7)
                        {
                            dateOfValues.Add(new KeyValuePair <DateTime, float[]>(date, new float[2] {
                                dLeft, dRight
                            }));
                        }
                        canvas.DrawRect(dLeft, dTop, dRight, dBottom, colorPaint);

                        bottoms[j] -= h;
                    }
                }
                foreach (var item in dateOfValues)
                {
                    System.Diagnostics.Debug.WriteLine(item.Key.Day + "  " + item.Value[0] + "-" + item.Value[1]);
                }
                // draw goal
                Paint dashespaint = new Paint();
                dashespaint.Color = Color.DarkGray;
                dashespaint.SetStyle(Paint.Style.Stroke);
                dashespaint.SetPathEffect(new DashPathEffect(new float[] { 10, 5 }, 0));
                //canvas.DrawLine (plotrect.Left, plotrect.Bottom - plotrect.Height () * goalBar, plotrect.Right, plotrect.Bottom - plotrect.Height () * goalBar, dashespaint);

                // use a path to draw dashes
                Path baseline = new Path();
                baseline.MoveTo(plotrect.Left, plotrect.Bottom - plotrect.Height() * goalBar);
                baseline.LineTo(plotrect.Right, plotrect.Bottom - plotrect.Height() * goalBar);
                canvas.DrawPath(baseline, dashespaint);
            }
            catch (Exception ex)
            {
                LittleWatson.ReportException(ex);
            }
        }
		/// <summary>
		/// Implement this to do your drawing.
		/// </summary>
		/// <param name="canvas">the canvas on which the background will be drawn</param>
		/// <since version="Added in API level 1" />
		/// <remarks>
		///   <para tool="javadoc-to-mdoc">Implement this to do your drawing.</para>
		///   <para tool="javadoc-to-mdoc">
		///   <format type="text/html">
		///   <a href="http://developer.android.com/reference/android/view/View.html#onDraw(android.graphics.Canvas)" target="_blank">[Android Documentation]</a>
		///   </format>
		///   </para>
		/// </remarks>
		protected override void OnDraw(Canvas canvas)
		{
			base.OnDraw(canvas);

			if (IsInEditMode || _tabCount == 0)
			{
				//Log(LogPriority.Info, "Exiting OnDraw early");
				return;
			}

			int height = Height;

			// draw indicator line

			_rectPaint.Color = _indicatorColor;

			// default: line below current tab
			View currentTab = _tabsContainer.GetChildAt(_currentPosition);
			float lineLeft = currentTab.Left;
			float lineRight = currentTab.Right;
			// if there is an offset, start interpolating left and right coordinates between current and next tab

			if (_currentPositionOffset > 0f && _currentPosition < _tabCount - 1)
			{
				View nextTab = _tabsContainer.GetChildAt(_currentPosition + 1);
				float nextTabLeft = nextTab.Left;
				float nextTabRight = nextTab.Right;

				lineLeft = (_currentPositionOffset * nextTabLeft + (1f - _currentPositionOffset) * lineLeft);
				lineRight = (_currentPositionOffset * nextTabRight + (1f - _currentPositionOffset) * lineRight);
			}

			canvas.DrawRect(lineLeft, height - _indicatorHeight, lineRight, height, _rectPaint);

			// draw underliner
			_rectPaint.Color = _underlineColor;
			canvas.DrawRect(0, height - _underlineHeight, _tabsContainer.Width, height, _rectPaint);

			// draw divider

			_dividerPaint.Color = _dividerColor;
			for (int i = 0; i < _tabCount - 1; i++)
			{
				View tab = _tabsContainer.GetChildAt(i);
				canvas.DrawLine(tab.Right, _dividerPadding, tab.Right, height - _dividerPadding, _dividerPaint);
			}
		}
            public override void OnDraw(Canvas canvas, Rect bounds)
            {
                if (Log.IsLoggable (Tag, LogPriority.Debug)) {
                    Log.Debug (Tag, "onDraw");
                }
                long now = Java.Lang.JavaSystem.CurrentTimeMillis ();
                time.Set (now);
                int milliseconds = (int)(now % 1000);

                int width = bounds.Width ();
                int height = bounds.Height ();

                // Draw the background, scaled to fit.
                if (backgroundScaledBitmap == null
                    || backgroundScaledBitmap.Width != width
                    || backgroundScaledBitmap.Height != height) {
                    backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap,
                        width, height, true /* filter */);
                }
                canvas.DrawColor (Color.Black);
                canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null);

                float centerX = width / 2.0f;
                float centerY = height / 2.0f;

                // Draw the ticks.
                float innerTickRadius = centerX - 10;
                float outerTickRadius = centerX;
                for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
                    float tickRot = (float)(tickIndex * Math.PI * 2 / 12);
                    float innerX = (float)Math.Sin (tickRot) * innerTickRadius;
                    float innerY = (float)-Math.Cos (tickRot) * innerTickRadius;
                    float outerX = (float)Math.Sin (tickRot) * outerTickRadius;
                    float outerY = (float)-Math.Cos (tickRot) * outerTickRadius;
                    canvas.DrawLine (centerX + innerX, centerY + innerY,
                        centerX + outerX, centerY + outerY, tickPaint);
                }

                float seconds = time.Second + milliseconds / 1000f;
                float secRot = seconds / 30f * (float)Math.PI;
                int minutes = time.Minute;
                float minRot = minutes / 30f * (float)Math.PI;
                float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI;

                float secLength = centerX - 20;
                float minLength = centerX - 40;
                float hrLength = centerX - 80;

                if (!IsInAmbientMode) {
                    float secX = (float)Math.Sin (secRot) * secLength;
                    float secY = (float)-Math.Cos (secRot) * secLength;
                    canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint);
                }

                float minX = (float)Math.Sin (minRot) * minLength;
                float minY = (float)-Math.Cos (minRot) * minLength;
                canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint);

                float hrX = (float)Math.Sin (hrRot) * hrLength;
                float hrY = (float)-Math.Cos (hrRot) * hrLength;
                canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);

                if (IsVisible && !IsInAmbientMode) {
                    Invalidate ();
                }
            }
Esempio n. 35
0
			/// <summary>
			/// Draws the ship, fuel/speed bars, and background to the provided
			/// Canvas.
			/// </summary>
			private void DoDraw(Canvas canvas)
			{
				// Draw the background image. Operations on the Canvas accumulate
				// so this is like clearing the screen.
				canvas.DrawBitmap(mBackgroundImage, 0, 0, null);

				int yTop = mCanvasHeight - ((int) mY + mLanderHeight / 2);
				int xLeft = (int) mX - mLanderWidth / 2;

				// Draw the fuel gauge
				int fuelWidth = (int)(UI_BAR * mFuel / PHYS_FUEL_MAX);
				mScratchRect.Set(4, 4, 4 + fuelWidth, 4 + UI_BAR_HEIGHT);
				canvas.DrawRect(mScratchRect, mLinePaint);

				// Draw the speed gauge, with a two-tone effect
				double speed = Math.Sqrt(mDX * mDX + mDY * mDY);
				int speedWidth = (int)(UI_BAR * speed / PHYS_SPEED_MAX);

				if (speed <= mGoalSpeed)
				{
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + speedWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaint);
				}
				else
				{
					// Draw the bad color in back, with the good color in front of
					// it
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + speedWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaintBad);
					int goalWidth = (UI_BAR * mGoalSpeed / PHYS_SPEED_MAX);
					mScratchRect.Set(4 + UI_BAR + 4, 4, 4 + UI_BAR + 4 + goalWidth, 4 + UI_BAR_HEIGHT);
					canvas.DrawRect(mScratchRect, mLinePaint);
				}

				// Draw the landing pad
				canvas.DrawLine(mGoalX, 1 + mCanvasHeight - TARGET_PAD_HEIGHT, mGoalX + mGoalWidth, 1 + mCanvasHeight - TARGET_PAD_HEIGHT, mLinePaint);


				// Draw the ship with its current rotation
				canvas.Save();
				canvas.Rotate((float) mHeading, (float) mX, mCanvasHeight - (float) mY);
				if (mMode == STATE_LOSE)
				{
					mCrashedImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mCrashedImage.Draw(canvas);
				}
				else if (mEngineFiring)
				{
					mFiringImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mFiringImage.Draw(canvas);
				}
				else
				{
					mLanderImage.SetBounds(xLeft, yTop, xLeft + mLanderWidth, yTop + mLanderHeight);
					mLanderImage.Draw(canvas);
				}
				canvas.Restore();
			}
Esempio n. 36
0
        protected override void OnDraw(Canvas canvas)
        {
            base.OnDraw(canvas);

            if (Border == false)
            {
                return;
            }

            float width = this.Width - (paint.StrokeWidth);
            float height = this.Height - (paint.StrokeWidth);

            canvas.DrawLine(0, 0, width, 0, paint);
            canvas.DrawLine(width, 0, width, height, paint);
            canvas.DrawLine(0, height, width, height, paint);
            canvas.DrawLine(0, 0, 0, height, paint);
        }
Esempio n. 37
0
        private void DoDraw(Canvas canvas)
        {
			// Increment / reset
            size += delta;
            if (size > 250)
            {
				delta = -1;
            } 
			else if (size < 30) 
			{
				delta = 1;
			}

            // Set background color
            canvas.DrawColor(Color.BLUE); 
            var paint = new Paint();
            paint.TextAlign =(Paint.Align.CENTER);

            // Draw some lines
            canvas.DrawLine(mX, mY, mY + 33, mX + 100, paint);
            paint.Color =(Color.RED);
            paint.StrokeWidth = (10);
            canvas.DrawLine(87, 0, 75, 100, paint);
            paint.Color =(Color.GREEN);
            paint.StrokeWidth = (5);
            for (int y = 30, alpha = 128; alpha > 2; alpha >>= 1, y += 10)
            {
                paint.Alpha = (alpha);

                canvas.DrawLine(mY, y, mY + 100, y, paint);
            }

            // Draw a red rectangle
            paint.Color =(Color.RED);
            var rect = new Rect();
            rect.Set(size + 120, 130, size + 156, 156);
            canvas.DrawRect(rect, paint);

            // Draw a circle
            paint.Color =(Color.ParseColor("#ffd700"));
            canvas.DrawCircle(size * 2, 220, 30, paint); //faster circle

            // Draw red'ish rectangle
            paint.Color =(Color.Rgb(128, 20, 20));
            canvas.DrawRect(size, 67, 68, 45, paint);

            // Draw green circle
            paint.Color =(Color.GREEN);
            canvas.DrawCircle(size, 140.0f - size / 3, 45.0f, paint); //move circle across screen
            paint.Color =(Color.RED);
            canvas.DrawText("Dot42", size, 140.0f - size / 3, paint);

            // Draw magenta circle
            paint.Color =(Color.MAGENTA);
            canvas.DrawCircle(mX, mY, size / 4.0f, paint); //move circle down screen
            paint.Color =(Color.GREEN);
            canvas.DrawText("is", mX, mY, paint);

            // Draw yellow rectangle
            paint.Alpha = (64);
            paint.Color =(Color.YELLOW);
            canvas.DrawRect(size, size, size + 45, size + 45, paint);
            // Draw text on rectangle
            paint.Alpha = (255);
            paint.Color =(Color.DKGRAY);
            canvas.DrawText("fun!", size + 45 / 2, size + 45 / 2, paint);
        }
Esempio n. 38
0
            //Actual Draw of analogue niddle in Canvas which will show in watch surface
            public override void OnDraw(Canvas canvas, Rect bounds)
            {
                time.SetToNow ();
                int width = bounds.Width ();
                int height = bounds.Height ();

                // Draw the background, scaled to fit.
                if (backgroundScaledBitmap == null
                    || backgroundScaledBitmap.Width != width
                    || backgroundScaledBitmap.Height != height) {
                    backgroundScaledBitmap = Bitmap.CreateScaledBitmap (backgroundBitmap,
                        width, height, true /* filter */);
                }
                canvas.DrawColor (Color.Black);
                canvas.DrawBitmap (backgroundScaledBitmap, 0, 0, null);

                float centerX = width / 2.0f;
                float centerY = height / 2.0f;

                // Draw the ticks.
                float innerTickRadius = centerX - 10;
                float outerTickRadius = centerX;
                for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
                    float tickRot = (float)(tickIndex * Math.PI * 2 / 12);
                    float innerX = (float)Math.Sin (tickRot) * innerTickRadius;
                    float innerY = (float)-Math.Cos (tickRot) * innerTickRadius;
                    float outerX = (float)Math.Sin (tickRot) * outerTickRadius;
                    float outerY = (float)-Math.Cos (tickRot) * outerTickRadius;
                    canvas.DrawLine (centerX + innerX, centerY + innerY,
                        centerX + outerX, centerY + outerY, tickPaint);
                }

                float secRot = time.Second / 30f * (float)Math.PI;
                int minutes = time.Minute;
                float minRot = minutes / 30f * (float)Math.PI;
                float hrRot = ((time.Hour + (minutes / 60f)) / 6f) * (float)Math.PI;

                float secLength = centerX - 20;
                float minLength = centerX - 40;
                float hrLength = centerX - 80;

                if (!IsInAmbientMode) {
                    float secX = (float)Math.Sin (secRot) * secLength;
                    float secY = (float)-Math.Cos (secRot) * secLength;
                    canvas.DrawLine (centerX, centerY, centerX + secX, centerY + secY, secondPaint);
                }

                float minX = (float)Math.Sin (minRot) * minLength;
                float minY = (float)-Math.Cos (minRot) * minLength;
                canvas.DrawLine (centerX, centerY, centerX + minX, centerY + minY, minutePaint);

                float hrX = (float)Math.Sin (hrRot) * hrLength;
                float hrY = (float)-Math.Cos (hrRot) * hrLength;
                canvas.DrawLine (centerX, centerY, centerX + hrX, centerY + hrY, hourPaint);
            }
Esempio n. 39
0
			void DrawFace(Canvas canvas, Rect bounds)
			{
				var width = bounds.Width();
				var height = bounds.Height();

				// Draw the background, scaled to fit.
				if (backgroundScaledBitmap == null
					|| backgroundScaledBitmap.Width != width
					|| backgroundScaledBitmap.Height != height)
				{
					backgroundScaledBitmap = Bitmap.CreateScaledBitmap(backgroundBitmap,
						width, height, true /* filter */);
				}
				canvas.DrawColor(Color.Black);
				canvas.DrawBitmap(backgroundScaledBitmap, 0, 0, null);

				var centerX = width / 2.0f;
				var centerY = height / 2.0f;

				// Draw the ticks.
				var innerTickRadius = centerX - 10;
				var outerTickRadius = centerX;
				for (var tickIndex = 0; tickIndex < 12; tickIndex++)
				{
					var tickRot = (float)(tickIndex * Math.PI * 2 / 12);
					var innerX = (float)Math.Sin(tickRot) * innerTickRadius;
					var innerY = (float)-Math.Cos(tickRot) * innerTickRadius;
					var outerX = (float)Math.Sin(tickRot) * outerTickRadius;
					var outerY = (float)-Math.Cos(tickRot) * outerTickRadius;
					canvas.DrawLine(centerX + innerX, centerY + innerY,
						centerX + outerX, centerY + outerY, tickPaint);
				}
			}
		protected override void OnDraw(Canvas ca)  {
			if (fullImage == null || shouldUpdate) {
				fullImage = Bitmap.CreateBitmap (Width, Height, Bitmap.Config.Argb8888);
				Canvas canvas = new Canvas(fullImage);
				String max = (int)maxY+"";// used to display max
				String min = (int)minY+"";// used to display min
				paint.Reset ();
				Path path = new Path();

				float bottomPadding = 1, topPadding = 0;
				float sidePadding = 10;
				if (this.showMinAndMax)
					sidePadding = txtPaint.MeasureText(max);

				float usableHeight = Height - bottomPadding - topPadding;
				float usableWidth = Width - sidePadding*2;
				float lineSpace = usableHeight/10;

				int lineCount = 0;
				foreach (Line line in lines) {
					int count = 0;
					float lastXPixels = 0, newYPixels;
					float lastYPixels = 0, newXPixels;
					float maxYd = getMaxY ();
					float minYd = getMinY();
					float maxXd = getMaxX();
					float minXd = getMinX();

					if (lineCount == lineToFill){
						paint.Color = Color.White;
						paint.Alpha = 30;	
						paint.StrokeWidth = 2;
						for (int i = 10; i-Width < Height; i = i+20){
							canvas.DrawLine(i, Height-bottomPadding, 0, Height-bottomPadding-i, paint);
						}

						paint.Reset();

						paint.SetXfermode (new PorterDuffXfermode (Android.Graphics.PorterDuff.Mode.Clear));
						foreach (LinePoint p  in line.getPoints()) {
							float yPercent = (p.getY()-minY)/(maxYd - minYd);
							float xPercent = (p.getX()-minX)/(maxXd - minXd);
							if (count == 0){
								lastXPixels = sidePadding + (xPercent*usableWidth);
								lastYPixels = Height - bottomPadding - (usableHeight*yPercent);
								path.MoveTo(lastXPixels, lastYPixels);
							} else {
								newXPixels = sidePadding + (xPercent*usableWidth);
								newYPixels = Height - bottomPadding - (usableHeight*yPercent);
								path.LineTo(newXPixels, newYPixels);
								Path pa = new Path();
								pa.MoveTo(lastXPixels, lastYPixels);
								pa.LineTo(newXPixels, newYPixels);
								pa.LineTo(newXPixels, 0);
								pa.LineTo(lastXPixels, 0);
								pa.Close();
								canvas.DrawPath(pa, paint);
								lastXPixels = newXPixels;
								lastYPixels = newYPixels;
							}
							count++;
						}

						path.Reset();

						path.MoveTo(0, Height-bottomPadding);
						path.LineTo(sidePadding, Height-bottomPadding);
						path.LineTo(sidePadding, 0);
						path.LineTo(0, 0);
						path.Close();
						canvas.DrawPath(path, paint);

						path.Reset();

						path.MoveTo(Width, Height-bottomPadding);
						path.LineTo(Width-sidePadding, Height-bottomPadding);
						path.LineTo(Width-sidePadding, 0);
						path.LineTo(Width, 0);
						path.Close();

						canvas.DrawPath(path, paint);

					}

					lineCount++;
				}

				paint.Reset();

				paint.Color = Color.White;
				//paint.setColor(this.gridColor);
				paint.Alpha = 50;
				paint.AntiAlias = true;
				canvas.DrawLine(sidePadding, Height - bottomPadding, Width, Height-bottomPadding, paint);
				if(this.showHorizontalGrid1)
					for(int i=1;i<=10;i++)
					{
						canvas.DrawLine(sidePadding, Height - bottomPadding-(i*lineSpace), Width, Height-bottomPadding-(i*lineSpace), paint);
					}
				paint.Alpha = 255;

				foreach (Line line in lines) {
					int count = 0;
					float lastXPixels = 0, newYPixels;
					float lastYPixels = 0, newXPixels;
					float maxYd = getMaxY();
					float minYd = getMinY();
					float maxXd = getMaxX();
					float minXd = getMinX();

					paint.Color = Color.Yellow;
					//paint.setColor(line.getColor());
					paint.StrokeWidth = 6;

					foreach (LinePoint p in line.getPoints()) {
						float yPercent = (p.getY()-minY)/(maxYd - minYd);
						float xPercent = (p.getX()-minX)/(maxXd - minXd);
						if (count == 0){
							lastXPixels = sidePadding + (xPercent*usableWidth);
							lastYPixels = Height - bottomPadding - (usableHeight*yPercent);
						} else {
							newXPixels = sidePadding + (xPercent*usableWidth);
							newYPixels = Height - bottomPadding - (usableHeight*yPercent);
							canvas.DrawLine(lastXPixels, lastYPixels, newXPixels, newYPixels, paint);
							lastXPixels = newXPixels;
							lastYPixels = newYPixels;
						}
						count++;
					}
				}


				int pointCount = 0;

				foreach (Line line  in lines) {
					float maxYd = getMaxY();
					float minYd = getMinY();
					float maxXd = getMaxX();
					float minXd = getMinX();

					paint.Color = Color.Yellow;
					//paint.setColor(line.getColor());
					paint.StrokeWidth = 6;
					paint.StrokeCap = Paint.Cap.Round;

					if (line.isShowingPoints()){
						foreach (LinePoint p in line.getPoints()) {
							float yPercent = (p.getY()-minYd)/(maxYd - minYd);
							float xPercent = (p.getX()-minXd)/(maxXd - minXd);
							float xPixels = sidePadding + (xPercent*usableWidth);
							float yPixels = Height - bottomPadding - (usableHeight*yPercent);

							paint.Color = Color.Gray;
							canvas.DrawCircle(xPixels, yPixels, 10, paint);
							paint.Color = Color.White;
							canvas.DrawCircle(xPixels, yPixels, 5, paint);

							Path path2 = new Path();
							path2.AddCircle(xPixels, yPixels, 30, Android.Graphics.Path.Direction.Cw);
							p.setPath(path2);
							p.setRegion(new Region((int)(xPixels-30), (int)(yPixels-30), (int)(xPixels+30), (int)(yPixels+30)));
							if (indexSelected == pointCount && listener != null){
								paint.Color=Color.ParseColor("#33B5E5");
								paint.Alpha = 100;
								canvas.DrawPath(p.getPath(), paint);
								paint.Alpha = 255;
							}

							pointCount++;
						}
					}
				}

				shouldUpdate = false;
				if (this.showMinAndMax) {
					ca.DrawText(max, 0, txtPaint.TextSize, txtPaint);
					ca.DrawText(min,0,this.Height,txtPaint);
				}
			}
			ca.DrawBitmap(fullImage, 0, 0, null);
		}