예제 #1
0
        private void toggleCrossing(object sender, ListViewColumnMouseEventArgs e)
        {
            int crossingId = Int32.Parse(e.Item.SubItems[0].Text); //get switch id

            Console.WriteLine(crossingId);

            foreach (TrackController ctrl in TrackControllerModule.activeControllers)
            {
                Console.WriteLine(ctrl.controllerName);
                if (ctrl.getCrossings().Find(x => x.blockId == crossingId) != null)
                {
                    bool newState = ctrl.toggleCrossing(crossingId);
                    e.Item.SubItems[1].Text = newState.ToString();
                    MessageBox.Show(this, @"Crossing at block " + crossingId + ": Activated - " + newState);
                }
            }
        }
예제 #2
0
        private void changeSwitch(object sender, ListViewColumnMouseEventArgs e)
        {
            Console.WriteLine("Changing switch");
            Console.WriteLine(e.Button);
            int switchId = Int32.Parse(e.Item.SubItems[0].Text); //get switch id

            foreach (TrackController ctrl in TrackControllerModule.activeControllers)
            {
                if (ctrl.getSwitches().Find(x => x.switchId == switchId) != null)
                {
                    int?newState = ctrl.changeSwitchState(switchId);
                    newState = TrainSimulation.trackModelWindow.findBlock((int)newState).blockNum;
                    e.Item.SubItems[2].Text = newState.ToString();
                    MessageBox.Show(this, @"Switch " + switchId + " changed to block " + newState);
                    updateSwitchLights();
                    break;
                }
            }
        }