Exemplo n.º 1
0
        /// <summary>
        /// Either gets or creates the control of the given type for
        /// the current control number we're on.
        /// </summary>
        private T GetControl <T>(GuiLayoutOption settings, ControlRegistration.ConstructorMethod create) where T : GuiControl
        {
            var id      = "Control" + (nextValueId++);
            var control = _controls.Get <T>(id, create);

            control.Settings = settings;
            _currentLayout.Controls.Add(control);
            return(control);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Either gets or creates the value control object with the
        /// given settings.
        /// </summary>
        private ValueControl GetValueControl(GuiControlType type, double value, double minValue, double maxValue, GuiLayoutOption settings)
        {
            // controls are only created the first time to avoid object churning
            var id      = "ValueControl" + (nextValueId++);
            var control = _controls.Get <ValueControl>(id, () =>
            {
                switch (type)
                {
                case GuiControlType.Knob:
                    return(new KnobControl());

                case GuiControlType.HorizontalFader:
                    return(new FaderControl(FaderControl.FaderType.Horizontal));

                case GuiControlType.VerticalFader:
                    return(new FaderControl(FaderControl.FaderType.Vertical));
                }
                return(null);
            });

            // values that are always set to the implant's input
            control.Settings = settings;
            control.MinValue = minValue;
            control.MaxValue = maxValue;

            // allow the implant one chance to grab a changed gui value
            if (control.GuiChangedValue)
            {
                control.GuiChangedValue = false;
            }
            else
            {
                control.Value = value;
            }

            // add control to current layout
            _currentLayout.Controls.Add(control);
            return(control);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets a control using a default constructor when creating
 /// controls that don't exist yet.
 /// </summary>
 private T GetControl <T>(GuiLayoutOption settings) where T : GuiControl, new()
 {
     return(GetControl <T>(settings, () => { return new T(); }));
 }