From 512fc44e0f303fc62df408682244f7941f23bc5f Mon Sep 17 00:00:00 2001 From: maxluli Date: Wed, 25 Jan 2023 12:10:40 +0100 Subject: [PATCH] Started to setup the UI --- Caisses/Form1.Designer.cs | 240 ++++++++++++++++++++++++++++------- Caisses/Form1.cs | 84 +++++++++++- Caisses/GraphicalCheckout.cs | 2 +- Caisses/GraphicalClient.cs | 5 + Caisses/GraphicalStore.cs | 37 ++++++ 5 files changed, 317 insertions(+), 51 deletions(-) diff --git a/Caisses/Form1.Designer.cs b/Caisses/Form1.Designer.cs index 8595aaa..462b33f 100644 --- a/Caisses/Form1.Designer.cs +++ b/Caisses/Form1.Designer.cs @@ -31,9 +31,6 @@ this.components = new System.ComponentModel.Container(); this.pbxRayons = new System.Windows.Forms.PictureBox(); this.pbxCaisses = new System.Windows.Forms.PictureBox(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.btnAddTime = new System.Windows.Forms.Button(); - this.btnAddClients = new System.Windows.Forms.Button(); this.btnStartStop = new System.Windows.Forms.Button(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.lblTime = new System.Windows.Forms.Label(); @@ -45,11 +42,26 @@ this.tmrRefresh = new System.Windows.Forms.Timer(this.components); this.tmrDraw = new System.Windows.Forms.Timer(this.components); this.pbxWaitRoom = new System.Windows.Forms.PictureBox(); + this.pnlOptions = new System.Windows.Forms.Panel(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.trackBar1 = new System.Windows.Forms.TrackBar(); + this.trackBar2 = new System.Windows.Forms.TrackBar(); + this.label4 = new System.Windows.Forms.Label(); + this.trackBar3 = new System.Windows.Forms.TrackBar(); + this.label5 = new System.Windows.Forms.Label(); + this.btnAdd5Clients = new System.Windows.Forms.Button(); + this.btnAddOneHour = new System.Windows.Forms.Button(); + this.btnEmptyStore = new System.Windows.Forms.Button(); + this.btnEmptyWaitingRoom = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).BeginInit(); - this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbxWaitRoom)).BeginInit(); + this.pnlOptions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit(); this.SuspendLayout(); // // pbxRayons @@ -72,42 +84,14 @@ this.pbxCaisses.TabStop = false; this.pbxCaisses.Click += new System.EventHandler(this.pbxCaisses_Click); // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.btnAddTime); - this.groupBox1.Controls.Add(this.btnAddClients); - this.groupBox1.Controls.Add(this.btnStartStop); - this.groupBox1.Location = new System.Drawing.Point(1696, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 125); - this.groupBox1.TabIndex = 2; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "controls"; - // - // btnAddTime - // - this.btnAddTime.Location = new System.Drawing.Point(6, 91); - this.btnAddTime.Name = "btnAddTime"; - this.btnAddTime.Size = new System.Drawing.Size(188, 29); - this.btnAddTime.TabIndex = 5; - this.btnAddTime.Text = "Passer une heure"; - this.btnAddTime.UseVisualStyleBackColor = true; - // - // btnAddClients - // - this.btnAddClients.Location = new System.Drawing.Point(6, 56); - this.btnAddClients.Name = "btnAddClients"; - this.btnAddClients.Size = new System.Drawing.Size(188, 29); - this.btnAddClients.TabIndex = 4; - this.btnAddClients.Text = "Ajouter 5 clients"; - this.btnAddClients.UseVisualStyleBackColor = true; - // // btnStartStop // - this.btnStartStop.Location = new System.Drawing.Point(6, 21); + this.btnStartStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStartStop.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnStartStop.ForeColor = System.Drawing.Color.White; + this.btnStartStop.Location = new System.Drawing.Point(7, 278); this.btnStartStop.Name = "btnStartStop"; - this.btnStartStop.Size = new System.Drawing.Size(188, 29); + this.btnStartStop.Size = new System.Drawing.Size(474, 43); this.btnStartStop.TabIndex = 3; this.btnStartStop.Text = "Start"; this.btnStartStop.UseVisualStyleBackColor = true; @@ -115,14 +99,14 @@ // // groupBox2 // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.BackColor = System.Drawing.Color.Transparent; this.groupBox2.Controls.Add(this.lblTime); this.groupBox2.Controls.Add(this.lblAvgWaitingTime); this.groupBox2.Controls.Add(this.lblClients); this.groupBox2.Controls.Add(this.lblAvaiblePlaces); this.groupBox2.Controls.Add(this.lblClientsWithoutCheckout); this.groupBox2.Controls.Add(this.label1); - this.groupBox2.Location = new System.Drawing.Point(1696, 138); + this.groupBox2.Location = new System.Drawing.Point(0, 0); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(200, 120); this.groupBox2.TabIndex = 6; @@ -195,6 +179,7 @@ // // pbxWaitRoom // + this.pbxWaitRoom.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(79)))), ((int)(((byte)(79)))), ((int)(((byte)(79))))); this.pbxWaitRoom.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pbxWaitRoom.Location = new System.Drawing.Point(0, 306); this.pbxWaitRoom.Name = "pbxWaitRoom"; @@ -203,26 +188,182 @@ this.pbxWaitRoom.TabStop = false; this.pbxWaitRoom.Click += new System.EventHandler(this.pbxWaitRoom_Click); // + // pnlOptions + // + this.pnlOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.pnlOptions.Controls.Add(this.btnEmptyWaitingRoom); + this.pnlOptions.Controls.Add(this.btnEmptyStore); + this.pnlOptions.Controls.Add(this.btnAddOneHour); + this.pnlOptions.Controls.Add(this.btnAdd5Clients); + this.pnlOptions.Controls.Add(this.trackBar3); + this.pnlOptions.Controls.Add(this.label5); + this.pnlOptions.Controls.Add(this.btnStartStop); + this.pnlOptions.Controls.Add(this.trackBar2); + this.pnlOptions.Controls.Add(this.label4); + this.pnlOptions.Controls.Add(this.trackBar1); + this.pnlOptions.Controls.Add(this.label3); + this.pnlOptions.Controls.Add(this.label2); + this.pnlOptions.Location = new System.Drawing.Point(989, 0); + this.pnlOptions.Name = "pnlOptions"; + this.pnlOptions.Size = new System.Drawing.Size(492, 525); + this.pnlOptions.TabIndex = 8; + this.pnlOptions.Visible = false; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("Microsoft YaHei UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label2.Location = new System.Drawing.Point(211, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(102, 30); + this.label2.TabIndex = 0; + this.label2.Text = "Options"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(3, 57); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(94, 23); + this.label3.TabIndex = 1; + this.label3.Text = "Checkouts"; + // + // trackBar1 + // + this.trackBar1.Location = new System.Drawing.Point(7, 83); + this.trackBar1.Maximum = 20; + this.trackBar1.Minimum = 1; + this.trackBar1.Name = "trackBar1"; + this.trackBar1.Size = new System.Drawing.Size(474, 56); + this.trackBar1.TabIndex = 2; + this.trackBar1.Value = 10; + // + // trackBar2 + // + this.trackBar2.LargeChange = 1; + this.trackBar2.Location = new System.Drawing.Point(7, 149); + this.trackBar2.Maximum = 4; + this.trackBar2.Minimum = 1; + this.trackBar2.Name = "trackBar2"; + this.trackBar2.Size = new System.Drawing.Size(474, 56); + this.trackBar2.TabIndex = 4; + this.trackBar2.Value = 1; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label4.Location = new System.Drawing.Point(3, 123); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(149, 23); + this.label4.TabIndex = 3; + this.label4.Text = "Clients multiplier"; + // + // trackBar3 + // + this.trackBar3.LargeChange = 1; + this.trackBar3.Location = new System.Drawing.Point(7, 216); + this.trackBar3.Maximum = 30; + this.trackBar3.Minimum = 5; + this.trackBar3.Name = "trackBar3"; + this.trackBar3.Size = new System.Drawing.Size(474, 56); + this.trackBar3.TabIndex = 6; + this.trackBar3.Value = 10; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label5.Location = new System.Drawing.Point(3, 190); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(132, 23); + this.label5.TabIndex = 5; + this.label5.Text = "Crossover time"; + // + // btnAdd5Clients + // + this.btnAdd5Clients.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAdd5Clients.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAdd5Clients.ForeColor = System.Drawing.Color.White; + this.btnAdd5Clients.Location = new System.Drawing.Point(7, 327); + this.btnAdd5Clients.Name = "btnAdd5Clients"; + this.btnAdd5Clients.Size = new System.Drawing.Size(474, 43); + this.btnAdd5Clients.TabIndex = 7; + this.btnAdd5Clients.Text = "Add 5 clients"; + this.btnAdd5Clients.UseVisualStyleBackColor = true; + this.btnAdd5Clients.Click += new System.EventHandler(this.btnAdd5Clients_Click); + // + // btnAddOneHour + // + this.btnAddOneHour.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnAddOneHour.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAddOneHour.ForeColor = System.Drawing.Color.White; + this.btnAddOneHour.Location = new System.Drawing.Point(7, 376); + this.btnAddOneHour.Name = "btnAddOneHour"; + this.btnAddOneHour.Size = new System.Drawing.Size(474, 43); + this.btnAddOneHour.TabIndex = 8; + this.btnAddOneHour.Text = "Add 1 Hour"; + this.btnAddOneHour.UseVisualStyleBackColor = true; + // + // btnEmptyStore + // + this.btnEmptyStore.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnEmptyStore.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnEmptyStore.ForeColor = System.Drawing.Color.White; + this.btnEmptyStore.Location = new System.Drawing.Point(7, 425); + this.btnEmptyStore.Name = "btnEmptyStore"; + this.btnEmptyStore.Size = new System.Drawing.Size(474, 43); + this.btnEmptyStore.TabIndex = 9; + this.btnEmptyStore.Text = "Empty the store"; + this.btnEmptyStore.UseVisualStyleBackColor = true; + this.btnEmptyStore.Click += new System.EventHandler(this.btnEmptyStore_Click); + // + // btnEmptyWaitingRoom + // + this.btnEmptyWaitingRoom.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnEmptyWaitingRoom.Font = new System.Drawing.Font("Microsoft YaHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnEmptyWaitingRoom.ForeColor = System.Drawing.Color.White; + this.btnEmptyWaitingRoom.Location = new System.Drawing.Point(7, 474); + this.btnEmptyWaitingRoom.Name = "btnEmptyWaitingRoom"; + this.btnEmptyWaitingRoom.Size = new System.Drawing.Size(474, 43); + this.btnEmptyWaitingRoom.TabIndex = 10; + this.btnEmptyWaitingRoom.Text = "Empty waiting room"; + this.btnEmptyWaitingRoom.UseVisualStyleBackColor = true; + this.btnEmptyWaitingRoom.Click += new System.EventHandler(this.btnEmptyWaitingRoom_Click); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1902, 1033); + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + this.ClientSize = new System.Drawing.Size(1482, 835); + this.ControlBox = false; + this.Controls.Add(this.pnlOptions); this.Controls.Add(this.pbxWaitRoom); this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); this.Controls.Add(this.pbxCaisses); this.Controls.Add(this.pbxRayons); + this.ForeColor = System.Drawing.Color.White; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.ImeMode = System.Windows.Forms.ImeMode.NoControl; this.Name = "Form1"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); + this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress); + this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseDown); this.Resize += new System.EventHandler(this.Form1_Resize); ((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).EndInit(); - this.groupBox1.ResumeLayout(false); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbxWaitRoom)).EndInit(); + this.pnlOptions.ResumeLayout(false); + this.pnlOptions.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit(); this.ResumeLayout(false); } @@ -231,9 +372,6 @@ private System.Windows.Forms.PictureBox pbxRayons; private System.Windows.Forms.PictureBox pbxCaisses; - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.Button btnAddTime; - private System.Windows.Forms.Button btnAddClients; private System.Windows.Forms.Button btnStartStop; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label lblTime; @@ -245,6 +383,18 @@ private System.Windows.Forms.Timer tmrRefresh; private System.Windows.Forms.Timer tmrDraw; private System.Windows.Forms.PictureBox pbxWaitRoom; + private System.Windows.Forms.Panel pnlOptions; + private System.Windows.Forms.TrackBar trackBar3; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TrackBar trackBar2; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TrackBar trackBar1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button btnEmptyWaitingRoom; + private System.Windows.Forms.Button btnEmptyStore; + private System.Windows.Forms.Button btnAddOneHour; + private System.Windows.Forms.Button btnAdd5Clients; } } diff --git a/Caisses/Form1.cs b/Caisses/Form1.cs index 939dbfd..4c9cd23 100644 --- a/Caisses/Form1.cs +++ b/Caisses/Form1.cs @@ -4,6 +4,7 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,15 +13,28 @@ namespace Caisses { public partial class Form1 : Form { + // for the drag and drop of the form + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HT_CAPTION = 0x2; + [DllImportAttribute("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + [DllImportAttribute("user32.dll")] + public static extern bool ReleaseCapture(); + // for the drag and drop of the form + GraphicalStore store; public Form1() { InitializeComponent(); DoubleBuffered = true; - store = new GraphicalStore(10,12,pbxCaisses.Size); + store = new GraphicalStore(10, 12, pbxCaisses.Size); } private void btnStartStop_Click(object sender, EventArgs e) + { + StartSimulation(); + } + public void StartSimulation() { if (tmrRefresh.Enabled) { @@ -34,7 +48,6 @@ namespace Caisses tmrDraw.Start(); btnStartStop.Text = "Stop"; } - } private void tmrRefresh_Tick(object sender, EventArgs e) @@ -44,7 +57,7 @@ namespace Caisses private void tmrDraw_Tick(object sender, EventArgs e) { - List result = store.Draw(pbxRayons.Size,pbxWaitRoom.Size,pbxCaisses.Size); + List result = store.Draw(pbxRayons.Size, pbxWaitRoom.Size, pbxCaisses.Size); if (pbxRayons.Image != null) { pbxRayons.Image.Dispose(); @@ -62,15 +75,20 @@ namespace Caisses pbxCaisses.Image = result[2]; lblClients.Text = "Clients : " + store.Clients.Count(); - lblClientsWithoutCheckout.Text = "Clients without checkout : "+ store.WaitingClients.Count(); + lblClientsWithoutCheckout.Text = "Clients without checkout : " + store.WaitingClients.Count(); lblAvaiblePlaces.Text = "Avaible places = " + store.TotalPlacesLeftCount; lblAvgWaitingTime.Text = "AverageWaitingTime = " + store.AverageWaitingTime; - lblTime.Text = "Time of the day : "+store.TimeOfTheDayInHours + ":"+store.TimeOfTheDayInMinuts % 60; + lblTime.Text = "Time of the day : " + store.TimeOfTheDayInHours + ":" + store.TimeOfTheDayInMinuts % 60; } private void Form1_Load(object sender, EventArgs e) { ResizeCanvas(); + pbxCaisses.MouseDown += Form1_MouseDown; + pbxRayons.MouseDown += Form1_MouseDown; + pbxWaitRoom.MouseDown += Form1_MouseDown; + + this.KeyPreview = true; } private void pbxWaitRoom_Click(object sender, EventArgs e) @@ -94,12 +112,68 @@ namespace Caisses } private void ResizeCanvas() { + /* pbxRayons.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 5.0)); pbxRayons.Location = new Point(0, 0); pbxWaitRoom.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 2.0)); pbxWaitRoom.Location = new Point(0, pbxRayons.Height); pbxCaisses.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 3.0)); pbxCaisses.Location = new Point(0, pbxWaitRoom.Location.Y + pbxWaitRoom.Height); + */ + pbxRayons.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 7.0)); + pbxRayons.Location = new Point(0, 0); + + pbxWaitRoom.Size = new Size(this.Width / 6, this.Height / 3); + pbxWaitRoom.Location = new Point(this.Width - pbxWaitRoom.Width, 0); + + pbxCaisses.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 3.0)); + pbxCaisses.Location = new Point(0, pbxRayons.Height); + } + + private void Form1_KeyPress(object sender, KeyPressEventArgs e) + { + if (e.KeyChar == 'f' || e.KeyChar == 'F') + { + //We need to put the form in fullScreen + if (this.WindowState == FormWindowState.Normal) + { + this.WindowState = FormWindowState.Maximized; + } + else + { + this.WindowState = FormWindowState.Normal; + } + } + if (e.KeyChar == (char)Keys.Escape) + Application.Exit(); + if (e.KeyChar == 'o' || e.KeyChar == 'O') + pnlOptions.Visible = !pnlOptions.Visible; + if (e.KeyChar == (char)Keys.Space) + StartSimulation(); + } + + private void Form1_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + ReleaseCapture(); + SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); + } + } + + private void btnAdd5Clients_Click(object sender, EventArgs e) + { + store.AddClients(5); + } + + private void btnEmptyStore_Click(object sender, EventArgs e) + { + store.ClearStore(); + } + + private void btnEmptyWaitingRoom_Click(object sender, EventArgs e) + { + store.ClearWaitingRoom(); } } } diff --git a/Caisses/GraphicalCheckout.cs b/Caisses/GraphicalCheckout.cs index ed5a7ae..47741bd 100644 --- a/Caisses/GraphicalCheckout.cs +++ b/Caisses/GraphicalCheckout.cs @@ -24,7 +24,7 @@ namespace Caisses } public void Draw(Bitmap checkoutAreaImage,int checkoutNumber, int checkoutId) { - Size = new Size(checkoutAreaImage.Width / checkoutNumber + 1, checkoutAreaImage.Height - checkoutAreaImage.Height / 20); + Size = new Size(checkoutAreaImage.Width / checkoutNumber + 1, checkoutAreaImage.Height - checkoutAreaImage.Height / 10); Position = new Point(checkoutId * Size.Width, 0); int radius = Math.Min(Size.Width, Size.Height / MAX_CAPACITY); Size clientSize = new Size(radius,radius); diff --git a/Caisses/GraphicalClient.cs b/Caisses/GraphicalClient.cs index cbf78d1..96b06d9 100644 --- a/Caisses/GraphicalClient.cs +++ b/Caisses/GraphicalClient.cs @@ -44,6 +44,11 @@ namespace Caisses //base.Tick(); Position = checkBounds(Position, StoreArea, WaitingRoomArea); Color = Color.FromArgb(ShoppingTime * 2, 0, 0); + + if (State == ClientState.Waiting) + { + Speed = new PointF(Speed.X + WaitingTime / 100f,Speed.Y + WaitingTime / 100f); + } } public void Draw(Bitmap storeImage, Bitmap waitingRoomImage) { diff --git a/Caisses/GraphicalStore.cs b/Caisses/GraphicalStore.cs index 1c17ac6..770a2e8 100644 --- a/Caisses/GraphicalStore.cs +++ b/Caisses/GraphicalStore.cs @@ -233,6 +233,43 @@ namespace Caisses } return result; } + public void AddClients(int amount) + { + for (int i = 0; i < amount; i++) + { + Clients.Add(new GraphicalClient(new Point(0,0),rnd)); + } + } + public void ClearStore() + { + List clientsToRemove = new List(); + foreach (GraphicalClient client in Clients) + { + if (client.State == Client.ClientState.Shopping) + { + clientsToRemove.Add(client); + } + } + foreach (GraphicalClient client in clientsToRemove) + { + Clients.Remove(client); + } + } + public void ClearWaitingRoom() + { + List clientsToRemove = new List(); + foreach (GraphicalClient client in Clients) + { + if (client.State == Client.ClientState.Waiting) + { + clientsToRemove.Add(client); + } + } + foreach (GraphicalClient client in clientsToRemove) + { + Clients.Remove(client); + } + } } }