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"); }
//private User user; public SignUpViewModel() { ImageSource = images.Emojis.ElementAt(0); try { FileStream fileUsr = new FileStream(Constants.UsersFile, FileMode.Open); fileUsr.Dispose(); } catch (FileNotFoundException) { return; } this.users = serializationActions.DeserializeUsers(Constants.UsersFile); }
public SignIn() { InitializeComponent(); DataContext = actions.DeserializeUsers("User.xml"); }
public SignUpViewModel() { ImageSource = images.ImagesList.ElementAt(0); signInVM = actions.DeserializeUsers("User.xml"); }
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); }
public SignInViewModel() { this.users = serializationActions.DeserializeUsers(Constants.UsersFile); ImageSource = users.List.Count > 0 ? new BitmapImage(new Uri(images.Emojis.ElementAt(users.List[0].ImageIndex).UriSource.ToString(), UriKind.Relative)) : new BitmapImage(new Uri(@"/Assets/Emojis/Emoji_1.png", UriKind.Relative)); }