private static Achievement createAchievement2() { Achievement a = new Achievement(); a.name = "Beatles and Rolling Stones"; a.description = "Sing at least one beatles and at least one rolling stones song."; a.ID = 0; a.image = AchievementImage.Image1; a.statementsAnd = true; a.selectList = new AchievementSelect[2]; AchievementSelect select = new AchievementSelect(); select.startDate = DateTime.MinValue; select.endDate = DateTime.MaxValue; select.selectKeyword = SelectKeyword.CountGTE; select.selectValue = "1"; select.clauseKeyword = ClauseKeyword.Artist; select.clauseValue = "Rolling Stones"; a.selectList[0] = select; AchievementSelect select2 = new AchievementSelect(); select2.startDate = DateTime.MinValue; select2.endDate = DateTime.MaxValue; select2.selectKeyword = SelectKeyword.CountGTE; select2.selectValue = "1"; select2.clauseKeyword = ClauseKeyword.Artist; select2.clauseValue = "Beatles"; a.selectList[1] = select2; a.isPermanant = false; a.visible = true; return a; }
//Constructor for displaying a previous AcheivementSelect object public ConditionControl(AchievementSelect select) { InitializeComponent(); selectKeywordList = new ObservableCollection<SelectKeywordItem>(); clauseKeywordList = new ObservableCollection<ClauseKeywordItem>(); FillTypeCombobox(); FillQuanitifierCombobox(); FillInAchievementSelect(select); _select = select; }
private static Achievement createAchievement1() { Achievement a = new Achievement(); a.name = "Kansas"; a.description = "Carry on."; a.ID = 0; a.image = AchievementImage.Image0; a.statementsAnd = true; a.selectList = new AchievementSelect[1]; AchievementSelect select = new AchievementSelect(); select.startDate = DateTime.MinValue; select.endDate = DateTime.MaxValue; select.selectKeyword = SelectKeyword.Max; select.selectValue = "1"; select.clauseKeyword = ClauseKeyword.Title; select.clauseValue = "Carry on Wayward Son"; a.isPermanant = false; a.selectList[0] = select; a.visible = true; return a; }
private static Achievement createAchievement3() { Achievement a = new Achievement(); a.name = "Most Recent"; a.description = "Sing the most recent song."; a.ID = 0; a.image = AchievementImage.Image2; a.statementsAnd = true; a.selectList = new AchievementSelect[1]; AchievementSelect select = new AchievementSelect(); select.startDate = DateTime.MinValue; select.endDate = DateTime.MaxValue; select.selectKeyword = SelectKeyword.Newest; select.selectValue = "1"; select.clauseKeyword = ClauseKeyword.Title; select.clauseValue = "%"; a.selectList[0] = select; a.isPermanant = false; a.visible = true; return a; }
//Fill in the appropriate AchievementSelect data to the controls private void FillInAchievementSelect(AchievementSelect select) { ComboBoxQuantifier.SelectedIndex = GetQuantifierIndex(select.selectKeyword); NumberPickerQuanitifier.Value = int.Parse(select.selectValue); ComboBoxType.SelectedIndex = GetClauseIndex(select.clauseKeyword); if (select.clauseKeyword == ClauseKeyword.SongID) { int songID = -1; try { songID = int.Parse(select.clauseValue); Song song = DJModel.Instance.SongDictionary[songID]; List<SongSearchResult> itemList = new List<SongSearchResult>(); SongSearchResult result = new SongSearchResult(song, song.artist, song.title); itemList.Add(result); TextBoxTypeValue.ItemsSource = itemList; TextBoxTypeValue.SelectedItem = result; } catch { TextBoxTypeValue.Text = select.clauseValue; } } else TextBoxTypeValue.Text = select.clauseValue; if (select.startDate.Equals(new DateTime(1980, 1, 1))) { CheckBoxDateStart.IsChecked = false; DatePickerStart.DisplayDate = DateTime.Today; DatePickerStart.SelectedDate = null; } else { CheckBoxDateStart.IsChecked = true; DatePickerStart.SelectedDate = select.startDate; } if (select.endDate.Equals(DateTime.MaxValue)) { CheckBoxDateEnd.IsChecked = false; DatePickerEnd.DisplayDate = DateTime.Today; DatePickerEnd.SelectedDate = null; } else { CheckBoxDateEnd.IsChecked = true; DatePickerEnd.SelectedDate = select.endDate; } }
//Get the AchievementSelect object from the control based off the values entered by the user public AchievementSelect GetAchievementSelect() { AchievementSelect select = new AchievementSelect(); select.clauseKeyword = ((ClauseKeywordItem)ComboBoxType.SelectedItem).ClauseKeyword; if (select.clauseKeyword == ClauseKeyword.SongID) { if (TextBoxTypeValue.SelectedItem != null) select.clauseValue = ((SongSearchResult)TextBoxTypeValue.SelectedItem).Song.ID.ToString(); else select.clauseValue = "%"; } else select.clauseValue = TextBoxTypeValue.Text.Trim(); select.selectKeyword = ((SelectKeywordItem)ComboBoxQuantifier.SelectedItem).SelectKeyword; select.selectValue = NumberPickerQuanitifier.Value.ToString(); if ((bool)CheckBoxDateStart.IsChecked) select.startDate = (DateTime)DatePickerStart.SelectedDate; else select.startDate = new DateTime(1980, 1, 1); if ((bool)CheckBoxDateEnd.IsChecked) select.endDate = (DateTime)DatePickerEnd.SelectedDate; else select.endDate = DateTime.MaxValue; return select; }