From f6f3bbbc5b7741ad0db3c88a398cfc3943988529 Mon Sep 17 00:00:00 2001 From: "Ramaekers,Aldrik A.N" Date: Wed, 16 Sep 2020 09:42:04 +0200 Subject: work --- MainForm.cs | 95 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 45 deletions(-) (limited to 'MainForm.cs') 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); + } + } +} -- cgit v1.2.3-70-g09d2