예제 #1
0
        public void Build(StuctureItemCollection list)
        {
            this.ImageList = Program.Window.SPMimageList;
            // Dispose all objects
            ClearNodes(this.Nodes);

            //var rules = CompositionProvider.GetOrderedExports<IRule<ISPNode>>();
            var rules = IoCContainer.Resolve <IEnumerable <IRule <ISPNode> > >().Ordered();

            SPProvider           = new SPNodeProvider(SPFarm.Local, rules, IoCContainer);
            SPProvider.ViewLevel = ViewLevel;
            SPProvider.GetLocalizedTextFunction = p => SPMLocalization.GetString(p);
            Trace.WriteLine("ViewLevel: " + SPProvider.ViewLevel);
            var treeViewProvider = new TreeViewNodeProvider(SPProvider, IoCContainer);

            FarmNode = treeViewProvider.LoadFarmNode();

            this.Nodes.Add(FarmNode);

            if (list != null)
            {
                FarmNode.Reload(FarmNode, list);
            }
            else
            {
                ExpandToDefault(FarmNode, DefaultExpandTypes);
            }
        }
예제 #2
0
        public void Initialize(SPTreeNode treeNode)
        {
            TreeNode = treeNode;

            this.Items.AddRange(EnsureTreeNode(IoCContainer.Resolve <IEnumerable <ISPMenuItem> >(TreeNode.Model.GetType().AssemblyQualifiedName), TreeNode));
            if (this.Items.Count > 0)
            {
                this.Items.Add(new ToolStripSeparator());
            }
            this.Items.AddRange(EnsureTreeNode(IoCContainer.Resolve <IEnumerable <ISPMenuItem> >(this.GetType().AssemblyQualifiedName), TreeNode));
        }
예제 #3
0
        private ToolStripItem[] EnsureTreeNode(IEnumerable <ISPMenuItem> collection, SPTreeNode treeNode)
        {
            var list = new List <ToolStripItem>();

            foreach (var menuItem in collection)
            {
                if (menuItem != null)
                {
                    menuItem.TreeNode = treeNode;
                }
                list.Add((ToolStripItem)menuItem);
            }
            return(list.ToArray());
        }
예제 #4
0
        private void ExpandToDefault(SPTreeNode parent, List <string> types)
        {
            if (types == null || types.Count <= 0)
            {
                this.SelectedNode = parent;
                return;
            }
            ExpandNode(parent);
            var item = types[0];

            types.RemoveAt(0);

            foreach (SPTreeNode node in parent.Nodes)
            {
                if (item.Equals(node.Model.GetType().Name))
                {
                    ExpandToDefault(node, types);
                    break;
                }
            }
        }
예제 #5
0
파일: MainForm.cs 프로젝트: jpfocus/SPM
        private void ExplorerClick(SPTreeNode treeNode)
        {
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                this.toolStripStatusLabel.Text = treeNode.ToolTipText;
                UpdateMenu(treeNode);

                ArrayList nodeColl = new ArrayList(treeNode.GetTabPages());

                int i = 0;
                while (i < tabControl.TabPages.Count)
                {
                    TabPage page = tabControl.TabPages[i];
                    if (nodeColl.Contains(page))
                    {
                        i++;
                    }
                    else
                    {
                        tabControl.TabPages.Remove(page);
                    }
                }

                foreach (TabPage page in nodeColl)
                {
                    if (!tabControl.Contains(page))
                    {
                        tabControl.TabPages.Add(page);
                    }
                }
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #6
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;

                SPTreeNodeGroup currGroup;

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

                currGroupIndex++;

                if (treeGroups.Count > currGroupIndex)
                {
                    currGroup = (SPTreeNodeGroup) (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();
                        }

                        SPTreeNode 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 SPTreeNode(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
                {
                    SPTreeNode 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 = pdDisplayColl[this.DisplayMember.ToLowerInvariant()];
                        PropertyDescriptor pdValueloc = pdDisplayColl[this.ValueMember.ToLowerInvariant()];

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

                    currNodes.Add((TreeNode) myNewLeafNode);
                    currentListIndex++;
                }
            }
예제 #7
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)
                    {
                        SPTreeNodeGroup currGroup = (SPTreeNodeGroup) (treeGroups[currGroupIndex]);
                        SPTreeNode 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 SPTreeNode(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
            }
예제 #8
0
 protected virtual bool SyncNameList(SPTreeNode InnerNode)
 {
     foreach (SPTreeNode node in InnerNode.Nodes)
     {
         if (node.Index == DetailBinding.Position)
         {
             tvwName.SelectedNode = node;
             return true;
         }
         else
         {
             SyncNameList(node);
         }
     }
     return false;
 }