Пример #1
0
 public void Start(MainWindowViewModel mainWindowViewModel, IPlayablePuzzle puzzle)
 {
     this.Vm = mainWindowViewModel;
     this.StartTimer();
     this.PlayablePuzzle = puzzle;
     this.Grid           = this.PlayablePuzzle.Grid.Map(puzzleSquare => new PlayablePuzzleSquareViewModel(puzzleSquare)).Copy();
 }
Пример #2
0
 public PlayablePuzzleViewModel(MainWindowViewModel Mainvm, IPlayablePuzzle puzzle, String title)
 {
     this.VM           = Mainvm;
     this.puzzle       = puzzle;
     this.Title        = title;
     this.SelectPuzzle = new Select(this.VM, this.puzzle);
 }
Пример #3
0
 public PuzzleVM(StartupVM startup, IPlayablePuzzle IplayablePuzzle)
 {
     this.wrapped       = IplayablePuzzle;
     this.StartupVM     = startup;
     this.PiCrossFacade = new PiCrossFacade();
     this.Grid          = this.wrapped.Grid.Map(puzzleSquare => new SquareVM(puzzleSquare)).Copy();
 }
Пример #4
0
        public void Start(MainViewModel viewModel, IPlayablePuzzle puzzle)
        {
            this.Vm             = viewModel;
            this.PlayablePuzzle = puzzle;
            this.Grid           = this.PlayablePuzzle.Grid.Map(puzzlesquare => new PuzzleSquareViewModel(puzzlesquare)).Copy();
            this.Chronometer    = new Chronometer();

            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(250);
            timer.Tick    += (o, s) =>
            {
                if (IsSolved.Value)
                {
                    timer.Stop();
                    Chronometer.Pause();
                }
                else
                {
                    Chronometer.Tick();
                }
            };
            timer.Start();

            this.Chronometer.Start();
        }
Пример #5
0
 public PuzzleViewModel(Puzzle puzzle, MainViewModel mainViewModel)
 {
     this.Puzzle         = puzzle;
     this.MainViewModel  = mainViewModel;
     this.PlayablePuzzle = this.MainViewModel.PiCrossFacade.CreatePlayablePuzzle(this.Puzzle);
     this.Select         = new Command(() => this.MainViewModel.StartGame(this.PlayablePuzzle));
 }
Пример #6
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();
        }
Пример #7
0
 public GameViewModel(MainWindowViewModel mainWindowViewModel, IPlayablePuzzle playablePuzzle)
 {
     this.MainWindowViewModel = mainWindowViewModel;
     this.Start(mainWindowViewModel, playablePuzzle);
     this.StartTimer();
     this.BackCommand = new EasyCommand(() => this.MainWindowViewModel.StartView());
     this.QuitCommand = new EasyCommand(() => this.MainWindowViewModel.CloseWindow());
 }
Пример #8
0
        public PlayablePuzzleVM(IPlayablePuzzle puzzle)
        {
            this.puzzle = puzzle;

            this.RowConstraints    = Sequence.FromEnumerable(puzzle.RowConstraints.Select(constraint => new ConstraintsVM(constraint)));
            this.ColumnConstraints = Sequence.FromEnumerable(puzzle.ColumnConstraints.Select(constraint => new ConstraintsVM(constraint)));
            this.Grid     = puzzle.Grid.Map(square => new SquareVM(square)).Copy();
            this.IsSolved = puzzle.IsSolved;
        }
Пример #9
0
 public PlayWindowViewModel(IPlayablePuzzle puzzle)
 {
     this.DemoPlayablePluzzle = puzzle;
     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);
 }
        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;
        }
Пример #11
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();
        }
Пример #12
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;
        }
Пример #13
0
        public HelpCommand(IPlayablePuzzle puzzle)
        {
            this.puzzle = puzzle;
            var facade = new PiCrossFacade();

            solvedPuzzle = facade.CreateStepwisePuzzleSolver(PlayablePuzzleConstraintsToConstraints(puzzle.RowConstraints), PlayablePuzzleConstraintsToConstraints(puzzle.ColumnConstraints));
            while (!solvedPuzzle.IsSolved)
            {
                solvedPuzzle.Step();
            }
        }
Пример #14
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();
        }
Пример #15
0
        private void initialize(MainViewModel mainViewModel, IPlayablePuzzle playablePuzzle)
        {
            this.MainViewModel  = mainViewModel;
            this.PlayablePuzzle = playablePuzzle;
            // => is een lambda expressie, di een blok code die behandeld wordt als een object
            // normaal --> een anonieme inner klasse maken
            //public void actionPerformed(ActionEvent square){
            //   square = new...
            //}

            //copy creeert de grid
            this.Grid = PlayablePuzzle.Grid.Map(square => new SquareViewModel(square)).Copy();
            this.Quit = new Command(() => this.MainViewModel.Close());
            this.Back = new Command(() => this.MainViewModel.BackToStart());
        }
Пример #16
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);
        }
Пример #17
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();
        }
Пример #18
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();
        }
Пример #19
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;
        }
Пример #20
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);
        }
Пример #21
0
 public void startGame(IPlayablePuzzle puzzle)
 {
     this.ActiveWindow = new PlayWindowViewModel(puzzle);
 }
Пример #22
0
 public PuzzleVM(IPlayablePuzzle playablePuzzle)
 {
     this.playablePuzzle = playablePuzzle;
 }
Пример #23
0
 internal void Newgame(IPlayablePuzzle puzzle)
 {
     this.CurrentWindow = new PuzzleVM(this, puzzle);
 }
Пример #24
0
 public Select(MainWindowViewModel Mainvm, IPlayablePuzzle puzzle)
 {
     this.VM     = Mainvm;
     this.puzzle = puzzle;
 }
Пример #25
0
 public void StartGame(IPlayablePuzzle puzzle)
 {
     this.ActiveScreen = new GameViewModel(this, puzzle);
 }
Пример #26
0
 public GameScreenViewModel(MainScreenViewModel mainScreenViewModel, IPlayablePuzzle playablePuzzle)
 {
     this.Start(mainScreenViewModel, playablePuzzle);
 }
Пример #27
0
 public CheckSolutionCommand(IPlayablePuzzle puzzle)
 {
     this.puzzle = puzzle;
 }
Пример #28
0
 public void Start(MainScreenViewModel mainScreenViewModel, IPlayablePuzzle puzzle)
 {
     this.Msvm           = mainScreenViewModel;
     this.PlayablePuzzle = puzzle;
     this.Grid           = this.PlayablePuzzle.Grid.Map(square => new SquareViewModel(square)).Copy();
 }
Пример #29
0
 public IEnumerator PlayPuzzle(IPlayablePuzzle puzzle)
 {
     throw new System.NotImplementedException();
 }
Пример #30
0
 public GameViewModel(MainViewModel mainViewModel, IPlayablePuzzle puzzle)
 {
     this.initialize(mainViewModel, puzzle);
 }