Files
Std_Caisses/Caisses/GraphicalCheckout.cs

73 lines
2.8 KiB
C#

/*
* Rohmer Maxime
* STD Project
* 25/01/2023
* V1.0
* GraphicalCheckout.cs
* A graphical override for the checkout object
*/
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;
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()
{
}
public void Draw(Bitmap checkoutAreaImage,int checkoutNumber, int checkoutId)
{
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);
int xOffset = Size.Width / 2 - radius / 2;
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.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)
{
for (int i = 0; i < Clients.Count; i++)
{
Point clientPos = new Point(Position.X + xOffset, (i) * clientSize.Height + Position.Y);
if (i == 0)
{
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(new SolidBrush(Color.FromArgb(175, 143, 233)), new Rectangle(clientPos, clientSize));
}
}
}
}
else
{
g.FillRectangle(new SolidBrush(Color.FromArgb(244, 113, 116)), new Rectangle(Position, Size));
}
}
}
}