public async Task SetBrightness_ForMultiPortDevice_TurnOn_Port1_SendsTurnOnPort1()
        {
            // Arrange
            string messageId = "Message12";
            var    device    = new DeviceDto {
                Id = "Endpoint1"
            };
            var deviceAndPort = new DeviceAndPort(device, 1);
            var request       = BuildRequest(messageId, "SetBrightness", deviceAndPort.ToString());

            List <DeviceDto> devices = new List <DeviceDto>
            {
                new DeviceDto
                {
                    DisplayName = "Device 1"
                }
            };

            var devicesClient      = new FakeDevicesClient(devices);
            var measurementsClient = new FakeMeasurementsClient();
            var statusClient       = new FakeStatusClient();

            var controller = new BrightnessController(devicesClient, measurementsClient, statusClient);

            // Act
            BrightnessControlResponse response = (BrightnessControlResponse)await controller.HandleAlexaRequest(request, null);

            // Assert
            Assert.IsNotNull(response);
            Assert.AreEqual("@Switch Set brightness 50 port-1", statusClient.SentMessage);
        }
 public static string CurrentDisplayBrightnessValue()
 {
     if (!BrightnessController.IsDDCSupported)
     {
         return("Unknown");
     }
     else
     {
         return(BrightnessController.GetBrightness().ToString() + "%");
     }
 }
Esempio n. 3
0
    void Start()
    {
        option_manager_script = FindObjectOfType <OptionManager>();

        _brightness_ctrler_script = _bright_slider.gameObject.GetComponent <BrightnessController>();

        //InitSliderValue(); //GameMgr 스크립트로 옮김

        //songManager_script = FindObjectOfType<SoundManger>();

        gameMgr_script = GameObject.FindObjectOfType <GameMgr>();
    }
    private void Awake()
    {
        DontDestroyOnLoad(gameObject);
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance          = this;
        brightnessOverlay = GetComponent <Image>();
        SetBrightness(PlayerPrefs.GetFloat("Brightness", 1f));
    }
        public void SetBrightnessTest()
        {
            BrightnessController brightnessController = new BrightnessController();

            Assert.Throws <Exception>(() => { brightnessController.SetBrightness(0.6f); });
            //try
            //{
            //    brightnessController.SetBrightness(0.6f);
            //    Assert.
            //}
            //catch
            //{
            //    Assert.True(true);
            //}
        }
Esempio n. 6
0
        private void VisualForm_Load(object sender, EventArgs e)
        {
            Controls.Add(Percentage);
            Percentage.Font      = new Font("Segoe UI", 15.75f, FontStyle.Regular);
            Percentage.Location  = new Point(55, 204);
            Percentage.Size      = new Size(80, 50);
            Percentage.ForeColor = Color.White;

            ValidBrightnessLevels = QueryAvailableBrightnessLevels();
            if (ValidBrightnessLevels.Count() == 0)
            {
                MessageBox.Show("This computer does not appear to support brightness control. Make sure the driver is installed and the video card supports brightness controlling.", "BControl", MessageBoxButtons.OK, MessageBoxIcon.Error);
                BrightnessController.Enabled = false;
            }
            else
            {
                BrightnessController.Value         = FetchCurrentBrightness();
                BrightnessController.TickFrequency = ValidBrightnessLevels.Count();
                BrightnessController.Maximum       = ValidBrightnessLevels.Count() - 1;
                BrightnessController.Update();
                BrightnessController.Refresh();
                Percentage.Text = BrightnessController.Value + "%";
            }
        }
        public static void ChangeBrightness(int timeofDayIndex)
        {
            if (IsDDCSupported())
            {
                if (JsonConfig.settings.useAutoBrightness || JsonConfig.settings.useCustomAutoBrightness)
                {
                    switch (timeofDayIndex)
                    {
                    // ALL DAY
                    case 0:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(ALL_DAY_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.allDayBrightness);
                        }
                        break;

                    // ALL NIGHT
                    case 1:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(ALL_NIGHT_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.allNightBrightness);
                        }
                        break;

                    // SUNRISE
                    case 2:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(SUNRISE_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.sunriseBrightness);
                        }
                        break;

                    // DAY
                    case 3:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(DAY_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.dayBrightness);
                        }
                        break;

                    // SUNSET
                    case 4:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(SUNSET_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.sunsetBrightness);
                        }
                        break;

                    // NIGHT
                    case 5:
                        if (JsonConfig.settings.useAutoBrightness)
                        {
                            BrightnessController.ChangeBrightness(NIGHT_AUTO);
                        }
                        else
                        {
                            BrightnessController.ChangeBrightness(JsonConfig.settings.nightBrightness);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
 public static void Initialize()
 {
     BrightnessController.GetBrightness();
 }
Esempio n. 9
0
 public void OnBrightnessValueChanged(float newValue)
 {
     BrightnessController.SetBrightness(newValue);
     PlayerPrefs.SetFloat("Brightness", newValue);
     PlayerPrefs.Save();
 }