Example #1
0
        public void CopyFrom(Relations source)
        {
            this.ClearAll();

            List <RelationItem> arr = source._items;

            foreach (RelationItem ri in arr)
            {
                RelationItem item = new RelationItem(this._owner);
                item.CopyFrom(ri);
                this._items.Add(item);
            }
        }
Example #2
0
        public void OnOwnerSizeChanged(Vector2 deltaSize)
        {
            int count = this._items.Count;

            if (count == 0)
            {
                return;
            }

            for (int i = 0; i < count; i++)
            {
                RelationItem item = this._items[i];
                item.ApplyOnSelfSizeChanged(deltaSize);
            }
        }
Example #3
0
        private void AddItems(GObject target, string sidePairs)
        {
            string[] arr = sidePairs.Split(JOINT_CHAR0);

            RelationItem newItem = new RelationItem(this._owner);

            newItem.target = target;

            int cnt = arr.Length;

            for (int i = 0; i < cnt; i++)
            {
                string s = arr[i];
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }

                bool usePercent;
                if (s[s.Length - 1] == '%')
                {
                    s          = s.Substring(0, s.Length - 1);
                    usePercent = true;
                }
                else
                {
                    usePercent = false;
                }

                int j = s.IndexOf("-", StringComparison.Ordinal);
                if (j == -1)
                {
                    s = s + "-" + s;
                }

                int tid = Array.IndexOf(RELATION_NAMES, s);
                if (tid == -1)
                {
                    throw new ArgumentException("invalid relation type: " + s);
                }

                newItem.QuickAdd(( RelationType )tid, usePercent);
            }

            this._items.Add(newItem);
        }
Example #4
0
        public void Add(GObject target, RelationType relationType, bool usePercent)
        {
            int count = this._items.Count;

            for (int i = 0; i < count; i++)
            {
                RelationItem item = this._items[i];
                if (item.target == target)
                {
                    item.Add(relationType, usePercent);
                    return;
                }
            }
            RelationItem newItem = new RelationItem(this._owner);

            newItem.target = target;
            newItem.Add(relationType, usePercent);
            this._items.Add(newItem);
        }
Example #5
0
        public void ClearFor(GObject target)
        {
            int cnt = this._items.Count;
            int i   = 0;

            while (i < cnt)
            {
                RelationItem item = this._items[i];
                if (item.target == target)
                {
                    item.Dispose();
                    this._items.RemoveAt(i);
                    cnt--;
                }
                else
                {
                    i++;
                }
            }
        }
Example #6
0
        public void Remove(GObject target, RelationType relationType)
        {
            int cnt = this._items.Count;
            int i   = 0;

            while (i < cnt)
            {
                RelationItem item = this._items[i];
                if (item.target == target)
                {
                    item.Remove(relationType);
                    if (item.isEmpty)
                    {
                        item.Dispose();
                        this._items.RemoveAt(i);
                        cnt--;
                        continue;
                    }
                    i++;
                }
                i++;
            }
        }