コード例 #1
0
        private void buttonAddLocation_Click(object sender, EventArgs e)
        {
            FormAddLocation formAddLocation = new FormAddLocation();
            EDLocation      newLocation     = formAddLocation.AddLocation(listBoxLocations, this);

            if (newLocation == null)
            {
                return;
            }
            _locations.Add(newLocation);
        }
コード例 #2
0
        private void buttonEditLocation_Click(object sender, EventArgs e)
        {
            if (listBoxLocations.SelectedIndex < 0)
            {
                return;
            }

            try
            {
                FormAddLocation formAddLocation = new FormAddLocation();
                EDLocation      location        = _locations[listBoxLocations.SelectedIndex];
                formAddLocation.EditLocation(location, this);
                if (!((string)listBoxLocations.SelectedItem).Equals(location.Name))
                {
                    listBoxLocations.Items[listBoxLocations.SelectedIndex] = location.Name;
                }
            }
            catch { }
        }
コード例 #3
0
        private void comboBoxLocation_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxLocation.SelectedIndex < 0)
            {
                return;
            }

            if (comboBoxLocation.SelectedIndex == 0)
            {
                // Show the location editor
                comboBoxLocation.SelectedIndex = -1;
                FormAddLocation formAddLocation = new FormAddLocation();
                EDLocation      newLocation     = formAddLocation.GetLocation(this);
                if (newLocation != null)
                {
                    LocationManager.AddLocation(newLocation);
                    comboBoxLocation.Items.Add(newLocation.Name);
                    comboBoxLocation.SelectedIndex = comboBoxLocation.Items.Count - 1;
                }
                formAddLocation.Dispose();
                return;
            }

            LocationManager locationManager = new LocationManager();

            if (locationManager.Locations.Count > 0)
            {
                foreach (EDLocation location in locationManager.Locations)
                {
                    if (location.Name.Equals(comboBoxLocation.SelectedItem.ToString()))
                    {
                        _targetPosition = location;
                        UpdateTrackingTarget(location.Name);
                        DisplayTarget();
                        break;
                    }
                }
            }
            locationManager.Dispose();
        }