示例#1
0
        // --- ADD WAYPOINT/OBSTACLE BUTTON ---
        private void btn_MiWbObAdd_Click(object sender, EventArgs e)
        {
            switch (cb_miUc_WpOb.SelectedIndex)
            {
                case 0:
                    // waypoint
                    float mi_WpLat, mi_WpLon;
                    if (!float.TryParse(tb_miUc_WpObLat.Text, style, culture, out mi_WpLat))
                    {
                        addLineToEventLog("Error parsing mission waypoint latitude");
                        return;
                    }
                    if (!float.TryParse(tb_miUc_wpObLon.Text, style, culture, out mi_WpLon))
                    {
                        addLineToEventLog("Error parsing mission waypoint longitude");
                        return;
                    }

                    // create waypoint
                    AS_GUI_data.waypoint_list_s wp = new AS_GUI_data.waypoint_list_s("Waypoint" + clb_miUc_wp.Items.Count.ToString(), mi_WpLat, mi_WpLon);

                    // add to checked list box
                    clb_miUc_wp.Items.Add(wp);
                    clb_miUc_wp.SetItemChecked(clb_miUc_wp.Items.Count - 1, wp.isChecked);
                    addLineToEventLog("Waypoint added");
                    break;
                case 1:
                    // obstacle
                    float mi_ObLat, mi_ObLon, mi_ObRad;
                    if (!float.TryParse(tb_miUc_WpObLat.Text, style, culture, out mi_ObLat))
                    {
                        addLineToEventLog("Error parsing mission obstacle latitude");
                        return;
                    }
                    if (!float.TryParse(tb_miUc_wpObLon.Text, style, culture, out mi_ObLon))
                    {
                        addLineToEventLog("Error parsing mission obstacle longitude");
                        return;
                    }
                    if (!float.TryParse(tb_miUc_obRad.Text, style, culture, out mi_ObRad))
                    {
                        addLineToEventLog("Error parsing mission obstacle radius");
                        return;
                    }

                    // create obstacle
                    AS_GUI_data.waypoint_s ob_center = new AS_GUI_data.waypoint_s("ob_center" + clb_miUc_ob.Items.Count.ToString(), mi_ObLat, mi_ObLon);
                    AS_GUI_data.obstacle_list_s ob = new AS_GUI_data.obstacle_list_s("Obstacle" + clb_miUc_ob.Items.Count.ToString(), ob_center, mi_ObRad);

                    // add to checked list box
                    clb_miUc_ob.Items.Add(ob);
                    clb_miUc_ob.SetItemChecked(clb_miUc_ob.Items.Count - 1, ob.isChecked);
                    addLineToEventLog("Obstacle added");
                    break;
                default:
                    // nothing selected
                    addLineToEventLog("Must select either waypoint or obstacle");
                    break;
            }
        }
示例#2
0
        // --- CF ADD BUOY BUTTON ---
        private void btn_frBuoyAdd_Click(object sender, EventArgs e)
        {
            // try to parse input values
            float fr_buoyLat, fr_buoyLon, fr_buoyRad;
            if (!float.TryParse(tb_frBuoyLat.Text, style, culture, out fr_buoyLat))
            {
                addLineToEventLog("Error parsing frame buoy latitude");
                return;
            }
            if (!float.TryParse(tb_frBuoyLon.Text, style, culture, out fr_buoyLon))
            {
                addLineToEventLog("Error parsing frame buoy longitude");
                return;
            }
            if (!float.TryParse(tb_frBuoyRad.Text, style, culture, out fr_buoyRad))
            {
                addLineToEventLog("Error parsing frame buoy radius");
                return;
            }
            int fr_buoyRot;
            if (cb_frBuoyRot.SelectedIndex == -1)
            {
                addLineToEventLog("Error parsing frame buoy rotation");
                return;
            } else
            {
                fr_buoyRot = cb_frBuoyRot.SelectedIndex;
            }

            // create buoy
            AS_GUI_data.waypoint_s bu_wp = new AS_GUI_data.waypoint_s("bu_body_center", fr_buoyLat, fr_buoyLon);
            AS_GUI_data.obstacle_s bu_ob = new AS_GUI_data.obstacle_s("bu_body", bu_wp, fr_buoyRad);
            AS_GUI_data.buoy_list_s bu = new AS_GUI_data.buoy_list_s("Buoy" + clb_frBuoys.Items.Count.ToString(), bu_ob, fr_buoyRot);

            // add to checked list box
            clb_frBuoys.Items.Add(bu);
            clb_frBuoys.SetItemChecked(clb_frBuoys.Items.Count - 1, bu.isChecked);

            // advertise
            addLineToEventLog("Buoy added");
        }