Ejemplo n.º 1
0
        protected override void OnAfterSelect(TreeViewEventArgs e)
        {
            dbTreeNode leafNode = (dbTreeNode)e.Node;

            if (leafNode != null)
            {
                if (this.m_currencyManager.Position != leafNode.Position)
                {
                    this.m_currencyManager.Position = leafNode.Position;
                }
            }
            // TODO:  Add MyTreeViewCtrl.OnAfterSelect implementation
            base.OnAfterSelect(e);
        }
Ejemplo n.º 2
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;;
            Group  currGroup;

            if (prevGroupByField != "")
            {
                pdPrevGroupBy = this.m_currencyManager.GetItemProperties()[prevGroupByField];
            }

            currGroupIndex += 1;

            if (treeGroups.Count > currGroupIndex)
            {
                currGroup = ( Group)treeGroups[currGroupIndex];
                PropertyDescriptor pdGroupBy = null;
                PropertyDescriptor pdValue   = null;
                PropertyDescriptor pdDisplay = null;

                pdGroupBy = this.m_currencyManager.GetItemProperties()[currGroup.GroupBy];
                pdValue   = this.m_currencyManager.GetItemProperties()[currGroup.ValueMember];
                pdDisplay = this.m_currencyManager.GetItemProperties()[currGroup.DisplayMember];

                string currGroupBy = null;

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

                    dbTreeNode 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 dbTreeNode(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
            {
                dbTreeNode myNewLeafNode;
                object     currObject = this.m_currencyManager.List[currentListIndex];

                if ((this.DisplayMember != null) && (this.ValueMember != null) &&
                    (this.DisplayMember != "") && (this.ValueMember != ""))
                {
                    PropertyDescriptor pdDisplayloc =
                        this.m_currencyManager.GetItemProperties()[this.DisplayMember];
                    PropertyDescriptor pdValueloc =
                        this.m_currencyManager.GetItemProperties()[this.ValueMember];

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

                currNodes.Add((TreeNode)myNewLeafNode);
                currentListIndex += 1;
            }
        }
Ejemplo 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)
                {
                    Group              currGroup   = (Group)treeGroups[currGroupIndex];
                    dbTreeNode         myFirstNode = null;
                    PropertyDescriptor pdGroupBy;
                    PropertyDescriptor pdValue;
                    PropertyDescriptor pdDisplay;

                    pdGroupBy = this.m_currencyManager.GetItemProperties()[currGroup.GroupBy];
                    pdValue   = this.m_currencyManager.GetItemProperties()[currGroup.ValueMember];
                    pdDisplay = this.m_currencyManager.GetItemProperties()[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 dbTreeNode(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
                }                 // 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
        }