private void Window_Loaded(object sender, RoutedEventArgs e) { this.rbtInt.IsEnabled = isNew; this.rbtStr.IsEnabled = isNew; this.Key.IsReadOnly = !isNew; if (!isNew) { this.Key.Text = Value.key; if (Value is CustomDataValueInt) { this.rbtInt.IsChecked = true; this.rbtStr.IsChecked = false; this.IntValue.Value = (int)Value.getValue( ); this.IntValue.Visibility = Visibility.Visible; return; } if (Value is CustomDataValueString) { this.rbtInt.IsChecked = false; this.rbtStr.IsChecked = true; this.StrValue.Text = (string)Value.getValue( ); this.StrValue.Visibility = Visibility.Visible; return; } } }
private void Done_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(Key.Text)) { MessageBox.Show("This custom data must have a key"); return; } if (!isNew) { if (rbtInt.IsChecked == true) { Value.setValue((int)IntValue.Value); goto finish; } if (rbtStr.IsChecked == true) { Value.setValue(StrValue.Text); goto finish; } } else { if (rbtInt.IsChecked == true) { Value = new CustomDataValueInt( ) { key = this.Key.Text }; Value.setValue((int)this.IntValue.Value); goto finish; } if (rbtStr.IsChecked == true) { Value = new CustomDataValueString( ) { key = this.Key.Text }; Value.setValue(this.StrValue.Text); goto finish; } } finish: if (Value == null) { MessageBox.Show("An unexpected error occurred"); return; } DialogResult = true; this.Close( ); return; }
public void addCustomData( ) { DM.Dialogs.CustomDataDialogue cdd = new DM.Dialogs.CustomDataDialogue(); if (cdd.ShowDialog( ) == true) { ACustomDataValue value = cdd.Value; Event.addCustomDataValue(value); //SaveToDB ( ); RaisePropertyChanged("CustomData"); } }
public CustomDataDialogue(ACustomDataValue Value) : this() { this.Value = Value; isNew = false; }