public void Init(Pedal pedal, IList<Knob> knobs)
        {
            tableLayoutPanel.RowCount = knobs.Count;
            for (var i = 0; i < knobs.Count; i++)
            {
                var knob = knobs[i];
                var label = new Label();
                tableLayoutPanel.Controls.Add(label, 0, i);
                var name = knob.Name;
                var niceName = nameParser.Match(name);
                if(niceName != null && niceName.Groups.Count > 1) {
                    name = niceName.Groups[1].Value;
                }
                label.Text = name;
                label.Anchor = AnchorStyles.Left;

                var numericControl = new NumericUpDownFixed();
                tableLayoutPanel.Controls.Add(numericControl, 1, i);
                numericControl.Minimum = knob.MinValue;
                numericControl.Maximum = knob.MaxValue;
                numericControl.Increment = knob.ValueStep;
                numericControl.DecimalPlaces = 1;
                numericControl.Value = pedal.KnobValues[knob.Key];
                numericControl.ValueChanged += (obj, args) =>
                    pedal.KnobValues[knob.Key] = numericControl.Value;

            }
        }
        public void Init(dynamic pedal, IList<ToolkitKnob> knobs)
        {
            var sortedKnobs = knobs.OrderBy(k => k.Index).ToList();
            tableLayoutPanel.RowCount = knobs.Count;
            for (var i = 0; i < sortedKnobs.Count; i++)
            {
                var knob = sortedKnobs[i];
                var label = new Label();
                tableLayoutPanel.Controls.Add(label, 0, i);
                if (knob.Name != null)
                {
                    var name = knob.Name;
                    var niceName = nameParser.Match(name);
                    if(niceName.Groups.Count > 1) {
                        name = niceName.Groups[1].Value;
                    }
                    label.Text = name;
                }
                label.Anchor = AnchorStyles.Left;

                var numericControl = new NumericUpDownFixed();
                tableLayoutPanel.Controls.Add(numericControl, 1, i);
                numericControl.DecimalPlaces = 2;
                numericControl.Minimum = (decimal)knob.MinValue;
                numericControl.Maximum = (decimal)knob.MaxValue;
                numericControl.Increment = (decimal)knob.ValueStep;                
                numericControl.Value = Math.Min((decimal)pedal.KnobValues[knob.Key], numericControl.Maximum);
                numericControl.ValueChanged += (obj, args) =>
                    pedal.KnobValues[knob.Key] = (float)Math.Min(numericControl.Value, numericControl.Maximum);
            }
        }
示例#3
0
        public void Init(dynamic pedal, IList <ToolkitKnob> knobs)
        {
            var sortedKnobs = knobs.OrderBy(k => k.Index).ToList();

            tableLayoutPanel.RowCount = knobs.Count;
            for (var i = 0; i < sortedKnobs.Count; i++)
            {
                var knob  = sortedKnobs[i];
                var label = new Label();
                tableLayoutPanel.Controls.Add(label, 0, i);
                if (knob.Name != null)
                {
                    var name     = knob.Name;
                    var niceName = nameParser.Match(name);
                    if (niceName.Groups.Count > 1)
                    {
                        name = niceName.Groups[1].Value;
                    }
                    label.Text = name;
                }
                label.Anchor = AnchorStyles.Left;

                var numericControl = new NumericUpDownFixed();
                tableLayoutPanel.Controls.Add(numericControl, 1, i);
                numericControl.DecimalPlaces = 2;
                numericControl.Minimum       = (decimal)knob.MinValue;
                numericControl.Maximum       = (decimal)knob.MaxValue;
                numericControl.Increment     = (decimal)knob.ValueStep;
                numericControl.Value         = Math.Min((decimal)pedal.KnobValues[knob.Key], numericControl.Maximum);
                numericControl.ValueChanged += (obj, args) =>
                                               pedal.KnobValues[knob.Key] = (float)Math.Min(numericControl.Value, numericControl.Maximum);
            }
        }