Example #1
0
        public void AddTweakControl(TweakControl tweakControl)
        {
            Tweakable t = new Tweakable();

            // Add label
            {
                t.Label      = new Label();
                t.Label.Text = tweakControl.Attr.Name;

                _leftPanel.Controls.Add(t.Label);

                t.Label.Left   = 0;
                t.Label.Width  = t.Label.Parent.Width;
                t.Label.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            }

            // Add tweak control
            {
                t.TweakControl = tweakControl;

                _rightPanel.Controls.Add(t.TweakControl);

                t.TweakControl.Left   = 0;
                t.TweakControl.Width  = t.TweakControl.Parent.Width;
                t.TweakControl.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;

                //t.TweakControl.Tweak += this.HandleTweak;
                t.TweakControl.Tag = t;
            }

            _tweakables.Add(t);

            ArrangeControls();
        }
Example #2
0
        //-///////////////////////////////////////////////////////////////////////
        //-///////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Adds tweaks as appropriate for the given list of attributes.
        /// </summary>
        /// <param name="attrs"></param>
        private void tweaks(Attr[] attrs)
        {
            for (int i = 0; i < attrs.Length; ++i)
            {
                Attr attr = attrs[i];

                TweakControl tweakControl = null;

                object attrValue = attr.GetValue();

                // Check...
                if (attrValue is string)
                {
                    tweakControl = new TweakStringControl(attr);
                }
                else if (attrValue is V2)
                {
                    tweakControl = new TweakV2Control(attr);
                }
                else if (attrValue is float || attrValue is double)
                {
                    tweakControl = new TweakFloatControl(attr);
                }
                else
                {
                    throw new ArgumentException(string.Format("Attr {0} - no tweaker for type {1}.", attr.Name, attrValue.GetType()));
                }

                _mainForm.TweaksPanel.AddTweakControl(tweakControl);
            }
        }