Esempio n. 1
0
        // ComboBox drop down opened
        private void cmbDevices_DropDown(object sender, EventArgs e)
        {
            // Find devices
            uint count = Rgbledctrl.find();

            writeToLog(String.Format("Devices found: {0}", count));
            writeToLog("------");

            cmbDevices.Items.Clear();

            // Show devices
            for (uint i = 0; i < count; i++)
            {
                cmbDevices.Items.Add(i);
            }
        }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Must be called before any other stuff!
            Rgbledctrl.init();

            // Create RGB LED object
            rgbLed = new Rgbledctrl();

            // Start poke timer
            tmrPoke.Enabled = true;

            // Thread for getting average screen colour
            Thread t = new Thread(new ThreadStart(tCapScreen));

            t.IsBackground = true;
            t.Start();
        }
Esempio n. 3
0
        // Open
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (cmbDevices.SelectedItem == null || cmbDevices.SelectedItem.ToString() == "")
            {
                writeToLog("No device selected");
            }
            else
            {
                uint device;
                uint.TryParse(cmbDevices.SelectedItem.ToString(), out device);

                writeToLog(String.Format("Opening device #{0}", device));

                Rgbledctrl newRgbLed = new Rgbledctrl();

                if (newRgbLed.open(device)) // Open
                {
                    // See if the new handle and old handle are handles to the same device
                    if (!Rgbledctrl.sameDevice(rgbLed.handle, newRgbLed.handle))
                    {
                        writeToLog("Device opened");
                        rgbLed.close(); // Close old handle
                        rgbLed = newRgbLed;
                    }
                    else
                    {
                        writeToLog("Device is already open");
                        newRgbLed.close(); // Close handle
                    }
                }
                else // Failed to open
                {
                    writeToLog("Failed to open device");
                }
            }

            writeToLog("------");
        }