Exemplo n.º 1
0
    public void TestNumberExtensionMethodGeneration()
    {
        var entityStates = new HassState[] {
            new() {
                EntityId       = "number.living_bass",
                AttributesJson = new { unit_of_measurement = "%", }.AsJsonElement()
            },
            new() {
                EntityId       = "unknown.number",
                AttributesJson = new { unit_of_measurement = "pcs", }.AsJsonElement()
            },
            new() {
                EntityId = "unknown.string",
            },
        };

        var hassServiceDomains = new HassServiceDomain[] {
            new() {
                Domain   = "number",
                Services = new HassService[] {
                    new() {
                        Service = "set_value",
                        Target  = new TargetSelector {
                            Entity = new() { Domain = "number" }
                        },
                        Fields = new HassServiceField[] {
                            new() { Field = "value", Selector = new NumberSelector(), },
                        },
                    }
                }
            }
        };
Exemplo n.º 2
0
    public void ChangeNumberIfOverMaxSides()
    {
        int currentSidesHigh = GameObject.Find("sideshigh").GetComponentInChildren <NumberSelector>().current;
        //maximum number we should be able to use for removals is whatever can take us from the high number of sides down to 3 sides
        int            newMax    = currentSidesHigh - 3;
        NumberSelector numSelect = GetComponent <NumberSelector>();

        numSelect.max = newMax;
        if (numSelect.current > newMax)
        {
            numSelect.current      = newMax;
            numSelect.numText.text = "" + numSelect.current;
        }
    }
Exemplo n.º 3
0
        public void TestServicesGeneration()
        {
            var readOnlyCollection = new HassState[]
            {
                new() { EntityId = "light.light1" },
            };

            var hassServiceDomains = new HassServiceDomain[]
            {
                new()
                {
                    Domain   = "light",
                    Services = new HassService[]
                    {
                        new()
                        {
                            Service = "turn_off",
                            Target  = new TargetSelector()
                            {
                                Entity = new() { Domain = "light" }
                            }
                        },
                        new()
                        {
                            Service = "turn_on",
                            Fields  = new HassServiceField[]
                            {
                                new()
                                {
                                    Field    = "transition",
                                    Selector = new NumberSelector(),
                                },
                                new()
                                {
                                    Field    = "brightness",
                                    Selector = new NumberSelector {
                                        Step = 0.2f
                                    },
                                }
                            },
                            Target = new TargetSelector()
                            {
                                Entity = new() { Domain = "light" }
                            }
                        }
                    }
                }
            };
Exemplo n.º 4
0
        private void load()
        {
            SelectionContainer.Add(text = new SpriteText
            {
                Anchor = Anchor.CentreLeft,
                Origin = Anchor.CentreLeft,
                Font   = new FontUsage(size: 25),
            });
            Current.BindValueChanged(v => text.Text = v.NewValue?.ToString() ?? string.Empty, true);

            Action = () =>
            {
                dropdown          = (NumberSelector)Activator.CreateInstance(typeof(NumberSelector), (object)Current);
                dropdown.Position = ToSpaceOfOtherDrawable(new Vector2(Width / 2, DrawHeight), selectorOverlay);
                selectorOverlay.Show(dropdown);
            };
        }
Exemplo n.º 5
0
        private void CreateGateSettings(InputContainer componentMenu)
        {
            foreach (Type t in gateTypes)
            {
                ParameterInfo[] paras = { };
                foreach (var cs in t.GetConstructors())
                {
                    if (paras.Length < cs.GetParameters().Length)
                    {
                        paras = cs.GetParameters();
                    }
                }

                InputContainer temp   = new InputContainer();
                List <Iinput>  inputs = new List <Iinput>();
                int            oldY   = CurrentY;
                foreach (var para in paras)
                {
                    if (typeof(int).IsAssignableFrom(para.ParameterType))
                    {
                        Point start = new Point(X + Padding, CurrentY);
                        temp.Add(new Label(new Text(para.Name, Color.Black), start));

                        int textLength = (int)InputController.DefaultFont.MeasureString(para.Name).X;
                        int textHeight = (int)InputController.DefaultFont.MeasureString(para.Name).Y;
                        int x          = start.X + Padding + textLength;
                        int width      = X + Width - x - Padding;
                        var input      = new NumberSelector(new Rectangle(x, start.Y, width, textHeight), 1, 99, textHeight, 10);
                        temp.Add(input);
                        inputs.Add(input);

                        CurrentY += textHeight + Padding;

                        temp.Active = false;
                        temp.DeFocus();
                    }
                }
                CurrentY = oldY;
                Containers[t.FullName] = temp;
                Inputs.Add(temp, inputs);
            }
            componentMenu.Add(Containers.Values);
        }
 public void Initialise()
 {
     selector = new NumberSelector();
 }
Exemplo n.º 7
0
 public NumberAssert(NumberSelector number) : base(number)
 {
     NumberSelector = number;
 }
 public void Initialise()
 {
     selector = new NumberSelector();
 }