private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (lboxEnnemyListAdd.SelectedItem != null)
                {
                    lboxEnnemyListAdd.Items.Remove(lboxEnnemyListAdd.SelectedItem);

                    var list = "";

                    foreach (var item in lboxEnnemyListAdd.Items)
                    {
                        list = list + "/" + item.ToString();
                    }
                    Service.TXTFile tXT = new Service.TXTFile();
                    tXT.delete(list, "ListEnnemy");
                }
                else
                {
                    MessageBox.Show("Aucune ligne n'est sélectionnée.");
                }
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            };
            WAddEnnemy sten = new WAddEnnemy();

            sten.Show();
            this.Close();
        }
        private void btnRefresh_Click(object sender, RoutedEventArgs e)
        {
            Service.TXTFile tx = new Service.TXTFile();
            tx.clear("GameEnnemy");
            WAddEnnemy sten = new WAddEnnemy();

            sten.Show();
            this.Close();
        }
 private void btnAddEn_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (lboxEnnemyListAdd.SelectedItem != null)
         {
             string       ennemy = "" + lboxEnnemyListAdd.SelectedItem;
             string       line;
             string       container = "";
             StreamReader file      = new StreamReader(@"c:\JDR(Lisa)\ListEnnemy.txt");
             while ((line = file.ReadLine()) != null)
             {
                 string[] words = line.Split(' ');
                 // Get Name
                 if (ennemy == words[0])
                 {
                     Service.Service serv = new Service.Service();
                     string          id   = serv.RandomString(6);
                     container = id + "/" + words[0] + " " + words[1] + " " + words[2] + " " + words[3] + " " + words[4] + " " + words[5] + " " + words[6];
                 }
             }
             file.Close();
             Service.TXTFile tf1 = new Service.TXTFile();
             tf1.write(container, "GameEnnemy");
             WAddEnnemy sten = new WAddEnnemy();
             sten.Show();
             this.Close();
         }
         else
         {
             MessageBox.Show("Aucune ligne n'est sélectionnée.");
         }
     }
     catch (Exception error)
     {
         MessageBox.Show(error.Message);
     };
 }
Ejemplo n.º 4
0
        private void btnEnnemy_Click(object sender, RoutedEventArgs e)
        {
            WAddEnnemy stsen = new WAddEnnemy();

            stsen.Show();
        }
Ejemplo n.º 5
0
        private void bntAddEnnemy_Click(object sender, RoutedEventArgs e)
        {
            string line;
            string container = "";
            string name      = txtName.Text;
            string hp        = txtHp.Text;
            string xp        = txtXp.Text;
            string gold      = txtXp.Text;
            string loot      = "";
            string aptitude  = "";
            string atk       = txtAtk.Text;

            if (name == "" || name == null)
            {
                name = "none";
            }

            if (hp == "" || hp == null)
            {
                hp = "1";
            }

            if (xp == "" || xp == null)
            {
                xp = "1";
            }

            if (gold == "" || gold == null)
            {
                gold = "1";
            }

            if (loot == "" || loot == null)
            {
                loot = "none";
            }
            if (aptitude == "" || aptitude == null)
            {
                aptitude = "none";
            }
            if (atk == "" || atk == null)
            {
                atk = "none";
            }


            StreamReader file = new StreamReader(@"c:\JDR(Lisa)\GameEnnemy.txt");

            while ((line = file.ReadLine()) != null)
            {
                string[] words = line.Split(' ');
                if (name == words[0])
                {
                    MessageBox.Show("0");
                    container = container + "%" + name + " " + hp + " " + xp + " " + gold + " " + loot + " " + aptitude + " " + atk;
                }
                else
                {
                    MessageBox.Show("1");
                    container = container + "%" + line;
                }
            }
            file.Close();
            Service.TXTFile tf = new Service.TXTFile();
            tf.addEnnemy(container, "GameEnnemy");
            WAddEnnemy ad = new WAddEnnemy();

            ad.Show();
            this.Close();
        }