Exemplo n.º 1
0
 public static void Save(string path, FieldManageWindow control, List <Field> fields)
 {
     try
     {
         //Analogicznie do klasy Savegame:
         XmlDocument Xeconomy = new XmlDocument();
         Xeconomy.Load(path);
         XmlNodeList fieldList = Xeconomy.GetElementsByTagName("field");
         foreach (XmlNode elem in fieldList)
         {
             elem.Attributes["ownedByPlayer"].Value = fields.Single(x => x.Numer == elem.Attributes["number"].Value).Stan.ToString(); //przypisanie wartosci stanu pola gdzie zmienna Numer jest rowna numerowi w atrybucie nummber w wezle field
         }
         Xeconomy.Save(path);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 2
0
 public static void Load(string path, FieldManageWindow control, List <Field> fields)
 {
     try
     {
         XmlDocument Xeconomy = new XmlDocument(); //Przechowuje zawartosc XML
         Xeconomy.Load(path);                      //Wczytanie zawartosci
         //Analogicznie do klasy Savegame:
         XmlNodeList fieldList = Xeconomy.GetElementsByTagName("field");
         foreach (XmlNode elem in fieldList)
         {
             fields.Add(new Field()
             {
                 Numer = elem.Attributes["number"].Value, Stan = Convert.ToBoolean(elem.Attributes["ownedByPlayer"].Value)
             });
         }
         control.fieldDataGrid.ItemsSource = fields; //przypisujemy liste pol do daraGridu w trybie TwoWay
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Exemplo n.º 3
0
        private void FieldManageButton_Click(object sender, RoutedEventArgs e)
        {
            FieldManageWindow economyWindow = new FieldManageWindow(economyPath); //tworzymy okno zarzadzania polami

            economyWindow.Show();                                                 //wyswietlamy utworzone okno
        }