Ejemplo n.º 1
0
        public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            StartDrawing();

            var rect = TranslateView(new System.Drawing.RectangleF(x, y, width, height), true);

            pen.Apply(this);
            var yscale  = rect.Height / rect.Width;
            var centerY = RectangleFExtensions.GetMidY(rect);
            var centerX = RectangleFExtensions.GetMidX(rect);

            Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
            Control.AddArc(centerX, centerY, rect.Width / 2, Conversions.DegreesToRadians(startAngle), Conversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
            Control.StrokePath();
            EndDrawing();
        }
Ejemplo n.º 2
0
                public override void Layout()
                {
                    base.Layout();

                    CGSize size    = this.imageView.SizeThatFits(this.Bounds.Size);
                    CGSize cgSize1 = this.label.SizeThatFits(this.Bounds.Size);

                    if (size.Width > (nfloat)0 && (string.IsNullOrEmpty(this.Text) || cgSize1.Width > this.Bounds.Width / (nfloat)3))
                    {
                        this.imageView.Frame = new CGRect(CGPoint.Empty, size);
                        // TODO: I dunno.  Center image or something
                        //this.imageView.CenterXAnchor = RectangleFExtensions.GetMidX (this.Bounds);
                        //this.imageView.CenterYAnchor = RectangleFExtensions.GetMidY (this.Bounds);
                        this.label.Hidden = true;
                    }
                    else
                    {
                        this.label.Hidden = false;
                        CGSize cgSize2 = this.label.SizeThatFits(new CGSize(this.Bounds.Width - (nfloat)15f - size.Width, this.Bounds.Height - (nfloat)10f));
                        CGRect cgRect  = new CGRect(new CGPoint((this.Bounds.Width - cgSize2.Width - size.Width) / (nfloat)2, RectangleFExtensions.GetMidY(this.Bounds) - size.Height / (nfloat)2), size);
                        this.imageView.Frame = cgRect;
                        cgRect.X             = cgRect.Right + (nfloat)(size.Width > (nfloat)0 ? 5f : 0.0f);
                        cgRect.Size          = cgSize2;
                        cgRect.Height        = this.Bounds.Height;
                        cgRect.Y             = (nfloat)0;
                        this.label.Frame     = cgRect;
                    }
                }