Esempio n. 1
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            CategoryWindow cw = new CategoryWindow();

            cw.CallbackAction = async() => { await LoadData(); };
            cw.Show();
        }
Esempio n. 2
0
        private void addCategoryBtn(object sender, RoutedEventArgs e)
        {
            CategoryWindow categoryWindow = new CategoryWindow();

            categoryWindow.Closed += new EventHandler(categoryWindow_Closed);
            categoryWindow.Show();
        }
Esempio n. 3
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            Category       c  = ((FrameworkElement)sender).DataContext as Category;
            CategoryWindow cw = new CategoryWindow();

            cw.SetCategoryId(c.CategoryId);
            cw.CallbackAction = async() => { await LoadData(); };
            cw.Show();
        }
Esempio n. 4
0
        public void NewGame(object param)
        {
            user.GameProperty = new Game();
            CategoryWindow    window     = new CategoryWindow();
            CategoryViewModel categoryVM = new CategoryViewModel(user);

            window.DataContext = categoryVM;
            App.Current.MainWindow.Close();
            App.Current.MainWindow = window;
            window.Show();
        }
Esempio n. 5
0
        public void AddUserAndPlay(object param)
        {
            if (!HangmanValidators.CanAddUser(NameTextBox, users))
            {
                MessageBox.Show("This nickname is taken.");
                return;
            }
            int  imageIndex = images.Emojis.IndexOf(ImageSource);
            User user       = new User(NameTextBox, imageIndex);

            user.GameProperty = new Game();
            users.List.Add(new User(NameTextBox, imageIndex));
            serializationActions.SerializeUsers(Constants.UsersFile, users);
            CategoryWindow    categoryWindow = new CategoryWindow();
            CategoryViewModel categoryVM     = new CategoryViewModel(user, true);

            categoryWindow.DataContext = categoryVM;
            App.Current.MainWindow.Close();
            App.Current.MainWindow = categoryWindow;
            categoryWindow.Show();
        }
Esempio n. 6
0
        private void ShowMessageBox(string title, string details, MessageBoxImage messageBoxImage)
        {
            StopTimer();
            MessageBoxResult messageBoxResult = MessageBox.Show(details, title, MessageBoxButton.YesNo, messageBoxImage);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                Level = user.GameProperty.LevelProperty = 1;
                ReloadGame();
            }
            else
            {
                user.GameProperty.MistakesProperty = 0;
                user.GameProperty.LevelProperty    = 1;
                CategoryWindow    categoryWindow = new CategoryWindow();
                CategoryViewModel categoryVM     = new CategoryViewModel(user);
                categoryWindow.DataContext = categoryVM;
                App.Current.MainWindow.Close();
                App.Current.MainWindow = categoryWindow;
                categoryWindow.Show();
            }
        }
Esempio n. 7
0
        void category_Button_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var categoryWindow = new CategoryWindow();

            categoryWindow.Show();
        }
Esempio n. 8
0
        private void addCategory(object sender, EventArgs e)
        {
            CategoryWindow category = new CategoryWindow();

            category.Show();
        }
Esempio n. 9
0
        public void NewPressed(object param)
        {
            int seconds = (deadline - DateTime.Now).Seconds;

            StopTimer();
            MessageBoxResult messageBoxResult = MessageBox.Show("If you start a new game this game will count as lost.\nAre you sure you want to start a new game?", "New game", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                user.GameProperty.MistakesProperty = 0;
                user.GameProperty.LevelProperty    = 1;
                switch (user.GameProperty.CategoryProperty)
                {
                case Category.All:
                    user.StatisticsProperty.LostGamesAll += 1;
                    break;

                case Category.Cars:
                    user.StatisticsProperty.LostGamesCars += 1;
                    break;

                case Category.Movies:
                    user.StatisticsProperty.LostGamesMovies += 1;
                    break;

                case Category.States:
                    user.StatisticsProperty.LostGamesStates += 1;
                    break;

                case Category.Mountains:
                    user.StatisticsProperty.LostGamesMountains += 1;
                    break;

                case Category.Rivers:
                    user.StatisticsProperty.LostGamesRivers += 1;
                    break;

                default:
                    break;
                }
                foreach (var userInList in users.List)
                {
                    if (userInList.Name == user.Name)
                    {
                        userInList.StatisticsProperty = user.StatisticsProperty;
                        if (resumeGame)
                        {
                            userInList.GameProperty = new Game();
                        }
                    }
                }
                serializationActions.SerializeUsers(Constants.UsersFile, users);
                CategoryWindow    categoryWindow = new CategoryWindow();
                CategoryViewModel categoryVM     = new CategoryViewModel(user);
                categoryWindow.DataContext = categoryVM;
                App.Current.MainWindow.Close();
                App.Current.MainWindow = categoryWindow;
                categoryWindow.Show();
            }
            else
            {
                StartTimer(seconds);
            }
        }