From b5d4f9b9ce9f61eb45e833cdc4ce1a99155a6f21 Mon Sep 17 00:00:00 2001 From: Floris <f.k.h.vandezande@students.uu.nl> Date: Tue, 19 Nov 2024 21:31:38 +0100 Subject: [PATCH] PuzzleForm update added CreateUI(), UpdateUI(), couple adjustments to constructor method and members --- PuzzlePlayer/PuzzleForm.cs | 82 +++++++++++++++++++++++++++++++++--- PuzzlePlayer/PuzzlePlayer.cs | 2 +- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/PuzzlePlayer/PuzzleForm.cs b/PuzzlePlayer/PuzzleForm.cs index cf60bf8..5f8df87 100644 --- a/PuzzlePlayer/PuzzleForm.cs +++ b/PuzzlePlayer/PuzzleForm.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.Drawing.Text; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -9,15 +11,81 @@ namespace PuzzlePlayer_Namespace { internal class PuzzleForm : Form { - public Button solvebutton; - public Button hintbutton; - public Button generatebutton; - public TextBox informationbox; + private Button solvebutton; + private Button hintbutton; + private Button generatebutton; + private Label boardlabel; + private TextBox informationbox; + public Graphics graphics; + public Board board + { + get { return board; } + set + { + board = value; + //board.Draw(graphics, point, size); + } + } + + public PuzzleForm(Board b = null, Size s = default(Size)) + { + if (s == default(Size)) s = new Size(800, 500); + this.Size = s; + // board = b; + generatebutton = new Button(); + hintbutton = new Button(); + solvebutton = new Button(); + informationbox = new TextBox(); + CreateUI(); + UpdateUI(); + this.Resize += (object sender, EventArgs ea) => + { + UpdateUI(); + }; + } + private void CreateUI() + { + void CreateButton(Button b) + { + Controls.Add(b); + b.Size = new Size(80, 50); + b.BackColor = Color.Gainsboro; + b.Text = "DEFAULT0"; + } + CreateButton(generatebutton); + generatebutton.Text = "Generate"; + generatebutton.MouseClick += (object sender, MouseEventArgs mea) => + { + //board = Board.Generate(); + }; + CreateButton(hintbutton); + hintbutton.Text = "Hint"; + hintbutton.MouseClick += (object sender, MouseEventArgs mea) => + { + MessageBox.Show("Hint: geef op"); + }; + CreateButton(solvebutton); + solvebutton.Text = "Solve"; + solvebutton.MouseClick += (object sender, MouseEventArgs mea) => + { + //board = Board.Solve(board); + }; + + Controls.Add(informationbox); + informationbox.Multiline = true; + informationbox.Size = new Size(160, 400); + informationbox.BackColor = Color.LightGray; + informationbox.Text = $"DEFAULT1"; + //informationbox.Text = board.description; + //https://stackoverflow.com/questions/224236/adding-a-newline-into-a-string-in-c-sharp + } - private Board board; - public PuzzleForm(Board b) + private void UpdateUI() { - board = b; + generatebutton.Location = new Point(this.Width - 160, 30); + hintbutton.Location = new Point(this.Width - 160, 130); + solvebutton.Location = new Point(this.Width - 160, 230); + informationbox.Location = new Point(40, 30); } } } diff --git a/PuzzlePlayer/PuzzlePlayer.cs b/PuzzlePlayer/PuzzlePlayer.cs index 44011a4..3861f47 100644 --- a/PuzzlePlayer/PuzzlePlayer.cs +++ b/PuzzlePlayer/PuzzlePlayer.cs @@ -9,7 +9,7 @@ namespace PuzzlePlayer_Namespace { internal static void Main(string[] args) { - Application.Run(new MainForm()); + Application.Run(new PuzzleForm()); } } -- GitLab