Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Link Start point and end point are getting changed (Read 1764 times)
snype
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jul 7th, 2011
Link Start point and end point are getting changed
Jul 11th, 2011 at 8:08pm
Print Post  
I was trying to create a link between two anchor points . After the link is created the starting point and end point of the link are getting changed in some cases.

Here is the code.[code]
MainPage.cs
public partial class MainPage : UserControl
    {
       AnchorPattern apat1, apat2;
       public MainPage()
       {
           InitializeComponent();
           diagram.DefaultShape = Shapes.Rectangle;
           diagram.FontSize = 10.75;
           ShapeNode pb1, pb2, pb3, pb4, decb1, decb2;

           apat1 = new AnchorPattern(new AnchorPoint[]
{
new AnchorPoint(50, 0, true, true),
new AnchorPoint(100, 50, true, true),
new AnchorPoint(50, 100, true, true),
new AnchorPoint(0, 50, true, true)
});

           apat2 = new AnchorPattern(new AnchorPoint[]
{
new AnchorPoint(10, 0, true, false, MarkStyle.Circle, Brushes.Blue),
new AnchorPoint(50, 0, true, false, MarkStyle.Circle, Brushes.Blue),
new AnchorPoint(90, 0, true, false, MarkStyle.Circle, Brushes.Red),
new AnchorPoint(10, 100, false, true, MarkStyle.Rectangle),
new AnchorPoint(50, 100, false, true, MarkStyle.Rectangle),
new AnchorPoint(90, 100, false, true, MarkStyle.Rectangle),
new AnchorPoint(0, 50, true, true, MarkStyle.Rectangle)
});

           pb1 = new ShapeNode(diagram);
           pb1.Bounds = new Rect(38.4, 26.88, 96, 69.12);
           pb1.Shape = Shapes.Ellipse;
           pb1.Text = "Start";
           pb1.AnchorPattern = apat1;
           diagram.Nodes.Add(pb1);

           pb2 = new ShapeNode(diagram);
           pb2.Bounds = new Rect(76.8, 288, 96, 69.12);
           pb2.Text = "node 1";
           pb2.AnchorPattern = apat2;
           diagram.Nodes.Add(pb2);

           pb3 = new ShapeNode(diagram);
           pb3.Bounds = new Rect(268.8, 268.8, 96, 69.12);
           pb3.Text = "node 2";
           pb3.AnchorPattern = apat2;
           diagram.Nodes.Add(pb3);

           pb4 = new ShapeNode(diagram);
           pb4.Bounds = new Rect(307.2, 384, 96, 69.12);
           pb4.Shape = Shapes.Ellipse;
           pb4.Text = "End";
           pb4.AnchorPattern = apat1;
           diagram.Nodes.Add(pb4);

           decb1 = new ShapeNode(diagram);
           decb1.Bounds = new Rect(76.8, 134.4, 115.2, 76.8);
           decb1.Shape = Shapes.Decision;
           decb1.Text = "check 1";
           decb1.AnchorPattern = AnchorPattern.Decision1In3Out;
           diagram.Nodes.Add(decb1);

           decb2 = new ShapeNode(diagram);
           decb2.Bounds = new Rect(268.8, 115.2, 115.2, 76.8);

           decb2.Shape = Shapes.Decision;
           decb2.Text = "check 2";
           decb2.AnchorPattern = AnchorPattern.LeftInRightOut;
           diagram.Nodes.Add(decb2);

           DiagramLink link = new DiagramLink(diagram, decb1, decb2);
           diagram.Links.Add(link);

           var router = diagram.LinkRouter as QuickRouter;
           if (router != null)
               router.UBendMaxLen = 10;
           diagram.RoutingOptions.TriggerRerouting |= RerouteLinks.WhileCreating;
           diagram.RoutingOptions.Anchoring = Anchoring.Keep;
       }

       private void diagram_NodeCreated(object sender, NodeEventArgs e)
       {
           ShapeNode node = e.Node as ShapeNode;
           if (node == null)
               return;

           if (node.Shape == Shapes.Decision)
               node.AnchorPattern = AnchorPattern.Decision1In3Out;
           else
               node.AnchorPattern = apat2;
       }
      
    }



MainPage.xml

<UserControl x:Class="Servlight_Test.Dialogs.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:my="clr-namespace:MindFusion.Diagramming.Silverlight;assembly=MindFusion.Diagramming.Silverlight"
    Height="800"
    Width="800" >
    <Border
       CornerRadius="5">
         <Grid>
               <Grid.RowDefinitions>
                   <RowDefinition
                       Height="Auto" />
                   <RowDefinition />
               </Grid.RowDefinitions>               
         
           <my:Diagram
               Name="diagram"
               AllowUnconnectedLinks="True"
               NodeCreated="diagram_NodeCreated"               
               ShapeHandlesStyle="DashFrame"
               AlignToGrid="False"
               BackBrush="#FFE0E0E0"
               HorizontalAlignment="Stretch"
               VerticalAlignment="Stretch"
               LinkSegments="3"
               RouteLinks="True"
               AutoSnapLinks="True"
               AutoSnapDistance="10"
               DynamicLinks="True">
              
           </my:Diagram>
       </Grid>
      </Border>
     
</UserControl>
[/code]
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link Start point and end point are getting cha
Reply #1 - Jul 11th, 2011 at 8:44pm
Print Post  
Set DynamicLinks="False" to prevent that.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint