Esempio n. 1
0
        private void FirstUpdate(ForMiner new_game, bool isHard)
        //процедура первого обновления, заполняющая grid объектами классов Rectangle и Label

        {
            Grid current;

            if (isHard)
            {
                current = hard;
            }
            else
            {
                current = easy;
            }

            for (int i = 0; i < new_game.Size; i++)
            {
                current.Children.Add(rects[i]);
                Grid.SetColumn(rects[i], i % new_game.Num);
                Grid.SetRow(rects[i], i / new_game.Num);
                current.Children.Add(vals[i]);
                Grid.SetColumn(vals[i], i % new_game.Num);
                Grid.SetRow(vals[i], i / new_game.Num);
            }
        }
Esempio n. 2
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            MasterMode             = (bool)masterMode.IsChecked;
            game                   = new ForMiner(MasterMode);
            image.Visibility       = Visibility.Hidden;
            title.Visibility       = Visibility.Hidden;
            masterMode.Visibility  = Visibility.Hidden;
            startButton.Visibility = Visibility.Hidden;
            retryButton.Visibility = Visibility.Visible;
            time.Visibility        = Visibility.Visible;
            time1.Visibility       = Visibility.Visible;
            timer                  = new System.Windows.Threading.DispatcherTimer();

            timer.Tick += new EventHandler(timerTick);
            timer.Start();
            if (MasterMode)
            {
                easy.Visibility = Visibility.Hidden;
            }
            else
            {
                hard.Visibility = Visibility.Hidden;
            }
            newGame();
        }
Esempio n. 3
0
        private void newGame()
        {
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Start();
            time.Content = "0";
            if (rects != null)
            {
                rects.Clear();
            }
            if (game != null)
            {
                game.Clear();
            }
            if (vals != null)
            {
                vals.Clear();
            }
            game  = new ForMiner(MasterMode);
            rects = new List <Rectangle>();
            vals  = new List <Label>();
            SolidColorBrush brush  = new SolidColorBrush(Colors.Gray);
            SolidColorBrush stroke = new SolidColorBrush(Colors.Black);

            for (int i = 0; i < game.Size; i++)
            {
                Label val = new Label();
                val.HorizontalAlignment = HorizontalAlignment.Center;
                val.VerticalAlignment   = VerticalAlignment.Center;
                if (MasterMode)
                {
                    val.FontSize = 22;
                }
                else
                {
                    val.FontSize = 45;
                }
                val.FontFamily = new System.Windows.Media.FontFamily("Symbol");
                val.FontWeight = FontWeights.Bold;
                val.Content    = "";
                Rectangle empty_rec = new Rectangle();
                empty_rec.Fill   = brush;
                empty_rec.Stroke = stroke;

                vals.Add(val);
                rects.Add(empty_rec);
            }
            FirstUpdate(game, MasterMode);
            for (int i = 0; i < game.Size; i++)
            {
                this.rects[i].MouseLeftButtonDown  += new MouseButtonEventHandler(GridCtrl_MouseDown1);
                this.rects[i].MouseRightButtonDown += new MouseButtonEventHandler(GridCtrl_MouseDown2);
                this.vals[i].MouseRightButtonDown  += new MouseButtonEventHandler(GridCtrl_MouseDown3);
                this.vals[i].MouseLeftButtonDown   += new MouseButtonEventHandler(GridCtrl_MouseDown4);
            }
        }