Finalised Ui tweaks

This commit is contained in:
2023-01-25 21:20:45 +01:00
parent 512fc44e0f
commit 7ac7570470
6 changed files with 412 additions and 211 deletions
+63 -17
View File
@@ -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<GraphicalCheckout> _checkouts;
private List<GraphicalClient> _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<GraphicalClient>();
Checkouts = new List<GraphicalCheckout>();
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<Bitmap> Draw(Size shelvesRoom,Size waitRoom,Size checkoutsRoom)
public List<Bitmap> 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<Bitmap> { shelvesImage, waitingRoomImage, checkoutsImage};
return new List<Bitmap> { 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;
}
}
}