Пример #1
0
        public SequenceChristmas2020()
        {
            fxCandy          = new FxCandyCane();
            fxAll            = new FxScale(fxCandy);
            fxWindows        = new FxScale(fxAll);
            windowsLuminance = new ControlVariableRatio {
                Value = 0.2
            };
            periodSeconds = new ControlVariableInteger(0, 15, 1)
            {
                Value = fxCandy.PeriodSeconds
            };
            stripeColour = new ControlVariableColour {
                Value = fxCandy.ColourStripe
            };
            fillColour = new ControlVariableColour {
                Value = fxCandy.ColourBackground
            };
            pixWindows = new GlimPixelMap.Factory {
                devLounge, devDining
            }.Compile();
            pixRoof = new GlimPixelMap.Factory {
                devRoof
            }.Compile();

            AddLuminanceControl(v => fxAll.Luminance   = v);
            AddSaturationControl(v => fxAll.Saturation = v);
            Controls.Add("Windows Lum", windowsLuminance);
            windowsLuminance.ValueChanged += (s, e) => fxWindows.Luminance = windowsLuminance.Value;
            Controls.Add("Period (S)", periodSeconds);
            periodSeconds.ValueChanged += (s, e) => fxCandy.PeriodSeconds = periodSeconds.Value;
            //Controls.Add( "Colour Stripe",  );
        }
Пример #2
0
        public SequenceRainbow()
        {
            var fxr = new FxRainbow {
                HueCyclePixelLength = 94 / 3,
                HueSecondsPerCycle  = 8
            };

            mFxRainbowCycle = new FxScale(fxr);

            AddLuminanceControl(v => mFxRainbowCycle.Luminance   = v);
            AddSaturationControl(v => mFxRainbowCycle.Saturation = v);

            var ictl = new ControlVariableInteger(2, 200, 1)
            {
                Value = fxr.HueCyclePixelLength
            };

            ictl.ValueChanged += (s, e) => fxr.HueCyclePixelLength = ictl.Value;
            Controls.Add("Length", ictl);

            var dctl = new ControlVariableDouble(0.1, 30)
            {
                Value = fxr.HueSecondsPerCycle
            };

            dctl.ValueChanged += (s, e) => fxr.HueSecondsPerCycle = dctl.Value;
            Controls.Add("Period", dctl);
        }
Пример #3
0
        void AddJsonControl(JsonObject jctl)
        {
            var name    = jctl["Name"].AsString();
            var typestr = jctl["Type"].AsString();
            IControlVariable ctl;

            if (!Enum.TryParse <ControlType>(typestr, out ControlType type))
            {
                throw new JsonValueInvalidException(jctl["Type"], "Type must be one of: " + string.Join(",", Enum.GetNames(typeof(ControlType))));
            }
            switch (type)
            {
            case ControlType.Ratio:
                if (jctl.TryGetValue("Default", out JsonValue jctlvalue))
                {
                    ctl = new ControlVariableRatio {
                        Value = jctlvalue.AsNumber()
                    };
                }
                else
                {
                    ctl = new ControlVariableRatio();
                }
                break;

            case ControlType.Integer:
                int min  = int.MinValue;
                int max  = int.MaxValue;
                int step = 1;
                if (jctl.TryGetValue("Min", out JsonValue jmin))
                {
                    min = (int)jmin.AsNumber();
                }
                if (jctl.TryGetValue("Max", out JsonValue jmax))
                {
                    max = (int)jmax.AsNumber();
                }
                if (jctl.TryGetValue("Step", out JsonValue jstep))
                {
                    step = (int)jstep.AsNumber();
                }
                if (jctl.TryGetValue("Default", out JsonValue jdef))
                {
                    ctl = new ControlVariableInteger(min, max, step)
                    {
                        Value = (int)jdef.AsNumber()
                    };
                }
                else
                {
                    ctl = new ControlVariableInteger(min, max, step);
                }
                break;

            case ControlType.Double:
                double dmin = double.MinValue;
                double dmax = double.MaxValue;
                if (jctl.TryGetValue("Min", out jmin))
                {
                    dmin = jmin.AsNumber();
                }
                if (jctl.TryGetValue("Max", out jmax))
                {
                    dmax = jmax.AsNumber();
                }
                ctl = new ControlVariableDouble(dmin, dmax);
                break;

            case ControlType.Colour:
                // @todo: implement colour parsing
                ctl = new ControlVariableColour();
                throw new NotImplementedException("Nopeity nope.. haven't implemented Colour variables");

            //break;
            default:
                throw new ArgumentException("Unknown ControlType value");
            }
            Program.AddControl(name, ctl);
        }