diff options
Diffstat (limited to 'MainForm.cs')
| -rw-r--r-- | MainForm.cs | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/MainForm.cs b/MainForm.cs index 724f259..012b47f 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -1,45 +1,50 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace Chess -{ - public partial class MainForm : Form - { - private ChessBoard board; - - public MainForm() - { - InitializeComponent(); - } - - private void FitBoardContainerToScreen() - { - this.chessBoardBitmap.Location = new Point(0, 0); - this.chessBoardBitmap.Size = new Size(this.ClientSize.Width, this.ClientSize.Height); - } - - private void MainForm_Load(object sender, EventArgs e) - { - FitBoardContainerToScreen(); - this.board = new ChessBoard(this.chessBoardBitmap); - } - - private void MainForm_Resize(object sender, EventArgs e) - { - FitBoardContainerToScreen(); - this.board.HandleResize(); - } - - private void chessBoardBitmap_MouseClick(object sender, MouseEventArgs e) - { - this.board.SelectTile(this.board.MouseToTilePosition(e.X, e.Y)); - } - } -} +using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Chess
+{
+ public partial class MainForm : Form
+ {
+ private Game game;
+
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+
+ private void FitBoardContainerToScreen()
+ {
+ this.columnHeader1.Width = 30;
+
+ this.chessBoardBitmap.Location = new Point(0, 0);
+ this.chessBoardBitmap.Size = new Size(this.ClientSize.Width - this.gameControlPanel.Width, this.ClientSize.Height);
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ FitBoardContainerToScreen();
+ this.game = new Game(this);
+ }
+
+ private void MainForm_Resize(object sender, EventArgs e)
+ {
+ var form = sender as MainForm;
+ if (form.WindowState == FormWindowState.Minimized) return;
+
+ FitBoardContainerToScreen();
+ this.game.HandleResize();
+ }
+
+ private void chessBoardBitmap_MouseDown(object sender, MouseEventArgs e)
+ {
+ this.game.HandleClick(e.X, e.Y);
+ }
+ }
+}
|
