コード例 #1
0
ファイル: JoystickSettings.cs プロジェクト: wangbo121/UAV-NET
        public JoystickSettings(UAVCommons.UAVStructure joystick, UAVCommons.UAVDataMapping mapping)
        {
            InitializeComponent();
            this.mapping  = mapping;
            this.joystick = joystick;
            string[] keys = new string[mapping.Mapping.Keys.Count];
            mapping.Mapping.Keys.CopyTo(keys, 0);
            List <string> stearingFunctions = new List <string>();

            stearingFunctions.Add("phi_rollrate");
            stearingFunctions.Add("theta_rollrate");
            stearingFunctions.Add("psi_rollrate");
            stearingFunctions.Add("throttle");
            stearingFunctions.Add("");
            comboBox1.Items.AddRange(stearingFunctions.ToArray());
            comboBox2.Items.AddRange(stearingFunctions.ToArray());
            comboBox3.Items.AddRange(stearingFunctions.ToArray());
            comboBox4.Items.AddRange(stearingFunctions.ToArray());
            comboBox5.Items.AddRange(stearingFunctions.ToArray());
            comboBox6.Items.AddRange(stearingFunctions.ToArray());
            if (mapping.Mapping.ContainsKey("Axis0"))
            {
                comboBox1.SelectedItem = mapping.Mapping["Axis0"];
            }
            if (mapping.Mapping.ContainsKey("Axis1"))
            {
                comboBox2.SelectedItem = mapping.Mapping["Axis1"];
            }
            if (mapping.Mapping.ContainsKey("Axis2"))
            {
                comboBox3.SelectedItem = mapping.Mapping["Axis2"];
            }
            if (mapping.Mapping.ContainsKey("Axis3"))
            {
                comboBox4.SelectedItem = mapping.Mapping["Axis3"];
            }
            if (mapping.Mapping.ContainsKey("Axis4"))
            {
                comboBox5.SelectedItem = mapping.Mapping["Axis4"];
            }
            if (mapping.Mapping.ContainsKey("Axis5"))
            {
                comboBox6.SelectedItem = mapping.Mapping["Axis5"];
            }
            // mapping.ValueChanged += new UAVCommons.UAVStructure.ValueChangedHandler(mapping_ValueChanged);
            joystick.ValueChanged += new UAVCommons.UAVStructure.ValueChangedHandler(joystick_ValueChanged);
            if (((FlightControlCommons.UAVJoystick)joystick).errorOnCreate)
            {
                MessageBox.Show(this, "Es ist ein Fehler beim Verbinden mit dem Joystick aufgetrehten. Bitte prüfen Sie die Verbindung und die Treiber und starten Sie das Programm neu", "GroundControl", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
コード例 #2
0
        public JoystickSettings(UAVCommons.UAVStructure joystick, UAVCommons.UAVDataMapping mapping)
        {
            InitializeComponent();
            this.mapping = mapping;
            this.joystick = joystick;
            string[] keys = new string[mapping.Mapping.Keys.Count];
            mapping.Mapping.Keys.CopyTo(keys, 0);
            List<string> stearingFunctions = new List<string>();
            stearingFunctions.Add("phi_rollrate");
            stearingFunctions.Add("theta_rollrate");
            stearingFunctions.Add("psi_rollrate");
            stearingFunctions.Add("throttle");
            stearingFunctions.Add("");
            comboBox1.Items.AddRange(stearingFunctions.ToArray());
            comboBox2.Items.AddRange(stearingFunctions.ToArray());
            comboBox3.Items.AddRange(stearingFunctions.ToArray());
            comboBox4.Items.AddRange(stearingFunctions.ToArray());
            comboBox5.Items.AddRange(stearingFunctions.ToArray());
            comboBox6.Items.AddRange(stearingFunctions.ToArray());
            if (mapping.Mapping.ContainsKey("Axis0"))
            {
                comboBox1.SelectedItem = mapping.Mapping["Axis0"];
            }
            if (mapping.Mapping.ContainsKey("Axis1"))
            {

                comboBox2.SelectedItem = mapping.Mapping["Axis1"];
            }
            if (mapping.Mapping.ContainsKey("Axis2"))
            {
                comboBox3.SelectedItem = mapping.Mapping["Axis2"];
            }
            if (mapping.Mapping.ContainsKey("Axis3"))
            {

                comboBox4.SelectedItem = mapping.Mapping["Axis3"];
            }
            if (mapping.Mapping.ContainsKey("Axis4"))
            {

                comboBox5.SelectedItem = mapping.Mapping["Axis4"];
            }
            if (mapping.Mapping.ContainsKey("Axis5"))
            {

                comboBox6.SelectedItem = mapping.Mapping["Axis5"];
            }
               // mapping.ValueChanged += new UAVCommons.UAVStructure.ValueChangedHandler(mapping_ValueChanged);
            joystick.ValueChanged += new UAVCommons.UAVStructure.ValueChangedHandler(joystick_ValueChanged);
            if (((FlightControlCommons.UAVJoystick)joystick).errorOnCreate) MessageBox.Show(this, "Es ist ein Fehler beim Verbinden mit dem Joystick aufgetrehten. Bitte prüfen Sie die Verbindung und die Treiber und starten Sie das Programm neu", "GroundControl", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
        }