Ejemplo n.º 1
0
        private void OnTextBoxValueUpdate(object sender, EventArgs e)
        {
            OnLocationSave(sender, e);

            string team  = m_teams.First();
            string other = m_teams.Last();

            // Get friend location state
            RenamableButton key    = m_locations[team].First().ActiveButton();
            LocationState   friend = m_states[team][key];

            // Get target location state
            key = m_locations[other].First().ActiveButton();
            LocationState target = m_states[other][key];

            // run calculation
            LocationState result = LocationState.CalculateVector(friend, target);

            double distance = Math.Round(result.Distance, 1);

            Color result_text = (distance < 75 || distance > 150) ? (new ColorPalette.BasePalette()).Accent : Color.White;

            m_lbl_result_dist_value.ForeColor = m_lbl_result_azim_value.ForeColor = result_text;

            m_lbl_result_dist_value.Text = distance.ToString("F1");
            m_lbl_result_azim_value.Text = Math.Round(result.Azimuth, 1).ToString("F1");
        }
Ejemplo n.º 2
0
        private void OnLocationSave(object sender, EventArgs e)
        {
            NumericUpDown nud = (NumericUpDown)sender;

            if (nud.Parent != null)
            {
                RenamableButton button_key = null;
                Dictionary <RenamableButton, LocationState> state = null;
                foreach (string team in m_teams)
                {
                    if (nud.Name.Contains(team))
                    {
                        button_key = m_locations[team].First().ActiveButton();
                        state      = m_states[team];
                        break;
                    }
                }

                if (button_key != null && state != null)
                {
                    List <NumericUpDown> boxes = nud.Parent.Controls.OfType <NumericUpDown>().ToList();
                    if (nud == boxes.First())
                    {
                        state[button_key].Distance = (double)boxes.First().Value;
                    }
                    else if (nud == boxes.Last())
                    {
                        state[button_key].Azimuth = (double)boxes.Last().Value;
                    }
                    state[button_key].Default = false;
                }
            }
        }
Ejemplo n.º 3
0
        private void OnLoadLocationState(object sender, EventArgs e)
        {
            RenamableButton key = (RenamableButton)sender;

            if (key != null)
            {
                // Get my LocationState
                string        control_set = "";
                LocationState location    = null;
                foreach (string team in m_teams)
                {
                    if (key.Name.Contains(team))
                    {
                        control_set = team;
                        location    = m_states[team][key];
                        break;
                    }
                }

                // Load state values into my Parent's boxes
                if (control_set == m_teams.First())
                {
                    m_nud_friend_distance.Value = (decimal)location.Distance;
                    m_nud_friend_azimuth.Value  = (decimal)location.Azimuth;
                }
                else if (control_set == m_teams.Last())
                {
                    m_nud_target_distance.Value = (decimal)location.Distance;
                    m_nud_target_azimuth.Value  = (decimal)location.Azimuth;
                }
            }
        }