private List_Binding_Game Read_Games_Bindings(string fileName, List_Games list_Games, Task task_id) { List_Binding_Game list_binding_Game = new List_Binding_Game();//новый класс лист с нумерацией if (File.Exists(fileName)) { StreamReader sr = new StreamReader(fileName); string s0; while ((s0 = sr.ReadLine()) != null) { string[] ar = s0.Split(' '); if (Convert.ToInt32(ar[0]) == task_id.Id) { if ((list_Games[Convert.ToInt32(ar[1]) - 1].Id == Convert.ToInt32(ar[1])) & (list_Games[Convert.ToInt32(ar[1]) - 1].GameType.Contains(GameType_String))) //сходятся ли id игры { Binding_Game binding_game = new Binding_Game(list_binding_Game.Count + 1, list_Games[Convert.ToInt32(ar[1]) - 1]); //новый класс игры с нумерацией + добавление нумерации list_binding_Game.Add(binding_game); //добавление в лист } } } sr.Close(); sr.Dispose(); } return(list_binding_Game); }
//public List_Games(string fileName) //{ // if (File.Exists(fileName)) // { // StreamReader sr = new StreamReader(fileName); // string s0; // while ((s0 = sr.ReadLine()) != null) // { // string[] ar = s0.Split('*'); // if (ar.Length == 5) // { // Game game = new Game(Convert.ToInt32(ar[0]), ar[1], ar[2], ar[3], ar[4]); // this.Add(game); // } // else if (ar.Length == 3) // { // if ((s0 = sr.ReadLine()) != null) // { // string[] re = s0.Split('*'); // if (re.Length == 3) // { // Game game = new Game(Convert.ToInt32(ar[0]), ar[1], ar[2] + re[0], re[1], re[2]); // this.Add(game); // } // //else // // MessageBox.Show("ошибка во вложенном ифе"+ i); // } // } // //else // // MessageBox.Show("ошибка в основном ифе"+i); // } // sr.Close(); // sr.Dispose(); // } //} public List_Games(string fileName) { List_Games list_Games = new List_Games(); list_Games = null; XmlSerializer serializer = new XmlSerializer(typeof(List_Games)); using (StreamReader reader = new StreamReader(fileName)) { this.AddRange((List_Games)serializer.Deserialize(reader)); } }
private void Gamesto_List() { List_Task_UI.Visibility = Visibility.Hidden; List_Game_UI.Visibility = Visibility.Visible; Butt_Task.Visibility = Visibility.Hidden; Butt_Games.Visibility = Visibility.Visible; List_Games list_Games = new List_Games(FileName3); var t = List_Task_UI.SelectedItem; var binding_List_Games = Read_Games_Bindings(FileName4, list_Games, (Task)List_Task_UI.SelectedItem); List_Game_UI.ItemsSource = binding_List_Games; }