@@ -23,7 +23,7 @@ private CustomLineCap _defaultFlowCap
2323 get
2424 {
2525 GraphicsPath gp = new GraphicsPath ( ) ;
26- gp . AddLine ( new PointF ( - 1.5f , - 3.5f ) , new PointF ( 1.5f , - 1.5f ) ) ;
26+ gp . AddLine ( new PointF ( 1.5f , - 3.5f ) , new PointF ( 1.5f , - 1.5f ) ) ;
2727 return new CustomLineCap ( null , gp ) ;
2828 }
2929 }
@@ -64,16 +64,26 @@ public Pen ConstructPen(Brush brush, Definition definition)
6464 IElement elem = _GetLinkedElement ( definition ) ;
6565 if ( elem != null )
6666 {
67- if ( elem is Association )
67+ if ( elem is Association || elem is MessageFlow )
6868 ret . DashPattern = Constants . DASH_PATTERN ;
69- else if ( elem is MessageFlow )
69+ }
70+ return ret ;
71+ }
72+
73+ internal void AppendEnds ( Graphics gp , Brush brush , Definition definition )
74+ {
75+ Pen p = ConstructPen ( brush , definition ) ;
76+ IElement elem = _GetLinkedElement ( definition ) ;
77+ if ( elem != null )
78+ {
79+ Point [ ] points = Points ;
80+ if ( elem is MessageFlow )
7081 {
71- ret . DashPattern = Constants . DASH_PATTERN ;
72- ret . StartCap = System . Drawing . Drawing2D . LineCap . RoundAnchor ;
73- ret . EndCap = System . Drawing . Drawing2D . LineCap . ArrowAnchor ;
82+ gp . FillEllipse ( brush , new RectangleF ( new PointF ( ( float ) points [ 0 ] . X - 0.5f , ( float ) points [ 0 ] . Y - 0.5f ) , new SizeF ( 1.5f , 1.5f ) ) ) ;
83+ _GenerateTriangle ( gp , brush , points [ points . Length - 1 ] , points [ points . Length - 2 ] ) ;
7484 }
7585 else
76- ret . EndCap = System . Drawing . Drawing2D . LineCap . ArrowAnchor ;
86+ _GenerateTriangle ( gp , brush , points [ points . Length - 1 ] , points [ points . Length - 2 ] ) ;
7787 if ( elem is SequenceFlow || elem is MessageFlow )
7888 {
7989 string sourceRef = ( elem is SequenceFlow ? ( ( SequenceFlow ) elem ) . sourceRef : ( ( MessageFlow ) elem ) . sourceRef ) ;
@@ -83,12 +93,36 @@ public Pen ConstructPen(Brush brush, Definition definition)
8393 if ( gelem is AGateway )
8494 {
8595 if ( ( ( ( AGateway ) gelem ) . Default == null ? "" : ( ( AGateway ) gelem ) . Default ) == elem . id )
86- ret . CustomStartCap = _defaultFlowCap ;
96+ {
97+ PointF centre = new PointF (
98+ ( ( 0.5f * ( float ) points [ 0 ] . X ) + ( 0.5f * ( float ) points [ 1 ] . X ) ) ,
99+ ( ( 0.5f * ( float ) points [ 0 ] . Y ) + ( 0.5f * ( float ) points [ 1 ] . Y ) )
100+ ) ;
101+ gp . DrawLine ( p , new PointF ( centre . X - 3f , centre . Y - 3f ) , new PointF ( centre . X + 3f , centre . Y + 3f ) ) ;
102+ }
87103 }
88104 }
89105 }
90106 }
91- return ret ;
107+ }
108+
109+ private static readonly float _baseTLength = Constants . PEN_WIDTH * 1.5f ;
110+
111+ private void _GenerateTriangle ( Graphics gp , Brush brush , Point end , Point start )
112+ {
113+ float d = ( float ) Math . Sqrt ( Math . Pow ( ( double ) end . X - ( double ) start . X , 2 ) + Math . Pow ( ( double ) end . Y - ( double ) start . Y , 2 ) ) ;
114+ float t = _baseTLength / d ;
115+ PointF pc = new PointF ( ( ( 1f - t ) * ( float ) end . X ) + ( t * ( float ) start . X ) , ( ( 1f - t ) * ( float ) end . Y ) + ( t * ( float ) start . Y ) ) ;
116+ PointF fend = new PointF ( ( float ) end . X , ( float ) end . Y ) ;
117+ PointF p1 = new PointF ( pc . X - ( fend . Y - pc . Y ) , ( fend . X - pc . X ) + pc . Y ) ;
118+ PointF p2 = new PointF ( fend . Y - pc . Y + pc . X , pc . Y - ( fend . X - pc . X ) ) ;
119+ t = _baseTLength / d ;
120+ gp . DrawLine ( new Pen ( Brushes . White , Constants . PEN_WIDTH ) , fend , pc ) ;
121+ gp . FillPolygon ( brush , new PointF [ ] {
122+ fend ,
123+ p1 ,
124+ p2
125+ } ) ;
92126 }
93127
94128 public override bool IsValid ( out string [ ] err )
0 commit comments