public void ChangeView(string _name) { switch (_name.ToLower()) { case "game": //il y a certainement mieux à faire if (CurrentViewModel is SettingsViewModel model) { BoardViewModel.UpdateBackgroundColor(model.BackgroundColor); } CurrentViewModel = BoardViewModel; break; case "settings": if (BoardViewModel.IsStarted) { BoardViewModel.StopGame(); } CurrentViewModel = new SettingsViewModel(BoardViewModel.WhitePlayer, BoardViewModel.BlackPlayer, BoardViewModel.BackgroundColor); break; case "quit": Application.Current.Shutdown(0); break; } }
public MainViewModel() { Views = new ObservableCollection <ItemView> { new ItemView("Game", "../Images/game.png"), new ItemView("Settings", "../Images/settings.png"), new ItemView("Quit", "../Images/quit.png") }; BoardViewModel = new BoardViewModel(); CurrentViewModel = BoardViewModel; }