예제 #1
0
        /*
         * Helpers
         */

        public async Task <HeadSetErrorCode> setStaticColor(Color color)
        {
            if (color.Name == "ff000000" || color.Name == "Black")
            {
                colorModeBox.SelectedIndex = (int)HeadsetLightingEnum.OFF;
                return(HeadSetErrorCode.HID_WriteSuccess);
            }
            if (colorModeBox.SelectedIndex != (int)HeadsetLightingEnum.Static)
            {
                SetColorRegistry(color);
                colorModeBox.SelectedIndex = (int)HeadsetLightingEnum.Static;
                return(HeadSetErrorCode.HID_WriteSuccess);
            }
            HeadSetErrorCode error = await AccessoryHeadSetHelper.SetHeadsetStaticColorAsync(hidIndex, toHeadSetColor(color));

            if (checkErrors(error))
            {
                staticColorPanel.BackColor = color;
                if (color.Name != "ff000000" && color.Name != "Black")
                {
                    SetColorRegistry(color);
                }
            }
            return(error);
        }
예제 #2
0
        private async Task <HeadSetErrorCode> setCooling(HeadSetCoolingModes mode)
        {
            HeadSetErrorCode result = await AccessoryHeadSetHelper.SetHeadsetCoolingAsync(hidIndex, mode);

            if (checkErrors(result))
            {
                this.SaveCoolingLevelToRegistry(mode);
                highlightLabel(mode);
            }
            return(result);
        }
예제 #3
0
        private async Task <HeadSetErrorCode> setAudioAnimation()
        {
            if (colorModeBox.SelectedIndex != (int)HeadsetLightingEnum.Audio)
            {
                colorModeBox.SelectedIndex = (int)HeadsetLightingEnum.Audio;
                return(HeadSetErrorCode.HID_WriteSuccess);
            }
            HeadSetErrorCode result = await AccessoryHeadSetHelper.SetHeadsetAnimationAsync(hidIndex, HeadsetAnimation.Audio, defaultAnimationColors, 0);

            checkErrors(result);
            return(result);
        }
예제 #4
0
 private bool checkErrors(HeadSetErrorCode error, bool silent)
 {
     if (error != HeadSetErrorCode.HID_WriteSuccess)
     {
         if (!silent)
         {
             MessageBox.Show(error.ToString());
             this.Close();
         }
         return(false);
     }
     return(true);
 }
예제 #5
0
        private async Task <HeadSetErrorCode> setBlinkingAnimation(List <Color> colors)
        {
            if (colorModeBox.SelectedIndex != (int)HeadsetLightingEnum.ColorShift)
            {
                SetColorListRegistry("BlinkingColors", colors);
                colorModeBox.SelectedIndex = (int)HeadsetLightingEnum.ColorShift;
                return(HeadSetErrorCode.HID_WriteSuccess);
            }
            HeadSetErrorCode result = await AccessoryHeadSetHelper.SetHeadsetAnimationAsync(hidIndex, HeadsetAnimation.Blinking, toHeadSetColors(colors), (ushort)colorLengthBox.Value);

            if (checkErrors(result))
            {
                this.SetColorListRegistry("BlinkingColors", colors);
            }
            return(result);
        }
예제 #6
0
        private async void colorModeBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            HeadsetLightingEnum mode = (HeadsetLightingEnum)colorModeBox.SelectedIndex;

            SetLightModeRegistry(mode);
            switch (mode)
            {
            case HeadsetLightingEnum.ColorShift:
                btnStaticColor.Enabled = false;
                btnColorList.Enabled   = true;
                colorLengthBox.Enabled = true;
                await setBlinkingAnimation(GetColorListRegistry("BlinkingColors"));

                break;

            case HeadsetLightingEnum.Audio:
                btnStaticColor.Enabled = false;
                btnColorList.Enabled   = false;
                colorLengthBox.Enabled = false;
                await setAudioAnimation();

                break;

            case HeadsetLightingEnum.Static:
                btnStaticColor.Enabled = true;
                btnColorList.Enabled   = false;
                colorLengthBox.Enabled = false;
                await setStaticColor(GetColorRegistry());

                break;

            case HeadsetLightingEnum.OFF:
                btnStaticColor.Enabled = false;
                btnColorList.Enabled   = false;
                colorLengthBox.Enabled = false;
                HeadSetErrorCode error = await AccessoryHeadSetHelper.SetHeadsetStaticColorAsync(hidIndex, toHeadSetColor(Color.Black));

                if (checkErrors(error))
                {
                    staticColorPanel.BackColor = Color.Black;
                }
                break;
            }
        }
예제 #7
0
 private bool checkErrors(HeadSetErrorCode error)
 {
     return(checkErrors(error, false));
 }