diff --git a/CoordinateConverter/CoordinateConverter.csproj b/CoordinateConverter/CoordinateConverter.csproj index 01dec7b..9562f77 100644 --- a/CoordinateConverter/CoordinateConverter.csproj +++ b/CoordinateConverter/CoordinateConverter.csproj @@ -65,6 +65,9 @@ + + + Form diff --git a/CoordinateConverter/DCS/Aircraft/AV8B.cs b/CoordinateConverter/DCS/Aircraft/AV8B.cs new file mode 100644 index 0000000..7cd6b94 --- /dev/null +++ b/CoordinateConverter/DCS/Aircraft/AV8B.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace CoordinateConverter.DCS.Aircraft +{ + public class AV8B : DCSAircraft + { + public override List GetPointActions(CoordinateDataEntry coordinate) + { + throw new NotImplementedException(); + } + + public override List GetPointOptionsForType(string pointTypeStr) + { + throw new NotImplementedException(); + } + + public override List GetPointTypes() + { + throw new NotImplementedException(); + } + + public override List GetPostPointActions() + { + throw new NotImplementedException(); + } + + public override List GetPrePointActions() + { + throw new NotImplementedException(); + } + } +} diff --git a/CoordinateConverter/DCS/Aircraft/F15E.cs b/CoordinateConverter/DCS/Aircraft/F15E.cs new file mode 100644 index 0000000..3b08321 --- /dev/null +++ b/CoordinateConverter/DCS/Aircraft/F15E.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; + +namespace CoordinateConverter.DCS.Aircraft +{ + public class F15E : DCSAircraft + { + public override List GetPointActions(CoordinateDataEntry coordinate) + { + throw new NotImplementedException(); + } + + public override List GetPointOptionsForType(string pointTypeStr) + { + throw new NotImplementedException(); + } + + public override List GetPointTypes() + { + throw new NotImplementedException(); + } + + public override List GetPostPointActions() + { + throw new NotImplementedException(); + } + + public override List GetPrePointActions() + { + throw new NotImplementedException(); + } + } +} diff --git a/CoordinateConverter/DCS/Aircraft/M2000.cs b/CoordinateConverter/DCS/Aircraft/M2000.cs new file mode 100644 index 0000000..d7c9b83 --- /dev/null +++ b/CoordinateConverter/DCS/Aircraft/M2000.cs @@ -0,0 +1,32 @@ +using System.Collections.Generic; + +namespace CoordinateConverter.DCS.Aircraft +{ + public class M2000 : DCSAircraft + { + public override List GetPointActions(CoordinateDataEntry coordinate) + { + throw new System.NotImplementedException(); + } + + public override List GetPointOptionsForType(string pointTypeStr) + { + throw new System.NotImplementedException(); + } + + public override List GetPointTypes() + { + throw new System.NotImplementedException(); + } + + public override List GetPostPointActions() + { + throw new System.NotImplementedException(); + } + + public override List GetPrePointActions() + { + throw new System.NotImplementedException(); + } + } +} diff --git a/CoordinateConverter/MainForm.Designer.cs b/CoordinateConverter/MainForm.Designer.cs index f82aaaf..ccf70be 100644 --- a/CoordinateConverter/MainForm.Designer.cs +++ b/CoordinateConverter/MainForm.Designer.cs @@ -143,7 +143,7 @@ private void InitializeComponent() this.tsmi_F15E_WSO = new System.Windows.Forms.ToolStripMenuItem(); this.tsmi_F16Menu = new System.Windows.Forms.ToolStripMenuItem(); this.tsmi_F16 = new System.Windows.Forms.ToolStripMenuItem(); - this.tsmi_F16_SetStartFirstPoint = new System.Windows.Forms.ToolStripMenuItem(); + this.tsmi_F16_SetFirstPoint = new System.Windows.Forms.ToolStripMenuItem(); this.tsmi_F18 = new System.Windows.Forms.ToolStripMenuItem(); this.tsmi_JF17Menu = new System.Windows.Forms.ToolStripMenuItem(); this.tsmi_JF17 = new System.Windows.Forms.ToolStripMenuItem(); @@ -1484,7 +1484,7 @@ private void InitializeComponent() // this.tsmi_F16Menu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tsmi_F16, - this.tsmi_F16_SetStartFirstPoint}); + this.tsmi_F16_SetFirstPoint}); this.tsmi_F16Menu.Name = "tsmi_F16Menu"; this.tsmi_F16Menu.Size = new System.Drawing.Size(116, 22); this.tsmi_F16Menu.Text = "F16"; @@ -1498,10 +1498,10 @@ private void InitializeComponent() // // tsmi_F16_SetStartFirstPoint // - this.tsmi_F16_SetStartFirstPoint.Name = "tsmi_F16_SetStartFirstPoint"; - this.tsmi_F16_SetStartFirstPoint.Size = new System.Drawing.Size(171, 22); - this.tsmi_F16_SetStartFirstPoint.Text = "Set first point..."; - this.tsmi_F16_SetStartFirstPoint.Click += new System.EventHandler(this.Tsmi_F16_SetFirstPoint_Click); + this.tsmi_F16_SetFirstPoint.Name = "tsmi_F16_SetStartFirstPoint"; + this.tsmi_F16_SetFirstPoint.Size = new System.Drawing.Size(171, 22); + this.tsmi_F16_SetFirstPoint.Text = "Set first point..."; + this.tsmi_F16_SetFirstPoint.Click += new System.EventHandler(this.Tsmi_F16_SetFirstPoint_Click); // // tsmi_F18 // @@ -2106,7 +2106,7 @@ private void InitializeComponent() private ToolStripMenuItem tsmi_F15E_WSO; private ToolStripMenuItem tsmi_StopTransfer; private ToolStripMenuItem tsmi_F16; - private ToolStripMenuItem tsmi_F16_SetStartFirstPoint; + private ToolStripMenuItem tsmi_F16_SetFirstPoint; private ToolStripMenuItem tsmi_JF17Menu; private ToolStripMenuItem tsmi_JF17; private ToolStripMenuItem tsmi_JF17_SetFirstPoint; diff --git a/CoordinateConverter/MainForm.cs b/CoordinateConverter/MainForm.cs index b6bc4e2..51515af 100644 --- a/CoordinateConverter/MainForm.cs +++ b/CoordinateConverter/MainForm.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Data; using System.Drawing; +using System.Drawing.Text; using System.IO; using System.Linq; using System.Text; @@ -1819,6 +1820,23 @@ private List AircraftSelectionMenuStripItems { }; } + private Dictionary> AircraftMenuStripItemsForAircraftType + { + get => new Dictionary>() + { + { typeof(A10C), new List() { tsmi_A10C, tsmi_A10C_UseMGRS } }, + { typeof(AH64), new List() { tsmi_AH64_CPG, tsmi_AH64_PLT, tsmi_AH64_ClearPoints } }, + { typeof(AV8B), new List() { tsmi_AV8B } }, + { typeof(F15E), new List() { tsmi_F15E_Pilot, tsmi_F15E_WSO } }, + { typeof(F16C), new List() { tsmi_F16, tsmi_F16_SetFirstPoint } }, + { typeof(JF17), new List() { tsmi_JF17, tsmi_JF17_SetFirstPoint } }, + { typeof(F18C), new List() { tsmi_F18 } }, + { typeof(KA50), new List() { tsmi_KA50 } }, + { typeof(M2000), new List() { tsmi_M2000 } }, + + }; + } + private void Tsmi_Aircraft_Auto_Click(object objSender, EventArgs e) { ToolStripMenuItem sender = objSender as ToolStripMenuItem; @@ -1828,13 +1846,16 @@ private void Tsmi_Aircraft_Auto_Click(object objSender, EventArgs e) private void UpdateAircraftSelectionItemsBasedOnAutoSetting() { - if (tsmi_Auto.Checked) + foreach (var menuItemList in AircraftMenuStripItemsForAircraftType.Values) { - foreach (ToolStripMenuItem menuItem in AircraftSelectionMenuStripItems) + foreach (var menuItem in menuItemList) { menuItem.Enabled = false; menuItem.Checked = false; } + } + if (tsmi_Auto.Checked) + { selectedAircraft = null; } else @@ -1844,93 +1865,69 @@ private void UpdateAircraftSelectionItemsBasedOnAutoSetting() { menuItem.Enabled = true; } - tsmi_AH64_ClearPoints.Enabled = true; - tsmi_F16_SetStartFirstPoint.Enabled = true; - tsmi_JF17_SetFirstPoint.Enabled = true; } } private void AutoSelectAircraft(string model) { - foreach (ToolStripMenuItem mi in AircraftSelectionMenuStripItems) - { - mi.Enabled = false; - } - tsmi_AH64_ClearPoints.Enabled = false; - tsmi_F16_SetStartFirstPoint.Enabled = false; - tsmi_JF17_SetFirstPoint.Enabled = false; - tsmi_A10C_UseMGRS.Enabled = false; - if (string.IsNullOrEmpty(model) || model == "null") { selectedAircraft = null; + return; } - else + + // Switch aircraft. Ask user here which version of the cockpit they are in. (AH64, F15E) + switch (model) { - // Switch aircraft. Ask user here which version of the cockpit they are in. (AH64, F15E) - switch (model) - { - case "AH-64D_BLK_II": - tsmi_AH64_PLT.Enabled = true; - tsmi_AH64_CPG.Enabled = true; - tsmi_AH64_ClearPoints.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(AH64)) - { - break; - } - FormAskBinaryQuestion isPltForm = new FormAskBinaryQuestion(this, "Which station are you in?", "Pilot", "CPG"); - Tsmi_AircraftSelection_Click(isPltForm.Result ? tsmi_AH64_PLT : tsmi_AH64_CPG, null); - break; - case "FA-18C_hornet": - tsmi_F18.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(F18C)) - { - break; - } - Tsmi_AircraftSelection_Click(tsmi_F18, null); + case "AH-64D_BLK_II": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(AH64)) + { break; - case "F-16C_50": - tsmi_F16.Enabled = true; - tsmi_F16_SetStartFirstPoint.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(F16C)) - { - break; - } - Tsmi_AircraftSelection_Click(tsmi_F16, null); + } + FormAskBinaryQuestion isPltForm = new FormAskBinaryQuestion(this, "Which station are you in?", "Pilot", "CPG"); + Tsmi_AircraftSelection_Click(isPltForm.Result ? tsmi_AH64_PLT : tsmi_AH64_CPG, null); + break; + case "FA-18C_hornet": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(F18C)) + { break; - case "Ka-50": - case "Ka-50_3": - tsmi_KA50.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(KA50)) - { - break; - } - Tsmi_AircraftSelection_Click(tsmi_KA50, null); + } + Tsmi_AircraftSelection_Click(tsmi_F18, null); + break; + case "F-16C_50": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(F16C)) + { break; - case "A-10C": - case "A-10C_2": - tsmi_A10C_UseMGRS.Enabled = true; - tsmi_A10C.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(A10C)) - { - break; - } - Tsmi_AircraftSelection_Click(tsmi_A10C, null); + } + Tsmi_AircraftSelection_Click(tsmi_F16, null); + break; + case "Ka-50": + case "Ka-50_3": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(KA50)) + { break; - case "JF-17": - tsmi_JF17.Enabled = true; - tsmi_JF17_SetFirstPoint.Enabled = true; - if (selectedAircraft != null && selectedAircraft.GetType() == typeof(JF17)) - { - break; - } - Tsmi_AircraftSelection_Click(tsmi_JF17, null); + } + Tsmi_AircraftSelection_Click(tsmi_KA50, null); + break; + case "A-10C": + case "A-10C_2": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(A10C)) + { break; - default: - lbl_DCS_Status.Text = "Unknown aircraft: \"" + model + "\""; - lbl_DCS_Status.BackColor = DCS_ERROR_COLOR; + } + Tsmi_AircraftSelection_Click(tsmi_A10C, null); + break; + case "JF-17": + if (selectedAircraft != null && selectedAircraft.GetType() == typeof(JF17)) + { break; - } + } + Tsmi_AircraftSelection_Click(tsmi_JF17, null); + break; + default: + lbl_DCS_Status.Text = "Unknown aircraft: \"" + model + "\""; + lbl_DCS_Status.BackColor = DCS_ERROR_COLOR; + break; } } @@ -1946,16 +1943,62 @@ private void Tsmi_AircraftSelection_Click(object objSender, EventArgs e) mi.Checked = mi.Name == sender.Name; } + // turn off the aircraft specific menu items for all aircraft (we enable the correct ones later) + foreach (var menuItemList in AircraftMenuStripItemsForAircraftType.Values) + { + foreach (var menuItem in menuItemList) + { + if (AircraftSelectionMenuStripItems.Contains(menuItem)) + { + // ignore the aircraft item directly, only disable the extra menu items + // the aircraft selection menu items are handled by the auto menu item and aircraft auto select + continue; + } + menuItem.Enabled = false; + } + } + + if (!SetSelectedAircraft(sender.Name)) + { + // Unsupported aircraft + selectedAircraft = null; + lbl_Error.Visible = true; + lbl_Error.Text = "Currently this aircraft is not implemented"; + + cb_PointType.Items.Clear(); + cb_PointType.Items.Add(new ComboItem("Waypoint", "Point")); + cb_PointType.Enabled = false; + cb_PointType.SelectedIndex = 0; + RefreshDataGrid(EDataGridUpdateType.UpdateCells); + return; + } + + if (selectedAircraft != null) + { + foreach (var menuItem in AircraftMenuStripItemsForAircraftType[selectedAircraft.GetType()]) + { + menuItem.Enabled = true; + } + } + + UpdatePointTypesForSelectedAircraft(); + UpdateOrAddAircraftSpecificDataForInput(); + + RefreshDataGrid(EDataGridUpdateType.UpdateCells); + } + + private bool SetSelectedAircraft(string ControlName) + { // Remind user here: "Transfer uses MGRS instead of L/L if MGRS selected, cockpit must match" - if (sender.Name == tsmi_AH64_PLT.Name) + if (ControlName == tsmi_AH64_PLT.Name) { selectedAircraft = new AH64(true); } - else if (sender.Name == tsmi_AH64_CPG.Name) + else if (ControlName == tsmi_AH64_CPG.Name) { selectedAircraft = new AH64(false); } - else if (sender.Name == tsmi_F18.Name) + else if (ControlName == tsmi_F18.Name) { selectedAircraft = new F18C(); string message = "Make sure PRECISE mode is selected in HSI->Data.\n" + @@ -1964,13 +2007,13 @@ private void Tsmi_AircraftSelection_Click(object objSender, EventArgs e) "Make sure aircraft is in L/L Decimal mode (default). Check in HSI -> Data -> Aircraft -> Bottom right\n" + "Make sure no weapon is selected prior to entering weapon data\n" + "Maximum number SLAM-ER of steer points is 5."; - FormMessage reminder = new FormMessage(this, "Reminder", "OK", message); + new FormMessage(this, "Reminder", "OK", message).Dispose(); } - else if (sender.Name == tsmi_F16.Name) + else if (ControlName == tsmi_F16.Name) { - Tsmi_F16_SetFirstPoint_Click(tsmi_F16_SetStartFirstPoint, null); + Tsmi_F16_SetFirstPoint_Click(tsmi_F16_SetFirstPoint, null); } - else if (sender.Name == tsmi_A10C.Name) + else if (ControlName == tsmi_A10C.Name) { // Ask if user wants to use MGRS or LL string questionText = "Do you wish to use MGRS/UTM or L/L?\n" + @@ -1984,34 +2027,27 @@ private void Tsmi_AircraftSelection_Click(object objSender, EventArgs e) // Select aircraft selectedAircraft = new A10C(!useLL); } - else if (sender.Name == tsmi_JF17.Name) + else if (ControlName == tsmi_JF17.Name) { Tsmi_JF17_SetFirstPoint_Click(tsmi_JF17_SetFirstPoint, null); } - else if (sender.Name == tsmi_KA50.Name) + else if (ControlName == tsmi_KA50.Name) { selectedAircraft = new KA50(); } - else if (sender.Name == tsmi_A10C.Name) + else if (ControlName == tsmi_A10C.Name) { Tsmi_A10C_UseMGRS_Click(tsmi_A10C_UseMGRS, null); } else { - // Unsupported aircraft - selectedAircraft = null; - lbl_Error.Visible = true; - lbl_Error.Text = "Currently this aircraft is not implemented"; - - cb_PointType.Items.Clear(); - cb_PointType.Items.Add(new ComboItem("Waypoint", "Point")); - cb_PointType.Enabled = false; - cb_PointType.SelectedIndex = 0; - RefreshDataGrid(EDataGridUpdateType.UpdateCells); - return; + return false; } + return true; + } - // Update point types for aircraft that have them + private void UpdatePointTypesForSelectedAircraft() + { cb_PointType.Items.Clear(); if (selectedAircraft.GetType() == typeof(AH64)) { @@ -2048,9 +2084,10 @@ private void Tsmi_AircraftSelection_Click(object objSender, EventArgs e) cb_PointType.Items.AddRange(selectedAircraft.GetPointTypes().Select(x => new ComboItem(x, x)).ToArray()); } cb_PointType.Enabled = cb_PointType.Items.Count > 1; - + } - // Add aircraft specific data to the input if input is valid (exists) + private void UpdateOrAddAircraftSpecificDataForInput() + { if (selectedAircraft.GetType() == typeof(AH64)) { // if the point has AH64 data, we load it. @@ -2151,8 +2188,6 @@ private void Tsmi_AircraftSelection_Click(object objSender, EventArgs e) { cb_PointType.SelectedIndex = 0; } - - RefreshDataGrid(EDataGridUpdateType.UpdateCells); } private void Cb_pointType_SelectedIndexChanged(object objSender, EventArgs e)