first commit because I dont want to lose this project
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{210D00A1-C688-4053-9C6F-8939E30B01E3}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>Caisses</RootNamespace>
|
||||
<AssemblyName>Caisses</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Checkout.cs" />
|
||||
<Compile Include="Client.cs" />
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GraphicalCheckout.cs" />
|
||||
<Compile Include="GraphicalClient.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Store.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
internal class Checkout
|
||||
{
|
||||
public const int MAX_CAPACITY = 5;
|
||||
|
||||
private List<Client> clients;
|
||||
private bool open;
|
||||
private int crossoverTime;
|
||||
|
||||
public List<Client> Clients { get => clients; set => clients = value; }
|
||||
public bool Open { get => open; set => open = value; }
|
||||
|
||||
public Checkout()
|
||||
{
|
||||
Clients = new List<Client>();
|
||||
Open = false;
|
||||
}
|
||||
public void Tick(int averageWaitingTime, int CrossoverTime)
|
||||
{
|
||||
if (!Open && averageWaitingTime > CrossoverTime)
|
||||
{
|
||||
Open = true;
|
||||
}
|
||||
if (Open && averageWaitingTime < CrossoverTime && Clients.Count == 0)
|
||||
{
|
||||
Open = false;
|
||||
}
|
||||
/*
|
||||
if (Clients.Count != 0)
|
||||
{
|
||||
//This is the first client inline
|
||||
Client client = Clients[0];
|
||||
if (client.State == Client.ClientState.Inline)
|
||||
client.State = Client.ClientState.Checkout;
|
||||
|
||||
|
||||
if (client.CheckoutTime <= 0)
|
||||
{
|
||||
I think we need to do this processing in the store
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public const int MAX_SHOPPING_TIME = 100; //Original 100
|
||||
public const int MIN_SHOPPING_TIME = 10; //Original 10
|
||||
|
||||
public enum ClientState
|
||||
{
|
||||
Shopping,
|
||||
Waiting,
|
||||
Inline,
|
||||
Checkout,
|
||||
}
|
||||
|
||||
private int _shoppingTime;
|
||||
private int _waitingTime;
|
||||
private int _checkoutTime;
|
||||
private ClientState _state;
|
||||
protected static Random Random;
|
||||
public int ShoppingTime
|
||||
{
|
||||
get { return _shoppingTime; }
|
||||
//set { _shoppingTime = value; if (_shoppingTime <= 0) { State = ClientState.Waiting; } }
|
||||
set { _shoppingTime = value; }
|
||||
}
|
||||
public int WaitingTime { get => _waitingTime; set => _waitingTime = value; }
|
||||
public ClientState State { get => _state; set => _state = value; }
|
||||
public int CheckoutTime { get => _checkoutTime; set => _checkoutTime = value; }
|
||||
|
||||
public Client(Random random)
|
||||
{
|
||||
Random = random;
|
||||
ShoppingTime = Random.Next(MIN_SHOPPING_TIME,MAX_SHOPPING_TIME);
|
||||
CheckoutTime = ShoppingTime / 5;
|
||||
State = ClientState.Shopping;
|
||||
}
|
||||
public void Tick()
|
||||
{
|
||||
switch (State)
|
||||
{
|
||||
case ClientState.Shopping:
|
||||
ShoppingTime -= 1;
|
||||
if (ShoppingTime <= 0)
|
||||
{
|
||||
State = ClientState.Waiting;
|
||||
}
|
||||
break;
|
||||
case ClientState.Waiting:
|
||||
WaitingTime += 1;
|
||||
break;
|
||||
case ClientState.Inline:
|
||||
//We dont do anything when he is in a checkoutLine
|
||||
break;
|
||||
case ClientState.Checkout:
|
||||
CheckoutTime -= 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+227
@@ -0,0 +1,227 @@
|
||||
namespace Caisses
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
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();
|
||||
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.tmrRefresh = new System.Windows.Forms.Timer(this.components);
|
||||
this.tmrDraw = new System.Windows.Forms.Timer(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).BeginInit();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pbxRayons
|
||||
//
|
||||
this.pbxRayons.Location = new System.Drawing.Point(12, 12);
|
||||
this.pbxRayons.Name = "pbxRayons";
|
||||
this.pbxRayons.Size = new System.Drawing.Size(1044, 357);
|
||||
this.pbxRayons.TabIndex = 0;
|
||||
this.pbxRayons.TabStop = false;
|
||||
//
|
||||
// pbxCaisses
|
||||
//
|
||||
this.pbxCaisses.Location = new System.Drawing.Point(12, 375);
|
||||
this.pbxCaisses.Name = "pbxCaisses";
|
||||
this.pbxCaisses.Size = new System.Drawing.Size(838, 246);
|
||||
this.pbxCaisses.TabIndex = 1;
|
||||
this.pbxCaisses.TabStop = false;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
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(856, 375);
|
||||
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.Name = "btnStartStop";
|
||||
this.btnStartStop.Size = new System.Drawing.Size(188, 29);
|
||||
this.btnStartStop.TabIndex = 3;
|
||||
this.btnStartStop.Text = "Start";
|
||||
this.btnStartStop.UseVisualStyleBackColor = true;
|
||||
this.btnStartStop.Click += new System.EventHandler(this.btnStartStop_Click);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
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(856, 501);
|
||||
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.Name = "lblAvgWaitingTime";
|
||||
this.lblAvgWaitingTime.Size = new System.Drawing.Size(117, 16);
|
||||
this.lblAvgWaitingTime.TabIndex = 4;
|
||||
this.lblAvgWaitingTime.Text = "average wait : 0:03";
|
||||
//
|
||||
// lblClients
|
||||
//
|
||||
this.lblClients.AutoSize = true;
|
||||
this.lblClients.Location = new System.Drawing.Point(6, 66);
|
||||
this.lblClients.Name = "lblClients";
|
||||
this.lblClients.Size = new System.Drawing.Size(67, 16);
|
||||
this.lblClients.TabIndex = 3;
|
||||
this.lblClients.Text = "Clients: 50";
|
||||
//
|
||||
// lblAvaiblePlaces
|
||||
//
|
||||
this.lblAvaiblePlaces.AutoSize = true;
|
||||
this.lblAvaiblePlaces.Location = new System.Drawing.Point(6, 50);
|
||||
this.lblAvaiblePlaces.Name = "lblAvaiblePlaces";
|
||||
this.lblAvaiblePlaces.Size = new System.Drawing.Size(113, 16);
|
||||
this.lblAvaiblePlaces.TabIndex = 2;
|
||||
this.lblAvaiblePlaces.Text = "Avaible places : 8";
|
||||
//
|
||||
// lblClientsWithoutCheckout
|
||||
//
|
||||
this.lblClientsWithoutCheckout.AutoSize = true;
|
||||
this.lblClientsWithoutCheckout.Location = new System.Drawing.Point(6, 34);
|
||||
this.lblClientsWithoutCheckout.Name = "lblClientsWithoutCheckout";
|
||||
this.lblClientsWithoutCheckout.Size = new System.Drawing.Size(160, 16);
|
||||
this.lblClientsWithoutCheckout.TabIndex = 1;
|
||||
this.lblClientsWithoutCheckout.Text = "Clients without checkout: 0";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
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";
|
||||
//
|
||||
// tmrRefresh
|
||||
//
|
||||
this.tmrRefresh.Interval = 1000;
|
||||
this.tmrRefresh.Tick += new System.EventHandler(this.tmrRefresh_Tick);
|
||||
//
|
||||
// tmrDraw
|
||||
//
|
||||
this.tmrDraw.Interval = 17;
|
||||
this.tmrDraw.Tick += new System.EventHandler(this.tmrDraw_Tick);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1062, 630);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.pbxCaisses);
|
||||
this.Controls.Add(this.pbxRayons);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxRayons)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pbxCaisses)).EndInit();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
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;
|
||||
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.Timer tmrRefresh;
|
||||
private System.Windows.Forms.Timer tmrDraw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
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 Caisses
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
GraphicalStore store;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
DoubleBuffered = true;
|
||||
store = new GraphicalStore(10,12,pbxRayons.Size,pbxCaisses.Size);
|
||||
}
|
||||
|
||||
private void btnStartStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (tmrRefresh.Enabled)
|
||||
{
|
||||
tmrRefresh.Stop();
|
||||
tmrDraw.Stop();
|
||||
btnStartStop.Text = "Start";
|
||||
}
|
||||
else
|
||||
{
|
||||
tmrRefresh.Start();
|
||||
tmrDraw.Start();
|
||||
btnStartStop.Text = "Stop";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void tmrRefresh_Tick(object sender, EventArgs e)
|
||||
{
|
||||
store.Tick();
|
||||
}
|
||||
|
||||
private void tmrDraw_Tick(object sender, EventArgs e)
|
||||
{
|
||||
List<Bitmap> result = store.Draw();
|
||||
if (pbxRayons.Image != null)
|
||||
{
|
||||
pbxRayons.Image.Dispose();
|
||||
}
|
||||
if (pbxCaisses.Image != null)
|
||||
{
|
||||
pbxCaisses.Image.Dispose();
|
||||
}
|
||||
pbxRayons.Image = result[0];
|
||||
pbxCaisses.Image = result[1];
|
||||
|
||||
lblClients.Text = "Clients : " + store.Clients.Count();
|
||||
lblClientsWithoutCheckout.Text = "Clients without checkout : "+ store.GetClientsWithoutCheckout().Count();
|
||||
lblAvaiblePlaces.Text = "Avaible places = " + store.GetAmountOfPlacesLeft();
|
||||
lblAvgWaitingTime.Text = "AverageWaitingTime = " + store.GetAverageWaitingTime();
|
||||
lblTime.Text = "Time of the day : "+store.TimeOfTheDayInHours + ":"+store.TimeOfTheDayInMinuts % 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tmrRefresh.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="tmrDraw.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>148, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
internal class GraphicalCheckout : Checkout
|
||||
{
|
||||
private Point _position;
|
||||
private Color _color;
|
||||
private Size _size;
|
||||
private Rectangle _area;
|
||||
private Random Random;
|
||||
|
||||
public Point Position { get => _position; set => _position = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public Size Size { get => _size; set => _size = value; }
|
||||
public Rectangle Area { get => _area; set => _area = value; }
|
||||
public GraphicalCheckout(Point position,Rectangle area,int checkoutNumber)
|
||||
{
|
||||
Random = new Random();
|
||||
Position = position;
|
||||
Color = Color.FromArgb(Random.Next(0, 255), Random.Next(0, 255), Random.Next(0, 255));
|
||||
Size = new Size(area.Width / checkoutNumber + 1,area.Height-area.Height/10);
|
||||
}
|
||||
public void Draw(Bitmap checkoutAreaImage)
|
||||
{
|
||||
Graphics g = Graphics.FromImage(checkoutAreaImage);
|
||||
//g.DrawRectangle(new Pen(Color.FromArgb(Random.Next(0,255),Random.Next(0,255),Random.Next(0,255))),new Rectangle(Position,Size));
|
||||
g.DrawRectangle(new Pen(Color.Black),new Rectangle(Position,Size));
|
||||
if (Open)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Green),new Rectangle(Position, Size));
|
||||
g.DrawString(Clients.Count().ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(Position, Size));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
public class GraphicalClient : Client
|
||||
{
|
||||
const int MAX_CLIENT_SPEED = 5;
|
||||
const int MIN_CLIENT_SPEED = -5;
|
||||
|
||||
private Point _speed;
|
||||
private Point _position;
|
||||
private Color _color;
|
||||
private Size _size;
|
||||
private Rectangle _area;
|
||||
|
||||
public Point Speed { get => _speed; set => _speed = value; }
|
||||
public Point Position { get => _position; set => _position = value; }
|
||||
public Color Color { get => _color; set => _color = value; }
|
||||
public Size Size { get => _size; set => _size = value; }
|
||||
public Rectangle Area { get => _area; set => _area = value; }
|
||||
|
||||
public GraphicalClient(Point Entrance,Random random):base(random)
|
||||
{
|
||||
Random = random;
|
||||
Position = Entrance;
|
||||
Position = new Point(Random.Next(0, 100), Random.Next(0, 100));
|
||||
Speed = new Point(Random.Next(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED), Random.Next(MIN_CLIENT_SPEED, MAX_CLIENT_SPEED));
|
||||
Color = Color.FromArgb(ShoppingTime * 2, 0, 0);
|
||||
int clientWidth = Random.Next(20, 30);
|
||||
Size = new Size(clientWidth, clientWidth);
|
||||
}
|
||||
public void Update(Size area)
|
||||
{
|
||||
//base.Tick();
|
||||
Position = checkBounds(Position,area);
|
||||
Color = Color.FromArgb(ShoppingTime * 2, 0, 0);
|
||||
}
|
||||
public void Draw(Bitmap storeImage)
|
||||
{
|
||||
Update(storeImage.Size);
|
||||
Graphics g = Graphics.FromImage(storeImage);
|
||||
switch (State)
|
||||
{
|
||||
case ClientState.Shopping:
|
||||
g.FillEllipse(new SolidBrush(Color), new Rectangle(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 Rectangle(Position, Size));
|
||||
g.DrawString(WaitingTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.White), new PointF(Position.X, Position.Y));
|
||||
break;
|
||||
case ClientState.Inline:
|
||||
g.FillEllipse(new SolidBrush(Color.Violet), new Rectangle(Position, Size));
|
||||
break;
|
||||
case ClientState.Checkout:
|
||||
g.FillEllipse(new SolidBrush(Color.Green), new Rectangle(Position, Size));
|
||||
g.DrawString(CheckoutTime.ToString(), new Font("Arial", 16), new SolidBrush(Color.Black), new PointF(Position.X, Position.Y));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
public Point checkBounds(Point position, Size area)
|
||||
{
|
||||
Point newPosition = new Point(position.X,position.Y);
|
||||
/*
|
||||
if (position.X < 0)
|
||||
{
|
||||
newPosition.X = 0;
|
||||
Speed = new Point(Speed.X * -1, Speed.Y);
|
||||
}
|
||||
if (position.X > area.Width)
|
||||
{
|
||||
newPosition.X = area.Width;
|
||||
Speed = new Point(Speed.X * -1, Speed.Y);
|
||||
}
|
||||
|
||||
if (position.Y < 0)
|
||||
{
|
||||
newPosition.Y = 0;
|
||||
Speed = new Point(Speed.X, Speed.Y * -1);
|
||||
}
|
||||
if (position.Y > area.Height)
|
||||
{
|
||||
newPosition.Y = area.Height;
|
||||
Speed = new Point(Speed.X, Speed.Y * -1);
|
||||
}*/
|
||||
|
||||
if (position.X + Speed.X > 0 && position.X + Size.Width + Speed.X < area.Width)
|
||||
{
|
||||
newPosition.X = position.X + Speed.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
int diff = Math.Abs(position.X + Speed.X);
|
||||
newPosition.X = diff;
|
||||
//newPosition = new Point(0, position.Y);
|
||||
Speed = new Point(Speed.X * -1,Speed.Y);
|
||||
//speed.X += -1;
|
||||
}
|
||||
if (position.Y + Speed.Y > 0 && position.Y + Size.Height + Speed.Y < area.Height)
|
||||
{
|
||||
newPosition.Y = position.Y + Speed.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
int diff = Math.Abs(position.Y + Speed.Y);
|
||||
newPosition.Y = diff;
|
||||
//newPosition = new Point(position.X, 0);
|
||||
Speed = new Point(Speed.X,Speed.Y * -1);
|
||||
//speed.Y *= -1;
|
||||
}
|
||||
|
||||
return newPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Caisses")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Caisses")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("210d00a1-c688-4053-9c6f-8939e30b01e3")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Generated
+71
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Caisses.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Caisses.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Generated
+30
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Caisses.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Caisses
|
||||
{
|
||||
internal class GraphicalStore
|
||||
{
|
||||
private List<GraphicalCheckout> _checkouts;
|
||||
private List<GraphicalClient> _clients;
|
||||
private int _timeOfTheDayInMinuts;
|
||||
private Bitmap _shelvesCorner;
|
||||
private Bitmap _checkoutCorner;
|
||||
private Random rnd;
|
||||
|
||||
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 };
|
||||
const int CROSSOVER_TIME = 10;
|
||||
|
||||
public int TimeOfTheDayInMinuts { get => _timeOfTheDayInMinuts; set => _timeOfTheDayInMinuts = value; }
|
||||
public List<GraphicalClient> Clients { get => _clients; set => _clients = value; }
|
||||
internal List<GraphicalCheckout> Checkouts { get => _checkouts; set => _checkouts = value; }
|
||||
public Bitmap ShelvesCorner { get => _shelvesCorner; set => _shelvesCorner = value; }
|
||||
public Bitmap CheckoutCorner { get => _checkoutCorner; set => _checkoutCorner = value; }
|
||||
|
||||
public int TimeOfTheDayInHours
|
||||
{
|
||||
get { return _timeOfTheDayInMinuts / 60; }
|
||||
}
|
||||
|
||||
public GraphicalStore(int startingHour,int checkoutNumber, Size shelvesCornerSize,Size checkoutCornerSize)
|
||||
{
|
||||
TimeOfTheDayInMinuts = startingHour * 60;
|
||||
Clients = new List<GraphicalClient>();
|
||||
Checkouts = new List<GraphicalCheckout>();
|
||||
CheckoutCorner = new Bitmap(checkoutCornerSize.Width,checkoutCornerSize.Height);
|
||||
ShelvesCorner = new Bitmap(shelvesCornerSize.Width,shelvesCornerSize.Height);
|
||||
rnd = new Random();
|
||||
|
||||
FillStore(ATTENDANCE[TimeOfTheDayInHours]);
|
||||
populateCheckouts(checkoutNumber);
|
||||
Tick();
|
||||
}
|
||||
public void populateCheckouts(int numberOfCheckouts)
|
||||
{
|
||||
int checkoutWidth = CheckoutCorner.Width / numberOfCheckouts + 1;
|
||||
for (int i = 0; i < numberOfCheckouts; i++)
|
||||
{
|
||||
Point position = new Point(i * checkoutWidth + checkoutWidth / numberOfCheckouts, 0);
|
||||
Checkouts.Add(new GraphicalCheckout(position, new Rectangle(new Point(0, 0), new Size(CheckoutCorner.Width, CheckoutCorner.Height)), numberOfCheckouts));
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
TimeOfTheDayInMinuts++;
|
||||
if (TimeOfTheDayInMinuts % 60 == 0)
|
||||
{
|
||||
//Its a new Hour so we can send the new clients
|
||||
int amountOfNewCLients = ATTENDANCE[TimeOfTheDayInHours];
|
||||
FillStore(amountOfNewCLients);
|
||||
}
|
||||
|
||||
int cumulatedWaitingTime = 0;
|
||||
int averageWaitingTime = 0;
|
||||
|
||||
foreach (GraphicalClient client in Clients)
|
||||
{
|
||||
client.Tick();
|
||||
cumulatedWaitingTime += client.WaitingTime;
|
||||
}
|
||||
if (Clients.Count == 0)
|
||||
{
|
||||
averageWaitingTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
averageWaitingTime = cumulatedWaitingTime / Clients.Count;
|
||||
}
|
||||
foreach (GraphicalCheckout checkout in Checkouts)
|
||||
{
|
||||
checkout.Tick(averageWaitingTime,CROSSOVER_TIME);
|
||||
}
|
||||
|
||||
//Processing the checkout mechanism
|
||||
int openPlacesAmount = GetAmountOfPlacesLeft();
|
||||
|
||||
List<GraphicalClient> clientsToRemove = new List<GraphicalClient>();
|
||||
foreach (GraphicalClient client in Clients)
|
||||
{
|
||||
if (client.State == Client.ClientState.Waiting)
|
||||
{
|
||||
if (openPlacesAmount > 0)
|
||||
{
|
||||
List<GraphicalCheckout> checkoutsWithFreeSpace = GetNotFullCheckouts();
|
||||
if (checkoutsWithFreeSpace.Count > 0)
|
||||
{
|
||||
//Now we select a random one to put our waiting client
|
||||
int index = 0;
|
||||
int count = checkoutsWithFreeSpace.Count - 1;
|
||||
if (count > 0)
|
||||
{
|
||||
index = rnd.Next(0, checkoutsWithFreeSpace.Count - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
checkoutsWithFreeSpace[index].Clients.Add(client);
|
||||
//Clients.Remove(client);
|
||||
clientsToRemove.Add(client);
|
||||
client.State = Client.ClientState.Inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (GraphicalClient client in clientsToRemove)
|
||||
{
|
||||
Clients.Remove(client);
|
||||
}
|
||||
|
||||
foreach (GraphicalCheckout checkout in Checkouts)
|
||||
{
|
||||
if (checkout.Open && checkout.Clients.Count > 0)
|
||||
{
|
||||
Client cClient = checkout.Clients[0];
|
||||
if (cClient.State != Client.ClientState.Checkout)
|
||||
cClient.State = Client.ClientState.Checkout;
|
||||
|
||||
if (cClient.CheckoutTime <= 0)
|
||||
{
|
||||
checkout.Clients.Remove(cClient);
|
||||
//We dont load the next because he should be loaded the next time this function is loaded
|
||||
}
|
||||
|
||||
foreach (GraphicalClient ccClient in checkout.Clients)
|
||||
{
|
||||
ccClient.Tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Bitmap> Draw()
|
||||
{
|
||||
ShelvesCorner = new Bitmap(ShelvesCorner.Width,ShelvesCorner.Height);
|
||||
CheckoutCorner = new Bitmap(CheckoutCorner.Width,CheckoutCorner.Height);
|
||||
foreach (GraphicalClient client in Clients)
|
||||
{
|
||||
client.Draw(ShelvesCorner);
|
||||
}
|
||||
|
||||
foreach (GraphicalCheckout checkout in Checkouts)
|
||||
{
|
||||
checkout.Draw(CheckoutCorner);
|
||||
foreach (GraphicalClient client in checkout.Clients)
|
||||
{
|
||||
client.Draw(ShelvesCorner);
|
||||
}
|
||||
}
|
||||
|
||||
return new List<Bitmap> { ShelvesCorner, CheckoutCorner };
|
||||
}
|
||||
public virtual void FillStore(int amountOfNewClients)
|
||||
{
|
||||
for (int i = 0; i < amountOfNewClients; i++)
|
||||
{
|
||||
Clients.Add(new GraphicalClient(new Point(0,0),rnd));
|
||||
}
|
||||
}
|
||||
public List<GraphicalClient> GetClientsWithoutCheckout()
|
||||
{
|
||||
List<GraphicalClient> result = new List<GraphicalClient>();
|
||||
foreach (GraphicalClient client in Clients)
|
||||
{
|
||||
if (client.State == Client.ClientState.Waiting)
|
||||
result.Add(client);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<GraphicalCheckout> GetNotFullCheckouts()
|
||||
{
|
||||
List<GraphicalCheckout> result = new List<GraphicalCheckout>();
|
||||
foreach (GraphicalCheckout checkout in Checkouts)
|
||||
{
|
||||
if (checkout.Clients.Count < Checkout.MAX_CAPACITY && checkout.Open)
|
||||
{
|
||||
result.Add(checkout);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public int GetAmountOfPlacesLeft()
|
||||
{
|
||||
int result = 0;
|
||||
foreach(GraphicalCheckout checkout in Checkouts)
|
||||
{
|
||||
if (checkout.Open)
|
||||
{
|
||||
result += Checkout.MAX_CAPACITY - checkout.Clients.Count();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public int GetAverageWaitingTime()
|
||||
{
|
||||
int cumulatedWaitingTime = 0;
|
||||
int averageWaitingTime = 0;
|
||||
|
||||
foreach (GraphicalClient client in Clients)
|
||||
{
|
||||
cumulatedWaitingTime += client.WaitingTime;
|
||||
}
|
||||
if (Clients.Count == 0)
|
||||
{
|
||||
averageWaitingTime = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
averageWaitingTime = cumulatedWaitingTime / Clients.Count;
|
||||
}
|
||||
|
||||
return averageWaitingTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user