private void createValueEditor(Type type)
        {
            Type editorType = Plugin.InvokeEditorType(type);

            Debug.Check(editorType != null);

            ParInfo par = this._property as ParInfo;

            if (_property.Variable == null || _property.Variable.GetValueType() != type)
            {
                _property.Variable = new VariableDef(Plugin.DefaultValue(type));
            }

            _valueEditor                  = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, System.Reflection.BindingFlags.CreateInstance, null, null, new object[0]);
            _valueEditor.Margin           = new System.Windows.Forms.Padding(0);
            _valueEditor.Anchor           = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            _valueEditor.Width            = this.dispTextBox.Width;
            _valueEditor.Location         = this.dispTextBox.Location;
            _valueEditor.Location         = new Point(_valueEditor.Location.X, _valueEditor.Location.Y - _valueEditor.Height - 6);
            _valueEditor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged);

            if (par != null)
            {
                _valueEditor.SetPar(par, null);
            }
            else
            {
                _valueEditor.SetVariable(this._property.Variable, null);
            }

            _valueEditor.ValueWasAssigned();

            this.Controls.Add(_valueEditor);
            _valueEditor.BringToFront();
        }
Exemple #2
0
        public bool SetProperty(string valueName, string valueStr)
        {
            DesignerPropertyEditor propertyEditor = getPropertyEditor(valueName);

            if (propertyEditor == null)
            {
                return(false);
            }

            VariableDef var = propertyEditor.GetVariable();

            if (var.Value.ToString().ToLower() != valueStr.ToLower())
            {
                Plugin.InvokeTypeParser(null, var.GetValueType(), valueStr, (object value) => var.Value = value, null);

                propertyEditor.ValueWasnotAssigned();

                propertyEditor.SetVariable(var, null);

                propertyEditor.ValueWasAssigned();

                return(true);
            }

            return(false);
        }
Exemple #3
0
        public bool SetProperty(BehaviorNode behavior, string valueName, string valueStr)
        {
            DesignerPropertyEditor propertyEditor = getPropertyEditor(valueName);

            if (propertyEditor == null && behavior != null)
            {
                Node root = behavior as Node;

                foreach (PropertyDef p in root.LocalVars)
                {
                    if (!p.IsArrayElement && p.BasicName == valueName)
                    {
                        propertyEditor = addRowControl(p);
                        break;
                    }
                }
            }

            if (propertyEditor == null)
            {
                return(false);
            }

            VariableDef var = propertyEditor.GetVariable();

            if (var.Value.ToString().ToLower() != valueStr.ToLower())
            {
                Plugin.InvokeTypeParser(null, var.ValueType, valueStr, (object value) => var.Value = value, null);

                propertyEditor.ValueWasnotAssigned();

                propertyEditor.SetVariable(var, null);

                propertyEditor.ValueWasAssigned();

                return(true);
            }

            return(false);
        }
Exemple #4
0
        private DesignerPropertyEditor createPropertyEditor(PropertyDef property)
        {
            Type type       = property.Type;
            Type editorType = Plugin.InvokeEditorType(type);

            Debug.Check(editorType != null);

            DesignerPropertyEditor editor = (DesignerPropertyEditor)editorType.InvokeMember(string.Empty, BindingFlags.CreateInstance, null, null, new object[0]);

            editor.TabStop          = false;
            editor.Dock             = System.Windows.Forms.DockStyle.Fill;
            editor.Margin           = new System.Windows.Forms.Padding(0);
            editor.ValueWasChanged += new DesignerPropertyEditor.ValueChanged(editor_ValueWasChanged);

            VariableDef var = new VariableDef(Plugin.DefaultValue(type));

            editor.SetVariable(var, null);

            editor.ValueWasAssigned();

            return(editor);
        }