diff --git a/AIParkingApplication/AIParkingApplicationForm.cs b/AIParkingApplication/AIParkingApplicationForm.cs index 345add0..ac15df4 100644 --- a/AIParkingApplication/AIParkingApplicationForm.cs +++ b/AIParkingApplication/AIParkingApplicationForm.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.Linq; using System.Windows.Forms; namespace AIParkingApplication @@ -124,28 +125,49 @@ namespace AIParkingApplication private void toolStripMenuItemSwitchLaneInIn_Click(object sender, EventArgs e) { + UpdateMenuStripItemStatus(sender as ToolStripMenuItem); StopAllLanes(); UpdateLaneInIn(); } private void toolStripMenuItemSwitchLaneInOut_Click(object sender, EventArgs e) { + UpdateMenuStripItemStatus(sender as ToolStripMenuItem); StopAllLanes(); UpdateLaneInOut(); } private void toolStripMenuItemSwitchLaneOutIn_Click(object sender, EventArgs e) { + UpdateMenuStripItemStatus(sender as ToolStripMenuItem); StopAllLanes(); UpdateLaneOutIn(); } private void toolStripMenuItemSwitchLaneOutOut_Click(object sender, EventArgs e) { + UpdateMenuStripItemStatus(sender as ToolStripMenuItem); StopAllLanes(); UpdateLaneOutOut(); } + private void UpdateMenuStripItemStatus(ToolStripMenuItem selectedToolStripMenuItem) + { + if (selectedToolStripMenuItem != null) + { + ((ToolStripMenuItem)selectedToolStripMenuItem.OwnerItem).DropDownItems + .OfType().ToList() + .ForEach(item => + { + item.Checked = false; + item.Enabled = true; + }); + + selectedToolStripMenuItem.Checked = true; + selectedToolStripMenuItem.Enabled = false; + } + } + private void StopAllLanes() { laneIn12.DoorId = 10;