コード例 #1
0
        private void AddPressed(object sender, RoutedEventArgs e)
        {
            GunEditor editweapon = new GunEditor();

            editweapon.bSave.Visibility   = Visibility.Hidden;
            editweapon.Title              = "Add Weapon";
            editweapon.lbImage.Visibility = Visibility.Hidden;
            if (editweapon.ShowDialog() == true)
            {
                weaponcollection.Add(editweapon.MyWeapon);
                if (lbWeapons.ItemsSource == null)
                {
                    lbWeapons.ItemsSource = weaponcollection;
                }
                lbWeapons.Items.Refresh();
            }
        }
コード例 #2
0
        private void EditPressed(object sender, RoutedEventArgs e)
        {
            if (lbWeapons.SelectedIndex == -1)
            {
                return;
            }

            GunEditor editWeaponWindow = new GunEditor(lbWeapons.SelectedItem as Weapon);

            editWeaponWindow.lbTemp.Visibility = Visibility.Hidden;
            editWeaponWindow.MyWeapon          = lbWeapons.SelectedItem as Weapon;

            if (editWeaponWindow.ShowDialog() == true)
            {
                weaponcollection[lbWeapons.SelectedIndex] = editWeaponWindow.MyWeapon;
                lbWeapons.Items.Refresh();
            }
        }