//private static void DrawLine(RenderInfo info, PointF startPoint, PointF endPoint, Pen pen) //{ // info.Graphics.DrawLine(pen, startPoint, endPoint); //} private static PointF GetPoint(Rectangle bounds, int portOffset, UmlPortSide portSide) { const int marginSize = 20; var point = new PointF(); if (portSide == UmlPortSide.Left) { point.X = bounds.Left - marginSize; point.Y = bounds.Top + portOffset; } else if (portSide == UmlPortSide.Right) { point.X = bounds.Right + marginSize; point.Y = bounds.Top + portOffset; } else if (portSide == UmlPortSide.Top) { point.X = bounds.Left + portOffset; point.Y = bounds.Top - marginSize; } else if (portSide == UmlPortSide.Bottom) { point.X = bounds.Left + portOffset; point.Y = bounds.Bottom + marginSize; } else { throw new NotSupportedException(); } return(point); }
private void DrawArrowPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { int marginSize = 15; int arrowSize = 5; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y - 5, point.X + marginSize, point.Y); info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y + 5, point.X + marginSize, point.Y); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y - 5, point.X - marginSize, point.Y); info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y + 5, point.X - marginSize, point.Y); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); info.Graphics.DrawLine(pen, point.X - 5, point.Y + arrowSize, point.X, point.Y + marginSize); info.Graphics.DrawLine(pen, point.X + 5, point.Y + arrowSize, point.X, point.Y + marginSize); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); info.Graphics.DrawLine(pen, point.X - 5, point.Y - arrowSize, point.X, point.Y - marginSize); info.Graphics.DrawLine(pen, point.X + 5, point.Y - arrowSize, point.X, point.Y - marginSize); } }
private static void DrawArrowPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { const int marginSize = Margins.RelationPortMargin; const int arrowSize = Margins.RelationArrowSize; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y - Margins.RelationArrowSize, point.X + marginSize, point.Y); info.Graphics.DrawLine(pen, point.X + arrowSize, point.Y + Margins.RelationArrowSize, point.X + marginSize, point.Y); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y - Margins.RelationArrowSize, point.X - marginSize, point.Y); info.Graphics.DrawLine(pen, point.X - arrowSize, point.Y + Margins.RelationArrowSize, point.X - marginSize, point.Y); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); info.Graphics.DrawLine(pen, point.X - Margins.RelationArrowSize, point.Y + arrowSize, point.X, point.Y + marginSize); info.Graphics.DrawLine(pen, point.X + Margins.RelationArrowSize, point.Y + arrowSize, point.X, point.Y + marginSize); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); info.Graphics.DrawLine(pen, point.X - Margins.RelationArrowSize, point.Y - arrowSize, point.X, point.Y - marginSize); info.Graphics.DrawLine(pen, point.X + Margins.RelationArrowSize, point.Y - arrowSize, point.X, point.Y - marginSize); } }
private void DrawPortSelectionHandles(RenderInfo info, UmlPortSide portSide, PointF point) { if (Selected) { const int marginSize = Margins.RelationPortMargin; if (portSide == UmlPortSide.Left) { DrawSelectionHandle(info, new Point((int)point.X + marginSize, (int)point.Y)); } if (portSide == UmlPortSide.Right) { DrawSelectionHandle(info, new Point((int)point.X - marginSize, (int)point.Y)); } if (portSide == UmlPortSide.Top) { DrawSelectionHandle(info, new Point((int)point.X, (int)point.Y + marginSize)); } if (portSide == UmlPortSide.Bottom) { DrawSelectionHandle(info, new Point((int)point.X, (int)point.Y - marginSize)); } } }
private static void DrawInheritancePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { const int marginSize = Margins.RelationPortMargin; const int arrowSize = Margins.RelationArrowSize; var x = (int)point.X; var y = (int)point.Y; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); var points = new[] { new Point(x + marginSize, y), new Point(x + arrowSize, y + Margins.RelationArrowSize), new Point(x + arrowSize, y - Margins.RelationArrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); var points = new[] { new Point(x - marginSize, y), new Point(x - arrowSize, y + Margins.RelationArrowSize), new Point(x - arrowSize, y - Margins.RelationArrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); var points = new[] { new Point(x, y + marginSize), new Point(x + Margins.RelationArrowSize, y + arrowSize), new Point(x - Margins.RelationArrowSize, y + arrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); var points = new[] { new Point(x, y - marginSize), new Point(x + Margins.RelationArrowSize, y - arrowSize), new Point(x - Margins.RelationArrowSize, y - arrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } }
private void RouteLine(LineDrawer drawLine, float x1, float y1, float x2, float y2) { UmlPortSide startSide = DataSource.StartPortSide; UmlPortSide endSide = DataSource.EndPortSide; if (Math.Abs(x2 - x1) > Math.Abs(y2 - y1)) { DrawHorizontal(drawLine, x1, y1, x2, y2); } else { DrawVertical(drawLine, x1, y1, x2, y2); } }
public override void OnMouseMove(ShapeMouseEventArgs args) { if (args.BoundingItem.Data == StartPortIdentifier && args.Button == MouseButtons.Left) { Rectangle bounds = DataSource.Start.Bounds; int offset = 0; UmlPortSide side = DataSource.StartPortSide; int oppositeOffset = DataSource.EndPortOffset; UmlPortSide oppositeSide = DataSource.EndPortSide; MovePort(args, bounds, ref offset, ref side, oppositeOffset, oppositeSide); DataSource.StartPortSide = side; DataSource.StartPortOffset = offset; args.Redraw = true; } if (args.BoundingItem.Data == EndPortIdentifier && args.Button == MouseButtons.Left) { Rectangle bounds = DataSource.End.Bounds; int offset = 0; UmlPortSide side = DataSource.EndPortSide; int oppositeOffset = DataSource.StartPortOffset; UmlPortSide oppositeSide = DataSource.StartPortSide; MovePort(args, bounds, ref offset, ref side, oppositeOffset, oppositeSide); DataSource.EndPortSide = side; DataSource.EndPortOffset = offset; args.Redraw = true; } }
private void DrawPortBackground(RenderInfo info, UmlPortSide portSide, PointF point, object portIdentifier) { const int marginSize = Margins.RelationPortMargin; if (portSide == UmlPortSide.Left) { DrawPortSelector(info, point.X, point.Y, point.X + marginSize, point.Y, portIdentifier); } if (portSide == UmlPortSide.Right) { DrawPortSelector(info, point.X, point.Y, point.X - marginSize, point.Y, portIdentifier); } if (portSide == UmlPortSide.Top) { DrawPortSelector(info, point.X, point.Y, point.X, point.Y + marginSize, portIdentifier); } if (portSide == UmlPortSide.Bottom) { DrawPortSelector(info, point.X, point.Y, point.X, point.Y - marginSize, portIdentifier); } }
private static void MovePort(ShapeMouseEventArgs args, Rectangle bounds, ref int offset, ref UmlPortSide side, int oppositeOffset, UmlPortSide oppositeSide) { int x = args.X; int y = args.Y; int half = bounds.Width/2; int center = bounds.X + half; int xd = Math.Abs(x - center); int top = bounds.Top + half - xd; int bottom = bounds.Bottom - half + xd; if (x < center) { //left of side = UmlPortSide.Left; } else { //right of side = UmlPortSide.Right; } if (y < top) side = UmlPortSide.Top; if (y > bottom) side = UmlPortSide.Bottom; if (side == UmlPortSide.Top || side == UmlPortSide.Bottom) { offset = args.X - bounds.Left; if (args.X < bounds.Left) offset = 0; if (args.X > bounds.Right) offset = bounds.Width; } if (side == UmlPortSide.Left || side == UmlPortSide.Right) { offset = args.Y - bounds.Top; if (args.Y < bounds.Top) offset = 0; if (args.Y > bounds.Bottom) offset = bounds.Height; } if ((side == UmlPortSide.Left || side == UmlPortSide.Right) && (oppositeSide == UmlPortSide.Left || oppositeSide == UmlPortSide.Right)) { if (Math.Abs(offset - oppositeOffset) < 10) offset = oppositeOffset; } if ((side == UmlPortSide.Top || side == UmlPortSide.Bottom) && (oppositeSide == UmlPortSide.Top || oppositeSide == UmlPortSide.Bottom)) { if (Math.Abs(offset - oppositeOffset) < 10) offset = oppositeOffset; } }
//private static void DrawLine(RenderInfo info, PointF startPoint, PointF endPoint, Pen pen) //{ // info.Graphics.DrawLine(pen, startPoint, endPoint); //} private static PointF GetPoint(Rectangle bounds, int portOffset, UmlPortSide portSide) { const int marginSize = 20; var point = new PointF(); if (portSide == UmlPortSide.Left) { point.X = bounds.Left - marginSize; point.Y = bounds.Top + portOffset; } else if (portSide == UmlPortSide.Right) { point.X = bounds.Right + marginSize; point.Y = bounds.Top + portOffset; } else if (portSide == UmlPortSide.Top) { point.X = bounds.Left + portOffset; point.Y = bounds.Top - marginSize; } else if (portSide == UmlPortSide.Bottom) { point.X = bounds.Left + portOffset; point.Y = bounds.Bottom + marginSize; } else { throw new NotSupportedException(); } return point; }
private static void DrawAggregatePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { const int marginSize = 16; var x = (int) point.X; var y = (int) point.Y; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); var points = new[] { new Point(x + marginSize, y), new Point(x + marginSize/2, y + Margins.RelationArrowSize), new Point(x + 0, y), new Point(x + marginSize/2, y - Margins.RelationArrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); var points = new[] { new Point(x - marginSize, y), new Point(x - marginSize/2, y + Margins.RelationArrowSize), new Point(x - 0, y), new Point(x - marginSize/2, y - Margins.RelationArrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); var points = new[] { new Point(x, y + marginSize), new Point(x + Margins.RelationArrowSize, y + marginSize/2), new Point(x, y), new Point(x - Margins.RelationArrowSize, y + marginSize/2) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); var points = new[] { new Point(x, y - marginSize), new Point(x + Margins.RelationArrowSize, y - marginSize/2), new Point(x, y), new Point(x - Margins.RelationArrowSize, y - marginSize/2) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } }
private void DrawPortSelectionHandles(RenderInfo info, UmlPortSide portSide, PointF point) { if (Selected) { const int marginSize = Margins.RelationPortMargin; if (portSide == UmlPortSide.Left) { DrawSelectionHandle(info, new Point((int) point.X + marginSize, (int) point.Y)); } if (portSide == UmlPortSide.Right) { DrawSelectionHandle(info, new Point((int) point.X - marginSize, (int) point.Y)); } if (portSide == UmlPortSide.Top) { DrawSelectionHandle(info, new Point((int) point.X, (int) point.Y + marginSize)); } if (portSide == UmlPortSide.Bottom) { DrawSelectionHandle(info, new Point((int) point.X, (int) point.Y - marginSize)); } } }
private static void MovePort(ShapeMouseEventArgs args, Rectangle bounds, ref int offset, ref UmlPortSide side, int oppositeOffset, UmlPortSide oppositeSide) { int x = args.X; int y = args.Y; int half = bounds.Width / 2; int center = bounds.X + half; int xd = Math.Abs(x - center); int top = bounds.Top + half - xd; int bottom = bounds.Bottom - half + xd; if (x < center) { //left of side = UmlPortSide.Left; } else { //right of side = UmlPortSide.Right; } if (y < top) { side = UmlPortSide.Top; } if (y > bottom) { side = UmlPortSide.Bottom; } if (side == UmlPortSide.Top || side == UmlPortSide.Bottom) { offset = args.X - bounds.Left; if (args.X < bounds.Left) { offset = 0; } if (args.X > bounds.Right) { offset = bounds.Width; } } if (side == UmlPortSide.Left || side == UmlPortSide.Right) { offset = args.Y - bounds.Top; if (args.Y < bounds.Top) { offset = 0; } if (args.Y > bounds.Bottom) { offset = bounds.Height; } } if ((side == UmlPortSide.Left || side == UmlPortSide.Right) && (oppositeSide == UmlPortSide.Left || oppositeSide == UmlPortSide.Right)) { if (Math.Abs(offset - oppositeOffset) < 10) { offset = oppositeOffset; } } if ((side == UmlPortSide.Top || side == UmlPortSide.Bottom) && (oppositeSide == UmlPortSide.Top || oppositeSide == UmlPortSide.Bottom)) { if (Math.Abs(offset - oppositeOffset) < 10) { offset = oppositeOffset; } } }
private void DrawAggregatePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { int marginSize = 16; var x = (int)point.X; var y = (int)point.Y; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); var points = new[] { new Point(x + marginSize, y), new Point(x + marginSize / 2, y + 5), new Point(x + 0, y), new Point(x + marginSize / 2, y - 5) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); var points = new[] { new Point(x - marginSize, y), new Point(x - marginSize / 2, y + 5), new Point(x - 0, y), new Point(x - marginSize / 2, y - 5) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); var points = new[] { new Point(x, y + marginSize), new Point(x + 5, y + marginSize / 2), new Point(x, y), new Point(x - 5, y + marginSize / 2) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); var points = new[] { new Point(x, y - marginSize), new Point(x + 5, y - marginSize / 2), new Point(x, y), new Point(x - 5, y - marginSize / 2) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } }
private void DrawPort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { int marginSize = 15; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); } }
private void DrawInheritancePort(RenderInfo info, UmlPortSide portSide, PointF point, Pen pen) { int marginSize = 15; int arrowSize = 5; var x = (int) point.X; var y = (int) point.Y; if (portSide == UmlPortSide.Left) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X + marginSize, point.Y); var points = new[] { new Point(x + marginSize, y), new Point(x + arrowSize, y + 5), new Point(x + arrowSize, y - 5) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Right) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X - marginSize, point.Y); var points = new[] { new Point(x - marginSize, y), new Point(x - arrowSize, y + 5), new Point(x - arrowSize, y - 5) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Top) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y + marginSize); var points = new[] { new Point(x, y + marginSize), new Point(x + 5, y + arrowSize), new Point(x - 5, y + arrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } if (portSide == UmlPortSide.Bottom) { info.Graphics.DrawLine(pen, point.X, point.Y, point.X, point.Y - marginSize); var points = new[] { new Point(x, y - marginSize), new Point(x + 5, y - arrowSize), new Point(x - 5, y - arrowSize) }; info.Graphics.FillPolygon(System.Drawing.Brushes.White, points); info.Graphics.DrawPolygon(pen, points); } }