private static void DrawArrowHead(Context context, PointD tip, PointD tail) { // Length & width of arrow (Adjustable) const double aLength = 10.0; const double aWidth = 3.5; // Arrow direction & perpendicular vector PointD direction = tail.Substract(tip); // tail - tip direction = direction.Normalize(); PointD perpendicular = new PointD(-direction.Y, direction.X); // Arrow vertices PointD pointOnLine = tip.Add(direction.Multiply(aLength)); // tip + aLength * direction PointD arrowVertex1 = pointOnLine.Add(perpendicular.Multiply(aWidth)); // pointOnLine + aWidth * perpendicular PointD arrowVertex2 = pointOnLine.Substract(perpendicular.Multiply(aWidth)); // pointOnLine - aWidth * perpendicular context.MoveTo(tip); context.LineTo(arrowVertex1); context.LineTo(arrowVertex2); context.LineTo(tip); context.ClosePath(); context.FillPreserve(); context.Stroke(); }
void drawDesignOverlay(Context gr, Widget g, Rectangle cb, Rectangle hr, double coteStroke, double space = 6.5) { double z = zoom / 100.0; double coteW = 3, coteL = 5; bool fill = true; PointD p1 = new PointD(hr.X + 0.5, hr.Y - space); PointD p2 = new PointD(hr.Right - 0.5, hr.Y - space); if (p1.Y < cb.Top) { if (hr.Bottom > cb.Bottom - space) { p1.Y = p2.Y = hr.Bottom - space; } else { p1.Y = p2.Y = hr.Bottom + space; } } if (g.Width.IsFit) { gr.DrawCoteInverse(p1, p2, coteStroke, fill, coteW, coteL); } else if (g.Width.IsRelativeToParent) { gr.DrawCote(p1, p2, coteStroke, fill, coteW, coteL); if (g.Width.Value < 100) { drawCenteredTextLine(gr, p1.Add(p2.Substract(p1).Divide(2)), g.Width.ToString()); } } else if (g.Width.IsFixed) { gr.DrawCoteFixed(p1, p2, coteStroke * 2.0, coteW); drawCenteredTextLine(gr, p1.Add(p2.Substract(p1).Divide(2)), g.Width.Value.ToString()); } p1 = new PointD(hr.X - space, hr.Top + 0.5); p2 = new PointD(hr.X - space, hr.Bottom - 0.5); if (p1.X < cb.Left) { if (hr.Right > cb.Right - space) { p1.X = p2.X = hr.Right - space; } else { p1.X = p2.X = hr.Right + space; } } if (g.Height.IsFit) { gr.DrawCoteInverse(p1, p2, coteStroke, fill, coteW, coteL); } else if (g.Height.IsRelativeToParent) { gr.DrawCote(p1, p2, coteStroke, fill, coteW, coteL); if (g.Height.Value < 100) { drawCenteredTextLine(gr, p1.Add(p2.Substract(p1).Divide(2)), g.Height.ToString()); } } else if (g.Width.IsFixed) { gr.DrawCoteFixed(p1, p2, coteStroke * 2.0, coteW); drawCenteredTextLine(gr, p1.Add(p2.Substract(p1).Divide(2)), g.Height.Value.ToString()); } // hr.Inflate (2); //gr.SetDash (new double[]{ 1.0, 4.0 }, 0.0); //gr.SetSourceColor (Color.Grey); // gr.Rectangle (hr,coteStroke); // gr.Stroke (); gr.Operator = Operator.Over; }