From 2414f2edcc9a7db49ceee2640cf8287284d565a5 Mon Sep 17 00:00:00 2001 From: Evan Langlais Date: Fri, 3 Mar 2017 13:13:52 -0500 Subject: [PATCH] Added station inheretence and a controller / model idea. --- Enigma/Enigma.csproj | 22 +++- Enigma/Program.cs | 7 +- Enigma/Stations/DebugStation.cs | 22 ++++ Enigma/Stations/HostStation.cs | 19 +++ .../DebugStationView.Designer.cs} | 2 +- .../DebugStationView.cs} | 22 ++-- .../DebugStationView.resx} | 0 .../StationsGUI/HostStationView.Designer.cs | 47 +++++++ Enigma/StationsGUI/HostStationView.cs | 25 ++++ Enigma/StationsGUI/HostStationView.resx | 120 ++++++++++++++++++ EnigmaX/Classes/Station.cs | 28 ++-- 11 files changed, 288 insertions(+), 26 deletions(-) create mode 100644 Enigma/Stations/DebugStation.cs create mode 100644 Enigma/Stations/HostStation.cs rename Enigma/{DebugForm.Designer.cs => StationsGUI/DebugStationView.Designer.cs} (98%) rename Enigma/{DebugForm.cs => StationsGUI/DebugStationView.cs} (66%) rename Enigma/{DebugForm.resx => StationsGUI/DebugStationView.resx} (100%) create mode 100644 Enigma/StationsGUI/HostStationView.Designer.cs create mode 100644 Enigma/StationsGUI/HostStationView.cs create mode 100644 Enigma/StationsGUI/HostStationView.resx diff --git a/Enigma/Enigma.csproj b/Enigma/Enigma.csproj index c87a889..4959c33 100644 --- a/Enigma/Enigma.csproj +++ b/Enigma/Enigma.csproj @@ -62,16 +62,24 @@ - + Form - - DebugForm.cs + + DebugStationView.cs - - DebugForm.cs + + Form + + + HostStationView.cs + + + + + DebugStationView.cs ResXFileCodeGenerator @@ -82,6 +90,9 @@ True Resources.resx + + HostStationView.cs + SettingsSingleFileGenerator @@ -102,6 +113,7 @@ EnigmaX + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/EnigmaX/Classes/Station.cs b/EnigmaX/Classes/Station.cs index 162ac34..59bec25 100644 --- a/EnigmaX/Classes/Station.cs +++ b/EnigmaX/Classes/Station.cs @@ -3,20 +3,23 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows.Forms; namespace EnigmaX.Classes { public enum StationTypeDef { chef, waiter, admin, host }; - public class Station + public abstract class Station { - private string stationId = ""; - private StationTypeDef stationType; - public Intercom interCom; + private string _stationId = ""; + private StationTypeDef _stationType; private bool _registered; + public Form view; + public Intercom interCom; + public string StationID { get { - return stationId; + return _stationId; } } @@ -30,28 +33,35 @@ public StationTypeDef StationType { get { - return stationType; + return _stationType; } } public Station(StationTypeDef type, string stationid) { - stationType = type; + _stationType = type; if (stationid.Contains("%") || stationid.Contains("-") || stationid.Contains("|")) { throw new Exception("StationID cannot contain %, -, or | special characters"); } else { - stationId = stationid; + _stationId = stationid; } } public bool registerStation() { - interCom = new Intercom(stationId, stationType); + interCom = new Intercom(_stationId, _stationType); _registered = interCom.register(); return _registered; } + public virtual void showView() { + if (view != null) { + view.Show(); + view.WindowState = FormWindowState.Maximized; + } + } + }