Ejemplo n.º 1
0
        private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
        {
            IComponent        component        = null;
            IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (referenceService != null)
            {
                component = referenceService.GetComponent(context.Instance);
            }

            string fullAliasName = string.Empty;
            //this attribue is set to overcome issue with the TypedVariableDeclarationTypeConverter
            //not returning Name property at all. we alias that property to the VariableDeclaration itself
            DefaultPropertyAttribute aliasPropertyNameAttribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;

            if (aliasPropertyNameAttribute != null && aliasPropertyNameAttribute.Name != null && aliasPropertyNameAttribute.Name.Length > 0)
            {
                fullAliasName = propDesc.Name + "." + aliasPropertyNameAttribute.Name;
            }

            if (component != null)
            {
                ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(component as Activity);
                if (activityDesigner != null)
                {
                    if (!activityDesigner.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc) && !propDesc.IsReadOnly)
                    {
                        valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage(DR.Bind), OnBindProperty, DR.GetString(DR.BindProperty)));
                    }

                    string fullComponentName = referenceService.GetName(component);        //schedule1.send1
                    string fullPropertyName  = referenceService.GetName(context.Instance); //schedule1.send1.message
                    fullPropertyName = (fullPropertyName.Length > fullComponentName.Length) ? fullPropertyName.Substring(fullComponentName.Length + 1, fullPropertyName.Length - fullComponentName.Length - 1) + "." + propDesc.Name : string.Empty;

                    foreach (DesignerAction action in activityDesigner.DesignerActions)
                    {
                        string actionPropertyName = action.PropertyName as string;
                        if (actionPropertyName == null || actionPropertyName.Length == 0)
                        {
                            continue;
                        }

                        if (actionPropertyName == propDesc.Name || (actionPropertyName == fullPropertyName) || (actionPropertyName == fullAliasName))
                        {
                            PropertyValueUIItemHandler propValueUIItemhandler = new PropertyValueUIItemHandler(action);
                            valueUIItemList.Add(new PropertyValueUIItem(action.Image, propValueUIItemhandler.OnFixPropertyError, action.Text));
                            break;
                        }
                    }
                }
            }
        }
        private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
        {
            IComponent        reference = null;
            IReferenceService service   = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (service != null)
            {
                reference = service.GetComponent(context.Instance);
            }
            string str = string.Empty;
            DefaultPropertyAttribute attribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;

            if (((attribute != null) && (attribute.Name != null)) && (attribute.Name.Length > 0))
            {
                str = propDesc.Name + "." + attribute.Name;
            }
            if (reference != null)
            {
                ActivityDesigner designer = ActivityDesigner.GetDesigner(reference as Activity);
                if (designer != null)
                {
                    if ((!designer.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) && !propDesc.IsReadOnly)
                    {
                        valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage("Bind"), new PropertyValueUIItemInvokeHandler(this.OnBindProperty), DR.GetString("BindProperty", new object[0])));
                    }
                    string name = service.GetName(reference);
                    string str3 = service.GetName(context.Instance);
                    str3 = (str3.Length > name.Length) ? (str3.Substring(name.Length + 1, (str3.Length - name.Length) - 1) + "." + propDesc.Name) : string.Empty;
                    foreach (DesignerAction action in designer.DesignerActions)
                    {
                        string propertyName = action.PropertyName;
                        if (((propertyName != null) && (propertyName.Length != 0)) && (((propertyName == propDesc.Name) || (propertyName == str3)) || (propertyName == str)))
                        {
                            PropertyValueUIItemHandler handler = new PropertyValueUIItemHandler(action);
                            valueUIItemList.Add(new PropertyValueUIItem(action.Image, new PropertyValueUIItemInvokeHandler(handler.OnFixPropertyError), action.Text));
                            break;
                        }
                    }
                }
            }
        }
 private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
 {
     IComponent reference = null;
     IReferenceService service = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
     if (service != null)
     {
         reference = service.GetComponent(context.Instance);
     }
     string str = string.Empty;
     DefaultPropertyAttribute attribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;
     if (((attribute != null) && (attribute.Name != null)) && (attribute.Name.Length > 0))
     {
         str = propDesc.Name + "." + attribute.Name;
     }
     if (reference != null)
     {
         ActivityDesigner designer = ActivityDesigner.GetDesigner(reference as Activity);
         if (designer != null)
         {
             if ((!designer.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc)) && !propDesc.IsReadOnly)
             {
                 valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage("Bind"), new PropertyValueUIItemInvokeHandler(this.OnBindProperty), DR.GetString("BindProperty", new object[0])));
             }
             string name = service.GetName(reference);
             string str3 = service.GetName(context.Instance);
             str3 = (str3.Length > name.Length) ? (str3.Substring(name.Length + 1, (str3.Length - name.Length) - 1) + "." + propDesc.Name) : string.Empty;
             foreach (DesignerAction action in designer.DesignerActions)
             {
                 string propertyName = action.PropertyName;
                 if (((propertyName != null) && (propertyName.Length != 0)) && (((propertyName == propDesc.Name) || (propertyName == str3)) || (propertyName == str)))
                 {
                     PropertyValueUIItemHandler handler = new PropertyValueUIItemHandler(action);
                     valueUIItemList.Add(new PropertyValueUIItem(action.Image, new PropertyValueUIItemInvokeHandler(handler.OnFixPropertyError), action.Text));
                     break;
                 }
             }
         }
     }
 }
        private void OnPropertyGridAdornments(ITypeDescriptorContext context, PropertyDescriptor propDesc, ArrayList valueUIItemList)
        {
            IComponent component = null;
            IReferenceService referenceService = this.serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
            if (referenceService != null)
                component = referenceService.GetComponent(context.Instance);

            string fullAliasName = string.Empty;
            //this attribue is set to overcome issue with the TypedVariableDeclarationTypeConverter
            //not returning Name property at all. we alias that property to the VariableDeclaration itself 
            DefaultPropertyAttribute aliasPropertyNameAttribute = propDesc.Attributes[typeof(DefaultPropertyAttribute)] as DefaultPropertyAttribute;
            if (aliasPropertyNameAttribute != null && aliasPropertyNameAttribute.Name != null && aliasPropertyNameAttribute.Name.Length > 0)
                fullAliasName = propDesc.Name + "." + aliasPropertyNameAttribute.Name;

            if (component != null)
            {
                ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(component as Activity);
                if (activityDesigner != null)
                {
                    if (!activityDesigner.IsLocked && ActivityBindPropertyDescriptor.IsBindableProperty(propDesc) && !propDesc.IsReadOnly)
                        valueUIItemList.Add(new PropertyValueUIItem(DR.GetImage(DR.Bind), OnBindProperty, DR.GetString(DR.BindProperty)));

                    string fullComponentName = referenceService.GetName(component); //schedule1.send1
                    string fullPropertyName = referenceService.GetName(context.Instance); //schedule1.send1.message
                    fullPropertyName = (fullPropertyName.Length > fullComponentName.Length) ? fullPropertyName.Substring(fullComponentName.Length + 1, fullPropertyName.Length - fullComponentName.Length - 1) + "." + propDesc.Name : string.Empty;

                    foreach (DesignerAction action in activityDesigner.DesignerActions)
                    {
                        string actionPropertyName = action.PropertyName as string;
                        if (actionPropertyName == null || actionPropertyName.Length == 0)
                            continue;

                        if (actionPropertyName == propDesc.Name || (actionPropertyName == fullPropertyName) || (actionPropertyName == fullAliasName))
                        {
                            PropertyValueUIItemHandler propValueUIItemhandler = new PropertyValueUIItemHandler(action);
                            valueUIItemList.Add(new PropertyValueUIItem(action.Image, propValueUIItemhandler.OnFixPropertyError, action.Text));
                            break;
                        }
                    }
                }
            }
        }