示例#1
0
        /// <summary>
        /// Creates
        /// Creates a list of items from the EXD files
        /// </summary>
        public void FillTree()
        {
            var exdDict = ExdReader.GetEXDData();

            if (exdDict == null)
            {
                Properties.Settings.Default.FFXIV_Directory = "";
                Properties.Settings.Default.Language        = "en";
                Properties.Settings.Default.Save();
                System.Windows.Application.Current.Shutdown();
            }
            else
            {
                foreach (var cat in Info.MainCategoryList)
                {
                    TreeNode cm = new TreeNode
                    {
                        Name     = cat,
                        _subNode = exdDict[cat]
                    };
                    if (Category == null)
                    {
                        Category = new ObservableCollection <CategoryViewModel>();
                    }

                    var cvm = new CategoryViewModel(cm);
                    Category.Add(cvm);
                }

                oCategory = Category;
            }
        }
示例#2
0
        /// <summary>
        /// Creates
        /// Creates a list of items from the EXD files
        /// </summary>
        public void FillTree()
        {
            var exdDict = ExdReader.GetEXDData();

            foreach (var cat in Info.MainCategoryList)
            {
                TreeNode cm = new TreeNode
                {
                    Name     = cat,
                    _subNode = exdDict[cat]
                };
                if (Category == null)
                {
                    Category = new ObservableCollection <CategoryViewModel>();
                }

                var cvm = new CategoryViewModel(cm);
                Category.Add(cvm);
            }

            oCategory = Category;
        }
示例#3
0
        /// <summary>
        /// Filters the item list when input is detected in the search textbox
        /// </summary>
        private void SearchTextChanged()
        {
            if (SearchText.Length > 2)
            {
                Dictionary <string, TreeNode> catDict = new Dictionary <string, TreeNode>();

                foreach (var c in oCategory)
                {
                    catDict.Add(c.Name, new TreeNode()
                    {
                        Name = c.Name
                    });
                    Dictionary <string, TreeNode> subCatDict = new Dictionary <string, TreeNode>();

                    foreach (var ch in c.Children)
                    {
                        foreach (var ch1 in ch.Children)
                        {
                            if (ch1.Children.Count > 0)
                            {
                                Dictionary <string, TreeNode> subSubCatDict = new Dictionary <string, TreeNode>();

                                foreach (var ch2 in ch1.Children)
                                {
                                    if (ch2.Name.ToLower().Contains(searchText.ToLower()))
                                    {
                                        var itemNode = new TreeNode()
                                        {
                                            Name = ch2.Name, ItemData = ch2.ItemData
                                        };

                                        if (subSubCatDict.ContainsKey(ch1.Name))
                                        {
                                            subSubCatDict[ch1.Name]._subNode.Add(itemNode);
                                        }
                                        else
                                        {
                                            subSubCatDict.Add(ch1.Name, new TreeNode {
                                                Name = ch1.Name
                                            });
                                            subSubCatDict[ch1.Name]._subNode.Add(itemNode);
                                        }
                                    }
                                }

                                if (subSubCatDict.Values.Count > 0)
                                {
                                    if (!subCatDict.ContainsKey(ch.Name))
                                    {
                                        subCatDict.Add(ch.Name, new TreeNode()
                                        {
                                            Name = ch.Name
                                        });
                                    }

                                    foreach (var s in subSubCatDict.Values)
                                    {
                                        subCatDict[ch.Name]._subNode.Add(s);
                                    }
                                }
                            }
                            else
                            {
                                if (ch1.Name.ToLower().Contains(searchText.ToLower()))
                                {
                                    var itemNode = new TreeNode()
                                    {
                                        Name = ch1.Name, ItemData = ch1.ItemData
                                    };
                                    if (subCatDict.ContainsKey(ch.Name))
                                    {
                                        subCatDict[ch.Name]._subNode.Add(itemNode);
                                    }
                                    else
                                    {
                                        subCatDict.Add(ch.Name, new TreeNode()
                                        {
                                            Name = ch.Name
                                        });
                                        subCatDict[ch.Name]._subNode.Add(itemNode);
                                    }
                                }
                            }
                        }
                    }

                    if (subCatDict.Values.Count > 0)
                    {
                        foreach (var s in subCatDict.Values)
                        {
                            catDict[c.Name]._subNode.Add(s);
                        }
                    }
                }

                Category = new ObservableCollection <CategoryViewModel>();

                foreach (var c in catDict.Values)
                {
                    if (c.SubNode.Count > 0)
                    {
                        var cvm = new CategoryViewModel(c);
                        Category.Add(cvm);
                        cvm.ExpandAll();
                    }
                }
            }
            else
            {
                Category = oCategory;
            }
        }