Ejemplo n.º 1
0
		static d.PointF AddToPath(this ArcSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var pg = new PathGeometry {
				Figures = new PathFigureCollection {
					new PathFigure {
						IsFilled = true, IsClosed = true, StartPoint = new Point(startPoint.X, startPoint.Y), 
						Segments = new PathSegmentCollection { segment }
					}
				}
			};
			var r = pg.Bounds;
			r.Inflate(1,1);
			var g = Geometry.Combine(new RectangleGeometry(r), pg, GeometryCombineMode.Intersect, Transform.Identity);
			if (g.Figures.Count != 1)
				throw new InvalidOperationException("Geometry.Combine produced too many figures.");
			var pf = g.Figures[0];
			if (!(pf.Segments[0] is LineSegment))
                throw new InvalidOperationException("Geometry.Combine didn't start with a line");
			var lastPoint = startPoint;
			for(int i = 1; i < pf.Segments.Count; ++i) {
				if (pf.Segments[i] is ArcSegment)
                    throw new InvalidOperationException("Geometry.Combine produced an ArcSegment - oops, bad hack");
				lastPoint = pf.Segments[i].AddToPath(lastPoint, path);
			}
			return lastPoint;
		}
Ejemplo n.º 2
0
		GraphicsPathHandler (sd2.GraphicsPath control)
		{
			Control = control;
		}
Ejemplo n.º 3
0
		static d.PointF AddToPath(this QuadraticBezierSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var c = new d.PointF[3];
			QuadraticToCubic(startPoint, segment.Point1.ToGdiPlus(), segment.Point2.ToGdiPlus(), c, 0);
			path.AddBezier(startPoint, c[0], c[1], c[2]);
			return c[2];
		}
Ejemplo n.º 4
0
		static d.PointF AddToPath(this PolyQuadraticBezierSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var points = new d.PointF[3 * segment.Points.Count / 2 + 1];
			var j = 0;
			points[j++] = startPoint;
			for(var i = 0; i < segment.Points.Count; i += 2) {
				QuadraticToCubic(points[j - 1], segment.Points[i].ToGdiPlus(), segment.Points[i + 1].ToGdiPlus(), points, j);
				j += 3;
			}
			path.AddBeziers(points);
			return points[points.Length - 1];
		}
Ejemplo n.º 5
0
		static d.PointF AddToPath(this BezierSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var lastPoint = segment.Point3.ToGdiPlus();
			path.AddBezier(startPoint, segment.Point1.ToGdiPlus(), segment.Point2.ToGdiPlus(), lastPoint);
			return lastPoint;
		}
Ejemplo n.º 6
0
		static d.PointF AddToPath(this PolyBezierSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var points = new d.PointF[segment.Points.Count + 1];
			var i = 0;
			points[i++] = startPoint;
			foreach(var p in segment.Points) points[i++] = p.ToGdiPlus();
			path.AddBeziers(points);
			return points[points.Length - 1];
		}
Ejemplo n.º 7
0
		static d.PointF AddToPath(this PolyLineSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			d.PointF[] points = new d.PointF[segment.Points.Count + 1];
			var i = 0;
			points[i++] = startPoint;
			foreach(var p in segment.Points) points[i++] = p.ToGdiPlus();
			path.AddLines(points);
			return points[i - 1];
		}
Ejemplo n.º 8
0
		static d.PointF AddToPath(this LineSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			var lastPoint = segment.Point.ToGdiPlus();
			path.AddLine(startPoint, lastPoint);
			return lastPoint;
		}
Ejemplo n.º 9
0
		public static d.PointF AddToPath(this PathSegment segment, d.PointF startPoint, d2.GraphicsPath path) {
			ArcSegment a;
			BezierSegment b;
			LineSegment l;
			PolyBezierSegment pb;
			PolyLineSegment pl;
			PolyQuadraticBezierSegment pqb;
			QuadraticBezierSegment qb;

			if (!segment.IsStroked)
                Utility.Warning("Unstroked path segments not supported, use null pen instead.");
			// Except that they are used unecessarily on beziers auto-generated from arcs.
			//if (ps.IsSmoothJoin)
            //	Warning("Smooth join path segments not supported, use Pen.LineJoin=Round instead.");

			if ((a = segment as ArcSegment) != null)
				startPoint = a.AddToPath(startPoint, path);
			else if ((b = segment as BezierSegment) != null)
				startPoint = b.AddToPath(startPoint, path);
			else if ((l = segment as LineSegment) != null)
				startPoint = l.AddToPath(startPoint, path);
			else if ((pb = segment as PolyBezierSegment) != null)
				startPoint = pb.AddToPath(startPoint, path);
			else if ((pl = segment as PolyLineSegment) != null)
				startPoint = pl.AddToPath(startPoint, path);
			else if ((pqb = segment as PolyQuadraticBezierSegment) != null)
				startPoint = pqb.AddToPath(startPoint, path);
			else if ((qb = segment as QuadraticBezierSegment) != null)
				startPoint = qb.AddToPath(startPoint, path);
			else
				throw new ArgumentOutOfRangeException("segment", segment.GetType().ToString());
			return startPoint;
		}
Ejemplo n.º 10
0
		public MatrixHandler (sd2.Matrix matrix)
		{
			control = matrix;
		}
Ejemplo n.º 11
0
    private void DrawNode(TreeNodeEx node, Drawing.Graphics graphics, Drawing2D.Matrix matrix, ref int totalHeight)
    {
        if (node.Visible)
        {
            totalHeight += this.HeightIndent + this.Font.Height;

            // transform coordinates
            Drawing.PointF[] p = new Drawing.PointF[1];
            p[0] = new Drawing.PointF(0.0f, 0.0f);
            matrix.TransformPoints(p);

            // calculate location and size
            node.Location = new Drawing.Point((int)p[0].X, (int)p[0].Y);
            node.Size = new Drawing.Size(this.Width, this.Font.Height);

            if (dragOverNode == node)
            {
                // draw drag over line
                graphics.DrawLine(Drawing.Pens.Black, node.Location.X, node.Location.Y, this.Width, node.Location.Y);
            }

            // draw plus/minus
            if (this.ShowPlusMinus)
            {
                if (node.Nodes.Count > 0)
                {
                    graphics.DrawRectangle(Drawing.Pens.Black, (int)p[0].X + 2, (int)p[0].Y + 2, 8, 8);

                    if (!node.Expanded)
                    {
                        // line across
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6);
                        // down
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 6, (int)p[0].Y + 4, (int)p[0].X + 6, (int)p[0].Y + 8);
                    }
                    else
                    {
                        graphics.DrawLine(Drawing.Pens.Black, (int)p[0].X + 4, (int)p[0].Y + 6, (int)p[0].X + 8, (int)p[0].Y + 6);
                    }
                }

                p[0].X += 12;
            }

            // draw node image
            if (!this.imageList.Images.Empty)
            {
                this.imageList.Draw(graphics, new Drawing.Point((int)p[0].X, (int)p[0].Y), (node.Expanded) ? node.ExpandedImageIndex : node.CollapsedImageIndex);
                p[0].X += this.imageList.ImageSize.Width;
            }

            // draw node text
            Drawing.Brush textBrush;

            if (node == this.selectedNode && this.ChangeColorOnSelected)
                textBrush = this.TextSelectedBrush;
            else if (node == this.mouseOverNode && this.ChangeColorOnMouseOver)
                textBrush = this.TextMouseOverBrush;
            else
                textBrush = node.TextBrush;

            Drawing.Font font = new Drawing.Font(this.Font.FontFamily.Name, this.Font.Size, node.FontStyle);
            graphics.DrawString(node.Text, font, textBrush, p[0]);

            // go through children
            if (node.Expanded && node.Nodes.Count > 0)
            {
                matrix.Translate((float)this.WidthIndent, 0.0f);

                foreach (TreeNodeEx treeNode in node.Nodes)
                {
                    matrix.Translate(0.0f, this.HeightIndent + this.Font.Height);
                    DrawNode(treeNode, graphics, matrix, ref totalHeight);
                }

                matrix.Translate(-(float)this.WidthIndent, 0.0f);
            }
        }
        else
            matrix.Translate(0.0f, -((float)this.HeightIndent + this.Font.Height));
    }