Example #1
0
 public void SwapCollections(int collectionIndexA, int collectionIndexB)
 {
     if (collectionIndexA >= 0 && collectionIndexA < Collections.Count &&
         collectionIndexB >= 0 && collectionIndexB < Collections.Count &&
         Mathf.Abs(collectionIndexA - collectionIndexB) == 1)
     {
         PTFlatGroupCollection tmp = Collections[collectionIndexA];
         Collections[collectionIndexA] = Collections[collectionIndexB];
         Collections[collectionIndexB] = tmp;
         UpdateContent();
     }
 }
Example #2
0
        public Vector2 GetHorizontalRangeOf(PTFlatGroupCollection collection)
        {
            if (collection != null && collection.Count > 0)
            {
                Vector2 ret = new Vector2();

                //min
                ret.x = (collection.content[0].transform.position - 0.5f * ptZone.dimensionSpacings[0]).magnitude;
                //max
                ret.y = (collection.content[collection.Count - 1].transform.position + 0.5f * ptZone.dimensionSpacings[0]).magnitude;
            }
            return(Vector2.zero);
        }
Example #3
0
 public void AddCollection(PTFlatGroupElement element)
 {
     if (Contains(element))
     {
         return;
     }
     else
     {
         PTFlatGroupCollection newCollection = new PTFlatGroupCollection(false);
         newCollection.Add(element);
         Collections.Add(newCollection);
     }
 }
Example #4
0
        public void UnGroup(PTFlatGroupElement element)
        {
            KeyValuePair <int, PTFlatGroupCollection> collection = FindCollectionWithIndexBy(element);

            if (collection.Value != null)
            {
                collection.Value.Remove(element);
                PTFlatGroupCollection newCollection = new PTFlatGroupCollection(false);
                newCollection.Add(element);
                Collections.Insert(collection.Key + 1, newCollection);
                collection.Value.UpdateBackground(this);
                if (collection.Value.Count == 0)
                {
                    Collections.Remove(collection.Value);
                }
            }

            UpdateContent();
        }
Example #5
0
        public void Remove(PTFlatGroupElement element)
        {
            //Remove from collection
            PTFlatGroupCollection collection = FindCollectionBy(element);

            if (collection != null)
            {
                if (collection.Contains(element))
                {
                    collection.Remove(element);
                }
                if (collection.Count == 0)
                {
                    Collections.Remove(collection);
                }
            }

            //unparent
            if (element != null && this == element.GetComponentInParent <PTFlatGroups>())
            {
                element.transform.SetParent(null);
            }
        }
Example #6
0
 public void SetIsGroupIfSingle(PTFlatGroupCollection collection, bool value)
 {
     SetIsGroupIfSingle(Collections.IndexOf(collection), value);
 }
Example #7
0
 public int IndexOf(PTFlatGroupCollection collection)
 {
     return(Collections.IndexOf(collection));
 }