コード例 #1
0
        public void initPanels(RailRoad railroad)
        {
            lbTracks.Items.Clear();
            lbTracks.Items.Add("ID:               Occupied");
            lbTracks.Items.Add("");

            Dictionary<Track, TrainSet> tracks = railroad.getTrackStatus();
            foreach (Track t in tracks.Keys)
            {
                string status = "Track #" + t.id;
                if (tracks[t] != null)
                    status += "     " + tracks[t].name + "    ";
                else
                    status += "                      ";

                if (t is SwitchLeft || t is SwitchRight)
                {
                    if (t.turn)
                        status += "Switched";
                    else
                        status += "Through";

                }
                lbTracks.Items.Add(status);
            }
        }
コード例 #2
0
        public void updatePanels(RailRoad railroad)
        {
            lbTrains.Items.Clear();
            lbTrains.Items.Add("ID:               Speed");
            lbTrains.Items.Add("");

            lbSignals.Items.Clear();
            lbSignals.Items.Add("ID:                Status");
            lbSignals.Items.Add("");

            lbSensors.Items.Clear();
            lbSensors.Items.Add("ID:                     Status");
            lbSensors.Items.Add("");

            Dictionary<Track, TrainSet> tracks = railroad.getTrackStatus();
            int count = 1;
            foreach(Track t in tracks.Keys)
            {
                count++;
                string status = "Track #" + t.id;
                if (tracks[t] != null)
                    status += "     " + tracks[t].name + "    ";
                else
                    status += "                      ";

                if(t is SwitchLeft || t is SwitchRight)
                {
                    if (t.turn)
                        status += "Switched";
                    else
                        status += "Through";

                }
                lbTracks.Items[count] = status;

                if (t.signal != null)
                {
                    lbSignals.Items.Add(t.signal);
                }

                if (t.sensor != null)
                {
                    status = "";
                    if (t.sensor.state == Sensor.State.On)
                        status = "          On";
                    else
                        status = "          Off";
                    lbSensors.Items.Add("Sensor #" + t.sensor.id + status);
                }
            }

            foreach (TrainSet train in railroad.trains)
            {
                lbTrains.Items.Add(train);
            }
        }