Beispiel #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",  );
        }
Beispiel #2
0
        ControlVariableRatio AddStandardControl(string name, Action <double> cb, double dv)
        {
            var ctl = new ControlVariableRatio {
                Value = dv
            };

            ctl.ValueChanged += (s, e) => cb(ctl.Value);
            Controls.Add(name, ctl);
            return(ctl);
        }
Beispiel #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);
        }