예제 #1
0
        private void AddNewEnemy_Click(object sender, RoutedEventArgs e)
        {
            if (this.Resources.Contains("EnemyDB"))
            {
                XmlDataProvider dataProv = (XmlDataProvider)this.Resources["EnemyDB"];
                if (dataProv.Document != null)
                {
                    NewEnemyWindow eneWindow = new NewEnemyWindow(dataProv.Document, this);
                    var helper = new WindowInteropHelper(eneWindow);
                    helper.Owner = new WindowInteropHelper(this).Handle;
                    bool? res = eneWindow.ShowDialog();
                    if (res != null && (bool)res)
                    {
                    }
                    else
                    {
                        // MessageBox.Show("Did not add new enemy");
                    }
                }
                else
                {
                    Console.Out.WriteLine("There is no valid Enemy XML file to add enemy to!");
                }

            }
        }
예제 #2
0
 /*private void EnemyListBox_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     EnemyCountLabel.Content = EnemyListBox.Items.Count;
     if (e.Action == NotifyCollectionChangedAction.Add)
     {
         EnemyListBox.ScrollIntoView(e.NewItems[0]);
         
     }
     else if (e.Action == NotifyCollectionChangedAction.Remove)
     {
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
     }
 }*/
 private void NewEnemyFromTemplate_Click(object sender, RoutedEventArgs e)
 {
     var xmlEle = EnemyListBox.SelectedItem;
     if (xmlEle != null && xmlEle is XmlElement)
     {
         NewEnemyWindow eneWindow = new NewEnemyWindow((XmlElement)xmlEle, this);
         var helper = new WindowInteropHelper(eneWindow);
         helper.Owner = new WindowInteropHelper(this).Handle;
         bool? res = eneWindow.ShowDialog();
         if (res != null && (bool)res)
         {
         }
         else
         {
             //MessageBox.Show("Did not add new enemy");
         }
     }
     /*NewEnemyWindow eneWindow = new NewEnemyWindow(dataProv.Document);
     var helper = new WindowInteropHelper(eneWindow);
     helper.Owner = new WindowInteropHelper(this).Handle;
     bool? res = eneWindow.ShowDialog();
     if (res != null && (bool)res)
     {
     }
     else
     {
         MessageBox.Show("Did not add new enemy");
     }*/
 }