Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Bounds of DiagramLink is readonly (Read 4777 times)
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Bounds of DiagramLink is readonly
Mar 27th, 2009 at 2:14pm
Print Post  
Hello, I cannot seem to set the properties of the bounds of a link. I basically want to save to the database the location of the link and then retrieve this location and set it again, so the link appears exactly like it was at the time of save when the diagram is loaded. I can do this fine for the nodes as their bounds is not read only, but the link bounds is read only. How can I accomplish this persistance of the appearance/direction of the link?
I am also always using a cascading style for the link.
Thanks,
jay
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bounds of DiagramLink is readonly
Reply #1 - Mar 27th, 2009 at 2:37pm
Print Post  
Hi,

You must save and restore the points in the ControlPoints collection, along with the SegmentCount value. DiagramLink.Bounds a dynamically calculated property that returns the rectangle that contains all these points.

Stoyan
  
Back to top
 
IP Logged
 
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Re: Bounds of DiagramLink is readonly
Reply #2 - Mar 27th, 2009 at 4:43pm
Print Post  
This only seems to work if you do not set the style to cascade of the link on loading the diagram. If you set the style as well as define the control points and segmentcount, the link does not render correctly. I need to keep the link as cascade in case the nodes are moved the link needs to be redrawn cascade style. A workaround seems to be setting the style to cascade for any links associated with the node in the node modified event. It just seems kind of weird that I would have to do this.
Thanks,
jay
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bounds of DiagramLink is readonly
Reply #3 - Mar 29th, 2009 at 9:31am
Print Post  
Hi,

Are you using link auto-routing? The SegmentCount setter might ignore the value you try to assign to it if AutoRoute is enabled. You might check this thread for some tips on how to restore the points of auto-routed links when implementing custom serialization:
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=123661683...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Re: Bounds of DiagramLink is readonly
Reply #4 - Mar 30th, 2009 at 2:16pm
Print Post  
I was not using autoroute anywhere when loading the diagram. It was setting the style of the link to cascade that was causing the problem. After reading that suggested link, I noticed I had to do 3 things in order for it to render correctly.
1) The control points must be defined AFTER the style of the link is set.
2) You must call ControlPoints.Clear() before defining the control points. Otherwise, extra lines get drawn.
3)You have to reassign the origin and destination nodes of the link. Otherwise, even though the line segments render correctly,the arrowhead will be in the wrong place.

At least I see I have control over this now. Thanks for the quick response as always.

jay
  
Back to top
 
IP Logged
 
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Re: Bounds of DiagramLink is readonly
Reply #5 - Mar 30th, 2009 at 6:08pm
Print Post  
Ok. I am still having problems loading from the control points, so I have created an example from my database values. Below is my code:
aspx:

<form id="form1" runat="server">
       <asp:ScriptManager ID="ScriptManager1" runat="server" />
       <div>
           <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
               <ContentTemplate>
                   <table style="table-layout:fixed;">
                       <tr>
                           <td>
                               <ndiag:DiagramView ID="diagView" AutoScroll="true" runat="server" Height="480px" Width="780px" ClientSideMode="ImageMap">
                                   <Diagram AllowSelfLoops="false" AutoResize="RightAndDown" />
                               </ndiag:DiagramView>
                           </td>
                           <td style="vertical-align:top;">
                               <ndiag:Overview ID="ovw" runat="server" DiagramViewID="diagView" Style="left: 680px; width: 120px;
                               top: 320px; height: 160px; display:inline;" />
                           </td>
                       </tr>
                   </table>
                   <ndiag:InteractivityExtender ID="InteractivityExtender1" TargetControlID="diagView" runat="server" />
                   <ndiag:OverviewExtender ID="ovrExt" TargetControlID="ovw" runat="server" />
               </ContentTemplate>
           </asp:UpdatePanel>
      </div>
    </form>




and the aspx.vb:


Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Not IsPostBack Then
           diagView.Diagram.DefaultShape = Shapes.Rectangle
           Dim oSNode As DiagramNode
           Dim oDNode As DiagramNode
           oSNode = diagView.Diagram.Factory.CreateShapeNode(0, 25, 25, 10)
           oDNode = diagView.Diagram.Factory.CreateShapeNode(88.10624, 28.83958, 25.00001, 10.0)

           Dim oLink As DiagramLink
           oLink = diagView.Diagram.Factory.CreateDiagramLink(oSNode, oDNode)
           'oLink = New DiagramLink(diagView.Diagram)

           oLink.ControlPoints.Clear()
           oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 28.83958))
           oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 63.4052))
           oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 35.0))
           oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 63.4052))

           oLink.Origin = oSNode
           oLink.Destination = oDNode
           oLink.SegmentCount = 3
           'diagView.Diagram.Links.Add(oLink)
           oLink.Style = LinkStyle.Cascading
       End If
    End Sub



When it renders it looks nothing like the defined control points. When I comment out setting the style, it still does not look like the control points definition. Any help getting these control points to take would be greatly appreciated.
Thanks,
jay
  
Back to top
 
IP Logged
 
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Re: Bounds of DiagramLink is readonly
Reply #6 - Mar 30th, 2009 at 8:31pm
Print Post  
I played with the order in which some of these methods were called. I feel like I am getting closer with the below. However, the lines are drawn diaganol and should not be since the style is cascade...see code below:

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       If Not IsPostBack Then
           diagView.Diagram.DefaultShape = Shapes.Rectangle
           Dim oSNode As DiagramNode
           Dim oDNode As DiagramNode
           oSNode = diagView.Diagram.Factory.CreateShapeNode(0, 25, 25, 10)
           oDNode = diagView.Diagram.Factory.CreateShapeNode(88.10624, 28.83958, 25.00001, 10.0)

           Dim oLink As DiagramLink
           oLink = diagView.Diagram.Factory.CreateDiagramLink(oSNode, oDNode)

           oLink.Style = LinkStyle.Cascading
           oLink.SegmentCount = 3
           oLink.ControlPoints.Clear()
           oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 28.83958))
           oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 63.4052))
           oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 35.0))
           oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 63.4052))
           oLink.UpdateFromPoints(False, True)
       End If
    End Sub
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bounds of DiagramLink is readonly
Reply #7 - Mar 31st, 2009 at 9:35am
Print Post  
The points should be added in the same order as the link segments should follow from the start to end point. E.g. this works better:

oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 28.83958))
oLink.ControlPoints.Add(New System.Drawing.PointF(100.6062, 63.4052))
oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 63.4052))
oLink.ControlPoints.Add(New System.Drawing.PointF(12.5, 35.0))

Check if your database query returns the points in the order you have added them.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jcollins@scires
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 53
Joined: Feb 17th, 2009
Re: Bounds of DiagramLink is readonly
Reply #8 - Mar 31st, 2009 at 2:27pm
Print Post  
That was it. The order of the points needed to be saved!
Thanks a lot!
Jay
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint