public MinesweeperWindow(string mode, MainWindow main_window) { main_window.Close(); InitializeComponent(); game = new Field(); game.StartSession(mode); buttons = new Button[game.GetRows(), game.GetCols()]; flagged = new bool[game.GetRows(), game.GetCols()]; this.Height = game.GetRows() * CELL_SIZE; this.Width = game.GetCols() * CELL_SIZE; GRID_VAR.Rows = game.GetRows(); GRID_VAR.Columns = game.GetCols(); GRID_VAR.Height = game.GetRows() * CELL_SIZE; GRID_VAR.Width = game.GetCols() * CELL_SIZE; for (int i = 0; i < game.GetRows(); i++) { for (int j = 0; j < game.GetCols(); j++) { System.Windows.Controls.Button newBtn = new Button(); newBtn.Content = ""; newBtn.Name = ("B" + (i * game.GetCols() + j)).ToString(); newBtn.Click += Button_Click; newBtn.MouseRightButtonUp += RightClick; newBtn.MouseDoubleClick += DoubleClick; //newBtn.Width = CELL_SIZE; //newBtn.Height = CELL_SIZE; newBtn.BorderBrush = Brushes.Black; newBtn.BorderThickness = new Thickness(0.5); GRID_VAR.Children.Add(newBtn); buttons[i, j] = newBtn; flagged[i, j] = false; } } timer = new DispatcherTimer(); timer.Tick += UpdateTime; timer.Interval = new TimeSpan(0, 0, 0, 0, 1000); //this.MaxWidth = this.MinWidth = this.Width; //this.MaxHeight = this.MinHeight = this.Height; UpdateWindow(); TIME.Text = secCounter.ToString("000"); }