protected override bool SendNotification(object owner, Notify notification) { if (owner is ICustomTypeDescriptor descriptor) { owner = descriptor.GetPropertyOwner(PropertyDescriptor); } switch (notification) { case Notify.Reset: object[] objects = (object[])owner; if (objects is null || objects.Length == 0) { return(false); } IDesignerHost host = DesignerHost; DesignerTransaction transaction = host?.CreateTransaction(string.Format(SR.PropertyGridResetValue, PropertyName)); try { bool needChangeNotify = objects[0] is not IComponent component || component.Site is null; if (needChangeNotify) { if (!OnComponentChanging()) { transaction?.Cancel(); transaction = null; return(false); } } _mergedDescriptor.ResetValue(owner); if (needChangeNotify) { OnComponentChanged(); } NotifyParentsOfChanges(this); } finally { transaction?.Commit(); } return(false); case Notify.DoubleClick: case Notify.Return: Debug.Assert(PropertyDescriptor is MergePropertyDescriptor, "Did not get a MergePropertyDescriptor!!!"); Debug.Assert(owner is object[], "Did not get an array of objects!!"); if (PropertyDescriptor is MergePropertyDescriptor mergeDescriptor) { _eventBindings ??= this.GetService <IEventBindingService>(); if (_eventBindings is not null) { EventDescriptor eventDescriptor = _eventBindings.GetEvent(mergeDescriptor[0]); if (eventDescriptor is not null) { return(ViewEvent(owner, null, eventDescriptor, true)); } } return(false); } else { return(base.SendNotification(owner, notification)); } } return(base.SendNotification(owner, notification)); }
internal override bool NotifyValueGivenParent(object obj, int type) { if (obj is ICustomTypeDescriptor) { obj = ((ICustomTypeDescriptor)obj).GetPropertyOwner(_propertyInfo); } switch (type) { case NOTIFY_RESET: object[] objects = (object[])obj; if (objects != null && objects.Length > 0) { IDesignerHost host = DesignerHost; DesignerTransaction trans = null; if (host != null) { trans = host.CreateTransaction(string.Format(SR.PropertyGridResetValue, PropertyName)); } try { bool needChangeNotify = !(objects[0] is IComponent) || ((IComponent)objects[0]).Site is null; if (needChangeNotify) { if (!OnComponentChanging()) { if (trans != null) { trans.Cancel(); trans = null; } return(false); } } mergedPd.ResetValue(obj); if (needChangeNotify) { OnComponentChanged(); } NotifyParentChange(this); } finally { if (trans != null) { trans.Commit(); } } } return(false); case NOTIFY_DBL_CLICK: case NOTIFY_RETURN: Debug.Assert(_propertyInfo is MergePropertyDescriptor, "Did not get a MergePropertyDescriptor!!!"); Debug.Assert(obj is object[], "Did not get an array of objects!!"); if (_propertyInfo is MergePropertyDescriptor mpd) { object[] objs = (object[])obj; if (_eventBindings is null) { _eventBindings = (IEventBindingService)GetService(typeof(IEventBindingService)); } if (_eventBindings != null) { EventDescriptor descriptor = _eventBindings.GetEvent(mpd[0]); if (descriptor != null) { return(ViewEvent(obj, null, descriptor, true)); } } return(false); } else { return(base.NotifyValueGivenParent(obj, type)); } } return(base.NotifyValueGivenParent(obj, type)); }
protected internal override bool NotifyValueGivenParent(object @object, Notify type) { if (@object is ICustomTypeDescriptor descriptor) { @object = descriptor.GetPropertyOwner(_propertyInfo); } switch (type) { case Notify.Reset: object[] objects = (object[])@object; if (objects is not null && objects.Length > 0) { IDesignerHost host = DesignerHost; DesignerTransaction transaction = host?.CreateTransaction(string.Format(SR.PropertyGridResetValue, PropertyName)); try { bool needChangeNotify = objects[0] is not IComponent component || component.Site is null; if (needChangeNotify) { if (!OnComponentChanging()) { transaction?.Cancel(); transaction = null; return(false); } } _mergedDescriptor.ResetValue(@object); if (needChangeNotify) { OnComponentChanged(); } NotifyParentChange(this); } finally { transaction?.Commit(); } } return(false); case Notify.DoubleClick: case Notify.Return: Debug.Assert(_propertyInfo is MergePropertyDescriptor, "Did not get a MergePropertyDescriptor!!!"); Debug.Assert(@object is object[], "Did not get an array of objects!!"); if (_propertyInfo is MergePropertyDescriptor mpd) { _eventBindings ??= this.GetService <IEventBindingService>(); if (_eventBindings is not null) { EventDescriptor eventDescriptor = _eventBindings.GetEvent(mpd[0]); if (eventDescriptor is not null) { return(ViewEvent(@object, null, eventDescriptor, true)); } } return(false); } else { return(base.NotifyValueGivenParent(@object, type)); } } return(base.NotifyValueGivenParent(@object, type)); }