private static void UpdateLights()
        {
            int?newBrightness = null;
            ColorInformation colorInformation = new ColorInformation();

            switch (PartyOptions.activePartyOption.brightnessOptionIndex)
            {
            case 1:
                newBrightness = SetRandomBrightness();
                break;
            }

            switch (PartyOptions.activePartyOption.colorOptionIndex)
            {
            case 2:
                colorInformation = LightProcessingColor.SetRandomColorFromUIInput();
                break;
            }

            if (BridgeInformation.usedLights.Count > 0)
            {
                BasicLightController.SendCommonCommond();
            }

            if (newBrightness != null || colorInformation.rgbColor != null || colorInformation.colorTemperature != null)
            {
                PartyUIUpdater.UpdateOutputDisplay(newBrightness, colorInformation.rgbColor, colorInformation.colorTemperature);
            }
        }
        private void SetBrightness()
        {
            int brightness = Convert.ToInt32(BrightnessSlider.Value);

            BasicLightController.SetBrightness(brightness);

            UserControlUsed();
        }
        private static int?SetRandomBrightness()
        {
            Random random           = new Random();
            int    randomBrightness = random.Next(PartyOptions.activePartyOption.minRandomBrightness, PartyOptions.activePartyOption.maxRandomBrightness);

            BasicLightController.SetBrightnessInCommonCommand(randomBrightness);

            return(randomBrightness);
        }
Exemple #4
0
        public void LightSelectionChanged()
        {
            PartyOptions.useRGBColor = LightInformation.IsInRGBMode();
            partyOptionsFrameContent.LightSelectionChanged();

            if (!LightInformation.CheckIfTurnedOn())
            {
                BasicLightController.TurnOn();
            }
        }
Exemple #5
0
        private async void LightButtonClick(object sender, RoutedEventArgs e)
        {
            BasicLightController.canControl = false;

            int id = Convert.ToInt32(((Button)sender).Tag);

            SetLightButtonOutline((Button)sender, BasicLightController.ChangeLightSelection(id.ToString()), otherTargetOutlineThickness);
            SetAutoMainTarget();

            await BasicLightController.GetAllLights();

            BasicLightController.canControl = true;

            uiParent.LightSelectionChanged();
        }
Exemple #6
0
        public async Task UpdateLightButtons()
        {
            await Task.Delay(10);

            await BasicLightController.GetAllLights();

            foreach (Button lightButton in LightGrid.Children)
            {
                Light light = BridgeInformation.lights[Convert.ToInt32(lightButton.Tag) - 1];
                lightButton.Background = new LinearGradientBrush(GenerateGradientStopCollection(LightInformation.GetLightColor(light)), 0);

                Grid        buttonGrid  = (Grid)((Border)lightButton.Content).Child;
                ProgressBar progressBar = buttonGrid.Children[1] as ProgressBar;
                progressBar.Value = LightInformation.GetBrightnessInPercent(light);
            }
        }
        private void LightToggleSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;

            if (toggleSwitch.IsOn)
            {
                BasicLightController.TurnOn();
            }
            else
            {
                BasicLightController.TurnOff();
            }

            SetIsEnabled();
            UserControlUsed();
        }
Exemple #8
0
        private static int ProcessSoundLevelBrightness(double soundLevel)
        {
            double brightnessDouble = 0;

            if (!(soundLevel < PartyOptions.activePartyOption.minSoundLevel && PartyOptions.activePartyOption.startWithZeroInRange))
            {
                soundLevel = soundLevel > PartyOptions.activePartyOption.maxSoundLevel ? PartyOptions.activePartyOption.maxSoundLevel : soundLevel;

                brightnessDouble = (soundLevel - PartyOptions.activePartyOption.minSoundLevel) / (PartyOptions.activePartyOption.maxSoundLevel - PartyOptions.activePartyOption.minSoundLevel) * 100;
                if (!PartyOptions.activePartyOption.startWithZeroInRange)
                {
                    brightnessDouble = brightnessDouble < PartyOptions.activePartyOption.minSoundLevel ? PartyOptions.activePartyOption.minSoundLevel : brightnessDouble;
                }
            }

            int brightness = Convert.ToInt32(brightnessDouble);

            BasicLightController.SetBrightnessInCommonCommand(brightness);

            return(brightness);
        }
Exemple #9
0
        public static void NewSoundLevel(double soundLevel)
        {
            if (callCount > 8)
            {
                int?newBrightness = null;
                ColorInformation colorInformation = new ColorInformation();

                switch (PartyOptions.activePartyOption.brightnessOptionIndex)
                {
                case 0:
                    newBrightness = ProcessSoundLevelBrightness(soundLevel);
                    break;
                }

                switch (PartyOptions.activePartyOption.colorOptionIndex)
                {
                case 0:
                    colorInformation = LightProcessingColor.SetColorGradienStep((float)soundLevel / 100f);
                    break;

                case 1:
                    colorInformation = ProcessInputDifferenceColor(soundLevel);
                    break;
                }

                if (BridgeInformation.usedLights.Count > 0)
                {
                    BasicLightController.SendCommonCommond();
                }

                if (newBrightness != null || colorInformation.rgbColor != null || colorInformation.colorTemperature != null)
                {
                    PartyUIUpdater.UpdateOutputDisplay(newBrightness, colorInformation.rgbColor, colorInformation.colorTemperature);
                }

                callCount = 0;
            }

            callCount++;
        }
Exemple #10
0
        async void CreateLightButtons()
        {
            await BasicLightController.GetAllLights();

            int currentColumn = 0;

            foreach (Light light in BridgeInformation.lights)
            {
                Button newButton = new Button()
                {
                    Name = light.Name + "LightButton",
                    Tag  = light.Id,

                    HorizontalAlignment        = HorizontalAlignment.Stretch,
                    VerticalAlignment          = VerticalAlignment.Stretch,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    VerticalContentAlignment   = VerticalAlignment.Stretch,

                    Padding = new Thickness(-2),
                    Margin  = new Thickness(0, 0, 30, 0),

                    Background = new LinearGradientBrush(GenerateGradientStopCollection(LightInformation.GetLightColor(light)), 0)
                };
                newButton.Click += LightButtonClick;
                LightGrid.ColumnDefinitions.Add(new ColumnDefinition {
                    Width = GridLength.Auto
                });
                Grid.SetColumn(newButton, currentColumn);

                Border border = new Border()
                {
                    BorderThickness = new Thickness(0, 0, 0, 0),
                    BorderBrush     = new SolidColorBrush((Color)this.Resources["SystemAccentColor"])
                };

                Grid buttonGrid = new Grid();
                buttonGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(1, GridUnitType.Star)
                });
                buttonGrid.RowDefinitions.Add(new RowDefinition {
                    Height = new GridLength(6, GridUnitType.Pixel)
                });

                TextBlock lightNameBlock = new TextBlock()
                {
                    Text       = light.Name,
                    Style      = (Style)Application.Current.Resources["MediumInformation"],
                    Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)),

                    Padding = new Thickness(10, 0, 10, 0),

                    VerticalAlignment = VerticalAlignment.Center,
                    TextAlignment     = TextAlignment.Center
                };
                Grid.SetRowSpan(lightNameBlock, 2);
                Grid.SetRow(lightNameBlock, 0);
                buttonGrid.Children.Add(lightNameBlock);

                ProgressBar progressBar = new ProgressBar()
                {
                    Value   = LightInformation.GetBrightnessInPercent(light),
                    Minimum = 1,
                    Maximum = 100,

                    Foreground = new SolidColorBrush(Color.FromArgb(25, 0, 0, 0)),
                    Background = new SolidColorBrush(Color.FromArgb(22, 0, 0, 0)),

                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };
                Grid.SetRow(progressBar, 1);
                buttonGrid.Children.Add(progressBar);

                border.Child      = buttonGrid;
                newButton.Content = border;
                LightGrid.Children.Add(newButton);

                if (BridgeInformation.usedLights.Contains(light.Id.ToString()) && light.Id.ToString() != BridgeInformation.mainLightTarget.ToString())
                {
                    SetLightButtonOutline(newButton, true, otherTargetOutlineThickness);
                }

                if (BridgeInformation.mainLightTarget != null)
                {
                    if (light.Id.ToString() == BridgeInformation.mainLightTarget.Id.ToString())
                    {
                        SetLightButtonOutline(newButton, true, mainTargetOutlineThickness);
                    }
                }

                currentColumn++;
            }

            if (BridgeInformation.usedLights.Count > 0)
            {
                uiParent.LightSelectionChanged();
            }
        }
 public void SetColorTemperature(int colorTemperature)
 {
     BasicLightController.SetColorTemperature(colorTemperature);
     UserControlUsed();
 }
 public void SetRGBColor(Color color)
 {
     BasicLightController.SetRGBColor(new RGBColor(color.R, color.G, color.B));
     UserControlUsed();
 }