示例#1
0
        private void comZones_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comZones.SelectedIndex == -1)
            {
                return;
            }

            IZone zone = SelectedRealm.GetZone(comZones.SelectedItem.ToString());

            string[] values    = null;
            bool     validPath = false;

            if (!String.IsNullOrEmpty(EngineSettings.Default.InitialRoom))
            {
                values = EngineSettings.Default.InitialRoom.Split('>');

                if (values.Length == 3)
                {
                    validPath = true;
                }
            }

            if (zone == null)
            {
                MessageBox.Show("There was an error retreiving the specified Zone.", this.Text);
                return;
            }
            else
            {
                //Must be set prior to changing the list box index
                SelectedZone = zone;
            }

            IRoom[] rooms = zone.GetRooms();

            if (rooms == null)
            {
                return;
            }
            else if (rooms.Length == 0)
            {
                return;
            }

            foreach (IRoom room in rooms)
            {
                lstRooms.Items.Add(room.Name);

                if (validPath)
                {
                    if (values[2] == room.Name)
                    {
                        lstRooms.SelectedItem = room.Name;
                    }
                }
            }

            if (lstRooms.Items.Count > 0)
            {
                lstRooms.SelectedIndex = 0;
            }
        }