public LevelSelectorWindowViewModel(MainWindowViewModel Mainvm)
        {
            this.VM = Mainvm;
            var Facade = new PiCrossFacade();

            var Puzzle1 = Puzzle.FromRowStrings(
                ".xxx.",
                "x.x.x",
                "xxxxx",
                "x.x.x",
                ".xxx."
                );

            var Puzzle2 = Puzzle.FromRowStrings(
                "x...x",
                ".x.x.",
                "..x..",
                ".x.x.",
                "x...x"
                );

            this.Puzzles    = new PlayablePuzzleViewModel[2];
            this.Puzzles[0] = new PlayablePuzzleViewModel(VM, Facade.CreatePlayablePuzzle(Puzzle1), "Puzzel 1");
            this.Puzzles[1] = new PlayablePuzzleViewModel(VM, Facade.CreatePlayablePuzzle(Puzzle2), "Puzzel 2");
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void Start()
        {
            var facade = new PiCrossFacade();

            PlayablePuzzle = facade.CreatePlayablePuzzle(Puzzle);
            PlayablePuzzle.IsSolved.ValueChanged += IsSolvedValueChanged;
            grid.Value = PlayablePuzzle.Grid.Map(square => new SquareVM(square)).Copy();
        }
        //Puzzel genereren via de sub klassse in PiCrossFacade
        public void PuzzelMaken()
        {
            var facade = new PiCrossFacade();

            GoedePuzzel = facade.CreatePlayablePuzzle(puzzle);
            GoedePuzzel.IsSolved.ValueChanged += IsSolved_Verandering;

            this.grid.Value = this.GoedePuzzel.Grid.Map(square => new SquareViewModel(square)).Copy();
            IsSolved_Verandering();
        }
        public GameVM(Puzzle puzzle)
        {
            var facade = new PiCrossFacade();

            this.playablePuzzle    = facade.CreatePlayablePuzzle(puzzle);
            this.Grid              = this.playablePuzzle.Grid.Map(square => new SquareVM(square));
            this.RowConstraints    = this.playablePuzzle.RowConstraints.Map(row => new RowConstraintsVM(row));
            this.ColumnConstraints = this.playablePuzzle.ColumnConstraints.Map(column => new ColumnConstraintsVM(column));
            this.Completed         = this.playablePuzzle.IsSolved;
        }
Ejemplo n.º 6
0
        public PuzzleViewModel(Puzzle puzzle)
        {
            var facade = new PiCrossFacade();

            this.playablePuzzle    = facade.CreatePlayablePuzzle(puzzle);
            this.Grid              = playablePuzzle.Grid.Map((IPlayablePuzzleSquare s) => new SquareViewModel(s));
            this.ColumnConstraints = playablePuzzle.ColumnConstraints.Map((IPlayablePuzzleConstraints c) => new ConstraintsViewModel(c));
            this.RowConstraints    = playablePuzzle.RowConstraints.Map((IPlayablePuzzleConstraints c) => new ConstraintsViewModel(c));
            this.ElapsedTime       = Cell.Create(TimeSpan.Zero);
            InitiateTimer();
        }
Ejemplo n.º 7
0
        public PuzzleVM(StartupVM startup, Puzzle playablePuzzle)
        {
            var puzzle = playablePuzzle;

            this.StartupVM = startup;


            this.PiCrossFacade = new PiCrossFacade();
            this.wrapped       = PiCrossFacade.CreatePlayablePuzzle(puzzle);
            this.Grid          = this.wrapped.Grid.Map(puzzleSquare => new SquareVM(puzzleSquare)).Copy();
        }
Ejemplo n.º 8
0
        public GameViewModel(Puzzle puzzle)
        {
            var facade = new PiCrossFacade();

            this.playablePuzzle = facade.CreatePlayablePuzzle(puzzle);

            this.Grid              = this.playablePuzzle.Grid.Map(square => new SquareViewModel(square)).Copy();
            this.RowConstraints    = this.playablePuzzle.RowConstraints.Map(row => new RowViewModel(row)).Copy();
            this.ColumnConstraints = this.playablePuzzle.ColumnConstraints.Map(column => new ColumnViewModel(column)).Copy();
            IsSolved = playablePuzzle.IsSolved;
        }
Ejemplo n.º 9
0
        public PicrossViewModel(Puzzle puzzle)
        {
            IsSolved = Cell.Create <bool>(false);
            var facade = new PiCrossFacade();

            playablePuzzle   = facade.CreatePlayablePuzzle(puzzle);
            this.Grid        = this.playablePuzzle.Grid.Map(square => new SquareViewModel(square));
            this.Chronometer = new Chronometer();
            timer            = new DispatcherTimer();
            timer.Interval   = TimeSpan.FromMilliseconds(250);
            timer.Tick      += (o, s) => Chronometer.Tick();
            timer.Start();

            RowConstraints    = new PlayablePuzzleConstraintsViewModel(this.playablePuzzle.RowConstraints);
            ColumnConstraints = new PlayablePuzzleConstraintsViewModel(this.playablePuzzle.ColumnConstraints);
        }
Ejemplo n.º 10
0
        public PuzzleVM(StartupVM startup)
        {
            var puzzle = Puzzle.FromRowStrings(
                "xxxxx",
                "x...x",
                "x...x",
                "x...x",
                "xxxxx"
                );

            this.StartupVM = startup;


            this.PiCrossFacade = new PiCrossFacade();
            this.wrapped       = PiCrossFacade.CreatePlayablePuzzle(puzzle);
            this.Grid          = this.wrapped.Grid.Map(puzzleSquare => new SquareVM(puzzleSquare)).Copy();
        }
Ejemplo n.º 11
0
        public GameViewModel()
        {
            var puzzle = Puzzle.FromRowStrings(
                "xxxxx",
                "x...x",
                "x...x",
                "x...x",
                "xxxxx"
                );

            var facade = new PiCrossFacade();

            this.PlayablePuzzle = facade.CreatePlayablePuzzle(puzzle);
            Console.WriteLine(PlayablePuzzle.RowConstraints.Items);

            //var vmGrid = this.PlayablePuzzle.Grid.Map(square => new SquareViewModel(square)).Copy();
        }
Ejemplo n.º 12
0
        public GameViewModel(Puzzle puzzle)
        {
            var facade = new PiCrossFacade();

            this.playablePuzzle = facade.CreatePlayablePuzzle(puzzle);

            this.Grid = this.playablePuzzle.Grid.Map(square => new SquareVM(square)).Copy();

            this.ColumnConstraints = this.playablePuzzle.ColumnConstraints.Map(column => new ColumnsVM(column)).Copy();
            this.RowConstraints    = this.playablePuzzle.RowConstraints.Map(row => new RowsVM(row)).Copy();

            Check           = playablePuzzle.IsSolved;
            this.StartTimer = new StartTimer(this);
            this.StopTimer  = new StopTimer(this);
            lastTick        = DateTime.Now;
            timerken        = new DispatcherTimer(TimeSpan.FromMilliseconds(10), DispatcherPriority.Background,
                                                  t_Tick, Dispatcher.CurrentDispatcher);
            timerken.IsEnabled = true;
        }
Ejemplo n.º 13
0
        public PlayWindowViewModel(MainWindowViewModel Mainvm)
        {
            this.VM = Mainvm;
            var DemoPuzzle = Puzzle.FromRowStrings(
                ".xxx.",
                "x.x.x",
                "xxxxx",
                "x.x.x",
                ".xxx."
                );
            var Facade = new PiCrossFacade();

            this.DemoPlayablePluzzle = Facade.CreatePlayablePuzzle(DemoPuzzle);
            this.Grid = DemoPlayablePluzzle.Grid.Map(square => new PuzzleSquareViewModel(square)).Copy();
            this.ColumnConstraints = DemoPlayablePluzzle.ColumnConstraints.Map(constraint => new PuzzleConstraintsViewModel(constraint)).Copy();
            this.RowConstraints    = DemoPlayablePluzzle.RowConstraints.Map(constraint => new PuzzleConstraintsViewModel(constraint)).Copy();
            this.Retry             = new RetryCommand(this.VM);
            this.Exit = new ExitCommand(this.VM);
        }
Ejemplo n.º 14
0
        public PlayableWindow(Navigator navigator, Puzzle puzzle = null) : base(navigator)
        {
            if (puzzle == null)
            {
                puzzle = Puzzle.FromRowStrings(
                    "xxx",
                    "x..",
                    "x.x"
                    );
            }
            var facade = new PiCrossFacade();

            playablePuzzle = facade.CreatePlayablePuzzle(puzzle);



            this.Grid = playablePuzzle.Grid.Map(square => new ChangeableSquare(square)).Copy();
            this.ColumnConstraints = playablePuzzle.ColumnConstraints /*.Map(constraints => new ChangeableCC(constraints)).Copy()*/;
            this.RowConstraints    = playablePuzzle.RowConstraints /*.Map(constraints => new ChangeableCC(constraints)).Copy()*/;

            BackToStart = new EasyCommand(() => SwitchTo(new StartScreen(navigator)));
            Refresh     = new EasyCommand(() => SwitchTo(new PlayableWindow(navigator, puzzle)));
            ChooseOther = new EasyCommand(() => SwitchTo(new PuzzleGenerator(navigator)));
        }