public GameWindowViewModel(int level, string word, Category categoryProperty, int mistakes, int wordIndex, ObservableCollection <string> pickedWordsCollection, int sec, string imagePath)
        {
            currentUser      = SignInViewModel.SignedInUser;
            Level            = level;
            Word             = word;
            CategoryProperty = categoryProperty;
            switch (CategoryProperty)
            {
            case Category.AllCategories:
                AllCategoryChecked = true;
                break;

            case Category.Rivers:
                RiversCategoryChecked = true;
                break;

            case Category.Cars:
                CarsCategoryChecked = true;
                break;

            case Category.Movies:
                MoviesCategoryChecked = true;
                break;

            case Category.Flowers:
                FlowersCategoryChecked = true;
                break;

            default:
                break;
            }
            Mistakes              = mistakes;
            WordIndex             = wordIndex;
            PickedWordsCollection = pickedWordsCollection;
            Seconds = sec;
            StartTimer(Seconds);
            ImagePath             = imagePath;
            signInVM              = actions.DeserializeUsers("User.xml");
            dispatcherTimer.Tick += new EventHandler(TimerTick);
            words = new Words();
            words = actions.DeserializeWords("Words.xml");
        }
Ejemplo n.º 2
0
        public HomeViewModel(User user, bool resumeGame = false)
        {
            users = serializationActions.DeserializeUsers(Constants.UsersFile);
            words = serializationActions.DeserializeWords(Constants.WordsFile);
            foreach (var userInList in users.List)
            {
                if (userInList.Name == user.Name)
                {
                    users.List.Remove(userInList);
                    users.List.Add(user);
                    break;
                }
            }
            serializationActions.SerializeUsers(Constants.UsersFile, users);
            users     = serializationActions.DeserializeUsers(Constants.UsersFile);
            this.user = user;
            if (!resumeGame)
            {
                PickWord();
                CreateWordOnDisplay(user.GameProperty.WordToGuess);
                delay = 61;
            }
            else
            {
                switch (user.GameProperty.CategoryProperty)
                {
                case Models.Category.All:
                    AllIsSelected = true;
                    break;

                case Models.Category.Cars:
                    CarsIsSelected = true;
                    break;

                case Models.Category.Movies:
                    MoviesIsSelected = true;
                    break;

                case Models.Category.States:
                    StatesIsSelected = true;
                    break;

                case Models.Category.Mountains:
                    MountainsIsSelected = true;
                    break;

                case Models.Category.Rivers:
                    RiversIsSelected = true;
                    break;

                default:
                    break;
                }
                delay           = user.GameProperty.SecondsRemaining;
                firstCreation   = false;
                this.resumeGame = resumeGame;
            }
            HangImageSource = images.Hangs[user.GameProperty.MistakesProperty];
            timer.Tick     += new EventHandler(TimerTick);
            StartTimer(delay);
        }