Ejemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="gfx"></param>
        /// <param name="arc"></param>
        /// <param name="dx"></param>
        /// <param name="dy"></param>
        /// <param name="db"></param>
        /// <param name="r"></param>
        public void Draw(object gfx, XArc arc, double dx, double dy, ImmutableArray<ShapeProperty> db, Record r)
        {
            var a = GdiArc.FromXArc(arc, dx, dy);
            if (a.Width <= 0.0 || a.Height <= 0.0)
                return;

            var _gfx = gfx as Graphics;

            Brush brush = ToSolidBrush(arc.Style.Fill);
            Pen pen = ToPen(arc.Style, _scaleToPage);

            if (arc.IsFilled)
            {
                var path = new GraphicsPath();
                path.AddArc(
                    _scaleToPage(a.X),
                    _scaleToPage(a.Y),
                    _scaleToPage(a.Width),
                    _scaleToPage(a.Height),
                    (float)a.StartAngle,
                    (float)a.SweepAngle);

                _gfx.FillPath(brush, path);

                if (arc.IsStroked)
                {
                    _gfx.DrawPath(pen, path);
                }

                path.Dispose();
            }
            else
            {
                if (arc.IsStroked)
                {
                    _gfx.DrawArc(
                        pen,
                        _scaleToPage(a.X),
                        _scaleToPage(a.Y),
                        _scaleToPage(a.Width),
                        _scaleToPage(a.Height),
                        (float)a.StartAngle,
                        (float)a.SweepAngle);
                }
            }

            brush.Dispose();
            pen.Dispose();
        }
Ejemplo n.º 2
0
		GraphicsPath CreatePath()
		{
			var newPath = new GraphicsPath();
			var start = StartFigures;
			var close = CloseFigures;

			// connected segments

			newPath.MoveTo(10, 10);
			newPath.LineTo(20, 90);
			newPath.LineTo(10, 60);
			newPath.LineTo(90, 80);
			newPath.LineTo(60, 30);
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddArc(100, 0, 100, 50, 200, -160);
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddBezier(new PointF(200, 10), new PointF(285, 20), new PointF(210, 85), new PointF(300, 90));
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddCurve(new PointF(310, 90), new PointF(390, 90), new PointF(390, 10), new PointF(310, 10));
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddLine(410, 10, 410, 90);
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddLines(new PointF(420, 10), new PointF(420, 90));
			if (close && start)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddLines(new PointF(430, 10), new PointF(430, 90));
			if (close)
				newPath.CloseFigure();

			// separate segments

			if (start)
				newPath.StartFigure();
			newPath.AddEllipse(100, 100, 100, 45);
			if (close)
				newPath.CloseFigure();

			if (start)
				newPath.StartFigure();
			newPath.AddRectangle(10, 110, 80, 80);
			if (close)
				newPath.CloseFigure();

			// at the end, draw a line so we can potentially connect to parent path
			if (start)
				newPath.StartFigure();
			newPath.AddLines(new PointF(440, 10), new PointF(440, 90));
			if (close)
				newPath.CloseFigure();

			return newPath;
		}