private void LoadTreeViewContent( TreeView treeview )
        {
            //Load Skills and SkillSpecialitations
            var skillContext = new Db1Entities();
            _foundSkills = ( from c in skillContext.Skills.Include("SkillSpecialization") select c ).ToList();
            var skillMain = new TreeViewItem
            {
                Header = "Skills"
            };
            foreach (var skillitem in _foundSkills)
            {
                var tvi = new SkillTreeViewItem();
                if (skillitem.SkillSpecialization.Count > 0)
                {
                    foreach (var skillspec in skillitem.SkillSpecialization)
                    {
                        var tvi2 = new SkillTreeViewItem
                        {
                            Header = skillspec.Name,
                            StoredObject = skillspec,
                            Foreground = Brushes.White
                        };
                        if (skillspec.RequirementSet == true)
                        {
                            tvi2.Foreground = Brushes.Green;
                        }
                        tvi.Items.Add(tvi2);
                    }
                }
                tvi.Header = skillitem.SkillName;
                tvi.StoredObject = skillitem;
                tvi.Foreground = Brushes.White;
                if (skillitem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                skillMain.Items.Add(tvi);
            }
            treeview.Items.Add(skillMain);

            //Load Attributes
            var attributeMain = new TreeViewItem
            {
                Header = "Attributes"
            };

            var attributeContext = new Db1Entities();
            _foundAttributes = ( from c in attributeContext.Attribute select c ).ToList();
            foreach (var attItem in _foundAttributes)
            {
                var tvi = new SkillTreeViewItem
                {
                    Header = attItem.Name,
                    StoredObject = attItem,
                    Foreground = Brushes.White
                };
                if (attItem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                attributeMain.Items.Add(tvi);
            }
            treeview.Items.Add(attributeMain);

            //Load Advantages
            var advantagesMain = new TreeViewItem
            {
                Header = "Advantages"
            };

            var advantageContext = new Db1Entities();
            _foundAdvantages = ( from c in advantageContext.Advantages select c ).ToList();
            foreach (var advItem in _foundAdvantages)
            {
                var tvi = new SkillTreeViewItem
                {
                    Header = advItem.Name,
                    StoredObject = advItem,
                    Foreground = Brushes.White
                };
                if (advItem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                advantagesMain.Items.Add(tvi);
            }
            treeview.Items.Add(advantagesMain);
        }
Beispiel #2
0
        private void LoadTreeViewContent(TreeView treeview)
        {
            //Load Skills and SkillSpecialitations
            var skillContext = new Db1Entities();

            _foundSkills = (from c in skillContext.Skills.Include("SkillSpecialization") select c).ToList();
            var skillMain = new TreeViewItem
            {
                Header = "Skills"
            };

            foreach (var skillitem in _foundSkills)
            {
                var tvi = new SkillTreeViewItem();
                if (skillitem.SkillSpecialization.Count > 0)
                {
                    foreach (var skillspec in skillitem.SkillSpecialization)
                    {
                        var tvi2 = new SkillTreeViewItem
                        {
                            Header       = skillspec.Name,
                            StoredObject = skillspec,
                            Foreground   = Brushes.White
                        };
                        if (skillspec.RequirementSet == true)
                        {
                            tvi2.Foreground = Brushes.Green;
                        }
                        tvi.Items.Add(tvi2);
                    }
                }
                tvi.Header       = skillitem.SkillName;
                tvi.StoredObject = skillitem;
                tvi.Foreground   = Brushes.White;
                if (skillitem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                skillMain.Items.Add(tvi);
            }
            treeview.Items.Add(skillMain);

            //Load Attributes
            var attributeMain = new TreeViewItem
            {
                Header = "Attributes"
            };

            var attributeContext = new Db1Entities();

            _foundAttributes = (from c in attributeContext.Attribute select c).ToList();
            foreach (var attItem in _foundAttributes)
            {
                var tvi = new SkillTreeViewItem
                {
                    Header       = attItem.Name,
                    StoredObject = attItem,
                    Foreground   = Brushes.White
                };
                if (attItem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                attributeMain.Items.Add(tvi);
            }
            treeview.Items.Add(attributeMain);

            //Load Advantages
            var advantagesMain = new TreeViewItem
            {
                Header = "Advantages"
            };

            var advantageContext = new Db1Entities();

            _foundAdvantages = (from c in advantageContext.Advantages select c).ToList();
            foreach (var advItem in _foundAdvantages)
            {
                var tvi = new SkillTreeViewItem
                {
                    Header       = advItem.Name,
                    StoredObject = advItem,
                    Foreground   = Brushes.White
                };
                if (advItem.RequirementSet == true)
                {
                    tvi.Foreground = Brushes.Green;
                }
                advantagesMain.Items.Add(tvi);
            }
            treeview.Items.Add(advantagesMain);
        }