Esempio n. 1
0
        private void LoadParameters(ParameterType parameterType, List <ParameterData> parametersList)
        {
            if (parametersList == null || parametersList.Count == 0)
            {
                return;
            }

            Label title = new Label
            {
                Dock      = DockStyle.Top,
                Text      = GetParameterTypeDescription(parameterType),
                Font      = parameterHeaderLabel.Font,
                Height    = 25,
                TextAlign = ContentAlignment.BottomLeft
            };

            parametersPanel.Controls.Add(title);
            title.BringToFront();

            foreach (ParameterData parameterData in parametersList)
            {
                ParameterControl control = new ParameterControl(parameterData)
                {
                    Dock = DockStyle.Top
                };
                parametersPanel.Controls.Add(control);
                control.BringToFront();
            }
        }
Esempio n. 2
0
        public ParameterDefinition(
            System.Type type,
            string name,
            string description,
            ParameterControl control,
            int index
            )
        {
            this.name = name;

            this.type        = type;
            this.description = description;
            this.control     = control;
            this.index       = index;
        }
Esempio n. 3
0
        void Setup()
        {
            var linkedControls = ParameterControl.GetChildrenWithValue(this);

            foreach (var linkedControl in linkedControls)
            {
                var param   = linkedControl.Value;
                var control = linkedControl.Key as Control;

                var binding = new Binding("NumberedParameters[" + param.Value() + "]");
                binding.Source = viewModel;
                binding.Mode   = BindingMode.TwoWay;

                control.MouseEnter += (s, e) => viewModel.ActiveControl = param;
                control.MouseLeave += (s, e) => { if (viewModel.ActiveControl == param)
                                                  {
                                                      viewModel.ActiveControl = null;
                                                  }
                };

                if (control is Knob2)
                {
                    control.SetBinding(Knob2.ValueProperty, binding);
                }
                else if (control is ToggleButton)
                {
                    binding.Converter = new DoubleToBoolConverter();
                    control.SetBinding(ToggleButton.IsCheckedProperty, binding);
                }
                else if (control is Spinner)
                {
                    var spinner = control as Spinner;
                    binding.Converter = new FreeConverter <double, double>(
                        x => (int)(spinner.Min + x * (spinner.Max - spinner.Min) + 0.00001),
                        x => (x - spinner.Min) / (spinner.Max - spinner.Min));

                    control.SetBinding(Spinner.ValueProperty, binding);
                }
            }
        }