public SpawnWeightEntryWindow(AffixWeight w) { InitializeComponent(); Groups.ItemsSource = GroupTypes; editTarget = w; isEdit = true; Groups.SelectedItem = w.type; WeightInteger.Value = w.weight; }
private void ConfirmClick(object sender, RoutedEventArgs e) { if (Groups.SelectedItem == null) { MessageBox.Show("Type not selected", "Error", MessageBoxButton.OK); return; } GroupType selectedType = GetSelectedType(); int t = AffixBase.WeightContainsType(dic, selectedType); if (WeightInteger.Value == null) { MessageBox.Show("Value NaN", "Error", MessageBoxButton.OK); return; } if (t != -1) { MessageBox.Show("Key Already Exists", "Error", MessageBoxButton.OK); return; } else { if (isEdit) { editTarget.type = selectedType; editTarget.weight = (int)WeightInteger.Value; } else { AffixWeight w = new AffixWeight() { type = selectedType, weight = (int)WeightInteger.Value }; dic.Insert(0, w); } this.Close(); return; } }