Пример #1
0
 private void Btn_FeatNew_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     Button btn = (Button)sender;
     ObservableCollection<Feat> addedTo = btn.Parent == this.Grid_Feats ? this.Feats : this.Traits;
     CreateFeatWindow cfw = new CreateFeatWindow();
     cfw.SetDataContext(new Feat() { ImageList = this.Images });
     if (cfw.ShowDialog() ?? false)
     {
         addedTo.Add((Feat)cfw.DataContext);
     }
 }
Пример #2
0
 private void Btn_FeatEdit_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     Button btn = (Button)sender;
     ObservableCollection<Feat> addedTo = btn.Parent == this.Grid_Feats ? this.Feats : this.Traits;
     ListView editedFrom = btn.Parent == this.Grid_Feats ? this.LV_Feats : this.LV_Traits;
     if (editedFrom.SelectedItem is Feat f)
     {
         CreateFeatWindow cfw = new CreateFeatWindow();
         cfw.SetDataContext(f.Copy());
         if (cfw.ShowDialog() ?? false)
         {
             addedTo[addedTo.IndexOf(f)] = (Feat)cfw.DataContext;
         }
     }
 }