public MainWindow() { InitializeComponent(); vM = new ViewModel(Game.CreateNew()); this.DataContext = vM; }
private void Restart_Button_Click(object sender, RoutedEventArgs e) { vM = new ViewModel(Game.CreateNew()); this.DataContext = vM; }
private void Load_Button_Click(object sender, RoutedEventArgs e) { String Path = "../../_Resources/Save.txt"; Player Playr=null; ArrayList Lines = new ArrayList(); using (StreamReader sr = File.OpenText(Path)) { String str = ""; while ((str = sr.ReadLine()) != null) { Lines.Add(str); } } String[] Lns = new String[Lines.Count-1]; int i = 0; foreach(object L in Lines){ String Line = (String) L; if (i < Lns.Length) { Lns[i] = Line; } else { if (Line.Equals("1")) { Playr = Player.ONE; } else if (Line.Equals("2")) { Playr = Player.TWO; } } i++; } var Board=vM.ConvertSavedData(Lns); vM = new ViewModel(Game.CreateInProgress(Board, Playr)); this.DataContext = vM; }