Example #1
0
File: main.cs Project: leuher/WeDo
        private void BtSetMode_Click(object sender, EventArgs e)
        {
            if (FRgb == null)
            {
                MessageBox.Show("Device is not attached");
            }
            else
            {
                Boolean RgbEnabled   = (cbColorMode.SelectedIndex == 1);
                Boolean IndexEnabled = (cbColorMode.SelectedIndex == 0);

                Int32 Res = wclErrors.WCL_E_SUCCESS;
                if (RgbEnabled)
                {
                    Res = FRgb.SetMode(wclWeDoRgbLightMode.lmAbsolute);
                }
                else
                {
                    if (IndexEnabled)
                    {
                        Res = FRgb.SetMode(wclWeDoRgbLightMode.lmDiscrete);
                    }
                }

                if (Res != wclErrors.WCL_E_SUCCESS)
                {
                    MessageBox.Show("Unable to change color mode: 0x" + Res.ToString("X8"));
                }
                else
                {
                    EnableColorControls();

                    if (RgbEnabled)
                    {
                        UpdateRgb();
                    }
                    else
                    {
                        if (IndexEnabled)
                        {
                            UpdateIndex();
                        }
                    }
                }
            }
        }
Example #2
0
File: main.cs Project: leuher/WeDo
        private void btSetMode_Click(object sender, EventArgs e)
        {
            wclWeDoHub      Hub = GetHub();
            wclWeDoRgbLight Rgb = FRobot.GetRgbDevice(Hub);

            if (Rgb != null)
            {
                Boolean RgbEnabled   = (cbColorMode.SelectedIndex == 1);
                Boolean IndexEnabled = (cbColorMode.SelectedIndex == 0);

                Int32 Res = wclErrors.WCL_E_SUCCESS;
                if (RgbEnabled)
                {
                    Res = Rgb.SetMode(wclWeDoRgbLightMode.lmAbsolute);
                }
                else
                {
                    if (IndexEnabled)
                    {
                        Res = Rgb.SetMode(wclWeDoRgbLightMode.lmDiscrete);
                    }
                }

                if (Res != wclErrors.WCL_E_SUCCESS)
                {
                    MessageBox.Show("Unable to change color mode: 0x" + Res.ToString("X8"));
                }
                else
                {
                    if (RgbEnabled)
                    {
                        UpdateRgbColors(Rgb);
                    }
                    else
                    {
                        if (IndexEnabled)
                        {
                            UpdateRgbIndex(Rgb);
                        }
                    }
                }
            }
        }