Exemple #1
0
        /// <summary>
        /// Will fill the combobox that shows available picklist for selected theme
        /// </summary>
        private void FillPicklistCombobox()
        {
            //Get the current project type
            string fieldworkType = string.Empty;

            if (localSettings.GetSettingValue(Dictionaries.DatabaseLiterals.FieldUserInfoFWorkType) != null)
            {
                fieldworkType = localSettings.GetSettingValue(Dictionaries.DatabaseLiterals.FieldUserInfoFWorkType).ToString();
            }

            //Retrieve list of picklist from user selected theme
            VocabularyManager vocManager      = new VocabularyManager();
            List <object>     vocabManagerRaw = accessData.ReadTable(vocManager.GetType(), null);
            IEnumerable <VocabularyManager> vocManagerTable = vocabManagerRaw.Cast <VocabularyManager>(); //Cast to proper list type
            IEnumerable <VocabularyManager> vocThemeID      = from vm in vocManagerTable where vm.ThemeTable.ToLower().Contains(picklistTheme) && vm.ThemeEditable == Dictionaries.DatabaseLiterals.boolYes && (vm.ThemeProjectType == fieldworkType || vm.ThemeProjectType == "") select vm;

            //Special case for mineral table
            if (picklistTheme == Dictionaries.DatabaseLiterals.KeywordMineral)
            {
                vocThemeID = from vm in vocManagerTable where vm.ThemeTable.ToLower().Contains(picklistTheme) && !vm.ThemeTable.ToLower().Contains(Dictionaries.DatabaseLiterals.KeywordMA) && vm.ThemeEditable == Dictionaries.DatabaseLiterals.boolYes && (vm.ThemeProjectType == fieldworkType || vm.ThemeProjectType == "") select vm;
            }

            //Add theme list to dialog or a default NA value if nothing is available yet
            if (vocThemeID.Count() > 0)
            {
                foreach (VocabularyManager themeID in vocThemeID)
                {
                    Themes.ComboBoxItem picklistTheme = new Themes.ComboBoxItem();
                    picklistTheme.itemName  = themeID.ThemeNameDesc;
                    picklistTheme.itemValue = themeID.ThemeName;
                    _picklists.Add(picklistTheme);
                }
            }
            else
            {
                ResourceLoader appResources = ResourceLoader.GetForCurrentView();
                string         emptyTheme   = appResources.GetString("PicklistDialogEmptyList/Text");

                Themes.ComboBoxItem emptyPicklist = new Themes.ComboBoxItem();
                emptyPicklist.itemName  = emptyTheme;
                emptyPicklist.itemValue = string.Empty;
                _picklists.Add(emptyPicklist);
            }

            RaisePropertyChanged("Picklists");
        }