public object this [int[] aIdx] {
            get {
                if ((aIdx == null) || (aIdx.Length == 0))
                {
                    throw new NullReferenceException("Hierarchical index (int[]) can't be null or empty");
                }

                if (IsFiltered == false)
                {
                    if (TypeValidator.IsCompatible(ParentView.GetType(), typeof(IObservableList)) == true)
                    {
                        return((ParentView as IObservableList)[aIdx]);
                    }
                    else
                    {
                        return(HierarchicalList.Get(ParentView, aIdx));
                    }
                }

                if ((aIdx[0] < 0) || (aIdx[0] >= Count))
                {
                    throw new IndexOutOfRangeException(string.Format("Index {0} is out of range", aIdx.PathToString()));
                }

                return(HierarchicalList.Get(this, aIdx));
            }
        }
        protected override void ElementAddedIntoMaster(object aList, int[] aIdx)
        {
            int[] idx = aIdx.CopyPath();
            idx[0] = TranslateIndex(aIdx[0]);
            object o = HierarchicalList.Get(ParentView, aIdx);

            if (aIdx.Length > 1)
            {
                if (idx[0] > -1)
                {
                    OnElementAdded(idx);
                }
            }
            else if ((idx[0] > -1) && (o != null))
            {
                items.Insert(o);
                if (idx[0] >= localIndex.Count)
                {
                    localIndex.Add(o);
                }
                else
                {
                    localIndex.Insert(aIdx[0], o);
                }
                OnElementAdded(idx);
                OnPropertyChanged("Count");
            }
            idx = null;
        }
        public object this [int[] aIdx] {
            get {
                if ((aIdx == null) || (aIdx.Length == 0))
                {
                    throw new NullReferenceException("Hierarchical index (int[]) can't be null or empty");
                }

                return(HierarchicalList.Get(this, aIdx));
            }
        }
        protected override void ElementChangedInMaster(object aList, int[] aIdx)
        {
            int[] idx = aIdx.CopyPath();
            idx[0] = TranslateIndex(aIdx[0]);
            object o = HierarchicalList.Get(ParentView, aIdx);

            // Check if level is higher
            if (aIdx.Length > 1)
            {
                OnElementChanged(idx);
                idx = null;
                return;
            }

            items.Remove(localIndex[aIdx[0]], InstanceInformation.ObjectInstance);
            items.Insert(o);
            localIndex[aIdx[0]] = o;
            idx[0] = items.IndexOf(o);
            OnElementChanged(idx);
            idx = null;
        }
Пример #5
0
 /// <summary>
 /// Resolves any object in this list, supports hierarchy
 /// </summary>
 /// <param name="aIdx">
 /// Hierarchical path <see cref="System.Int32"/>
 /// </param>
 public object this [int[] aIdx] {
     get { return(HierarchicalList.Get(this, aIdx)); }
 }