diff --git a/Caisses/Checkout.cs b/Caisses/Checkout.cs index 70b4a97..325141a 100644 --- a/Caisses/Checkout.cs +++ b/Caisses/Checkout.cs @@ -23,7 +23,7 @@ namespace Caisses } public void Tick(GraphicalStore store) { - if (!Open && store.AverageWaitingTime > GraphicalStore.CROSSOVER_TIME && store.GetEmptyCheckoutCount() == 0 || store.OpenCheckoutCount == 0 || store.WaitingClients.Count > MAX_CAPACITY * 2 && store.GetEmptyCheckoutCount() == 0) + if (!Open && store.AverageWaitingTime > store.CrossoverTime && store.GetEmptyCheckoutCount() == 0 || store.OpenCheckoutCount == 0 || store.WaitingClients.Count > MAX_CAPACITY * 2 && store.GetEmptyCheckoutCount() == 0) { Open = true; } diff --git a/Caisses/Form1.Designer.cs b/Caisses/Form1.Designer.cs index 462b33f..959f21b 100644 --- a/Caisses/Form1.Designer.cs +++ b/Caisses/Form1.Designer.cs @@ -32,36 +32,46 @@ this.pbxRayons = new System.Windows.Forms.PictureBox(); this.pbxCaisses = new System.Windows.Forms.PictureBox(); this.btnStartStop = new System.Windows.Forms.Button(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.lblTime = new System.Windows.Forms.Label(); this.lblAvgWaitingTime = new System.Windows.Forms.Label(); this.lblClients = new System.Windows.Forms.Label(); this.lblAvaiblePlaces = new System.Windows.Forms.Label(); this.lblClientsWithoutCheckout = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.lblCrossoverTime = new System.Windows.Forms.Label(); + this.lblTime = new System.Windows.Forms.Label(); 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(); + this.btnEmptyStore = new System.Windows.Forms.Button(); + this.btnAddOneHour = new System.Windows.Forms.Button(); + this.btnAdd5Clients = new System.Windows.Forms.Button(); + this.trckCrossover = new System.Windows.Forms.TrackBar(); + this.label5 = new System.Windows.Forms.Label(); + this.trckClients = new System.Windows.Forms.TrackBar(); + this.label4 = new System.Windows.Forms.Label(); + this.trckCheckouts = new System.Windows.Forms.TrackBar(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.pnlInfos = new System.Windows.Forms.Panel(); + this.label6 = new System.Windows.Forms.Label(); + this.pnlControls = new System.Windows.Forms.Panel(); + this.lbl = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).BeginInit(); - 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(); + ((System.ComponentModel.ISupportInitialize)(this.trckCrossover)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trckClients)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.trckCheckouts)).BeginInit(); + this.pnlInfos.SuspendLayout(); + this.pnlControls.SuspendLayout(); this.SuspendLayout(); // // pbxRayons @@ -97,75 +107,66 @@ this.btnStartStop.UseVisualStyleBackColor = true; this.btnStartStop.Click += new System.EventHandler(this.btnStartStop_Click); // - // groupBox2 - // - 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(0, 0); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(200, 120); - this.groupBox2.TabIndex = 6; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "infos"; - // - // lblTime - // - this.lblTime.AutoSize = true; - this.lblTime.Location = new System.Drawing.Point(6, 98); - this.lblTime.Name = "lblTime"; - this.lblTime.Size = new System.Drawing.Size(139, 16); - this.lblTime.TabIndex = 5; - this.lblTime.Text = "Time of the day : 13:00"; - // // lblAvgWaitingTime // this.lblAvgWaitingTime.AutoSize = true; - this.lblAvgWaitingTime.Location = new System.Drawing.Point(6, 82); + this.lblAvgWaitingTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); + this.lblAvgWaitingTime.Location = new System.Drawing.Point(15, 173); this.lblAvgWaitingTime.Name = "lblAvgWaitingTime"; - this.lblAvgWaitingTime.Size = new System.Drawing.Size(117, 16); + this.lblAvgWaitingTime.Size = new System.Drawing.Size(196, 27); this.lblAvgWaitingTime.TabIndex = 4; - this.lblAvgWaitingTime.Text = "average wait : 0:03"; + this.lblAvgWaitingTime.Text = "Average wait : NaN"; // // lblClients // this.lblClients.AutoSize = true; - this.lblClients.Location = new System.Drawing.Point(6, 66); + this.lblClients.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); + this.lblClients.Location = new System.Drawing.Point(13, 146); this.lblClients.Name = "lblClients"; - this.lblClients.Size = new System.Drawing.Size(67, 16); + this.lblClients.Size = new System.Drawing.Size(128, 27); this.lblClients.TabIndex = 3; - this.lblClients.Text = "Clients: 50"; + this.lblClients.Text = "Clients: NaN"; // // lblAvaiblePlaces // this.lblAvaiblePlaces.AutoSize = true; - this.lblAvaiblePlaces.Location = new System.Drawing.Point(6, 50); + this.lblAvaiblePlaces.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); + this.lblAvaiblePlaces.Location = new System.Drawing.Point(13, 119); this.lblAvaiblePlaces.Name = "lblAvaiblePlaces"; - this.lblAvaiblePlaces.Size = new System.Drawing.Size(113, 16); + this.lblAvaiblePlaces.Size = new System.Drawing.Size(207, 27); this.lblAvaiblePlaces.TabIndex = 2; - this.lblAvaiblePlaces.Text = "Avaible places : 8"; + this.lblAvaiblePlaces.Text = "Avaible places : NaN"; // // lblClientsWithoutCheckout // this.lblClientsWithoutCheckout.AutoSize = true; - this.lblClientsWithoutCheckout.Location = new System.Drawing.Point(6, 34); + this.lblClientsWithoutCheckout.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); + this.lblClientsWithoutCheckout.Location = new System.Drawing.Point(15, 92); this.lblClientsWithoutCheckout.Name = "lblClientsWithoutCheckout"; - this.lblClientsWithoutCheckout.Size = new System.Drawing.Size(160, 16); + this.lblClientsWithoutCheckout.Size = new System.Drawing.Size(298, 27); this.lblClientsWithoutCheckout.TabIndex = 1; - this.lblClientsWithoutCheckout.Text = "Clients without checkout: 0"; + this.lblClientsWithoutCheckout.Text = "Clients without checkout: NaN"; // - // label1 + // lblCrossoverTime // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(6, 18); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(143, 16); - this.label1.TabIndex = 0; - this.label1.Text = "checkout opening : 10s"; + this.lblCrossoverTime.AutoSize = true; + this.lblCrossoverTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblCrossoverTime.Location = new System.Drawing.Point(15, 66); + this.lblCrossoverTime.Name = "lblCrossoverTime"; + this.lblCrossoverTime.Size = new System.Drawing.Size(246, 27); + this.lblCrossoverTime.TabIndex = 0; + this.lblCrossoverTime.Text = "Checkout opening : NaN"; + // + // lblTime + // + this.lblTime.AutoSize = true; + this.lblTime.BackColor = System.Drawing.Color.Transparent; + this.lblTime.Font = new System.Drawing.Font("Microsoft YaHei UI", 16.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblTime.Location = new System.Drawing.Point(12, 9); + this.lblTime.Name = "lblTime"; + this.lblTime.Size = new System.Drawing.Size(86, 36); + this.lblTime.TabIndex = 5; + this.lblTime.Text = "13:00"; // // tmrRefresh // @@ -195,12 +196,12 @@ 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.trckCrossover); this.pnlOptions.Controls.Add(this.label5); this.pnlOptions.Controls.Add(this.btnStartStop); - this.pnlOptions.Controls.Add(this.trackBar2); + this.pnlOptions.Controls.Add(this.trckClients); this.pnlOptions.Controls.Add(this.label4); - this.pnlOptions.Controls.Add(this.trackBar1); + this.pnlOptions.Controls.Add(this.trckCheckouts); this.pnlOptions.Controls.Add(this.label3); this.pnlOptions.Controls.Add(this.label2); this.pnlOptions.Location = new System.Drawing.Point(989, 0); @@ -209,116 +210,6 @@ 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; @@ -332,6 +223,231 @@ this.btnEmptyWaitingRoom.UseVisualStyleBackColor = true; this.btnEmptyWaitingRoom.Click += new System.EventHandler(this.btnEmptyWaitingRoom_Click); // + // 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); + // + // 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; + this.btnAddOneHour.Click += new System.EventHandler(this.btnAddOneHour_Click); + // + // 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); + // + // trckCrossover + // + this.trckCrossover.LargeChange = 1; + this.trckCrossover.Location = new System.Drawing.Point(7, 216); + this.trckCrossover.Maximum = 30; + this.trckCrossover.Minimum = 5; + this.trckCrossover.Name = "trckCrossover"; + this.trckCrossover.Size = new System.Drawing.Size(474, 56); + this.trckCrossover.TabIndex = 6; + this.trckCrossover.Value = 10; + this.trckCrossover.Scroll += new System.EventHandler(this.trckCrossover_Scroll); + // + // 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"; + // + // trckClients + // + this.trckClients.LargeChange = 1; + this.trckClients.Location = new System.Drawing.Point(7, 149); + this.trckClients.Maximum = 4; + this.trckClients.Minimum = 1; + this.trckClients.Name = "trckClients"; + this.trckClients.Size = new System.Drawing.Size(474, 56); + this.trckClients.TabIndex = 4; + this.trckClients.Value = 1; + this.trckClients.Scroll += new System.EventHandler(this.trckClients_Scroll); + // + // 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"; + // + // trckCheckouts + // + this.trckCheckouts.LargeChange = 1; + this.trckCheckouts.Location = new System.Drawing.Point(7, 83); + this.trckCheckouts.Maximum = 20; + this.trckCheckouts.Minimum = 1; + this.trckCheckouts.Name = "trckCheckouts"; + this.trckCheckouts.Size = new System.Drawing.Size(474, 56); + this.trckCheckouts.TabIndex = 2; + this.trckCheckouts.Value = 12; + this.trckCheckouts.Scroll += new System.EventHandler(this.trackBar1_Scroll); + // + // 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"; + // + // 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"; + // + // pnlInfos + // + this.pnlInfos.Controls.Add(this.lblAvgWaitingTime); + this.pnlInfos.Controls.Add(this.label6); + this.pnlInfos.Controls.Add(this.lblClients); + this.pnlInfos.Controls.Add(this.lblCrossoverTime); + this.pnlInfos.Controls.Add(this.lblAvaiblePlaces); + this.pnlInfos.Controls.Add(this.lblClientsWithoutCheckout); + this.pnlInfos.Location = new System.Drawing.Point(0, 57); + this.pnlInfos.Name = "pnlInfos"; + this.pnlInfos.Size = new System.Drawing.Size(330, 227); + this.pnlInfos.TabIndex = 9; + this.pnlInfos.Visible = false; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Font = new System.Drawing.Font("Microsoft YaHei UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label6.Location = new System.Drawing.Point(121, 26); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(68, 30); + this.label6.TabIndex = 11; + this.label6.Text = "Infos"; + // + // pnlControls + // + this.pnlControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.pnlControls.BackColor = System.Drawing.Color.Transparent; + this.pnlControls.Controls.Add(this.label12); + this.pnlControls.Controls.Add(this.label11); + this.pnlControls.Controls.Add(this.label10); + this.pnlControls.Controls.Add(this.label9); + this.pnlControls.Controls.Add(this.label8); + this.pnlControls.Controls.Add(this.label7); + this.pnlControls.Controls.Add(this.lbl); + this.pnlControls.Location = new System.Drawing.Point(1228, 591); + this.pnlControls.Name = "pnlControls"; + this.pnlControls.Size = new System.Drawing.Size(242, 232); + this.pnlControls.TabIndex = 10; + // + // lbl + // + this.lbl.AutoSize = true; + this.lbl.Font = new System.Drawing.Font("Microsoft YaHei UI", 13.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbl.Location = new System.Drawing.Point(64, 12); + this.lbl.Name = "lbl"; + this.lbl.Size = new System.Drawing.Size(107, 30); + this.lbl.TabIndex = 12; + this.lbl.Text = "Controls"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label7.Location = new System.Drawing.Point(3, 58); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(131, 27); + this.label7.TabIndex = 12; + this.label7.Text = "Space : Start"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label8.Location = new System.Drawing.Point(3, 85); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(133, 27); + this.label8.TabIndex = 13; + this.label8.Text = "Escape : exit "; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label9.Location = new System.Drawing.Point(3, 112); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(130, 27); + this.label9.TabIndex = 14; + this.label9.Text = "F : fullscreen"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label10.Location = new System.Drawing.Point(3, 139); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(117, 27); + this.label10.TabIndex = 15; + this.label10.Text = "O : options"; + // + // label11 + // + this.label11.AutoSize = true; + this.label11.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label11.Location = new System.Drawing.Point(3, 166); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(82, 27); + this.label11.TabIndex = 16; + this.label11.Text = "I : Infos"; + // + // label12 + // + this.label12.AutoSize = true; + this.label12.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label12.Location = new System.Drawing.Point(3, 193); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(132, 27); + this.label12.TabIndex = 17; + this.label12.Text = "X : Close this"; + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); @@ -339,14 +455,15 @@ 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.pnlControls); + this.Controls.Add(this.pnlInfos); + this.Controls.Add(this.lblTime); this.Controls.Add(this.pnlOptions); this.Controls.Add(this.pbxWaitRoom); - this.Controls.Add(this.groupBox2); 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"; @@ -356,15 +473,18 @@ this.Resize += new System.EventHandler(this.Form1_Resize); ((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).EndInit(); - 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(); + ((System.ComponentModel.ISupportInitialize)(this.trckCrossover)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trckClients)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.trckCheckouts)).EndInit(); + this.pnlInfos.ResumeLayout(false); + this.pnlInfos.PerformLayout(); + this.pnlControls.ResumeLayout(false); + this.pnlControls.PerformLayout(); this.ResumeLayout(false); + this.PerformLayout(); } @@ -373,28 +493,37 @@ private System.Windows.Forms.PictureBox pbxRayons; private System.Windows.Forms.PictureBox pbxCaisses; private System.Windows.Forms.Button btnStartStop; - private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.Label lblTime; private System.Windows.Forms.Label lblAvgWaitingTime; private System.Windows.Forms.Label lblClients; private System.Windows.Forms.Label lblAvaiblePlaces; private System.Windows.Forms.Label lblClientsWithoutCheckout; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label lblCrossoverTime; 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.TrackBar trckCrossover; private System.Windows.Forms.Label label5; - private System.Windows.Forms.TrackBar trackBar2; + private System.Windows.Forms.TrackBar trckClients; private System.Windows.Forms.Label label4; - private System.Windows.Forms.TrackBar trackBar1; + private System.Windows.Forms.TrackBar trckCheckouts; 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; + private System.Windows.Forms.Panel pnlInfos; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Panel pnlControls; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label lbl; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label9; } } diff --git a/Caisses/Form1.cs b/Caisses/Form1.cs index 4c9cd23..2400cc0 100644 --- a/Caisses/Form1.cs +++ b/Caisses/Form1.cs @@ -78,7 +78,7 @@ namespace Caisses 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 = store.TimeOfTheDayInHours + ":" + store.TimeOfTheDayInMinuts % 60; } private void Form1_Load(object sender, EventArgs e) @@ -150,6 +150,10 @@ namespace Caisses pnlOptions.Visible = !pnlOptions.Visible; if (e.KeyChar == (char)Keys.Space) StartSimulation(); + if(e.KeyChar == 'i' || e.KeyChar == 'I') + pnlInfos.Visible = !pnlInfos.Visible; + if(e.KeyChar == 'x' || e.KeyChar == 'X') + pnlControls.Visible = !pnlControls.Visible; } private void Form1_MouseDown(object sender, MouseEventArgs e) @@ -175,5 +179,25 @@ namespace Caisses { store.ClearWaitingRoom(); } + + private void btnAddOneHour_Click(object sender, EventArgs e) + { + store.AddTime(60); + } + + private void trackBar1_Scroll(object sender, EventArgs e) + { + store.UpdateCheckoutNumber(trckCheckouts.Value,pbxCaisses.Size); + } + + private void trckClients_Scroll(object sender, EventArgs e) + { + store.ChangeClientMultiplier(trckClients.Value); + } + + private void trckCrossover_Scroll(object sender, EventArgs e) + { + store.ChangeCrossoverTime(trckCrossover.Value); + } } } diff --git a/Caisses/GraphicalCheckout.cs b/Caisses/GraphicalCheckout.cs index 47741bd..d9d95da 100644 --- a/Caisses/GraphicalCheckout.cs +++ b/Caisses/GraphicalCheckout.cs @@ -35,7 +35,7 @@ namespace Caisses g.DrawRectangle(new Pen(Color.Black),new Rectangle(Position,Size)); if (Open) { - g.FillRectangle(new SolidBrush(Color.Green),new Rectangle(Position, Size)); + g.FillRectangle(new SolidBrush(Color.FromArgb(191,227,180)),new Rectangle(Position, Size)); //g.DrawString(Clients.Count().ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y)); if(Clients.Count > 0) @@ -45,19 +45,19 @@ namespace Caisses Point clientPos = new Point(Position.X + xOffset, (i) * clientSize.Height + Position.Y); if (i == 0) { - g.FillEllipse(Brushes.BlueViolet, new Rectangle(clientPos, clientSize)); - g.DrawString(Clients[i].CheckoutTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), clientPos); + g.FillEllipse(new SolidBrush(Color.FromArgb(181, 205, 215)), new Rectangle(clientPos, clientSize)); + g.DrawString(Clients[i].CheckoutTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), clientPos); } else { - g.FillEllipse(Brushes.Violet, new Rectangle(clientPos, clientSize)); + g.FillEllipse(new SolidBrush(Color.FromArgb(175, 143, 233)), new Rectangle(clientPos, clientSize)); } } } } else { - g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Position, Size)); + g.FillRectangle(new SolidBrush(Color.FromArgb(244, 113, 116)), new Rectangle(Position, Size)); } } } diff --git a/Caisses/GraphicalClient.cs b/Caisses/GraphicalClient.cs index 96b06d9..9901a38 100644 --- a/Caisses/GraphicalClient.cs +++ b/Caisses/GraphicalClient.cs @@ -60,11 +60,13 @@ namespace Caisses switch (State) { case ClientState.Shopping: + Color = Color.FromArgb(ShoppingTime * 2,ShoppingTime * 2,ShoppingTime* 2); g.FillEllipse(new SolidBrush(Color), new RectangleF(Position, Size)); g.DrawString(ShoppingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y)); break; case ClientState.Waiting: - g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Position, Size)); + Color = Color.FromArgb(244, 113, 116); + g.FillEllipse(new SolidBrush(Color), new RectangleF(Position, Size)); g.DrawString(WaitingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y)); break; case ClientState.Inline: diff --git a/Caisses/GraphicalStore.cs b/Caisses/GraphicalStore.cs index 770a2e8..0ad89a5 100644 --- a/Caisses/GraphicalStore.cs +++ b/Caisses/GraphicalStore.cs @@ -10,12 +10,13 @@ namespace Caisses internal class GraphicalStore { public static readonly int[] ATTENDANCE = { 0, 0, 0, 0, 0, 0, 0, 30, 30, 40, 50, 60, 100, 80, 50, 30, 80, 100, 50, 50, 80, 0, 0, 0 }; - public const int CROSSOVER_TIME = 10; + public int CrossoverTime = 10; private List _checkouts; private List _clients; private int _timeOfTheDayInMinuts; private Random rnd; + private int _clientsMultiplier; /// Stats @@ -42,30 +43,54 @@ namespace Caisses get { return _timeOfTheDayInMinuts / 60; } } + public int ClientsMultiplier { get => _clientsMultiplier; set => _clientsMultiplier = value; } + public GraphicalStore(int startingHour, int checkoutNumber, Size checkoutsRoom) { TimeOfTheDayInMinuts = startingHour * 60; Clients = new List(); Checkouts = new List(); rnd = new Random(); + ClientsMultiplier = 1; FillStore(ATTENDANCE[TimeOfTheDayInHours]); - populateCheckouts(checkoutsRoom,checkoutNumber); + populateCheckouts(checkoutsRoom, checkoutNumber); Tick(); } - public void populateCheckouts(Size checkoutRoom,int checkoutNumber) + public void populateCheckouts(Size checkoutRoom, int checkoutNumber) { int checkoutWidth = checkoutRoom.Width / checkoutNumber + 1; - for (int i = 0; i < checkoutNumber; i++) + if (Checkouts.Count > 0) { - Point position = new Point(i * checkoutWidth + checkoutWidth / checkoutNumber, 0); - Checkouts.Add(new GraphicalCheckout()); + //We are resizing + if (Checkouts.Count > checkoutNumber) + { + int checkoutsToRemove = Checkouts.Count - checkoutNumber; + for (int i = 0; i < checkoutsToRemove; i++) + { + Checkouts.RemoveAt(Checkouts.Count - 1); + } + } + else + { + int checkoutsToAdd = checkoutNumber - Checkouts.Count; + for (int i = 0; i < checkoutsToAdd; i++) + { + Checkouts.Add(new GraphicalCheckout()); + } + } + } + else + { + //We are creating + for (int i = 0; i < checkoutNumber; i++) + { + Checkouts.Add(new GraphicalCheckout()); + } } } - - public void Tick() + private void RefreshStoreFilling() { - TimeOfTheDayInMinuts++; if (TimeOfTheDayInMinuts % 60 == 0) { if (TimeOfTheDayInMinuts >= 24 * 60) @@ -74,8 +99,14 @@ namespace Caisses } //Its a new Hour so we can send the new clients int amountOfNewCLients = ATTENDANCE[TimeOfTheDayInHours]; - FillStore(amountOfNewCLients); + FillStore(amountOfNewCLients * ClientsMultiplier); } + } + + public void Tick() + { + TimeOfTheDayInMinuts++; + RefreshStoreFilling(); int cumulatedWaitingTime = 0; int waitingClients = 0; @@ -184,11 +215,11 @@ namespace Caisses } } } - public List Draw(Size shelvesRoom,Size waitRoom,Size checkoutsRoom) + public List Draw(Size shelvesRoom, Size waitRoom, Size checkoutsRoom) { - Bitmap shelvesImage = new Bitmap(shelvesRoom.Width,shelvesRoom.Height); + Bitmap shelvesImage = new Bitmap(shelvesRoom.Width, shelvesRoom.Height); Bitmap waitingRoomImage = new Bitmap(waitRoom.Width, waitRoom.Height); - Bitmap checkoutsImage= new Bitmap(checkoutsRoom.Width,checkoutsRoom.Height); + Bitmap checkoutsImage = new Bitmap(checkoutsRoom.Width, checkoutsRoom.Height); foreach (GraphicalClient client in Clients) { client.Draw(shelvesImage, waitingRoomImage); @@ -196,7 +227,7 @@ namespace Caisses for (int i = 0; i < Checkouts.Count; i++) { - Checkouts[i].Draw(checkoutsImage, Checkouts.Count,i); + Checkouts[i].Draw(checkoutsImage, Checkouts.Count, i); foreach (GraphicalClient client in Checkouts[i].Clients) { client.Draw(shelvesImage, waitingRoomImage); @@ -212,7 +243,7 @@ namespace Caisses } } */ - return new List { shelvesImage, waitingRoomImage, checkoutsImage}; + return new List { shelvesImage, waitingRoomImage, checkoutsImage }; } public virtual void FillStore(int amountOfNewClients) { @@ -237,7 +268,7 @@ namespace Caisses { for (int i = 0; i < amount; i++) { - Clients.Add(new GraphicalClient(new Point(0,0),rnd)); + Clients.Add(new GraphicalClient(new Point(0, 0), rnd)); } } public void ClearStore() @@ -270,6 +301,21 @@ namespace Caisses Clients.Remove(client); } } + public void AddTime(int time) + { + TimeOfTheDayInMinuts += time; + } + public void UpdateCheckoutNumber(int newCheckoutNumber, Size checkoutRoom) + { + populateCheckouts(checkoutRoom, newCheckoutNumber); + } + public void ChangeClientMultiplier(int newMultiplier) + { + ClientsMultiplier = newMultiplier; + } + public void ChangeCrossoverTime(int newCrossoverTime) + { + CrossoverTime = newCrossoverTime; + } } - }