Exemple #1
0
 public EventDescriptorCollection GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(m_SelectedObject, attributes, true));
 }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(this.GetType(), attributes));
 }
Exemple #3
0
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
 {
     return(TypeDescriptor.GetEvents(this, true));
 }
Exemple #4
0
 public EventDescriptorCollection GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(_wrappedObject, attributes));
 }
Exemple #5
0
        /// <summary>
        ///  Gets the properties of the specified component.
        /// </summary>
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object component, Attribute[] attributes)
        {
            IEventBindingService eventPropertySvc = GetEventPropertyService(component, context);

            if (eventPropertySvc == null)
            {
                return(new PropertyDescriptorCollection(null));
            }

            EventDescriptorCollection    events     = TypeDescriptor.GetEvents(component, attributes);
            PropertyDescriptorCollection realEvents = eventPropertySvc.GetEventProperties(events);

            // Add DesignerSerializationVisibilityAttribute.Content to attributes to see if we have any.
            var attributesPlusNamespace = new Attribute[attributes.Length + 1];

            Array.Copy(attributes, 0, attributesPlusNamespace, 0, attributes.Length);
            attributesPlusNamespace[attributes.Length] = DesignerSerializationVisibilityAttribute.Content;

            // If we do, then we traverse them to see if they have any events under the current attributes,
            // and if so, we'll show them as top-level properties so they can be drilled down into to get events.
            PropertyDescriptorCollection namespaceProperties = TypeDescriptor.GetProperties(component, attributesPlusNamespace);

            if (namespaceProperties.Count > 0)
            {
                ArrayList list = null;
                for (int i = 0; i < namespaceProperties.Count; i++)
                {
                    PropertyDescriptor nsProp = namespaceProperties[i];
                    TypeConverter      tc     = nsProp.Converter;
                    if (!tc.GetPropertiesSupported())
                    {
                        continue;
                    }

                    object namespaceValue = nsProp.GetValue(component);
                    EventDescriptorCollection namespaceEvents = TypeDescriptor.GetEvents(namespaceValue, attributes);
                    if (namespaceEvents.Count > 0)
                    {
                        if (list == null)
                        {
                            list = new ArrayList();
                        }

                        // Make this non-mergable
                        nsProp = TypeDescriptor.CreateProperty(nsProp.ComponentType, nsProp, MergablePropertyAttribute.No);
                        list.Add(nsProp);
                    }
                }

                // We've found some, so add them to the event list.
                if (list != null)
                {
                    var realNamespaceProperties = new PropertyDescriptor[list.Count];
                    list.CopyTo(realNamespaceProperties, 0);
                    var finalEvents = new PropertyDescriptor[realEvents.Count + realNamespaceProperties.Length];
                    realEvents.CopyTo(finalEvents, 0);
                    Array.Copy(realNamespaceProperties, 0, finalEvents, realEvents.Count, realNamespaceProperties.Length);
                    realEvents = new PropertyDescriptorCollection(finalEvents);
                }
            }

            return(realEvents);
        }
Exemple #6
0
 EventDescriptorCollection System.ComponentModel.ICustomTypeDescriptor.GetEvents()
 {
     return(TypeDescriptor.GetEvents(this, true));
 }
 public System.ComponentModel.EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(this, true));
 }
Exemple #8
0
 /// <include file='doc\AutomationExtenderManager.uex' path='docs/doc[@for="FilteredObjectWrapper.GetEvents"]/*' />
 /// <devdoc>
 ///     Retrieves an array of events that the given component instance
 ///     provides.  This may differ from the set of events the class
 ///     provides.  If the component is sited, the site may add or remove
 ///     additional events.
 /// </devdoc>
 public EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(baseObject));
 }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
 {
     return(TypeDescriptor.GetEvents(_propertyListView, true));
 }
Exemple #10
0
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => TypeDescriptor.GetEvents(wrapObj);
Exemple #11
0
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(wrapObj, attributes);
Exemple #12
0
        public virtual EventDescriptorCollection GetEvents(System.Attribute[] attributes)
        {
            EventDescriptorCollection edc = TypeDescriptor.GetEvents(this, attributes, true);

            return(edc);
        }
Exemple #13
0
        public virtual EventDescriptorCollection GetEvents()
        {
            EventDescriptorCollection edc = TypeDescriptor.GetEvents(this, true);

            return(edc);
        }
Exemple #14
0
 public EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(m_SelectedObject, true));
 }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes) => TypeDescriptor.GetEvents(this, attributes, true);
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(_propertyListView, attributes, true));
 }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents() => TypeDescriptor.GetEvents(this, true);
 /// <summary>
 /// Returns the events for this instance of Asset using the specified attribute array as a filter.
 /// </summary>
 /// <param name="attributes">An array of type Attribute that is used as a filter. </param>
 /// <returns>An EventDescriptorCollection that represents the filtered events for this Asset instance.</returns>
 public EventDescriptorCollection GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(m_asset, attributes, false));
 }
 public System.ComponentModel.EventDescriptorCollection GetEvents(System.Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(this, attributes, true));
 }
 /// <summary>
 /// Returns the events for this instance of Asset.
 /// </summary>
 /// <returns>An EventDescriptorCollection that represents the events for this Asset instance.</returns>
 public EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(m_asset, false));
 }
Exemple #21
0
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
 {
     return(TypeDescriptor.GetEvents(GetType()));
 }
Exemple #22
0
        public override PropertyDescriptorCollection GetProperties(object component, Attribute[] attributes)
        {
            IEventBindingService evtBind = GetEventService(component);

            return(evtBind.GetEventProperties(TypeDescriptor.GetEvents(component)));
        }
Exemple #23
0
 public EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(_wrappedObject));
 }
Exemple #24
0
 public EventDescriptor GetLoadEventDescriptor()
 {
     return(TypeDescriptor.GetEvents(Form).Find("Load", true));
 }
Exemple #25
0
        private object SetPropertyValue(object obj, object objVal, bool reset, string undoText)
        {
            DesignerTransaction trans = null;

            try
            {
                object oldValue = GetPropertyValueCore(obj);

                if (objVal != null && objVal.Equals(oldValue))
                {
                    return(objVal);
                }

                ClearCachedValues();

                IDesignerHost host = DesignerHost;

                if (host != null)
                {
                    string text = (undoText ?? string.Format(SR.PropertyGridSetValue, propertyInfo.Name));
                    trans = host.CreateTransaction(text);
                }

                // Usually IComponent things are sited and this notification will be
                // fired automatically by the PropertyDescriptor.  However, for non-IComponent sub objects
                // or sub objects that are non-sited sub components, we need to manuall fire
                // the notification.
                //
                bool needChangeNotify = !(obj is IComponent) || ((IComponent)obj).Site == null;

                if (needChangeNotify)
                {
                    try
                    {
                        if (ComponentChangeService != null)
                        {
                            ComponentChangeService.OnComponentChanging(obj, propertyInfo);
                        }
                    }
                    catch (CheckoutException coEx)
                    {
                        if (coEx == CheckoutException.Canceled)
                        {
                            return(oldValue);
                        }
                        throw coEx;
                    }
                }

                bool wasExpanded = InternalExpanded;
                int  childCount  = -1;
                if (wasExpanded)
                {
                    childCount = ChildCount;
                }

                RefreshPropertiesAttribute refreshAttr = (RefreshPropertiesAttribute)propertyInfo.Attributes[typeof(RefreshPropertiesAttribute)];
                bool needsRefresh = wasExpanded || (refreshAttr != null && !refreshAttr.RefreshProperties.Equals(RefreshProperties.None));

                if (needsRefresh)
                {
                    DisposeChildren();
                }

                // Determine if this is an event being created, and if so, navigate to the event code
                //

                EventDescriptor eventDesc = null;

                // This is possibly an event.  Check it out.
                //
                if (obj != null && objVal is string)
                {
                    if (eventBindings == null)
                    {
                        eventBindings = (IEventBindingService)GetService(typeof(IEventBindingService));
                    }
                    if (eventBindings != null)
                    {
                        eventDesc = eventBindings.GetEvent(propertyInfo);
                    }

                    // For a merged set of propertius, the event binding service won't
                    // find an event.  So, we ask type descriptor directly.
                    //
                    if (eventDesc == null)
                    {
                        // If we have a merged property descriptor, pull out one of
                        // the elements.
                        //
                        object eventObj = obj;

                        if (propertyInfo is MergePropertyDescriptor && obj is Array)
                        {
                            Array objArray = obj as Array;
                            if (objArray.Length > 0)
                            {
                                eventObj = objArray.GetValue(0);
                            }
                        }
                        eventDesc = TypeDescriptor.GetEvents(eventObj)[propertyInfo.Name];
                    }
                }

                bool setSuccessful = false;
                try
                {
                    if (reset)
                    {
                        propertyInfo.ResetValue(obj);
                    }
                    else if (eventDesc != null)
                    {
                        ViewEvent(obj, (string)objVal, eventDesc, false);
                    }
                    else
                    { // Not an event
                        SetPropertyValueCore(obj, objVal, true);
                    }

                    setSuccessful = true;

                    // Now notify the change service that the change was successful.
                    //
                    if (needChangeNotify && ComponentChangeService != null)
                    {
                        ComponentChangeService.OnComponentChanged(obj, propertyInfo, null, objVal);
                    }

                    NotifyParentChange(this);
                }
                finally
                {
                    // see if we need to refresh the property browser
                    // 1) if this property has the refreshpropertiesattribute, or
                    // 2) it's got expanded sub properties
                    //
                    if (needsRefresh && GridEntryHost != null)
                    {
                        RecreateChildren(childCount);
                        if (setSuccessful)
                        {
                            GridEntryHost.Refresh(refreshAttr != null && refreshAttr.Equals(RefreshPropertiesAttribute.All));
                        }
                    }
                }
            }
            catch (CheckoutException checkoutEx)
            {
                if (trans != null)
                {
                    trans.Cancel();
                    trans = null;
                }

                if (checkoutEx == CheckoutException.Canceled)
                {
                    return(null);
                }
                throw;
            }
            catch
            {
                if (trans != null)
                {
                    trans.Cancel();
                    trans = null;
                }

                throw;
            }
            finally
            {
                if (trans != null)
                {
                    trans.Commit();
                }
            }
            return(obj);
        }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(_itemProperties, attributes, true));
 }
 public EventDescriptorCollection GetEvents()
 {
     return(TypeDescriptor.GetEvents(this, true));
 }
 EventDescriptorCollection ICustomTypeDescriptor.GetEvents( )
 {
     return(TypeDescriptor.GetEvents(_itemProperties, true));
 }
Exemple #29
0
 public EventDescriptorCollection GetEvents(Attribute[] attributes)
 {
     return(TypeDescriptor.GetEvents(this, attributes, true));
 }
Exemple #30
0
        public EventDescriptorCollection GetEvents(Attribute[] attributes)
        {
            EventDescriptorCollection retval = TypeDescriptor.GetEvents(this, attributes, true);

            return(retval);
        }