コード例 #1
0
        public Drawing.LineSegment GetConnectionLine(ParentChildConnection <Node <T> > connection)
        {
            var parent_rect = connection.Parent.Rect;
            var child_rect  = connection.Child.Rect;

            double parent_x, parent_y;
            double child_x, child_y;

            if (TreeLayout <T> .IsVertical(this.Options.Direction))
            {
                parent_x = parent_rect.Center.X;
                child_x  = child_rect.Center.X;

                parent_y = TreeLayout <T> .GetSide(parent_rect, this.Options.Direction);

                child_y = TreeLayout <T> .GetSide(child_rect, TreeLayout <T> .GetOpposite(this.Options.Direction));
            }
            else
            {
                var parent_dir = this.Options.Direction;
                var child_dir  = TreeLayout <T> .GetOpposite(parent_dir);

                parent_x = TreeLayout <T> .GetSide(parent_rect, parent_dir);

                child_x = TreeLayout <T> .GetSide(child_rect, child_dir);

                parent_y = parent_rect.Center.Y;
                child_y  = child_rect.Center.Y;
            }

            var parent_attach_point = new Drawing.Point(parent_x, parent_y);
            var child_attach_point  = new Drawing.Point(child_x, child_y);

            return(new Drawing.LineSegment(parent_attach_point, child_attach_point));
        }
コード例 #2
0
        public Drawing.Point[] GetConnectionPolyline(ParentChildConnection <Node <T> > connection)
        {
            var lineseg = this.GetConnectionLine(connection);

            Drawing.Point m0, m1;

            var parent_attach_point = lineseg.Start;
            var child_attach_point  = lineseg.End;
            var dif = lineseg.End - lineseg.Start;
            var a   = (this.Options.LevelSeparation / 2.0);
            var b   = (this.Options.LevelSeparation / 2.0);

            if (TreeLayout <T> .IsVertical(this.Options.Direction))
            {
                if (this.Options.Direction == LayoutDirection.Up)
                {
                    b = -b;
                }
                m0 = new Drawing.Point(lineseg.Start.X, lineseg.End.Y + b);
                m1 = new Drawing.Point(lineseg.End.X, lineseg.End.Y + b);
            }
            else
            {
                if (this.Options.Direction == LayoutDirection.Left)
                {
                    a = -a;
                }
                m0 = new Drawing.Point(lineseg.End.X - a, lineseg.Start.Y);
                m1 = new Drawing.Point(lineseg.End.X - a, lineseg.End.Y);
            }

            return(new[] { lineseg.Start, m0, m1, lineseg.End });
        }
コード例 #3
0
 public IEnumerable <ParentChildConnection <Node <T> > > EnumConnections()
 {
     foreach (var parent in this.Nodes)
     {
         foreach (var child in parent.EnumChildren())
         {
             var connection = new ParentChildConnection <Node <T> >(parent, child);
             yield return(connection);
         }
     }
 }
コード例 #4
0
        public Drawing.Point[] GetConnectionBezier(ParentChildConnection <Node <T> > connection)
        {
            var lineseg = this.GetConnectionLine(connection);

            var parent_attach_point = lineseg.Start;
            var child_attach_point  = lineseg.End;

            double scale = this.Options.LevelSeparation / 2.0;
            var    dif   = child_attach_point.Subtract(parent_attach_point).Multiply(scale);


            var handle_displacement = TreeLayout <T> .IsVertical(this.Options.Direction)
                                          ? new Drawing.Point(0, dif.Y)
                                          : new Drawing.Point(dif.X, 0);

            var h1 = parent_attach_point.Add(handle_displacement);
            var h2 = child_attach_point.Add(handle_displacement * (-1));

            return(new[] { parent_attach_point, h1, h2, child_attach_point });
        }