Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bool joyAttached = false;

            this.Text += "  v" + Application.ProductVersion;

            clientTCP = new ClientTCP(this);
            clientUDP = new ClientUDP(this);
            serverTCP = new ServerTCP(this);
            serverUDP = new ServerUDP(this);

            Mode_comboBox.SelectedIndex = 0;

            try
            {
                Set_Joystick_Settings(null, null);    /* Find joystick if there is one and list in Menu -> Settings -> Joystick */
                joyAttached            = jyst.Poll(); // check to see if we can get data from joystick
                doCalibartion          = true;
                Joystick_timer.Enabled = true;
            }
            catch {
                debug.Append("Joystick failed to init\r\n");
                jystHandler.CenterX = PWMmidValue;
                jystHandler.CenterY = PWMmidValue;
                joyAttached         = false;
                MessageBox.Show("Joystick did not Initialize Correctly.\r\nEnsure it is plugged in and restart");
            }

            DiscoverSerialPorts();
            ServiceRegistry(false);

            UpldateRate_numericUpDown_ValueChanged(null, null);
            if (joyAttached && (joystickComboBox.SelectedIndex == -1))
            {
                // if we did not see a joystick in registry but we see one now, use that one
                joystickComboBox.SelectedIndex = 0;
            }

            if ((CommSerialPort_comboBox.Items.Count > 0) && (CommSerialPort_comboBox.SelectedIndex == -1))
            {
                CommSerialPort_comboBox.SelectedIndex = 0;
            }
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bool joyAttached = false;
            this.Text += "  v" + Application.ProductVersion;

            clientTCP = new ClientTCP(this);
            clientUDP = new ClientUDP(this);
            serverTCP = new ServerTCP(this);
            serverUDP = new ServerUDP(this);

            Mode_comboBox.SelectedIndex = 0;

            try
            {
                Set_Joystick_Settings(null, null);          /* Find joystick if there is one and list in Menu -> Settings -> Joystick */
                joyAttached = jyst.Poll(); // check to see if we can get data from joystick
                doCalibartion = true;
                Joystick_timer.Enabled = true;
            }
            catch {
                debug.Append("Joystick failed to init\r\n");
                jystHandler.CenterX = PWMmidValue;
                jystHandler.CenterY = PWMmidValue;
                joyAttached = false;
                MessageBox.Show("Joystick did not Initialize Correctly.\r\nEnsure it is plugged in and restart");
            }

            DiscoverSerialPorts();
            ServiceRegistry(false);

            UpldateRate_numericUpDown_ValueChanged(null, null);
            if (joyAttached && (joystickComboBox.SelectedIndex == -1))
            {
                // if we did not see a joystick in registry but we see one now, use that one
                joystickComboBox.SelectedIndex = 0;
            }

            if ((CommSerialPort_comboBox.Items.Count > 0) && (CommSerialPort_comboBox.SelectedIndex == -1))
            {
                CommSerialPort_comboBox.SelectedIndex = 0;
            }
        }