Chromatics.Chromatics.InitializeDevices C# (CSharp) Method

InitializeDevices() private method

private InitializeDevices ( ) : void
return void
        void InitializeDevices()
        {
            chk_deviceKeyboard.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceMouse.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceKeypad.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceMousepad.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceHeadset.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceCorsair.ForeColor = System.Drawing.Color.LightGray;
            chk_deviceLogitech.ForeColor = System.Drawing.Color.LightGray;

            //INIT REFERENCE SDKS

            //LOGITECH
            if (Process.GetProcessesByName("LCore").Length > 0)
            {
                LogitechGSDK.LogiLedInit();
                LogitechSDK = true;
            }
            else
            {
                LogitechSDK = false;
            }

            if (LogitechSDK == true)
            {
                chk_deviceLogitech.Checked = true;
                chk_deviceLogitech.AutoCheck = true;
                chk_deviceLogitech.ForeColor = SystemColors.ControlText;
            }
            else
            {
                chk_deviceLogitech.Checked = false;
                chk_deviceLogitech.AutoCheck = false;
                chk_deviceLogitech.ForeColor = System.Drawing.Color.LightGray;
            }

            //CORSAIR
            if (File.Exists(ProgramFilesx86() + @"\Corsair\Corsair Utility Engine\CorsairHID.exe"))
            {
                if (StartUp == false)
                {
                    if (!File.Exists(AppDataPath + @"\Advanced Combat Tracker\Plugins\CUESDK_2013.dll"))
                    {
                        DialogResult result = MessageBox.Show("The Corsair SDK has not been initialized on your system. Would you like to do it now?", "CUE SDK Not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            try
                            {
                                File.Copy(pluginEnviroment + @"\lib\CUESDK_2013.dll", AppDataPath + @"\Advanced Combat Tracker\Plugins\CUESDK_2013.dll", true);
                                MessageBox.Show("Corsair SDK has been enabled. Please restart ACT and run CUE to enable Corsair support.");
                                CorsairSDK = false;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Chromatics was unable to initialize the Corsair SDK. Please try again later. (Error Code: " + ex.Message + ")");
                                CorsairSDK = false;
                            }

                        }
                        else
                        {
                            MessageBox.Show("Corsair devices will be temporarily disabled. Please restart ACT if you wish to initialize the SDK.");
                            CorsairSDK = false;
                        }
                    }
                    else
                    {
                        try
                        {
                            CueSDK.Initialize();
                            CorsairSDK = true;
                            MessageBox.Show("Initialized with " + CueSDK.LoadedArchitecture + " -SDK","DEBUG");
                        }
                        catch (CUEException ex)
                        {
                            if (ex.Error.ToString() == "ServerNotFound")
                            {
                                CorsairSDK = false;
                                //CorsairState = 2;
                                Debug.WriteLine(ex.Error.ToString());
                                MessageBox.Show("CUE (Corsair Utility Engine) is currently not running or not installed. Please install or run the program and restart ACT to enable Corsair Support. If you are still getting this error message, please select 'Enable SDK' in the CUE application.");
                            }
                            else
                            {
                                CorsairSDK = false;
                                MessageBox.Show("An unknown error occurred while trying to load the Corsair libraries. Corsair support will be disabled.");
                            }
                        }
                        catch (WrapperException ex)
                        {
                            if (ex.Message == "CueSDK is already initialized.")
                            {
                                CorsairSDK = false;
                                //CorsairState = 2;
                                MessageBox.Show("An error occured where ACT attempted to start the Corsair Engine twice. Please restart ACT to re-enable Corsair device support.");
                            }
                            else
                            {
                                CorsairSDK = false;
                                MessageBox.Show("An unknown error occurred while trying to load the Corsair libraries. Corsair support will be disabled.");
                            }
                        }
                    }
                }
            }

            if (CorsairSDK == true)
            {
                corKeyboard = CueSDK.KeyboardSDK;
                CorsairMouse corMouse = CueSDK.MouseSDK;
                CorsairHeadset corHeadset = CueSDK.HeadsetSDK;

                if (corKeyboard != null)
                {
                    CorsairKeyboardDetect = true;
                    chk_deviceCorsair.Checked = true;
                    chk_deviceCorsair.AutoCheck = true;
                    chk_deviceCorsair.ForeColor = SystemColors.ControlText;

                }
                if (corMouse != null)
                {
                    CorsairMouseDetect = true;
                    chk_deviceCorsair.Checked = true;
                    chk_deviceCorsair.AutoCheck = true;
                    chk_deviceCorsair.ForeColor = SystemColors.ControlText;
                }
                if (corHeadset != null)
                {
                    CorsairHeadsetDetect = true;
                    chk_deviceCorsair.Checked = true;
                    chk_deviceCorsair.AutoCheck = true;
                    chk_deviceCorsair.ForeColor = SystemColors.ControlText;
                }

            }
            else
            {
                chk_deviceCorsair.Checked = false;
                chk_deviceCorsair.AutoCheck = false;
                chk_deviceCorsair.ForeColor = System.Drawing.Color.LightGray;
            }

            //RAZER
            if (Chroma.IsSdkAvailable() == false)
            {
                RazerSDK = false;
            }

            if (RazerSDK != false)
            {
                if (Chroma.Instance.Initialized != true)
                {
                    Chroma.Instance.Uninitialize();
                }
                else
                {
                    Chroma.Instance.Initialize();
                }
                Chroma chroma = (Chroma)Chroma.Instance;

                //Razer device auto-detection disabled due to bug in Razer SDK

                //Keyboards
                //if (chroma.Query(new Guid(0x2ea1bb63, 0xca28, 0x428d, 0x9f, 0x06, 0x19, 0x6b, 0x88, 0x33, 0x0b, 0xbb)).Connected == true) { chk_deviceKeyboard.Checked = true; chk_deviceKeyboard.AutoCheck = true; chk_deviceKeyboard.ForeColor = SystemColors.ControlText; } //Blackwidow
                //if (chroma.Query(new Guid(0xed1c1b82, 0xbfbe, 0x418f, 0xb4, 0x9d, 0xd0, 0x3f, 0x5, 0xb1, 0x49, 0xdf)).Connected == true) { chk_deviceKeyboard.Checked = true; chk_deviceKeyboard.AutoCheck = true; chk_deviceKeyboard.ForeColor = SystemColors.ControlText; } //BlackwidowTE
                //if (chroma.Query(new Guid(0x18c5ad9b, 0x4326, 0x4828, 0x92, 0xc4, 0x26, 0x69, 0xa6, 0x6d, 0x22, 0x83)).Connected == true) { chk_deviceKeyboard.Checked = true; chk_deviceKeyboard.AutoCheck = true; chk_deviceKeyboard.ForeColor = SystemColors.ControlText; } //Deathstalker

                //Mouse
                //if (chroma.Query(new Guid(0xaec50d91, 0xb1f1, 0x452f, 0x8e, 0x16, 0x7b, 0x73, 0xf3, 0x76, 0xfd, 0xf3)).Connected == true) { chk_deviceMouse.Checked = true; chk_deviceMouse.AutoCheck = true; chk_deviceMouse.ForeColor = SystemColors.ControlText; } //DeathAdder
                //if (chroma.Query(new Guid(0xff8a5929, 0x4512, 0x4257, 0x8d, 0x59, 0xc6, 0x47, 0xbf, 0x99, 0x35, 0xd0)).Connected == true) { chk_deviceMouse.Checked = true; chk_deviceMouse.AutoCheck = true; chk_deviceMouse.ForeColor = SystemColors.ControlText; } //Diamondback
                //if (chroma.Query(new Guid(0x7ec00450, 0xe0ee, 0x4289, 0x89, 0xd5, 0xd, 0x87, 0x9c, 0x19, 0x6, 0x1a)).Connected == true) { chk_deviceMouse.Checked = true; chk_deviceMouse.AutoCheck = true; chk_deviceMouse.ForeColor = SystemColors.ControlText; } //MambaTE

                //Keypad
                //if (chroma.Query(new Guid(0xf0545c, 0xe180, 0x4ad1, 0x8e, 0x8a, 0x41, 0x90, 0x61, 0xce, 0x50, 0x5e)).Connected == true) { chk_deviceKeypad.Checked = true; chk_deviceKeypad.AutoCheck = true; chk_deviceKeypad.ForeColor = SystemColors.ControlText; } //Tatarus
                //if (chroma.Query(new Guid(0x9d24b0ab, 0x162, 0x466c, 0x96, 0x40, 0x7a, 0x92, 0x4a, 0xa4, 0xd9, 0xfd)).Connected == true) { chk_deviceKeypad.Checked = true; chk_deviceKeypad.AutoCheck = true; chk_deviceKeypad.ForeColor = SystemColors.ControlText; } //Orbweaver

                //Mousepad
                //if (chroma.Query(new Guid(0x80f95a94, 0x73d2, 0x48ca, 0xae, 0x9a, 0x9, 0x86, 0x78, 0x9a, 0x9a, 0xf2)).Connected == true) { chk_deviceMousepad.Checked = true; chk_deviceMousepad.AutoCheck = true; chk_deviceMousepad.ForeColor = SystemColors.ControlText; } //Firefly

                //Headset
                //if (chroma.Query(new Guid(0xcd1e09a5, 0xd5e6, 0x4a6c, 0xa9, 0x3b, 0xe6, 0xd9, 0xbf, 0x1d, 0x20, 0x92)).Connected == true) { chk_deviceHeadset.Checked = true; chk_deviceHeadset.AutoCheck = true; chk_deviceHeadset.ForeColor = SystemColors.ControlText; } //Kraken 7.1

                chk_deviceKeyboard.Checked = true; chk_deviceKeyboard.AutoCheck = true; chk_deviceKeyboard.ForeColor = SystemColors.ControlText;
                chk_deviceMouse.Checked = true; chk_deviceMouse.AutoCheck = true; chk_deviceMouse.ForeColor = SystemColors.ControlText;
                chk_deviceKeypad.Checked = true; chk_deviceKeypad.AutoCheck = true; chk_deviceKeypad.ForeColor = SystemColors.ControlText;
                chk_deviceMousepad.Checked = true; chk_deviceMousepad.AutoCheck = true; chk_deviceMousepad.ForeColor = SystemColors.ControlText;
                chk_deviceHeadset.Checked = true; chk_deviceHeadset.AutoCheck = true; chk_deviceHeadset.ForeColor = SystemColors.ControlText;
            }

            ResetDevices();
            if (rescan == true)
            {
                if (RazerSDK == false)
                {
                    MessageBox.Show("The Razer SDK (RzChromaSDK64.dll) Could not be found on this computer. Please install Synapse and restart ACT if you wish to use Chromatics with Razer devices.");
                }
                if (CorsairSDK == false)
                {
                    MessageBox.Show("CUE (Corsair Utility Engine) is currently not running or not installed. Please install or run the program and restart ACT to enable Corsair Support. If you are still getting this error message, please select 'Enable SDK' in the CUE application.");
                }
                if (LogitechSDK == false)
                {
                    MessageBox.Show("Logitech Gaming Software is currently not running or not installed.Please install or run the program and restart ACT to enable Logitech Support.");
                }
                rescan = false;
            }

            StartUp = true;
        }
Chromatics