protected void FillDataSources(ITypeDescriptorContext context, object dataSource)
        {
            Nodes.Clear();
            BindingContext bindingManager = new BindingContext();

            if (multipleDataSources)
            {
                ComponentCollection components = context.Container.Components;
                foreach (IComponent comp in components)
                {
                    FillDataSource(bindingManager, comp);
                }
            }
            else
            {
                FillDataSource(bindingManager, dataSource);
            }

            TreeNode noneNode = new NoneNode();

            /* bug 74291: we should let the user have a noneNode
             * // bug 49873: if we do not select lists and we have nodes, then do not allow the
             * // user to select the None node, cause this would not be allowed in the backEnd
             * //
             * if (Nodes.Count == 0 && !this.selectLists)
             *  Nodes.Add(noneNode);
             */
            Nodes.Add(noneNode);
            if (selectedNode == null)
            {
                selectedNode = noneNode;
            }

            this.SelectedNode = selectedNode;
            selectedNode      = null;
            selectedItem      = null;
            allowSelection    = true;
        }
 private void FillTree(DesignBinding initialSelectedItem)
 {
     this.selectedItem = initialSelectedItem;
     this.EmptyTree();
     this.noneNode = new NoneNode();
     this.otherNode = new OtherNode();
     this.projectNode = new ProjectNode(this);
     if (((this.hostSvc != null) && (this.hostSvc.RootComponent != null)) && (this.hostSvc.RootComponent.Site != null))
     {
         this.instancesNode = new InstancesNode(this.hostSvc.RootComponent.Site.Name);
     }
     else
     {
         this.instancesNode = new InstancesNode(string.Empty);
     }
     this.treeViewCtrl.Nodes.Add(this.noneNode);
     if (this.showDataSources)
     {
         this.AddFormDataSources();
         this.AddProjectDataSources();
         if (this.projectNode.Nodes.Count > 0)
         {
             this.otherNode.Nodes.Add(this.projectNode);
         }
         if (this.instancesNode.Nodes.Count > 0)
         {
             this.otherNode.Nodes.Add(this.instancesNode);
         }
         if (this.otherNode.Nodes.Count > 0)
         {
             this.treeViewCtrl.Nodes.Add(this.otherNode);
         }
     }
     else
     {
         this.AddDataSourceContents(this.treeViewCtrl.Nodes, this.rootDataSource, this.rootDataMember, null);
     }
     if (this.selectedNode == null)
     {
         this.selectedNode = this.noneNode;
     }
     this.selectedItem = null;
     base.Width = Math.Max(base.Width, this.treeViewCtrl.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2));
 }
 private void EmptyTree()
 {
     this.noneNode = null;
     this.otherNode = null;
     this.projectNode = null;
     this.instancesNode = null;
     this.selectedNode = null;
     this.treeViewCtrl.Nodes.Clear();
 }
Ejemplo n.º 4
0
        public void CreateResourceLibraryData()
        {
            try
            {
                TopNodes = new ObservableCollection <ResourceNode>();
                ResourceModelDictionary = new Dictionary <int, ResourceNode>();

                Dictionary <int, ResourceNode> ResourceNodeDict = new Dictionary <int, ResourceNode>();

                var query = dbContext.REF_LIBRARY_PATH
                            .Include(x => x.GEN_FILE_LIB_PATH_CORL)
                            .ThenInclude(x => x.Gen_File_);

                foreach (var obj in query.ToList())
                {
                    ResourceNode node = new NoneNode();
                    node.ID = Convert.ToInt32(obj.Lib_Path_Id);
                    if (obj.Parent_Path_Id.HasValue)
                    {
                        node.ParentID = Convert.ToInt32(obj.Parent_Path_Id);
                    }
                    else
                    {
                        node.ParentID = -1;
                    }

                    node.TreeTextNode = obj.Path_Name;
                    node.Type         = ResourceNodeType.None;
                    node.Nodes        = new ObservableCollection <ResourceNode>();
                    List <ResourceNode> listItems = new List <ResourceNode>();
                    foreach (GEN_FILE_LIB_PATH_CORL corl in obj.GEN_FILE_LIB_PATH_CORL)
                    {
                        GEN_FILE doc = corl.Gen_File_;

                        if (ResourceModelDictionary.ContainsKey(doc.Gen_File_Id))  //Check if node is already created
                        {
                            ResourceNode getNode = ResourceModelDictionary[doc.Gen_File_Id];
                            listItems.Add(getNode);
                        }
                        else if (doc.File_Type_Id == 31)//pdf
                        {
                            ResourceNode pdfNode = new PDFNode(pdfDirectory, doc);
                            ResourceModelDictionary.Add(pdfNode.ID, pdfNode);
                            listItems.Add(pdfNode);
                        }
                        else if (doc.File_Type_Id == 41)//docx
                        {
                            ResourceNode docxNode = new XPSNode(xpsDirectory, doc);
                            ResourceModelDictionary.Add(docxNode.ID, docxNode);
                            listItems.Add(docxNode);
                        }
                        else
                        {
                            Debug.Assert(false, "Invalid document type: " + doc.File_Type_.File_Type1);
                        }
                    }
                    foreach (ResourceNode rn in listItems.OrderBy(x => x.TreeTextNode))
                    {
                        node.Nodes.Add(rn);
                    }
                    ResourceNodeDict.Add(node.ID, node);
                }

                foreach (ResourceNode libDoc in ResourceNodeDict.Values)
                {
                    if (libDoc.ParentID == -1)
                    {
                        TopNodes.Add(libDoc);
                    }
                    else
                    {
                        ResourceNode lib = ResourceNodeDict[libDoc.ParentID];
                        lib.Nodes.Add(libDoc);
                    }
                }


                ResourceNode procTopicModel = new NoneNode("Cyber Security Procurement Language");
                TopNodes.Add(procTopicModel);

                Dictionary <int, List <PROCUREMENTLANGUAGEDATA> > dictionaryProcurementLanguageData = new Dictionary <int, List <PROCUREMENTLANGUAGEDATA> >();

                foreach (PROCUREMENT_LANGUAGE_DATA data in dbContext.PROCUREMENT_LANGUAGE_DATA.ToList())
                {
                    List <PROCUREMENTLANGUAGEDATA> list;
                    if (!dictionaryProcurementLanguageData.TryGetValue(data.Parent_Heading_Id.Value, out list))
                    {
                        list = new List <PROCUREMENTLANGUAGEDATA>();
                        dictionaryProcurementLanguageData[data.Parent_Heading_Id.Value] = list;
                    }

                    list.Add(TinyMapper.Map <PROCUREMENTLANGUAGEDATA>(data));
                }

                foreach (PROCUREMENT_LANGUAGE_HEADINGS procHeading in dbContext.PROCUREMENT_LANGUAGE_HEADINGS.OrderBy(h => h.Heading_Num).ToList())
                {
                    ResourceNode procHeadingModel = new NoneNode(procHeading.Heading_Name);
                    procTopicModel.Nodes.Add(procHeadingModel);
                    List <PROCUREMENTLANGUAGEDATA> listItems = dictionaryProcurementLanguageData[procHeading.Id];
                    foreach (PROCUREMENTLANGUAGEDATA data in listItems.OrderBy(d => d.Section_Number))
                    {
                        ResourceNode procModel = new ProcurementLanguageTopicNode(data);
                        procHeadingModel.Nodes.Add(procModel);
                    }
                }


                ResourceNode recCatTopicModel = new NoneNode("Catalog of Recommendations");
                TopNodes.Add(recCatTopicModel);

                Dictionary <int, List <CATALOGRECOMMENDATIONSDATA> > dictionaryCatalogRecommendations = new Dictionary <int, List <CATALOGRECOMMENDATIONSDATA> >();

                foreach (CATALOG_RECOMMENDATIONS_DATA data in dbContext.CATALOG_RECOMMENDATIONS_DATA.ToList())
                {
                    List <CATALOGRECOMMENDATIONSDATA> list;
                    if (!dictionaryCatalogRecommendations.TryGetValue(data.Parent_Heading_Id.Value, out list))
                    {
                        list = new List <CATALOGRECOMMENDATIONSDATA>();
                        dictionaryCatalogRecommendations[data.Parent_Heading_Id.Value] = list;
                    }

                    list.Add(TinyMapper.Map <CATALOGRECOMMENDATIONSDATA>(data));
                }

                foreach (CATALOG_RECOMMENDATIONS_HEADINGS procHeading in dbContext.CATALOG_RECOMMENDATIONS_HEADINGS.OrderBy(h => h.Heading_Num).ToList())
                {
                    ResourceNode procHeadingModel = new NoneNode(procHeading.Heading_Name);
                    recCatTopicModel.Nodes.Add(procHeadingModel);

                    List <CATALOGRECOMMENDATIONSDATA> listItems = dictionaryCatalogRecommendations[procHeading.Id];
                    foreach (CATALOGRECOMMENDATIONSDATA data in listItems.OrderBy(d => d.Section_Short_Number))
                    {
                        ResourceNode procModel = new CatalogRecommendationsTopicNode(data);
                        procHeadingModel.Nodes.Add(procModel);
                    }
                }
            }
            catch (Exception ex)
            {
                //CSET_Main.Common.CSETLogger.Fatal("An exception occurred in loading resource library.", ex);
            }
        }