Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic set head and base shape colors differently (Read 2301 times)
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
set head and base shape colors differently
Oct 8th, 2008 at 1:00pm
Print Post  
Is it possible to have a headshape and baseshape rendered in different colors? It looks to me like we only have the 1 brush for both...

Thanks!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: set head and base shape colors differently
Reply #1 - Oct 8th, 2008 at 1:57pm
Print Post  
It isn't possible, but you might custom-draw one of the shapes in a different color. For example, you could call DiagramLink.GetBaseShapeDefinition() to get an ArrowHeadShape that describes the shape's geometry. If you have the source code, you might make the ArrowHeadShape.Draw method public and use it in the DrawLink handler. Otherwise you could copy this code and modify it to use the ArrowHeadShape public properties:
http://mindfusion.eu/_samples/ArrowHeadShape.Draw.txt

We are now releasing version 5.1.1 and will make that method public there.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
Re: set head and base shape colors differently
Reply #2 - Oct 10th, 2008 at 2:53am
Print Post  
Stoyo - I redid the code in vb.net (see below) and it works but the arrow heads are a little bigger than they should be. Can you let me know where I went wrong? (I left out the xoff, yoff for one thing...)

Private Sub OnCustomLinkDraw(ByVal sender As Object, ByVal e As MindFusion.Diagramming.DrawLinkEventArgs

           Dim base As MindFusion.Diagramming.ArrowHeadShape = e.Link.GetBaseShapeDefinition

           Dim c As Integer = 0

           Dim el As Integer
           For i As Integer = 0 To base.Elements.GetLength(0) - 1
               el = base.Elements(i)
               Select Case el
                   Case 0 ' line
                       c += 4
                   Case 1 ' shape
                       Dim pts As Integer = base.Elements(i + 1) - 1
                       Dim shape(pts) As Point
                       For j As Integer = 0 To pts
                           shape(j).X = base.Coordinates(c)
                           c += 1
                           shape(j).Y = base.Coordinates(c)
                           c += 1
                       Next
                       Dim brush As Drawing.Brush = Brushes.Black
                       Dim pen As Drawing.Pen = Pens.Black

                       e.Graphics.FillPolygon(brush, shape)
                       e.Graphics.DrawPolygon(pen, shape)

                   Case 2 ' circle
                       c += 3
               End Select
           Next
       End Sub
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: set head and base shape colors differently
Reply #3 - Oct 10th, 2008 at 6:49am
Print Post  
Perhaps Pens.Black is thicker than the one set for the link. Call e.Link.Pen.CreateGdiPen to get a System.Drawing.Pen object that corresponds to the link's pen properties and pass it to DrawPolygon instead of Pens.Black. Do not forget to call pen.Dispose() after DrawPolygon.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
deanhully
YaBB Newbies
*
Offline



Posts: 26
Joined: Aug 25th, 2008
Re: set head and base shape colors differently
Reply #4 - Oct 10th, 2008 at 12:21pm
Print Post  
You nailed it. Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint