示例#1
0
文件: Paths.cs 项目: kpalosaa/cross2d
        protected override void OnCreated()
        {
            triangle = CreatePath();
            triangle.BeginFigure(0, 0);
            triangle.AddLine(150, 120);
            triangle.AddLine(0, 240);
            triangle.EndFigure(true);

            arc = CreatePath();
            arc.BeginFigure(0, 0);
            arc.AddArc(0, 0, 100, MathHelper.ConvertDegToRad(0), MathHelper.ConvertDegToRad(90));
            arc.EndFigure(true);
        }
示例#2
0
        protected override void OnDraw(IContext context)
        {
            if (path == null)
            {
                path = CreatePath();

                path.BeginFigure(1, 1 + cornerRadius);
                path.AddArc(1 + cornerRadius, 1 + cornerRadius, cornerRadius, MathHelper.ConvertDegToRad(180), MathHelper.ConvertDegToRad(270));
                path.AddLine(context.Width - 2, 1);
                path.AddLine(context.Width - 2, context.Height - 2 - cornerRadius);
                path.AddArc(context.Width - 2 - cornerRadius, context.Height - 2 - cornerRadius, cornerRadius, MathHelper.ConvertDegToRad(0), MathHelper.ConvertDegToRad(90));
                path.AddLine(1, context.Height - 2);
                path.AddLine(1, 1 + cornerRadius);
                path.EndFigure(false);
            }

            context.Color       = Color.Green;
            context.StrokeWidth = 3;
            context.DrawPath(path, 0, 0);

            context.SetFont(font);
            context.DrawText(text, 0, 0, context.Width, context.Height, Xamarin.Forms.TextAlignment.Center, Xamarin.Forms.TextAlignment.Center);
        }