Exemplo n.º 1
0
        public CategoryFilterControl()
        {
            InitializeComponent();

            VocabDao dao = new VocabDao();

            DataContext = dao;

            var converter          = new VocabCategoriesToStringConverter();
            var allCategories      = dao.GetAllCategories().ToList();
            var filteredCategories = allCategories.Where(cat =>
            {
                // These are various types of archaic verbs.
                // We remove these from the category list for two reasons:
                // 1) The user would see these as individual categories;
                // 2) None of these categories currently have any vocab words.
                switch (cat.ShortName)
                {
                case "v4k":
                case "v4g":
                case "v4s":
                case "v4t":
                case "v4n":
                case "v4b":
                case "v4m":
                case "v2k-k":
                case "v2g-k":
                case "v2t-k":
                case "v2d-k":
                case "v2h-k":
                case "v2b-k":
                case "v2m-k":
                case "v2y-k":
                case "v2r-k":
                case "v2k-s":
                case "v2g-s":
                case "v2s-s":
                case "v2z-s":
                case "v2t-s":
                case "v2d-s":
                case "v2n-s":
                case "v2h-s":
                case "v2b-s":
                case "v2m-s":
                case "v2y-s":
                case "v2r-s":
                case "v2w-s":
                    return(false);
                }

                object convertedValue = converter.Convert(cat, null, null, null);
                return(!string.IsNullOrWhiteSpace(convertedValue as string));
            }).ToList();

            HiddenList.ItemsSource = filteredCategories;
            ComboBox.ItemsSource   = filteredCategories;
        }
Exemplo n.º 2
0
        static CategoryFilterViewModel()
        {
            var      converter     = new VocabCategoriesToStringConverter();
            VocabDao dao           = new VocabDao();
            var      allCategories = dao.GetAllCategories().OrderBy(cat => cat.Label);

            categories = allCategories.Where(
                cat =>
            {
                // These are various types of archaic verbs.
                // We remove these from the category list for two reasons:
                // 1) The user would see these as individual categories;
                // 2) None of these categories currently have any vocab words.
                switch (cat.ShortName)
                {
                case "v4k":
                case "v4g":
                case "v4s":
                case "v4t":
                case "v4n":
                case "v4b":
                case "v4m":
                case "v2k-k":
                case "v2g-k":
                case "v2t-k":
                case "v2d-k":
                case "v2h-k":
                case "v2b-k":
                case "v2m-k":
                case "v2y-k":
                case "v2r-k":
                case "v2k-s":
                case "v2g-s":
                case "v2s-s":
                case "v2z-s":
                case "v2t-s":
                case "v2d-s":
                case "v2n-s":
                case "v2h-s":
                case "v2b-s":
                case "v2m-s":
                case "v2y-s":
                case "v2r-s":
                case "v2w-s":
                    return(false);
                }

                object convertedValue = converter.Convert(cat, null, null, null);
                return(!string.IsNullOrWhiteSpace(convertedValue as string));
            }).ToArray();
        }