示例#1
0
        public static void UpdateEdge(PPath edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.

            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = node1.GlobalBounds.Location;
            PointF    end = node2.GlobalBounds.Location;
            float     h1x, h1y, h2x;

            if (nodes.Count > 2 && (int)nodes[2] == -1) //var link
            {
                start.X += node1.GlobalBounds.Width * 0.5f;
                start.Y += node1.GlobalBounds.Height;
                h1x      = h2x = 0;
                h1y      = end.Y > start.Y ? 200 * (float)Math.Log10((end.Y - start.Y) / 200 + 1) : 200 * (float)Math.Log10((start.Y - end.Y) / 100 + 1);
                end.X   += node2.GlobalBounds.Width / 2;
                end.Y   += node2.GlobalBounds.Height / 2;
            }
            else
            {
                start.X += node1.GlobalBounds.Width;
                start.Y += node1.GlobalBounds.Height * 0.5f;
                end.Y   += node2.GlobalBounds.Height * 0.5f;
                h1x      = h2x = end.X > start.X ? 200 * (float)Math.Log10((end.X - start.X) / 200 + 1) : 200 * (float)Math.Log10((start.X - end.X) / 100 + 1);
                h1y      = 0;
            }

            edge.Reset();
            //edge.AddLine(start.X, start.Y, end.X, end.Y);
            edge.AddBezier(start.X, start.Y, start.X + h1x, start.Y + h1y, end.X - h2x, end.Y, end.X, end.Y);
        }
        public void UpdateLink()
        {
            PointFx p1 = PUtil.CenterOfRectangle(node1.FullBounds);
            PointFx p2 = PUtil.CenterOfRectangle(node2.FullBounds);

            link.Reset();
            link.AddLine(p1.X, p1.Y, p2.X, p2.Y);
        }
示例#3
0
文件: LinkPath.cs 项目: you8/vvvv-sdk
        protected void BuildLine(PointF endpoint)
        {
            PPath.Reset();

            Points[0] = Start.GlobalMiddle;
            Points[Points.Count - 1] = endpoint;

            for (int i = 0; i < Points.Count - 1; i++)
            {
                PPath.AddLine(Points[i].X, Points[i].Y, Points[i + 1].X, Points[i + 1].Y);
            }
        }
        //! Создает линии - связи между узлами на графе диалогов
        public static void updateEdge(PPath edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.
            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = PUtil.CenterOfRectangle(node1.FullBounds);
            PointF    end   = PUtil.CenterOfRectangle(node2.FullBounds);

            edge.Reset();
            edge.AddLine(start.X, start.Y, end.X, end.Y);
        }
        /// <summary>
        /// Update the marquee bounds based on the given event data.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void UpdateMarquee(PInputEventArgs e)
        {
            RectangleF r = RectangleF.Empty;

            if (marqueeParent is PCamera)
            {
                r = PUtil.AddPointToRect(r, canvasPressPt);
                r = PUtil.AddPointToRect(r, e.CanvasPosition);
            }
            else
            {
                r = PUtil.AddPointToRect(r, presspt);
                r = PUtil.AddPointToRect(r, e.Position);
            }

            r = marquee.GlobalToLocal(r);
            marquee.Reset();
            SetSafeMarqueePen(r.Width, r.Height);
            marquee.AddRectangle(r.X, r.Y, r.Width, r.Height);

            r = RectangleF.Empty;
            r = PUtil.AddPointToRect(r, presspt);
            r = PUtil.AddPointToRect(r, e.Position);

            allItems.Clear();
            PNodeFilter filter = CreateNodeFilter(r);

            foreach (PNode parent in selectableParents)
            {
                PNodeList items;
                if (parent is PCamera)
                {
                    items = new PNodeList();
                    PCamera cameraParent = (PCamera)parent;
                    for (int i = 0; i < cameraParent.LayerCount; i++)
                    {
                        cameraParent.GetLayer(i).GetAllNodes(filter, items);
                    }
                }
                else
                {
                    items = parent.GetAllNodes(filter, null);
                }

                foreach (PNode node in items)
                {
                    allItems.Add(node, true);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Creates straight edged lines, from the center of the node.
        /// </summary>
        /// <param name="edge"></param>
        public static void UpdateEdgeStraight(PPath edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.

            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = node1.GlobalBounds.Location;
            PointF    end   = node2.GlobalBounds.Location;


            //float h1x, h1y, h2x;
            //if (nodes.Count > 2 && (int)nodes[2] == -1) //var link
            //{
            //    start.X += node1.GlobalBounds.Width * 0.5f;
            //    start.Y += node1.GlobalBounds.Height;
            //    h1x = h2x = 0;
            //    h1y = end.Y > start.Y ? 200 * (float)Math.Log10((end.Y - start.Y) / 200 + 1) : 200 * (float)Math.Log10((start.Y - end.Y) / 100 + 1);
            //    if (h1y < 15)
            //    {
            //        h1y = 15;
            //    }
            //    end.X += node2.GlobalBounds.Width / 2;
            //    end.Y += node2.GlobalBounds.Height / 2;
            //}
            //else
            //{
            //    start.X += node1.GlobalBounds.Width;
            //    start.Y += node1.GlobalBounds.Height * 0.5f;
            //    end.Y += node2.GlobalBounds.Height * 0.5f;
            //    h1x = h2x = end.X > start.X ? 200 * (float)Math.Log10((end.X - start.X) / 200 + 1) : 200 * (float)Math.Log10((start.X - end.X) / 100 + 1);
            //    if (h1x < 15)
            //    {
            //        h1x = h2x = 15;
            //    }
            //    h1y = 0;
            //}

            edge.Reset();
            edge.AddLine(start.X + node1.GlobalBounds.Width * 0.5f, start.Y + node1.GlobalBounds.Height * 0.5f, end.X + node2.GlobalBounds.Width * 0.5f, end.Y + node2.GlobalBounds.Height * 0.5f);
        }
示例#7
0
文件: Poly.cs 项目: neuston/vvvv-sdk
        protected void Rebuild()
        {
            if (IsClosed)            //solid
            {
                if (FPoints.Count > 2)
                {
                    PPath.Reset();
                    PPath.AddPolygon(FPoints.ToArray());
                }
            }
            else             //line strip
            {
                if (FPoints.Count > 1)
                {
                    PPath.Reset();

                    for (int i = 0; i < FPoints.Count - 1; i++)
                    {
                        PPath.AddLine(FPoints[i].X, FPoints[i].Y, FPoints[i + 1].X, FPoints[i + 1].Y);
                    }
                }
            }
        }
示例#8
0
 /// <summary>
 /// Overridden.  When the lens is resized this method gives us a chance to layout the
 /// lens's camera child appropriately.
 /// </summary>
 public override void LayoutChildren()
 {
     dragBar.Reset();
     dragBar.SetPathToRectangle((float)X, (float)Y, (float)Width, (float)LENS_DRAGBAR_HEIGHT);
     camera.SetBounds(X, Y + LENS_DRAGBAR_HEIGHT, Width, Height - LENS_DRAGBAR_HEIGHT);
 }