コード例 #1
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            TreeListBoxItem item2 = element as TreeListBoxItem;
            TreeListBoxInfo info  = item as TreeListBoxInfo;

            this.OnNewItemCreated(new TreeListBoxItemCreatedEventArgs(item2, info));
            item2.PrepareItem(info);
            base.PrepareContainerForItemOverride(element, info.DataItem);
        }
コード例 #2
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
 private void ResetFlattenedList()
 {
     if (Interlocked.Exchange(ref this.isResetting, 1) == 0)
     {
         lock (this.CompositeChildCollection)
         {
             if (this.currentDataSource != null)
             {
                 this.compositeChildCollection.Clear();
                 if (this.rootNodesInfo == null)
                 {
                     this.rootNodesInfo = new List <TreeListBoxInfo>();
                 }
                 else
                 {
                     this.rootNodesInfo.Clear();
                 }
                 foreach (object obj2 in this.currentDataSource)
                 {
                     TreeListBoxInfo item = new TreeListBoxInfo(0, obj2)
                     {
                         CreatedDuringReset = true
                     };
                     this.compositeChildCollection.Add(item);
                     if (item.IsExpanded)
                     {
                         this.AddDescendentsOnCreation(item);
                     }
                     this.rootNodesInfo.Add(item);
                     if (this.resetTimer.IsBatching)
                     {
                         this.isResetting = 0;
                         return;
                     }
                 }
                 if (this.GetFlattenedTreeItemCount() != this.compositeChildCollection.Count)
                 {
                     this.isResetting = 0;
                     this.RecalculateList();
                     return;
                 }
                 if (!this.resetTimer.IsBatching)
                 {
                     base.ItemsSource = this.compositeChildCollection;
                 }
             }
             else
             {
                 base.ItemsSource = null;
             }
             this.isResetting = 0;
             return;
         }
     }
     this.RecalculateList();
 }
コード例 #3
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
        private void AddDescendentsOnCreation(TreeListBoxInfo parent)
        {
            IEnumerable dataChildList = this.GetDataChildList(parent.DataItem);

            if (dataChildList != null)
            {
                foreach (object obj2 in dataChildList)
                {
                    this.AddChildHierarchy(parent, obj2);
                }
            }
        }
コード例 #4
0
        private void GenerateSingleItem(object item)
        {
            int index = this.treeListBox.CompositeChildCollection.IndexOf(this.currentInfo);

            if (index != -1)
            {
                TreeListBoxInfo info = new TreeListBoxInfo(this.level + 1, item);
                this.currentInfo.ChildItems.Add(info);
                this.treeListBox.CompositeChildCollection.Insert(index + this.lastChildItemCreatedIndex, info);
                this.lastChildItemCreatedIndex++;
            }
        }
コード例 #5
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
        private void AddChildHierarchy(TreeListBoxInfo parent, object item)
        {
            TreeListBoxInfo info = new TreeListBoxInfo(parent.Level + 1, item)
            {
                CreatedDuringReset = true
            };

            parent.ChildItems.Add(info);
            this.CompositeChildCollection.Add(info);
            if (info.IsExpanded)
            {
                this.AddDescendentsOnCreation(info);
            }
        }
コード例 #6
0
        private static int GetDescendentCount(TreeListBoxInfo info)
        {
            if ((info.childItems == null) || (info.childItems.Count == 0))
            {
                return(0);
            }
            int num = 0;

            foreach (TreeListBoxInfo info2 in info.childItems)
            {
                num += GetDescendentCount(info2);
                num++;
            }
            return(num);
        }
コード例 #7
0
        private bool DeleteSingleItem(TreeListBoxInfo info)
        {
            int index = this.treeListBox.CompositeChildCollection.IndexOf(info);

            if (index == -1)
            {
                return(false);
            }
            for (int i = 0; i < info.DescendentCount; i++)
            {
                this.treeListBox.CompositeChildCollection[index].IsExpanded = false;
                this.treeListBox.CompositeChildCollection.RemoveAt(index);
            }
            this.treeListBox.CompositeChildCollection[index].IsExpanded = false;
            this.treeListBox.CompositeChildCollection.RemoveAt(index);
            this.currentInfo.ChildItems.Remove(info);
            this.lastChildItemCreatedIndex--;
            return(true);
        }
コード例 #8
0
 internal virtual void PrepareItem(TreeListBoxInfo info)
 {
     this.currentInfo = info;
     this.level       = info.Level;
     if (info.IsExpanded)
     {
         this.IsExpanded = true;
     }
     this.isInitializing = false;
     this.InitChildListeners();
     this.HasItems = this.DoesDataItemHaveChildren();
     if (info.IsExpanded)
     {
         this.RegisterCollectionNotification();
     }
     if (this.HasItems && !info.CreatedDuringReset)
     {
         this.treeListBox.RecalculateList();
     }
 }
コード例 #9
0
 public void ExposePrepareItem(TreeListBoxInfo info)
 {
     this.PrepareItem(info);
 }
コード例 #10
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
        private void NotificationEnableCollectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            Predicate<TreeListBoxInfo> match = null;
            switch (e.Action)
            {
                case NotifyCollectionChangedAction.Add:
                    if (e.NewItems == null)
                    {
                        return;
                    }
                    lock (this.CompositeChildCollection)
                    {
                        int num = 0;
                        foreach (object obj2 in e.NewItems)
                        {
                            int index = Math.Min(e.NewStartingIndex + num, this.rootNodesInfo.Count);
                            int num3 = 0;
                            for (int j = index - 1; j >= 0; j--)
                            {
                                num3 += this.rootNodesInfo[j].DescendentCount + 1;
                            }
                            index = num3;
                            TreeListBoxInfo item = new TreeListBoxInfo(0, obj2);
                            this.rootNodesInfo.Insert(Math.Min(e.NewStartingIndex + num, this.rootNodesInfo.Count), item);
                            this.compositeChildCollection.Insert(index, item);
                            num++;
                        }
                        return;
                    }
                    break;

                case NotifyCollectionChangedAction.Remove:
                    break;

                case NotifyCollectionChangedAction.Replace:
                case NotifyCollectionChangedAction.Move:
                case NotifyCollectionChangedAction.Reset:
                    goto Label_01E9;

                default:
                    throw new InvalidOperationException();
            }
            lock (this.CompositeChildCollection)
            {
                if (match == null)
                {
                    match = i => i.DataItem == e.OldItems[0];
                }
                TreeListBoxInfo info2 = this.rootNodesInfo.Find(match);
                if (info2 != null)
                {
                    int num5 = this.compositeChildCollection.IndexOf(info2);
                    if (num5 >= 0)
                    {
                        int descendentCount = info2.DescendentCount;
                        for (int k = 0; k < descendentCount; k++)
                        {
                            this.compositeChildCollection.RemoveAt(num5);
                        }
                        this.compositeChildCollection.RemoveAt(num5);
                        this.rootNodesInfo.Remove(info2);
                    }
                }
                return;
            }
            Label_01E9:
            this.RecalculateList();
        }
コード例 #11
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
 private void ResetFlattenedList()
 {
     if (Interlocked.Exchange(ref this.isResetting, 1) == 0)
     {
         lock (this.CompositeChildCollection)
         {
             if (this.currentDataSource != null)
             {
                 this.compositeChildCollection.Clear();
                 if (this.rootNodesInfo == null)
                 {
                     this.rootNodesInfo = new List<TreeListBoxInfo>();
                 }
                 else
                 {
                     this.rootNodesInfo.Clear();
                 }
                 foreach (object obj2 in this.currentDataSource)
                 {
                     TreeListBoxInfo item = new TreeListBoxInfo(0, obj2) {
                         CreatedDuringReset = true
                     };
                     this.compositeChildCollection.Add(item);
                     if (item.IsExpanded)
                     {
                         this.AddDescendentsOnCreation(item);
                     }
                     this.rootNodesInfo.Add(item);
                     if (this.resetTimer.IsBatching)
                     {
                         this.isResetting = 0;
                         return;
                     }
                 }
                 if (this.GetFlattenedTreeItemCount() != this.compositeChildCollection.Count)
                 {
                     this.isResetting = 0;
                     this.RecalculateList();
                     return;
                 }
                 if (!this.resetTimer.IsBatching)
                 {
                     base.ItemsSource = this.compositeChildCollection;
                 }
             }
             else
             {
                 base.ItemsSource = null;
             }
             this.isResetting = 0;
             return;
         }
     }
     this.RecalculateList();
 }
コード例 #12
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
        private void NotificationEnableCollectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            Predicate <TreeListBoxInfo> match = null;

            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                if (e.NewItems == null)
                {
                    return;
                }
                lock (this.CompositeChildCollection)
                {
                    int num = 0;
                    foreach (object obj2 in e.NewItems)
                    {
                        int index = Math.Min(e.NewStartingIndex + num, this.rootNodesInfo.Count);
                        int num3  = 0;
                        for (int j = index - 1; j >= 0; j--)
                        {
                            num3 += this.rootNodesInfo[j].DescendentCount + 1;
                        }
                        index = num3;
                        TreeListBoxInfo item = new TreeListBoxInfo(0, obj2);
                        this.rootNodesInfo.Insert(Math.Min(e.NewStartingIndex + num, this.rootNodesInfo.Count), item);
                        this.compositeChildCollection.Insert(index, item);
                        num++;
                    }
                    return;
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                break;

            case NotifyCollectionChangedAction.Replace:
            case NotifyCollectionChangedAction.Move:
            case NotifyCollectionChangedAction.Reset:
                goto Label_01E9;

            default:
                throw new InvalidOperationException();
            }
            lock (this.CompositeChildCollection)
            {
                if (match == null)
                {
                    match = i => i.DataItem == e.OldItems[0];
                }
                TreeListBoxInfo info2 = this.rootNodesInfo.Find(match);
                if (info2 != null)
                {
                    int num5 = this.compositeChildCollection.IndexOf(info2);
                    if (num5 >= 0)
                    {
                        int descendentCount = info2.DescendentCount;
                        for (int k = 0; k < descendentCount; k++)
                        {
                            this.compositeChildCollection.RemoveAt(num5);
                        }
                        this.compositeChildCollection.RemoveAt(num5);
                        this.rootNodesInfo.Remove(info2);
                    }
                }
                return;
            }
Label_01E9:
            this.RecalculateList();
        }
コード例 #13
0
 public TreeListBoxItemCreatedEventArgs(TreeListBoxItem item, TreeListBoxInfo info)
 {
     this.newItem = item;
     this.newItemInfo = info;
 }
コード例 #14
0
 private static int GetDescendentCount(TreeListBoxInfo info)
 {
     if ((info.childItems == null) || (info.childItems.Count == 0))
     {
         return 0;
     }
     int num = 0;
     foreach (TreeListBoxInfo info2 in info.childItems)
     {
         num += GetDescendentCount(info2);
         num++;
     }
     return num;
 }
コード例 #15
0
        private void OnChildCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.HasItems = this.DoesDataItemHaveChildren();
            lock (this.treeListBox.CompositeChildCollection)
            {
                if (!this.currentInfo.IsExpanded)
                {
                    this.UnRegisterCollectionNotification();
                }
                else
                {
                    int index = this.treeListBox.CompositeChildCollection.IndexOf(this.currentInfo);
                    if (index < 0)
                    {
                        this.UnRegisterCollectionNotification();
                    }
                    else
                    {
                        switch (e.Action)
                        {
                            case NotifyCollectionChangedAction.Add:
                                if (e.NewItems != null)
                                {
                                    int num2 = 0;
                                    foreach (object obj2 in e.NewItems)
                                    {
                                        int num3 = Math.Min(e.NewStartingIndex + num2, this.currentInfo.ChildItems.Count);
                                        int num4 = 1;
                                        for (int i = num3 - 1; i >= 0; i--)
                                        {
                                            num4 += this.currentInfo.ChildItems[i].DescendentCount + 1;
                                        }
                                        int num6 = num4 + index;
                                        TreeListBoxInfo item = new TreeListBoxInfo(this.level + 1, obj2);
                                        this.currentInfo.ChildItems.Insert(Math.Min(e.NewStartingIndex + num2, this.currentInfo.ChildItems.Count), item);
                                        this.treeListBox.CompositeChildCollection.Insert(num6, item);
                                        num2++;
                                    }
                                }
                                goto Label_01D2;

                            case NotifyCollectionChangedAction.Remove:
                                goto Label_0182;

                            case NotifyCollectionChangedAction.Replace:
                            case NotifyCollectionChangedAction.Move:
                            case NotifyCollectionChangedAction.Reset:
                                this.treeListBox.RecalculateList();
                                goto Label_01D2;
                        }
                    }
                }
                goto Label_01D2;
            Label_0182:
                if (this.currentInfo.ChildItems.Count > e.OldStartingIndex)
                {
                    this.DeleteSingleItem(this.currentInfo.ChildItems[e.OldStartingIndex]);
                }
            Label_01D2:;
            }
        }
コード例 #16
0
 private void GenerateSingleItem(object item)
 {
     int index = this.treeListBox.CompositeChildCollection.IndexOf(this.currentInfo);
     if (index != -1)
     {
         TreeListBoxInfo info = new TreeListBoxInfo(this.level + 1, item);
         this.currentInfo.ChildItems.Add(info);
         this.treeListBox.CompositeChildCollection.Insert(index + this.lastChildItemCreatedIndex, info);
         this.lastChildItemCreatedIndex++;
     }
 }
コード例 #17
0
 private bool DeleteSingleItem(TreeListBoxInfo info)
 {
     int index = this.treeListBox.CompositeChildCollection.IndexOf(info);
     if (index == -1)
     {
         return false;
     }
     for (int i = 0; i < info.DescendentCount; i++)
     {
         this.treeListBox.CompositeChildCollection[index].IsExpanded = false;
         this.treeListBox.CompositeChildCollection.RemoveAt(index);
     }
     this.treeListBox.CompositeChildCollection[index].IsExpanded = false;
     this.treeListBox.CompositeChildCollection.RemoveAt(index);
     this.currentInfo.ChildItems.Remove(info);
     this.lastChildItemCreatedIndex--;
     return true;
 }
コード例 #18
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
 private void AddDescendentsOnCreation(TreeListBoxInfo parent)
 {
     IEnumerable dataChildList = this.GetDataChildList(parent.DataItem);
     if (dataChildList != null)
     {
         foreach (object obj2 in dataChildList)
         {
             this.AddChildHierarchy(parent, obj2);
         }
     }
 }
コード例 #19
0
 public void ExposePrepareItem(TreeListBoxInfo info)
 {
     this.PrepareItem(info);
 }
コード例 #20
0
 public TreeListBoxItemCreatedEventArgs(TreeListBoxItem item, TreeListBoxInfo info)
 {
     this.newItem     = item;
     this.newItemInfo = info;
 }
コード例 #21
0
        private void OnChildCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.HasItems = this.DoesDataItemHaveChildren();
            lock (this.treeListBox.CompositeChildCollection)
            {
                if (!this.currentInfo.IsExpanded)
                {
                    this.UnRegisterCollectionNotification();
                }
                else
                {
                    int index = this.treeListBox.CompositeChildCollection.IndexOf(this.currentInfo);
                    if (index < 0)
                    {
                        this.UnRegisterCollectionNotification();
                    }
                    else
                    {
                        switch (e.Action)
                        {
                        case NotifyCollectionChangedAction.Add:
                            if (e.NewItems != null)
                            {
                                int num2 = 0;
                                foreach (object obj2 in e.NewItems)
                                {
                                    int num3 = Math.Min(e.NewStartingIndex + num2, this.currentInfo.ChildItems.Count);
                                    int num4 = 1;
                                    for (int i = num3 - 1; i >= 0; i--)
                                    {
                                        num4 += this.currentInfo.ChildItems[i].DescendentCount + 1;
                                    }
                                    int             num6 = num4 + index;
                                    TreeListBoxInfo item = new TreeListBoxInfo(this.level + 1, obj2);
                                    this.currentInfo.ChildItems.Insert(Math.Min(e.NewStartingIndex + num2, this.currentInfo.ChildItems.Count), item);
                                    this.treeListBox.CompositeChildCollection.Insert(num6, item);
                                    num2++;
                                }
                            }
                            goto Label_01D2;

                        case NotifyCollectionChangedAction.Remove:
                            goto Label_0182;

                        case NotifyCollectionChangedAction.Replace:
                        case NotifyCollectionChangedAction.Move:
                        case NotifyCollectionChangedAction.Reset:
                            this.treeListBox.RecalculateList();
                            goto Label_01D2;
                        }
                    }
                }
                goto Label_01D2;
Label_0182:
                if (this.currentInfo.ChildItems.Count > e.OldStartingIndex)
                {
                    this.DeleteSingleItem(this.currentInfo.ChildItems[e.OldStartingIndex]);
                }
                Label_01D2 :;
            }
        }
コード例 #22
0
 internal virtual void PrepareItem(TreeListBoxInfo info)
 {
     this.currentInfo = info;
     this.level = info.Level;
     if (info.IsExpanded)
     {
         this.IsExpanded = true;
     }
     this.isInitializing = false;
     this.InitChildListeners();
     this.HasItems = this.DoesDataItemHaveChildren();
     if (info.IsExpanded)
     {
         this.RegisterCollectionNotification();
     }
     if (this.HasItems && !info.CreatedDuringReset)
     {
         this.treeListBox.RecalculateList();
     }
 }
コード例 #23
0
ファイル: TreeListBox.cs プロジェクト: netonjm/WindowsPhone
 private void AddChildHierarchy(TreeListBoxInfo parent, object item)
 {
     TreeListBoxInfo info = new TreeListBoxInfo(parent.Level + 1, item) {
         CreatedDuringReset = true
     };
     parent.ChildItems.Add(info);
     this.CompositeChildCollection.Add(info);
     if (info.IsExpanded)
     {
         this.AddDescendentsOnCreation(info);
     }
 }