private void SaveEntry(object sender, RoutedEventArgs e) { if (EntryEditor.IsValid()) { bool create = this.song == null; if (create) { this.song = new Data.Song(); } this.song.Title = EntryEditor.TitleBox.Text; this.song.Erschienen = EntryEditor.ReleasedBox.DisplayDate; this.song.Artist = EntryEditor.ArtistBox.Text; this.song.Favorit = true; this.song.Gerne = EntryEditor.GerneBox.Text; this.song.Laenge = EntryEditor.LengthBox.Text; this.song.YouTubeID = EntryEditor.YouTubeIdBox.Text; if (create) { this.song.Erstellen(); } else { this.song.Aktualisieren(); } ChangeState(State.Empty); LoadSongs(); } }
public virtual void Initialize(EntryEditorVM vm) { VM = vm ?? throw new ArgumentNullException(nameof(vm)); VM.ActivatingAction = () => this.InvokeIfRequired(() => base.Activate()); VM.ClosingAction = () => this.InvokeIfRequired(() => base.Close()); DataBindings.Add(nameof(Text), VM, nameof(VM.Title), false, DataSourceUpdateMode.OnPropertyChanged); VM.PropertyChanged += VM_PropertyChanged; EntryEditor.Initialize(VM); }
private void Add_Click(object sender, EventArgs e) { EntryEditor editor = new EntryEditor(); var result = editor.ShowDialog(); if (result == DialogResult.OK) { using (var context = new DatabaseContext()) { context.Bills.Add(editor.GetBillToSave()); context.SaveChanges(); var updatedBills2 = context.Bills.ToList(); } PopulateLabelsDropDown(); } }
private void ChangeState(State newstate) { this.state = newstate; this.SetDefaultState(); if (this.state == State.Empty || this.state == State.Sclected) { this.Title = "Musik Bibliothek"; } if (this.state == State.Empty) { this.song = null; SongList.UnselectAll(); NewButton.IsEnabled = true; SongList.Visibility = Visibility.Visible; } if (this.state == State.Sclected) { NewButton.IsEnabled = true; EditButton.IsEnabled = true; DeleteButton.IsEnabled = true; SongList.Visibility = Visibility.Visible; if (SongList.SelectedItems.Count < 1) { this.ChangeState(State.Empty); } } if (this.state == State.New) { BackButton.IsEnabled = true; EntryEditor.ResetForm(); EntryEditor.Visibility = Visibility.Visible; SaveButton.IsEnabled = true; this.Title = "Neuer Song erstellen"; } if (this.state == State.Edit) { BackButton.IsEnabled = true; EntryEditor.loadSong(this.song); EntryEditor.Visibility = Visibility.Visible; SaveButton.IsEnabled = true; this.Title = "Song bearbeiten"; } }