From 11bc1b5036803723e8dd875ae6184bb3227e0226 Mon Sep 17 00:00:00 2001 From: Evan Langlais Date: Tue, 7 Mar 2017 13:32:15 -0500 Subject: [PATCH] Added parties, tables, addparty popup form --- Enigma/Enigma.csproj | 9 ++ Enigma/Popups/AddParty.Designer.cs | 165 ++++++++++++++++++++++++++ Enigma/Popups/AddParty.cs | 46 +++++++ Enigma/Popups/AddParty.resx | 120 +++++++++++++++++++ Enigma/Stations/HostStation.cs | 3 + Enigma/StationsGUI/HostStationView.cs | 2 +- EnigmaX/Classes/Party.cs | 34 ++++++ EnigmaX/Classes/Station.cs | 1 + EnigmaX/Classes/Table.cs | 52 ++++++++ EnigmaX/EnigmaX.csproj | 2 + 10 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 Enigma/Popups/AddParty.Designer.cs create mode 100644 Enigma/Popups/AddParty.cs create mode 100644 Enigma/Popups/AddParty.resx create mode 100644 EnigmaX/Classes/Party.cs create mode 100644 EnigmaX/Classes/Table.cs diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index 4959c33..d33b703 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -62,6 +62,12 @@ + + Form + + + AddParty.cs + Form @@ -78,6 +84,9 @@ + + AddParty.cs + DebugStationView.cs diff --git a/Enigma/Popups/AddParty.Designer.cs b/Enigma/Popups/AddParty.Designer.cs new file mode 100644 index 0000000..8b5f579 --- /dev/null +++ b/Enigma/Popups/AddParty.Designer.cs @@ -0,0 +1,165 @@ +namespace Enigma.Popups +{ + partial class AddParty + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.partyName = new MetroFramework.Controls.MetroTextBox(); + this.metroLabel1 = new MetroFramework.Controls.MetroLabel(); + this.addPartyButton = new MetroFramework.Controls.MetroButton(); + this.metroLabel2 = new MetroFramework.Controls.MetroLabel(); + this.countBox = new System.Windows.Forms.NumericUpDown(); + this.metroLabel3 = new MetroFramework.Controls.MetroLabel(); + this.tableSelectionBox = new MetroFramework.Controls.MetroComboBox(); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).BeginInit(); + this.SuspendLayout(); + // + // partyName + // + // + // + // + this.partyName.CustomButton.Image = null; + this.partyName.CustomButton.Location = new System.Drawing.Point(668, 1); + this.partyName.CustomButton.Name = ""; + this.partyName.CustomButton.Size = new System.Drawing.Size(21, 21); + this.partyName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; + this.partyName.CustomButton.TabIndex = 1; + this.partyName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light; + this.partyName.CustomButton.UseSelectable = true; + this.partyName.CustomButton.Visible = false; + this.partyName.Lines = new string[] { + "Name of Party"}; + this.partyName.Location = new System.Drawing.Point(81, 60); + this.partyName.MaxLength = 32767; + this.partyName.Name = "partyName"; + this.partyName.PasswordChar = '\0'; + this.partyName.ScrollBars = System.Windows.Forms.ScrollBars.None; + this.partyName.SelectedText = ""; + this.partyName.SelectionLength = 0; + this.partyName.SelectionStart = 0; + this.partyName.ShortcutsEnabled = true; + this.partyName.Size = new System.Drawing.Size(690, 23); + this.partyName.TabIndex = 0; + this.partyName.Text = "Name of Party"; + this.partyName.UseSelectable = true; + this.partyName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); + this.partyName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + // + // metroLabel1 + // + this.metroLabel1.AutoSize = true; + this.metroLabel1.Location = new System.Drawing.Point(23, 60); + this.metroLabel1.Name = "metroLabel1"; + this.metroLabel1.Size = new System.Drawing.Size(52, 19); + this.metroLabel1.TabIndex = 1; + this.metroLabel1.Text = "Name: "; + // + // addPartyButton + // + this.addPartyButton.Location = new System.Drawing.Point(777, 60); + this.addPartyButton.Name = "addPartyButton"; + this.addPartyButton.Size = new System.Drawing.Size(178, 90); + this.addPartyButton.TabIndex = 4; + this.addPartyButton.Text = "Add Party"; + this.addPartyButton.UseSelectable = true; + this.addPartyButton.Click += new System.EventHandler(this.addPartyButton_Click); + // + // metroLabel2 + // + this.metroLabel2.AutoSize = true; + this.metroLabel2.Location = new System.Drawing.Point(23, 89); + this.metroLabel2.Name = "metroLabel2"; + this.metroLabel2.Size = new System.Drawing.Size(47, 19); + this.metroLabel2.TabIndex = 3; + this.metroLabel2.Text = "Count:"; + // + // countBox + // + this.countBox.Location = new System.Drawing.Point(81, 89); + this.countBox.Name = "countBox"; + this.countBox.Size = new System.Drawing.Size(180, 26); + this.countBox.TabIndex = 5; + this.countBox.Value = new decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // metroLabel3 + // + this.metroLabel3.AutoSize = true; + this.metroLabel3.Location = new System.Drawing.Point(23, 122); + this.metroLabel3.Name = "metroLabel3"; + this.metroLabel3.Size = new System.Drawing.Size(42, 19); + this.metroLabel3.TabIndex = 6; + this.metroLabel3.Text = "Table:"; + // + // tableSelectionBox + // + this.tableSelectionBox.FormattingEnabled = true; + this.tableSelectionBox.ItemHeight = 23; + this.tableSelectionBox.Items.AddRange(new object[] { + "None"}); + this.tableSelectionBox.Location = new System.Drawing.Point(81, 121); + this.tableSelectionBox.Name = "tableSelectionBox"; + this.tableSelectionBox.Size = new System.Drawing.Size(323, 29); + this.tableSelectionBox.TabIndex = 7; + this.tableSelectionBox.UseSelectable = true; + // + // AddParty + // + this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(978, 172); + this.Controls.Add(this.tableSelectionBox); + this.Controls.Add(this.metroLabel3); + this.Controls.Add(this.countBox); + this.Controls.Add(this.addPartyButton); + this.Controls.Add(this.metroLabel2); + this.Controls.Add(this.metroLabel1); + this.Controls.Add(this.partyName); + this.Name = "AddParty"; + this.Text = "Add Party"; + this.Load += new System.EventHandler(this.AddPatron_Load); + ((System.ComponentModel.ISupportInitialize)(this.countBox)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private MetroFramework.Controls.MetroTextBox partyName; + private MetroFramework.Controls.MetroLabel metroLabel1; + private MetroFramework.Controls.MetroButton addPartyButton; + private MetroFramework.Controls.MetroLabel metroLabel2; + private System.Windows.Forms.NumericUpDown countBox; + private MetroFramework.Controls.MetroLabel metroLabel3; + private MetroFramework.Controls.MetroComboBox tableSelectionBox; + } +} \ No newline at end of file diff --git a/Enigma/Popups/AddParty.cs b/Enigma/Popups/AddParty.cs new file mode 100644 index 0000000..088fb51 --- /dev/null +++ b/Enigma/Popups/AddParty.cs @@ -0,0 +1,46 @@ +using EnigmaX.Classes; +using MetroFramework.Forms; +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 Enigma.Popups +{ + public partial class AddParty : MetroForm + { + + List tables; + + public AddParty(List
_tables) + { + InitializeComponent(); + tables = _tables; + } + + private void AddPatron_Load(object sender, EventArgs e) + { + foreach (Table table in tables) { + tableSelectionBox.Items.Add("Table " + table.tableId() + " " + table.count + " / " + table.capacity); + } + } + + private void addPartyButton_Click(object sender, EventArgs e) + { + Party party = new Party(partyName.Text, (int)countBox.Value); + if (tableSelectionBox.SelectedIndex > 0) { + // index 0 is always "none" + Table selected = tables[tableSelectionBox.SelectedIndex - 1]; + if (selected.remaining >= (int)countBox.Value) { + selected.addPatron(party); + party.setTable(selected); + } + } + } + } +} diff --git a/Enigma/Popups/AddParty.resx b/Enigma/Popups/AddParty.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Enigma/Popups/AddParty.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Enigma/Stations/HostStation.cs b/Enigma/Stations/HostStation.cs index 88a9635..4da3379 100644 --- a/Enigma/Stations/HostStation.cs +++ b/Enigma/Stations/HostStation.cs @@ -9,6 +9,9 @@ namespace Enigma.Stations { class HostStation : Station { + + public List
tables = new List
(); + public HostStation(StationTypeDef type, string stationid) : base(type, stationid) { view = new StationsGUI.HostStationView(); diff --git a/Enigma/StationsGUI/HostStationView.cs b/Enigma/StationsGUI/HostStationView.cs index a92a80f..b958cba 100644 --- a/Enigma/StationsGUI/HostStationView.cs +++ b/Enigma/StationsGUI/HostStationView.cs @@ -28,7 +28,7 @@ public HostStationView() private void HostStationView_Load(object sender, EventArgs e) { - + } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) diff --git a/EnigmaX/Classes/Party.cs b/EnigmaX/Classes/Party.cs new file mode 100644 index 0000000..fb97ac8 --- /dev/null +++ b/EnigmaX/Classes/Party.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnigmaX.Classes +{ + public class Party + { + + public string name; + public DateTime queueTime; + public Table table; + public int count; + + public Party(string name, int count) { + this.name = name; + table = null; + this.count = count; + queueTime = new DateTime(); + } + + public void setTable(Table table) + { + this.table = table; + } + + public bool isWaiting() { + return (table == null); + } + + } +} diff --git a/EnigmaX/Classes/Station.cs b/EnigmaX/Classes/Station.cs index 59bec25..4e3299d 100644 --- a/EnigmaX/Classes/Station.cs +++ b/EnigmaX/Classes/Station.cs @@ -52,6 +52,7 @@ public Station(StationTypeDef type, string stationid) { public bool registerStation() { interCom = new Intercom(_stationId, _stationType); _registered = interCom.register(); + Console.WriteLine(_stationId + " registered: " + _registered); return _registered; } diff --git a/EnigmaX/Classes/Table.cs b/EnigmaX/Classes/Table.cs new file mode 100644 index 0000000..e9bfce0 --- /dev/null +++ b/EnigmaX/Classes/Table.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EnigmaX.Classes +{ + public class Table + { + private int id; + public int capacity; + public int count; + public List patrons; + + public Table(int id, int capacity) { + this.id = id; + this.capacity = capacity; + patrons = new List(); + count = 0; + } + + public bool isFull() { + return count >= capacity; + } + + public int remaining { + get { + return capacity - count; + } + } + + public int tableId() { + return id; + } + + public void addPatron(Party p) { + if (!isFull()) { + patrons.Add(p); + p.setTable(this); + count++; + } + } + + public void removePatron(Party p) { + patrons.Remove(p); + count--; + } + + + } +} diff --git a/EnigmaX/EnigmaX.csproj b/EnigmaX/EnigmaX.csproj index 4abf994..709de8d 100644 --- a/EnigmaX/EnigmaX.csproj +++ b/EnigmaX/EnigmaX.csproj @@ -61,7 +61,9 @@ + +