Пример #1
0
        public DefaultApp()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var notifiableView = new NotifiableGameView();;

            this.view = notifiableView;
            var board = new SquareBoard(4);
            var game  = new Game(notifiableView, board);

            this.controller = new DefaultGameController(game);
            mainWindow      = new Window(view, controller);
            mainWindow.SetEventOnNewImageSelected(ChangePuzzleImage);

            var outputControl = FindControl(boardOutputControlName);
            var defaultImage  = Image.FromFile(defaultImagePath);
            var cellFactory   = new BoardCellFactory(controller, defaultImage);

            this.boardRenderer = new BoardRenderer(outputControl, board, cellFactory);
            view.SetEventOnCellMoved(boardRenderer.SwapCells);
            view.SetEventOnBoardChanged(boardRenderer.Render);

            boardRenderer.Render(board);
        }
Пример #2
0
        public Window(ObservableGameView view, GameController controller)
        {
            InitializeComponent();

            this.view       = view;
            this.controller = controller;

            this.ctrl_boardSize.OnNewSizeSelected += controller.ChangeBoardSize;
            view.SetEventOnSolutionFound(OnSolutionFound);
            view.SetEventOnSolutionStepUpdated(OnSolutionStepChanged);
            view.SetEventOnDrawCountChanged(OnDrawCountChanged);
        }
Пример #3
0
 private void CreateObservableAndGameView()
 {
     gameView = new NotifiableGameView();
     view     = gameView;
 }