/// <summary>
 /// Initializes a new instance of the <see cref="AnalogAlphaLayer"/> class.
 /// </summary>
 /// <param name="AnalogAlphaValue">The AnalogAlphaValue object containing the values to be set for the layer.</param>
 public  AnalogAlphaLayer(AnalogAlphaValue AnalogAlphaValue) {Set(AnalogAlphaValue);}
 /// <summary>
 /// Sets the value and the alpha value of the layer.
 /// </summary>
 /// <param name="AnalogAlphaValue">The analog alpha value object containing the values to be set.</param>
 public void Set(AnalogAlphaValue AnalogAlphaValue)
 {
     this.Value = AnalogAlphaValue.Value;
     this.Alpha = AnalogAlphaValue.Alpha;
 }
Beispiel #3
0
 /// <summary>
 /// Sets the value and the alpha value of the layer.
 /// </summary>
 /// <param name="AnalogAlphaValue">The analog alpha value object containing the values to be set.</param>
 public void Set(AnalogAlphaValue AnalogAlphaValue)
 {
     this.Value = AnalogAlphaValue.Value;
     this.Alpha = AnalogAlphaValue.Alpha;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnalogAlphaLayer"/> class.
 /// </summary>
 /// <param name="AnalogAlphaValue">The AnalogAlphaValue object containing the values to be set for the layer.</param>
 public AnalogAlphaLayer(AnalogAlphaValue AnalogAlphaValue)
 {
     Set(AnalogAlphaValue);
 }
Beispiel #5
0
        private void SetupTable(Table.Table Table, Dictionary<int, TableConfig> TableConfigDict, Dictionary<int, Dictionary<int, IToy>> ToyAssignments)
        {
            foreach (KeyValuePair<int, TableConfig> KV in TableConfigDict)
            {
                int LedWizNr = KV.Key;
                if (ToyAssignments.ContainsKey(LedWizNr))
                {
                    TableConfig TC = KV.Value;


                    foreach (TableConfigColumn TCC in TC.Columns)
                    {

                        if (ToyAssignments[LedWizNr].ContainsKey(TCC.Number))
                        {
                            IToy Toy = ToyAssignments[LedWizNr][TCC.Number];

                            int SettingNumber = 0;
                            foreach (TableConfigSetting TCS in TCC)
                            {
                                SettingNumber++;
                                IEffect Effect = null;

                                int Layer = (TCS.Layer.HasValue ? TCS.Layer.Value : SettingNumber);

                                if (Toy is IRGBAToy || Toy is IAnalogAlphaToy)
                                {
                                    if (Toy is IRGBAToy)
                                    {
                                        RGBAColor ActiveColor = null;
                                        if (TCS.ColorConfig != null)
                                        {
                                            ActiveColor = TCS.ColorConfig.GetCabinetColor().GetRGBAColor();
                                        }
                                        else
                                        {
                                            if (!TCS.ColorName.IsNullOrWhiteSpace())
                                            {
                                                if (TCS.ColorName.StartsWith("#"))
                                                {
                                                    ActiveColor = new RGBAColor();
                                                    if (!ActiveColor.SetColor(TCS.ColorName))
                                                    {
                                                        ActiveColor = null;
                                                        Log.Warning("Skipped setting {0} in column {1} for LedWizEqivalent number {2} since {3} is not a valid color specification.".Build(new object[] { SettingNumber, TCC.Number, LedWizNr, TCS.ColorName }));
                                                    }
                                                }
                                                else
                                                {
                                                    Log.Warning("Skipped setting {0} in column {1} for LedWizEqivalent number {2} since {3} is not a valid color specification.".Build(new object[] { SettingNumber, TCC.Number, LedWizNr, TCS.ColorName }));
                                                }
                                            }
                                            else
                                            {
                                                Log.Warning("Skipped setting {0} in column {1} for LedWizEqivalent number {2} since it does not contain a color specification.".Build(SettingNumber, TCC.Number, LedWizNr));
                                            }
                                        }
                                        if (ActiveColor != null)
                                        {
                                            if (TCS.FadingDownDurationMs > 0 || TCS.FadingUpDurationMs > 0)
                                            {
                                                //Must fade, use fadeeffect
                                                Effect = new RGBAFadeOnOffEffect() { ToyName = Toy.Name, Layer = Layer, FadeActiveDurationMs = TCS.FadingUpDurationMs, FadeInactiveDurationMs = TCS.FadingDownDurationMs, RetriggerBehaviour = RetriggerBehaviourEnum.IgnoreRetrigger, FadeMode = FadeModeEnum.CurrentToDefined, ActiveColor = ActiveColor, InactiveColor = new RGBAColor(0, 0, 0, 0) };

                                            }
                                            else
                                            {
                                                //No fadinging, set color directly
                                                Effect = new RGBAOnOffEffect() { ToyName = Toy.Name, Layer = Layer, ActiveColor = ActiveColor, InactiveColor = new RGBAColor(0, 0, 0, 0) };
                                            }


                                        }
                                    }
                                    else if (Toy is IAnalogAlphaToy)
                                    {
                                        AnalogAlphaValue AAV = new AnalogAlphaValue(((int)((double)TCS.Intensity * 5.3125)).Limit(0, 255));
                                        if (TCS.FadingDownDurationMs > 0 || TCS.FadingUpDurationMs > 0)
                                        {
                                            Effect = new AnalogToyFadeOnOffEffect() { ToyName = Toy.Name, Layer = Layer, FadeActiveDurationMs = TCS.FadingUpDurationMs, FadeInactiveDurationMs = TCS.FadingDownDurationMs, RetriggerBehaviour = RetriggerBehaviourEnum.IgnoreRetrigger, FadeMode = FadeModeEnum.CurrentToDefined, ActiveValue = AAV, InactiveValue = new AnalogAlphaValue(0, 0) };
                                        }
                                        else
                                        {
                                            Effect = new AnalogToyOnOffEffect() { ToyName = Toy.Name, Layer = Layer, ActiveValue = AAV, InactiveValue = new AnalogAlphaValue(0, 0) };
                                        }

                                    }
                                    if (Effect != null)
                                    {
                                        Effect.Name = "Ledwiz {0:00} Column {1:00} Setting {2:00} {3}".Build(new object[] { LedWizNr, TCC.Number, SettingNumber, Effect.GetType().Name });
                                        MakeEffectNameUnique(Effect, Table);

                                        Table.Effects.Add(Effect);

                                        if (TCS.Blink != 0)
                                        {
                                            Effect = new BlinkEffect() { Name = "Ledwiz {0:00} Column {1:00} Setting {2:00} BlinkEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.Name, DurationActiveMs = TCS.BlinkIntervalMs, DurationInactiveMs = TCS.BlinkIntervalMs };
                                            MakeEffectNameUnique(Effect, Table);
                                            Table.Effects.Add(Effect);
                                        }

                                        if (TCS.DurationMs > 0 || TCS.Blink > 0)
                                        {
                                            int Duration = (TCS.DurationMs > 0 ? TCS.DurationMs : (TCS.Blink * 2 - 1) * TCS.BlinkIntervalMs + 1);
                                            Effect = new DurationEffect() { Name = "Ledwiz {0:00} Column {1:00} Setting {2:00} DurationEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.Name, DurationMs = Duration, RetriggerBehaviour = RetriggerBehaviourEnum.RestartEffect };
                                            MakeEffectNameUnique(Effect, Table);
                                            Table.Effects.Add(Effect);
                                        }
                                        if (TCS.MinDurationMs > 0 || (Toy is IRGBAToy && EffectRGBMinDurationMs > 0) || (!(Toy is IRGBAToy) && EffectMinDurationMs > 0))
                                        {
                                            string N = (TCS.MinDurationMs > 0 ? "MinDuratonEffect" : "DefaultMinDurationEffect");
                                            int Min = (TCS.MinDurationMs > 0 ? TCS.MinDurationMs : (Toy is IRGBAToy ? EffectRGBMinDurationMs : EffectMinDurationMs));
                                            Effect = new MinDurationEffect() { Name = "Ledwiz {0:00} Column {1:00} Setting {2:00} {3}".Build(new object[] { LedWizNr, TCC.Number, SettingNumber, N }), TargetEffectName = Effect.Name, MinDurationMs = Min };
                                            MakeEffectNameUnique(Effect, Table);
                                            Table.Effects.Add(Effect);
                                        }


                                        if (TCS.WaitDurationMs > 0)
                                        {
                                            Effect = new DelayEffect() { Name = "Ledwiz {0:00} Column {1:00} Setting {2:00} DelayEffect".Build(LedWizNr, TCC.Number, SettingNumber), TargetEffectName = Effect.Name, DelayMs = TCS.WaitDurationMs };
                                            MakeEffectNameUnique(Effect, Table);
                                            Table.Effects.Add(Effect);
                                        }

                                        switch (TCS.OutputControl)
                                        {
                                            case OutputControlEnum.FixedOn:
                                                Table.AssignedStaticEffects.Add(new AssignedEffect(Effect.Name));
                                                break;
                                            case OutputControlEnum.Controlled:
                                                if (!Table.TableElements.Contains(TCS.TableElementType, TCS.TableElementNumber))
                                                {
                                                    Table.TableElements.UpdateState(TCS.TableElementType, TCS.TableElementNumber, 0);
                                                }
                                                Table.TableElements[TCS.TableElementType, TCS.TableElementNumber].AssignedEffects.Add(new AssignedEffect(Effect.Name));
                                                break;
                                            case OutputControlEnum.FixedOff:
                                            default:
                                                break;
                                        }
                                    }
                                }

                            }
                        }
                    }
                }
            }
        }