Beispiel #1
0
        /// <summary>
        /// Change the <see cref="P:Northwoods.Go.GoObject.Parent" /> of an object to be the common subgraph that
        /// contains two given objects, or if there is no such subgraph, add the object to the given layer.
        /// </summary>
        /// <param name="obj">the <see cref="T:Northwoods.Go.GoObject" /> to reparent</param>
        /// <param name="child1">an object that may belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <param name="child2">another object that may belong to a <see cref="T:Northwoods.Go.GoSubGraphBase" /></param>
        /// <param name="behind">whether to add the <paramref name="obj" /> at the beginning of the list
        /// of the subgraph's children (thus behind all other subgraph children), or at the end of the list
        /// (thus appearing in front of all the other subgraph children)</param>
        /// <param name="layer">
        /// the <see cref="T:Northwoods.Go.GoLayer" /> to which the <paramref name="obj" /> should be added,
        /// if there is no common parent <see cref="T:Northwoods.Go.GoSubGraphBase" /> for <paramref name="child1" /> and
        /// <paramref name="child2" />
        /// </param>
        /// <remarks>
        /// All of the arguments to this method should be non-null.
        /// </remarks>
        public static void ReparentToCommonSubGraph(GoObject obj, GoObject child1, GoObject child2, bool behind, GoLayer layer)
        {
            GoSubGraphBase a        = FindParentSubGraph(child1);
            GoSubGraphBase b        = FindParentSubGraph(child2);
            GoObject       goObject = GoObject.FindCommonParent(a, b);

            while (goObject != null && !(goObject is GoSubGraphBase))
            {
                goObject = goObject.Parent;
            }
            GoSubGraphBase goSubGraphBase = goObject as GoSubGraphBase;

            if (obj.Parent == goSubGraphBase && obj.Layer != null)
            {
                return;
            }
            if (obj.Parent == null && obj.Layer == null)
            {
                if (goSubGraphBase != null)
                {
                    if (behind)
                    {
                        goSubGraphBase.InsertBefore(null, obj);
                    }
                    else
                    {
                        goSubGraphBase.InsertAfter(null, obj);
                    }
                }
                else
                {
                    layer.Add(obj);
                }
            }
            else
            {
                GoCollection goCollection = new GoCollection();
                goCollection.Add(obj);
                if (goSubGraphBase != null)
                {
                    goSubGraphBase.AddCollection(goCollection, reparentLinks: false);
                }
                else
                {
                    layer.AddCollection(goCollection, reparentLinks: false);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Unlike the standard behavior provided by <see cref="T:Northwoods.Go.GoGroup" />'s <see cref="M:Northwoods.Go.GoGroup.PickObjects(System.Drawing.PointF,System.Boolean,Northwoods.Go.IGoCollection,System.Int32)" />,
 /// subgraphs allow the picking of more than one child, if they overlap each other at the given point.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="selectableOnly"></param>
 /// <param name="coll"></param>
 /// <param name="max"></param>
 /// <returns></returns>
 /// <remarks>
 /// If <see cref="M:Northwoods.Go.GoObject.CanView" /> is false for this group, no children are added to the collection.
 /// </remarks>
 public override IGoCollection PickObjects(PointF p, bool selectableOnly, IGoCollection coll, int max)
 {
     if (coll == null)
     {
         coll = new GoCollection();
     }
     if (coll.Count >= max)
     {
         return(coll);
     }
     if (!GoObject.ContainsRect(Bounds, p))
     {
         return(coll);
     }
     if (!CanView())
     {
         return(coll);
     }
     foreach (GoObject backward in base.Backwards)
     {
         GoSubGraphBase goSubGraphBase = backward as GoSubGraphBase;
         if (goSubGraphBase != null)
         {
             goSubGraphBase.PickObjects(p, selectableOnly, coll, max);
         }
         else
         {
             GoObject goObject = backward.Pick(p, selectableOnly);
             if (goObject != null)
             {
                 coll.Add(goObject);
                 if (coll.Count >= max)
                 {
                     return(coll);
                 }
             }
         }
     }
     if (PickableBackground && (!selectableOnly || CanSelect()))
     {
         coll.Add(this);
     }
     return(coll);
 }