private void OnRandomMysteryDataCollectionChanged(object sender, EventArgs args) { if (!this.RandomMysteryData.Contains(this.SelectedMystery)) { this.SelectedMystery = this.lastSelectedIndex < this.RandomMysteryData.Count && this.lastSelectedIndex >= 0 ? this.RandomMysteryData[this.lastSelectedIndex] : this.RandomMysteryData.LastOrDefault(); } this.OnPropertyChanged(nameof(this.RandomMysteryData)); }
protected override void SetStringValue(string value) { base.SetStringValue(value); var newType = default(int); var mystery = default(RandomMystery); var newFlag = default(int); using (var reader = new StringReader(value)) { string line; var lineNo = 0; while ((line = reader.ReadLine()) != null) { lineNo++; if (lineNo == 3) { if (!this.Validate(line, "Missing mystery definition line 3.", l => l.StartsWith("Mystery:", StringComparison.InvariantCulture))) { break; } var mysterySections = line.Split(':'); if (!this.Validate(mysterySections, "Malformed mystery definition.", s => s.Length == 2)) { break; } var mysteryEntries = mysterySections[1].Split(','); if (!this.Validate(mysteryEntries, "Invalid number of parameters.", e => e.Length == 6)) { break; } newType = (int)this.ParseEnumOrAddError <MysteryTypeNumber>(mysteryEntries[0]); mystery = new RandomMystery { Category = this.ParseIntOrAddError(mysteryEntries[1]), ID = this.ParseIntOrAddError(mysteryEntries[2]), Data = this.ParseIntOrAddError(mysteryEntries[3]), ItemKey = mysteryEntries[4] }; newFlag = this.ParseIntOrAddError(mysteryEntries[5]); } } } this.type = newType; this.OnPropertyChanged(nameof(this.Type)); this.BaseMystery = mystery; this.Flag = newFlag; }