public GameWindowViewModel(MainWindowViewModel main) { Main = main; var puzzle = Puzzle.FromRowStrings( "xxxxx", "x...x", "x...x", "x...x", "xxxxx" ); var facade = new PiCrossFacade(); //timer var timeService = ServiceLocator.Current.GetInstance <ITimeService>(); _start = timeService.Now; _timer = ServiceLocator.Current.GetInstance <ITimerService>(); _timer.Tick += Timer_Tick; _timer.Start(new TimeSpan(0, 0, 0, 0, 100)); PlayablePuzzle = facade.CreatePlayablePuzzle(puzzle); SquareGrid = Grid.Create <SquareViewModel>(PlayablePuzzle.Grid.Size, p => new SquareViewModel(PlayablePuzzle.Grid[p])); Timer = "00:00:00"; CloseGameWindow = new CloseGameWindowCommand(main); IsSolved = new IsSolvedCommand(this); }
public void StartGame(IPuzzleLibraryEntry puzzle) { ActivePuzzle = puzzle.Puzzle; this.PlayablePuzzle = new PiCrossFacade().CreatePlayablePuzzle(puzzle.Puzzle); this.SquareGrid = Grid.Create <SquareViewModel>(PlayablePuzzle.Grid.Size, p => new SquareViewModel(PlayablePuzzle.Grid[p])); }