Example #1
0
        public MenuViewModel(Action <Puzzle> puzzleScreenSwitcher)
        {
            var       facade   = new PiCrossFacade();
            IGameData gameData = facade.CreateDummyGameData();

            this.Choices = gameData.PuzzleLibrary.Entries.Select((IPuzzleLibraryEntry s) => new ChoiceViewModel(s.Puzzle, puzzleScreenSwitcher));
        }
Example #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);
        }
Example #3
0
        public void Execute(object parameter)
        {
            PuzzleEditScreen screen = (PuzzleEditScreen)parameter;

            screen.Editor.ResolveAmbiguity();
            var  facade = new PiCrossFacade();
            bool am     = false;

            foreach (IPuzzleEditorSquare square in screen.Editor.Grid.Items)
            {
                if (square.Ambiguity.Value == Ambiguity.Ambiguous)
                {
                    am = true;
                    break;
                }
            }
            if (!am)
            {
                IGameData           gameData = facade.LoadGameData("../../../../python/picross.zip", true);
                Puzzle              puzzle   = screen.Editor.BuildPuzzle();
                IPuzzleLibraryEntry entry    = gameData.PuzzleLibrary.Create(puzzle, "Jonas");
                screen.navigator.selectionScreen.cell.Value.Add(new PuzzleViewModel(entry));
                screen.navigator.selectionScreen.PuzzleSizes.Add(puzzle.Size);
                screen.SwitchTo(new MenuScreen(screen.navigator));
            }
        }
Example #4
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();
 }
        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");
        }
Example #6
0
        public StartViewModel()
        {
            var facade = new PiCrossFacade();

            data           = facade.CreateDummyGameData();
            Puzzles        = data.PuzzleLibrary.Entries;
            SelectedPuzzle = Puzzles.ElementAt(0);
        }
Example #7
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();
        }
Example #8
0
        public SelectViewModel()
        {
            var facade = new PiCrossFacade();

            gameData     = facade.CreateDummyGameData();
            Puzzles      = gameData.PuzzleLibrary.Entries;
            ChosenPuzzle = Puzzles.ElementAt(0);
        }
        //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;
        }
Example #11
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();
        }
Example #12
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();
            }
        }
Example #13
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;
        }
Example #14
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();
        }
Example #15
0
 public void Execute(object parameter)
 {
     object[] parameters = (object[])parameter;
     if (!parameters[0].Equals("") && !parameters[1].Equals(""))
     {
         int rows    = Int32.Parse((string)parameters[0]);
         int columns = Int32.Parse((string)parameters[1]);
         PuzzleEditorScreen screen = (PuzzleEditorScreen)parameters[2];
         Puzzle             puzzle = Puzzle.CreateEmpty(new Size(columns, rows));
         var facade = new PiCrossFacade();
         screen.SwitchTo(new PuzzleEditScreen(screen.navigator, facade.CreatePuzzleEditor(puzzle)));
     }
 }
        public SelectPuzzleViewModel(MainWindowViewModel main)
        {
            this.Main = main;
            Library   = new PiCrossFacade().LoadGameData(path);
            Puzzles   = new List <PuzzleEntryViewModel>();
            Chosen    = Cell.Create <PuzzleEntryViewModel>(new PuzzleEntryViewModel("empty"));

            ClosePuzzleSelect  = new ClosePuzzleSelectCommand(Main);
            SelectPuzzleSelect = new SelectPuzzleSelectCommand(this);


            foreach (IPuzzleLibraryEntry i in Library.PuzzleLibrary.Entries)
            {
                Puzzles.Add(new PuzzleEntryViewModel(i, this));
            }
        }
Example #17
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);
        }
Example #18
0
        public SelectionScreen(Navigator navigator) : base(navigator)
        {
            var facade = new PiCrossFacade();

            cell            = Cell.Create <IList <PuzzleViewModel> >(facade.LoadGameData("../../../../python/picross.zip").PuzzleLibrary.Entries.Select(entry => new PuzzleViewModel(entry)).ToList());
            backup          = this.Puzzles.Select(puzzle => puzzle).ToList();
            PuzzleSizes     = this.Puzzles.Select(puzzle => puzzle.Entry.Puzzle.Size).Distinct().ToList();
            GoToPuzzle      = new GoToPuzzleCommand(navigator, this);
            GoToMenu        = new EasyCommand(() => SwitchTo(new MenuScreen(navigator)));
            FilterUnsolved  = new FilterUnsolvedCommand();
            FilterSize      = new FilterSizeCommand();
            ClearFilters    = new ClearFiltersCommand();
            OrderBySolved   = new OrderBySolvedCommand();
            OrderByUnsolved = new OrderByUnsolvedCommand();
            OrderBySize     = new OrderBySizeCommand();
        }
        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();
        }
Example #20
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();
        }
Example #21
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);
        }
Example #22
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;
        }
Example #23
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)));
        }
Example #24
0
 public MainWindowVM()
 {
     ActiveScreen  = new StartVM(this);
     PiCrossFacade = new PiCrossFacade();
 }
 //Launcht op de Home screen view
 public MainViewModel()
 {
     this.Active        = new HomeScreenViewModel(this);
     this.PiCrossFacade = new PiCrossFacade();
 }
Example #26
0
        public PuzzleGenerator(Navigator navigator) : base(navigator)
        {
            var facade = new PiCrossFacade();

            var puzzle1 = Puzzle.FromRowStrings(
                ".......xx.xxxx.",
                ".....xxx.xxxxxx",
                "...xxxx.xxxxx.x",
                "..xxxx.xxxxxxxx",
                ".xxxx.xxxxx.xxx",
                "xx...x...x.xxxx",
                "x.........xxxx.",
                "x.........xxxx.",
                ".x.......xxxxx.",
                ".x.......xxxx..",
                ".x.......xxxx..",
                ".x.......xxx...",
                ".x.......xxx...",
                ".x.......xx....",
                ".xxxxxxxxx....."
                );

            var puzzle2 = Puzzle.FromRowStrings(
                ".x...",
                "xx.xx",
                ".xxx.",
                ".xxx.",
                "..x.."
                );

            var puzzle3 = Puzzle.FromRowStrings(
                ".xx....xx.",
                "...xxxx...",
                "x.xxxxxx.x",
                ".xx.xx.xx.",
                ".xxxxxxxx.",
                ".x.xxxx.x.",
                ".xxxxxxxx.",
                ".xx.xx.xx.",
                "x.xxxxxx.x",
                "...xxxx..."
                );
            var puzzle4 = Puzzle.FromRowStrings(
                "x..x.....x",
                "xx.xx...xx",
                ".xx.xxxxx.",
                "..xx.....x",
                "..x.......",
                "..x.x....x",
                ".x.xx...xx",
                ".xx...x...",
                ".xx..xxx..",
                "..xx.....x"
                );

            this.Puzzles    = new PlayablePuzzles[4];
            this.Puzzles[0] = new PlayablePuzzles(navigator, puzzle1, "Bread");
            this.Puzzles[1] = new PlayablePuzzles(navigator, puzzle2, "Chicken");
            this.Puzzles[2] = new PlayablePuzzles(navigator, puzzle3, "LadyBug");
            this.Puzzles[3] = new PlayablePuzzles(navigator, puzzle4, "Pikachu");
        }
Example #27
0
 public GameVM(MainVM mainVM)
 {
     playablePuzzle = new PiCrossFacade().CreatePlayablePuzzle(puzzle);
     PVM            = new PuzzleVM(playablePuzzle);
     this.mainVM    = mainVM;
 }
Example #28
0
 public MainViewModel()
 {
     this.activeScreen  = new WelcomeViewModel(this);
     this.PiCrossFacade = new PiCrossFacade();
 }
Example #29
0
 public StartupVM()
 {
     this.currentWindow = new SelectionScreenVM(this);
     this.PiCrossFacade = new PiCrossFacade();
 }