Exemplo n.º 1
0
        private void AddNodes(int currGroupIndex, ref int currentListIndex, TreeNodeCollection currNodes, string prevGroupByField)
        {
            IList innerList = this.m_currencyManager.List;
            System.ComponentModel.PropertyDescriptor pdPrevGroupBy = null;
            string prevGroupByValue = null;

            DataTreeNodeGroup currGroup;

            if (prevGroupByField != "")
            {
                pdPrevGroupBy = GetDescriptor(this.m_currencyManager.GetItemProperties(), prevGroupByField);
            }

            currGroupIndex++;

            if (treeGroups.Count > currGroupIndex)
            {
                currGroup = (DataTreeNodeGroup) (treeGroups[currGroupIndex]);
                PropertyDescriptor pdGroupBy = null;
                PropertyDescriptor pdValue = null;
                PropertyDescriptor pdDisplay = null;
                PropertyDescriptorCollection pdc = this.m_currencyManager.GetItemProperties();

                pdGroupBy = GetDescriptor(pdc, currGroup.GroupBy);
                pdValue = GetDescriptor(pdc, currGroup.ValueMember);
                pdDisplay = GetDescriptor(pdc, currGroup.DisplayMember);

                string currGroupBy = null;

                if (innerList.Count > currentListIndex)
                {
                    if (pdPrevGroupBy != null)
                    {
                        prevGroupByValue = pdPrevGroupBy.GetValue(innerList[currentListIndex]).ToString();
                    }

                    DataTreeNode myFirstNode = null;
                    object currObject = null;

                    while ((currentListIndex < innerList.Count) && (pdPrevGroupBy != null) && (pdPrevGroupBy.GetValue(innerList[currentListIndex]).ToString() == prevGroupByValue))
                    {
                        currObject = innerList[currentListIndex];
                        if (pdGroupBy.GetValue(currObject).ToString() != currGroupBy)
                        {
                            currGroupBy = pdGroupBy.GetValue(currObject).ToString();

                            myFirstNode = new DataTreeNode(currGroup.Name, pdDisplay.GetValue(currObject).ToString(), currObject, pdValue.GetValue(innerList[currentListIndex]), currGroup.ImageIndex, currGroup.SelectedImageIndex, currentListIndex);

                            currNodes.Add((TreeNode) myFirstNode);
                        }
                        else
                        {
                            AddNodes(currGroupIndex, ref currentListIndex, myFirstNode.Nodes, currGroup.GroupBy);
                        }
                    }
                }
            }
            else
            {
                DataTreeNode myNewLeafNode;
                object currObject = this.m_currencyManager.List[currentListIndex];

                if ((this.DisplayMember != null) && (this.ValueMember != null) && (this.DisplayMember != "") && (this.ValueMember != ""))
                {
                    PropertyDescriptorCollection pdDisplayColl = this.m_currencyManager.GetItemProperties();
                    PropertyDescriptor pdDisplayloc = GetDescriptor(pdDisplayColl, this.DisplayMember);
                    PropertyDescriptor pdValueloc = GetDescriptor(pdDisplayColl, this.ValueMember);

                    if (this.Tag == null)
                    {
                        myNewLeafNode = new DataTreeNode("", pdDisplayloc.GetValue(currObject).ToString(), currObject, pdValueloc.GetValue(currObject), currentListIndex);
                    }
                    else
                    {
                        myNewLeafNode = new DataTreeNode(this.Tag.ToString(), pdDisplayloc.GetValue(currObject).ToString(), currObject, pdValueloc.GetValue(currObject), currentListIndex);
                    }
                }
                else
                {
                    myNewLeafNode = new DataTreeNode("", currentListIndex.ToString(), currObject, currObject, this.ImageIndex, this.SelectedImageIndex, currentListIndex);
                }

                currNodes.Add((TreeNode) myNewLeafNode);
                currentListIndex++;
            }
        }
Exemplo n.º 2
0
 protected virtual bool SyncNameList(DataTreeNode InnerNode)
 {
     foreach (DataTreeNode node in InnerNode.Nodes)
         {
             if (node.Index == DetailBinding.Position)
             {
                 tvwName.SelectedNode = node;
                 return true;
             }
             else
             {
                 SyncNameList(node);
             }
         }
         return false;
 }
Exemplo n.º 3
0
        public void BuildTree()
        {
            this.Nodes.Clear();
            if ((this.m_currencyManager != null) && (this.m_currencyManager.List != null))
            {
                IList innerList = this.m_currencyManager.List;
                TreeNodeCollection currNode = this.Nodes;
                int currGroupIndex = 0;
                int currListIndex = 0;

                if (this.treeGroups.Count > currGroupIndex)
                {
                    DataTreeNodeGroup currGroup = (DataTreeNodeGroup) (treeGroups[currGroupIndex]);
                    DataTreeNode myFirstNode = null;
                    PropertyDescriptor pdGroupBy;
                    PropertyDescriptor pdValue;
                    PropertyDescriptor pdDisplay;

                    PropertyDescriptorCollection pdc = this.m_currencyManager.GetItemProperties();
                    pdGroupBy = GetDescriptor(pdc, currGroup.GroupBy);
                    pdValue = GetDescriptor(pdc, currGroup.ValueMember);
                    pdDisplay = GetDescriptor(pdc, currGroup.DisplayMember);

                    string currGroupBy = null;
                    if (innerList.Count > currListIndex)
                    {
                        object currObject;
                        while (currListIndex < innerList.Count)
                        {
                            currObject = innerList[currListIndex];
                            if (pdGroupBy.GetValue(currObject).ToString() != currGroupBy)
                            {
                                currGroupBy = pdGroupBy.GetValue(currObject).ToString();

                                myFirstNode = new DataTreeNode(currGroup.Name, pdDisplay.GetValue(currObject).ToString(), currObject, pdValue.GetValue(innerList[currListIndex]), currGroup.ImageIndex, currGroup.SelectedImageIndex, currListIndex);

                                currNode.Add((TreeNode) myFirstNode);
                            }
                            else
                            {
                                AddNodes(currGroupIndex, ref currListIndex, myFirstNode.Nodes, currGroup.GroupBy);
                            }
                        } // end while
                    } // end if
                }
                else
                {
                    while (currListIndex < innerList.Count)
                    {
                        AddNodes(currGroupIndex, ref currListIndex, this.Nodes, "");
                    }
                } // end else

                if (this.Nodes.Count > 0)
                {
                    this.SelectedNode = this.Nodes[0];
                }

            } // end if
        }