public EffectParameterSetup(IEffectModuleDescriptor descriptor, IEffectModuleInstance effect)
        {
            InitializeComponent();
            Icon = Resources.Properties.Resources.Icon_Vixen3;

            _descriptor = descriptor;

            IEffectEditorControl[] controls = ApplicationServices.GetEffectEditorControls(descriptor.TypeId).ToArray();
            for (int i = 0; i < descriptor.Parameters.Count; i++)
            {
                IEffectEditorControl effectEditorControl = controls[i];
                Control control = effectEditorControl as Control;
                effectEditorControl.TargetEffect = effect;
                control.Dock = DockStyle.Top;
                tableLayoutPanel.Controls.Add(new Label {
                    Text = descriptor.Parameters[i].Name
                });
                tableLayoutPanel.Controls.Add(control);
            }

            object[] effectParameters = (effect != null) ? effect.ParameterValues : new object[_descriptor.Parameters.Count];
            if (controls.Length == 1)
            {
                // One control for all parameters.
                controls[0].EffectParameterValues = effectParameters;
            }
            else
            {
                // One control per parameter.
                for (int i = 0; i < descriptor.Parameters.Count; i++)
                {
                    controls[i].EffectParameterValues = new[] { effectParameters[i] };
                }
            }
        }
Exemple #2
0
        public TimedSequenceEditorEffectEditor(EffectNode effectNode)
        {
            InitializeComponent();
            ForeColor = ThemeColorTable.ForeColor;
            BackColor = ThemeColorTable.BackgroundColor;
            ThemeUpdateControls.UpdateControls(this);
            _effectNode  = effectNode;
            _effectNodes = null;
            IEnumerable <IEffectEditorControl> controls =
                ApplicationServices.GetEffectEditorControls(_effectNode.Effect.Descriptor.TypeId);

            if (controls == null)
            {
                Label l = new Label();
                l.Text   = "Can't find any effect editors that can edit this effect!";
                l.Anchor = AnchorStyles.None;
                tableLayoutPanelEffectEditors.Controls.Add(l);
                tableLayoutPanelEffectEditors.SetColumnSpan(l, 2);
                return;
            }

            _controls = new List <IEffectEditorControl>();
            object[] values = _effectNode.Effect.ParameterValues;
            if (_effectNode.Effect.EffectName.Equals("Nutcracker"))
            {
                var data = _effectNode.Effect.ParameterValues.First() as ICloneable;
                values = new [] { data.Clone() };
            }


            _cleanValues = _effectNode.Effect.ParameterValues;

            // if there were multiple controls returned, or there was only a single control needed (ie. the efffect parameters had only
            // a single item) then add controls inside a ParameterEditor wrapper using editors for that type, and label them appropriately.
            // if it was only a single control returned, it must have matched the entire effect (by GUID or signature), so just dump the
            // control it, and let it deal with everything it needs to.
            if (controls.Count() > 1 ||
                (controls.Count() == 1 && (_effectNode.Effect.Descriptor as IEffectModuleDescriptor).Parameters.Count == 1))
            {
                _usedSingleControl = false;
                int i = 0;
                foreach (IEffectEditorControl ec in controls)
                {
                    // as it's a single control for a single parameter, it *should* take the corresponding indexed parameter from the effect.
                    // so pull that individual parameter out, and give it to the control as a single item. This is a bit of an assumption
                    // and seems...... prone to breaking. TODO: review.
                    ec.EffectParameterValues = values[i].AsEnumerable().ToArray();

                    ec.TargetEffect = effectNode.Effect;

                    if (_effectNode.Effect.Parameters[i].ShowLabel)
                    {
                        Label l = new Label();
                        l.Width    = 1;
                        l.Height   = 1;
                        l.Text     = string.Format("{0}:", _effectNode.Effect.Parameters[i].Name);
                        l.AutoSize = true;
                        l.Anchor   = AnchorStyles.None;
                        tableLayoutPanelEffectEditors.Controls.Add(l);
                    }

                    (ec as Control).Anchor = AnchorStyles.None;
                    tableLayoutPanelEffectEditors.Controls.Add(ec as Control);

                    // save the editor control into a list we can use as a reference later on, to pull the data back out of them in the right order.
                    _controls.Add(ec);
                    i++;
                }
            }
            else
            {
                _usedSingleControl = true;
                IEffectEditorControl control = controls.First();
                control.EffectParameterValues = _effectNode.Effect.ParameterValues;
                control.TargetEffect          = effectNode.Effect;
                tableLayoutPanelEffectEditors.Controls.Add(control as Control);
                tableLayoutPanelEffectEditors.SetColumnSpan((control as Control), 2);

                _controls.Add(control);
            }
        }
Exemple #3
0
 public static void SetParametersAndMarkAsDirty
     (this IEffectEditorControl obj, object[] value)
 {
     obj.EffectParameterValues = value;
     obj.IsDirty = true;
 }