Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodesIn"></param>
        /// <returns></returns>
        protected NodeCollection GetAllowedNodes(NodeCollection nodesIn)
        {
            NodeCollection nodesOut = new NodeCollection();

            IEnumerator enumNodesIn = nodesIn.GetEnumerator();

            while (enumNodesIn.MoveNext())
            {
                bool allowed = true;

                IPropertyContainer curProps = enumNodesIn.Current as IPropertyContainer;
                if (curProps != null)
                {
                    allowed = (bool)curProps.GetPropertyValue("AllowMove");
                }

                if (allowed)
                {
                    nodesOut.Add(enumNodesIn.Current as INode);
                }
            }

            return(nodesOut);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="nodes"></param>
        /// <returns></returns>
        public static System.Drawing.RectangleF GetAggregateBounds(NodeCollection nodes)
        {
            RectangleF rcBounds  = new RectangleF(0, 0, 0, 0);
            bool       firstNode = true;

            foreach (INode node in nodes)
            {
                IBounds2DF nodeBounds = node as IBounds2DF;
                if (nodeBounds != null)
                {
                    if (firstNode)
                    {
                        rcBounds  = nodeBounds.Bounds;
                        firstNode = false;
                    }
                    else
                    {
                        rcBounds = Geometry.Union(rcBounds, nodeBounds.Bounds);
                    }
                }
            }

            return(rcBounds);
        }
Example #3
0
        /// <summary>
        /// Constructs a NodePathTracker object given a view and a collection
        /// of nodes to track.
        /// </summary>
        /// <param name="view">View to attach to</param>
        /// <param name="nodes">Collection of nodes to track</param>
        public NodePathTracker(View view, NodeCollection nodes) : base(view)
        {
            // Load array of bounding rectangles
            this.trackingPath = new GraphicsPath();
            this.ptUpperLeft  = new Point(int.MaxValue, int.MaxValue);
            System.Drawing.Rectangle curBounds;

            foreach (INode curNode in nodes)
            {
                IGraphics      graphicsObj = curNode as IGraphics;
                IBounds2DF     nodeBounds  = curNode as IBounds2DF;
                ITransform     nodeTrans   = curNode as ITransform;
                ICompositeNode nodeParent  = curNode.Parent;

                // Push the parent transforms for the current node onto the stack
                if (nodeTrans != null)
                {
                    Global.MatrixStack.Push(nodeTrans.ParentTransform);
                }

                // Get the bounds of the current node in world coordinates
                if (nodeBounds != null)
                {
                    curBounds = this.view.ViewToDevice(this.view.WorldToView(nodeBounds.Bounds));

                    if (curBounds.Left < this.ptUpperLeft.X)
                    {
                        this.ptUpperLeft.X = curBounds.Left;
                    }

                    if (curBounds.Top < this.ptUpperLeft.Y)
                    {
                        this.ptUpperLeft.Y = curBounds.Top;
                    }
                }
                else
                {
                    curBounds = new System.Drawing.Rectangle(0, 0, 0, 0);
                }

                if (graphicsObj != null)
                {
                    GraphicsPath grfxPath = graphicsObj.GraphicsPath;
                    if (grfxPath != null)
                    {
                        this.trackingPath.AddPath(grfxPath, false);
                    }
                }
                else if (nodeBounds != null)
                {
                    this.trackingPath.AddRectangle(curBounds);
                }

                // Get the constraining region for the current node and add it
                // to the constraining region for the tracker
                Region curRgnConstraint = null;
                if (nodeParent != null)
                {
                    curRgnConstraint = nodeParent.GetConstrainingRegion(curNode);
                    if (curRgnConstraint != null)
                    {
                        if (this.rgnConstraint == null)
                        {
                            this.rgnConstraint = curRgnConstraint.Clone();
                        }
                        else
                        {
                            this.rgnConstraint.Union(curRgnConstraint);
                        }
                    }
                }

                // Reset matrix stack
                Global.MatrixStack.Clear();
            }
        }
Example #4
0
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="src">Source object to copy from</param>
 public NodeCollection(NodeCollection src) : base(src)
 {
 }