Esempio n. 1
0
        //private void UpdateProperties(IList<DesignerPropertyInfo> properties, List<MethodDef.Param> parameters, string parametersCategory)
        private void UpdateProperties(IList <DesignerPropertyInfo> properties)
        {
            //Console.WriteLine("UpdateProperties");
            //this.SuspendLayout();

            List <string> categories = new List <string>();

            foreach (DesignerPropertyInfo property in properties)
            {
                if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) &&
                    (property.Attribute.CategoryResourceString != "CategoryVersion" || Settings.Default.ShowVersionInfo) &&
                    !categories.Contains(property.Attribute.CategoryResourceString))
                {
                    categories.Add(property.Attribute.CategoryResourceString);
                }
            }

            categories.Sort();

            Nodes.Node     node           = SelectedObject as Nodes.Node;
            List <ParInfo> pars           = new List <ParInfo>();
            bool           referrencedPar = false;
            NodeUIPolicy   uiPolicy       = null;

            if (node != null)
            {
                node.GetAllPars(ref pars);

                uiPolicy = NodeUIPolicy.CreateUIPolicy(node);
                uiPolicy.Initialize(SelectedObject);
            }
            else
            {
                Attachments.Attach attachment = SelectedObject as Behaviac.Design.Attachments.Attach;
                if (attachment != null)
                {
                    node           = attachment.Node;
                    referrencedPar = true;
                    attachment.GetAllPars(ref pars);

                    uiPolicy = NodeUIPolicy.CreateUIPolicy(attachment);
                    uiPolicy.Initialize(SelectedObject);
                }
            }

            if (pars.Count > 0 && !categories.Contains("CategoryPar"))
            {
                categories.Add("CategoryPar");
            }

            foreach (string category in categories)
            {
                propertyGrid.AddCategory(Plugin.GetResourceString(category), true);

                foreach (DesignerPropertyInfo property in properties)
                {
                    if (!property.Attribute.HasFlags(DesignerProperty.DesignerFlags.NoDisplay) &&
                        property.Attribute.CategoryResourceString == category)
                    {
                        Type  type  = property.Attribute.GetEditorType(property.Property.GetValue(_selectedObject, null));
                        Label label = propertyGrid.AddProperty(property.Attribute.DisplayName, type, property.Attribute.HasFlags(DesignerProperty.DesignerFlags.ReadOnly));

                        // register description showing
                        label.MouseEnter += new EventHandler(label_MouseEnter);

                        // when we found an editor we connect it to the object
                        if (type != null)
                        {
                            DesignerPropertyEditor editor = (DesignerPropertyEditor)label.Tag;
                            editor.SetRootNode((Nodes.Node) this._rootBehavior);
                            editor.SetProperty(property, _selectedObject);
                            editor.ValueWasAssigned();
                            editor.MouseEnter            += editor_MouseEnter;
                            editor.DescriptionWasChanged += editor_DescriptionWasChanged;
                            editor.ValueWasChanged       += editor_ValueWasChanged;

                            if (uiPolicy != null)
                            {
                                uiPolicy.AddEditor(editor);
                            }
                        }

                        MethodDef          method             = null;
                        bool               methodEditorEnable = true;
                        DesignerMethodEnum propertyMethod     = property.Attribute as DesignerMethodEnum;
                        if (propertyMethod != null)
                        {
                            if (propertyMethod.MethodType != MethodType.Status)
                            {
                                method             = property.Property.GetValue(_selectedObject, null) as MethodDef;
                                methodEditorEnable = (propertyMethod.MethodType != MethodType.Event);
                            }
                        }
                        else
                        {
                            DesignerRightValueEnum propertyRV = property.Attribute as DesignerRightValueEnum;
                            if (propertyRV != null)
                            {
                                RightValueDef rv = property.Property.GetValue(_selectedObject, null) as RightValueDef;
                                if (rv != null && rv.IsMethod)
                                {
                                    method = rv.Method;
                                }
                            }
                        }

                        if (method != null)
                        {
                            createParamEditor(method, methodEditorEnable);
                        }
                    }
                }

                if (pars.Count > 0 && "CategoryPar" == category)
                {
                    createParEditor(pars, referrencedPar ? typeof(DesignerParComboEnumEditor) : typeof(DesignerParEditor));
                }
            }

            if (uiPolicy != null)
            {
                uiPolicy.Update();
            }

            //this.ResumeLayout(false);
        }
Esempio n. 2
0
 public SubItemEffector(Attach e)
     : base(e)
 {
 }
 /// <summary>
 /// Creates a new subitm which can render an event on the node.
 /// </summary>
 /// <param name="evnt">The event we want to draw.</param>
 public SubItemEvent(Attach evnt)
     : base(evnt, _theDefaultEventBrush, _theSelectedEventBrush, _theEventLabelFont, null)
 {
 }
Esempio n. 4
0
 public SubItemPrecondition(Attach e)
     : base(e)
 {
 }
 /// <summary>
 /// Creates a new subitm which can render a AttachAction on the node.
 /// </summary>
 /// <param name="predicate">The event we want to draw.</param>
 public SubItemAttachAction(Attach p)
     : base(p) {
 }