public override void Render(WidgetRenderingContext context) { Graphics g = context.Graphics; if (!(Element is Arc)) { throw new InvalidOperationException("Petri Net Element must be convertible to Arc for ArcWidget."); } Arc arc = (Arc)Element; if (arc.StartElement == null || arc.EndElement == null) { throw new InvalidOperationException("StartElement and EndElement of arc cannot be null."); } PetriNetElementWidget startWidget = (PetriNetElementWidget)context.WidgetLocator.FindWidget(arc.StartElement.ID); PetriNetElementWidget endWidget = (PetriNetElementWidget)context.WidgetLocator.FindWidget(arc.EndElement.ID); Point arcStartPoint = startWidget.GetLineIntersectionPoint(endWidget.Location); Point arcEndPoint = endWidget.GetLineIntersectionPoint(startWidget.Location); using (Pen arrowPen = new Pen(Brushes.Black)) { using (AdjustableArrowCap arrowCap = new AdjustableArrowCap(2, 1)) { arrowCap.WidthScale = 5; arrowCap.BaseCap = LineCap.Square; arrowCap.Height = 2; arrowPen.CustomEndCap = arrowCap; g.DrawLine(arrowPen, arcStartPoint, arcEndPoint); } } }
public override void Render(WidgetRenderingContext context) { Graphics g = context.Graphics; g.FillRectangle(!context.IsSelected ? Brushes.White : Brushes.LightYellow, Location.X - Size / 2, Location.Y - Size / 2, Size + 1, Size + 1); g.DrawRectangle(Pens.Gainsboro, Location.X - Size / 2 + 1, Location.Y - Size / 2 + 1, Size, Size); g.DrawRectangle(Pens.Black, Location.X - Size / 2, Location.Y - Size / 2, Size, Size); DrawLabel(context); }
public virtual void DrawLabel(WidgetRenderingContext context) { string labelText = GetLabelText(); if (labelText == null) { return; } Graphics g = context.Graphics; Font labelFont = context.TextFont; SizeF labelSize = g.MeasureString(labelText, labelFont); g.DrawString(labelText, labelFont, Brushes.WhiteSmoke, Location.X - labelSize.Width / 2 + 1, Location.Y + Size / 10 * 7 + 1); g.DrawString(labelText, labelFont, Brushes.Black, Location.X - labelSize.Width / 2, Location.Y + Size / 10 * 7); }
public override void Render(WidgetRenderingContext context) { Graphics g = context.Graphics; g.FillEllipse(!context.IsSelected ? Brushes.White : Brushes.LightYellow, Location.X - Size / 2, Location.Y - Size / 2, Size, Size); g.DrawEllipse(Pens.Gainsboro, Location.X - Size / 2, Location.Y - Size / 2 + 1, Size, Size); g.DrawEllipse(Pens.Gainsboro, Location.X - Size / 2 + 1, Location.Y - Size / 2 + 1, Size, Size); g.DrawEllipse(Pens.Black, Location.X - Size / 2, Location.Y - Size / 2, Size, Size); Place place = (Place)Element; if (place.Marking == 1) { g.FillEllipse(Brushes.Black, Location.X - Size / 5, Location.Y - Size / 5, Size / 5 * 2, Size / 5 * 2); } if (place.Marking == 2) { g.FillEllipse(Brushes.Black, Location.X - Size / 20 * 7, Location.Y - Size / 20 * 3, Size / 10 * 3, Size / 10 * 3); g.FillEllipse(Brushes.Black, Location.X + Size / 20 * 2 - 1, Location.Y - Size / 20 * 3, Size / 10 * 3, Size / 10 * 3); } if (place.Marking == 3) { g.FillEllipse(Brushes.Black, Location.X - Size / 20 * 7, Location.Y - Size / 20 * 5, Size / 10 * 3, Size / 10 * 3); g.FillEllipse(Brushes.Black, Location.X + Size / 20 * 1, Location.Y - Size / 20 * 5, Size / 10 * 3, Size / 10 * 3); g.FillEllipse(Brushes.Black, Location.X - Size / 20 * 3, Location.Y + Size / 20 * 2, Size / 10 * 3, Size / 10 * 3); } if (place.Marking > 3) { using (Font font = new Font(context.TextFont.FontFamily, Size / 2.5F)) { SizeF textSize = g.MeasureString(place.Marking.ToString(), font); g.DrawString ( place.Marking.ToString(), font, Brushes.Black, new RectangleF ( Location.X - textSize.Width / 2, Location.Y - textSize.Height / 2 + 1, textSize.Width, textSize.Height ) ); } } DrawLabel(context); }
public override void Render(WidgetRenderingContext context) { Graphics g = context.Graphics; g.FillRectangle(!context.IsSelected ? Brushes.White : Brushes.LightYellow, Location.X - Size / 2, Location.Y - Size / 2, Size + 1, Size + 1); g.DrawRectangle(Pens.Gainsboro, Location.X - Size / 2 + 1, Location.Y - Size / 2 + 1, Size, Size); g.FillRectangle(!context.IsSelected ? Brushes.Gainsboro : Brushes.DarkGray, Location.X - Size / 2, Location.Y - Size / 2, Size / 10 * 4, Size); g.DrawRectangle(Pens.Black, Location.X - Size / 2, Location.Y - Size / 2, Size, Size); g.DrawLine(Pens.Black, Location.X - Size / 10, Location.Y - Size / 2, Location.X - Size / 10, Location.Y + Size / 2); Point[] polygonPoints = new[] { new Point(Location.X - Size / 2, Location.Y - Size / 2), new Point(Location.X - Size / 10, Location.Y), new Point(Location.X - Size / 2, Location.Y + Size / 2), }; g.FillPolygon(!context.IsSelected ? Brushes.White : Brushes.LightYellow, polygonPoints); g.DrawPolygon(Pens.Black, polygonPoints); DrawLabel(context); }