private void SetNewInterface()
        {
            string selected_name = RGB_Output.Items[RGB_Output.SelectedIndex] as string;

            try
            {
                IRGBOutput new_interface = null;
                foreach (IRGBOutput _interface in _rgb_manager.GetAvailableOutputs())
                {
                    string name = _interface.GetName();

                    if (name == selected_name)
                    {
                        new_interface = _interface;
                        break;
                    }
                }
                _current_rgb_creator.Pause();
                // Look if interface changed or checkbox is set to false
                if (_current_rgb_output != null && (_current_rgb_output.GetName() != selected_name || CkbSerial.IsChecked == false))
                {
                    if (_current_rgb_output.IsEnabled())
                    {
                        _current_rgb_output.Shutdown();
                        _current_rgb_output.SetEnable(false);
                    }
                }
                _current_rgb_output = new_interface;


                if (CkbSerial.IsChecked == true)
                {
                    if (!_current_rgb_output.IsEnabled())
                    {
                        _current_rgb_output.Initialize();
                        _current_rgb_output.SetEnable(true);
                    }
                }

                SetNewRGBCreator(_current_rgb_creator);
            }
            catch (RGBOutputException ex)
            {
                CkbSerial.IsChecked = !CkbSerial.IsChecked; // Reset state
                string test = "Error setting new Interace \"" + selected_name + "\":\n\n" + ex.Message;
                MessageBox.Show(test, "Error setting RGB Output");
            }
        }
Example #2
0
 public RGBOutputCheckbox(IRGBOutput output)
 {
     this.Output = output;
     this.Text   = output.GetName();
 }