Started to setup the UI
This commit is contained in:
+79
-5
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
@@ -12,15 +13,28 @@ namespace Caisses
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
// for the drag and drop of the form
|
||||
public const int WM_NCLBUTTONDOWN = 0xA1;
|
||||
public const int HT_CAPTION = 0x2;
|
||||
[DllImportAttribute("user32.dll")]
|
||||
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
|
||||
[DllImportAttribute("user32.dll")]
|
||||
public static extern bool ReleaseCapture();
|
||||
// for the drag and drop of the form
|
||||
|
||||
GraphicalStore store;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
DoubleBuffered = true;
|
||||
store = new GraphicalStore(10,12,pbxCaisses.Size);
|
||||
store = new GraphicalStore(10, 12, pbxCaisses.Size);
|
||||
}
|
||||
|
||||
private void btnStartStop_Click(object sender, EventArgs e)
|
||||
{
|
||||
StartSimulation();
|
||||
}
|
||||
public void StartSimulation()
|
||||
{
|
||||
if (tmrRefresh.Enabled)
|
||||
{
|
||||
@@ -34,7 +48,6 @@ namespace Caisses
|
||||
tmrDraw.Start();
|
||||
btnStartStop.Text = "Stop";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void tmrRefresh_Tick(object sender, EventArgs e)
|
||||
@@ -44,7 +57,7 @@ namespace Caisses
|
||||
|
||||
private void tmrDraw_Tick(object sender, EventArgs e)
|
||||
{
|
||||
List<Bitmap> result = store.Draw(pbxRayons.Size,pbxWaitRoom.Size,pbxCaisses.Size);
|
||||
List<Bitmap> result = store.Draw(pbxRayons.Size, pbxWaitRoom.Size, pbxCaisses.Size);
|
||||
if (pbxRayons.Image != null)
|
||||
{
|
||||
pbxRayons.Image.Dispose();
|
||||
@@ -62,15 +75,20 @@ namespace Caisses
|
||||
pbxCaisses.Image = result[2];
|
||||
|
||||
lblClients.Text = "Clients : " + store.Clients.Count();
|
||||
lblClientsWithoutCheckout.Text = "Clients without checkout : "+ store.WaitingClients.Count();
|
||||
lblClientsWithoutCheckout.Text = "Clients without checkout : " + store.WaitingClients.Count();
|
||||
lblAvaiblePlaces.Text = "Avaible places = " + store.TotalPlacesLeftCount;
|
||||
lblAvgWaitingTime.Text = "AverageWaitingTime = " + store.AverageWaitingTime;
|
||||
lblTime.Text = "Time of the day : "+store.TimeOfTheDayInHours + ":"+store.TimeOfTheDayInMinuts % 60;
|
||||
lblTime.Text = "Time of the day : " + store.TimeOfTheDayInHours + ":" + store.TimeOfTheDayInMinuts % 60;
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
ResizeCanvas();
|
||||
pbxCaisses.MouseDown += Form1_MouseDown;
|
||||
pbxRayons.MouseDown += Form1_MouseDown;
|
||||
pbxWaitRoom.MouseDown += Form1_MouseDown;
|
||||
|
||||
this.KeyPreview = true;
|
||||
}
|
||||
|
||||
private void pbxWaitRoom_Click(object sender, EventArgs e)
|
||||
@@ -94,12 +112,68 @@ namespace Caisses
|
||||
}
|
||||
private void ResizeCanvas()
|
||||
{
|
||||
/*
|
||||
pbxRayons.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 5.0));
|
||||
pbxRayons.Location = new Point(0, 0);
|
||||
pbxWaitRoom.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 2.0));
|
||||
pbxWaitRoom.Location = new Point(0, pbxRayons.Height);
|
||||
pbxCaisses.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 3.0));
|
||||
pbxCaisses.Location = new Point(0, pbxWaitRoom.Location.Y + pbxWaitRoom.Height);
|
||||
*/
|
||||
pbxRayons.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 7.0));
|
||||
pbxRayons.Location = new Point(0, 0);
|
||||
|
||||
pbxWaitRoom.Size = new Size(this.Width / 6, this.Height / 3);
|
||||
pbxWaitRoom.Location = new Point(this.Width - pbxWaitRoom.Width, 0);
|
||||
|
||||
pbxCaisses.Size = new Size(this.Width, Convert.ToInt32((this.Height / 10.0) * 3.0));
|
||||
pbxCaisses.Location = new Point(0, pbxRayons.Height);
|
||||
}
|
||||
|
||||
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == 'f' || e.KeyChar == 'F')
|
||||
{
|
||||
//We need to put the form in fullScreen
|
||||
if (this.WindowState == FormWindowState.Normal)
|
||||
{
|
||||
this.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
}
|
||||
}
|
||||
if (e.KeyChar == (char)Keys.Escape)
|
||||
Application.Exit();
|
||||
if (e.KeyChar == 'o' || e.KeyChar == 'O')
|
||||
pnlOptions.Visible = !pnlOptions.Visible;
|
||||
if (e.KeyChar == (char)Keys.Space)
|
||||
StartSimulation();
|
||||
}
|
||||
|
||||
private void Form1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
ReleaseCapture();
|
||||
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnAdd5Clients_Click(object sender, EventArgs e)
|
||||
{
|
||||
store.AddClients(5);
|
||||
}
|
||||
|
||||
private void btnEmptyStore_Click(object sender, EventArgs e)
|
||||
{
|
||||
store.ClearStore();
|
||||
}
|
||||
|
||||
private void btnEmptyWaitingRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
store.ClearWaitingRoom();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user