public System.ComponentModel.EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(targetControl)); }
public virtual EventDescriptor GetDefaultEvent() { EventDescriptor ed = TypeDescriptor.GetDefaultEvent(this, true); return(ed); }
/// <summary>GetDefaultEvent.</summary> /// <returns>EventDescriptor</returns> public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(m_SelectedObject, true)); }
public virtual EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_componentPointer, true)); }
public System.ComponentModel.EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(this.GetType())); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(masterConfigurationNode)); }
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(typeof(T))); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { EventDescriptor result = TypeDescriptor.GetDefaultEvent(component); return((result == null || hidden.Contains(result.Name)) ? null : result); }
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(elementViewModel, true)); }
// This method is called when a user double-clicks (the representation of) a component. // Tries to bind the default event to a method or creates a new one. // public virtual void DoDefaultAction() { IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); DesignerTransaction transaction = null; if (host != null) { transaction = host.CreateTransaction("ComponentDesigner_AddEvent"); } IEventBindingService eventBindingService = GetService(typeof(IEventBindingService)) as IEventBindingService; EventDescriptor defaultEventDescriptor = null; if (eventBindingService != null) { ISelectionService selectionService = this.GetService(typeof(ISelectionService)) as ISelectionService; try { if (selectionService != null) { ICollection selectedComponents = selectionService.GetSelectedComponents(); foreach (IComponent component in selectedComponents) { EventDescriptor eventDescriptor = TypeDescriptor.GetDefaultEvent(component); if (eventDescriptor != null) { PropertyDescriptor eventProperty = eventBindingService.GetEventProperty(eventDescriptor); if (eventProperty != null && !eventProperty.IsReadOnly) { string methodName = eventProperty.GetValue(component) as string; bool newMethod = true; if (methodName != null || methodName != String.Empty) { ICollection compatibleMethods = eventBindingService.GetCompatibleMethods(eventDescriptor); foreach (string signature in compatibleMethods) { if (signature == methodName) { newMethod = false; break; } } } if (newMethod) { if (methodName == null) { methodName = eventBindingService.CreateUniqueMethodName(component, eventDescriptor); } eventProperty.SetValue(component, methodName); } if (component == _component) { defaultEventDescriptor = eventDescriptor; } } } } } } catch { if (transaction != null) { transaction.Cancel(); transaction = null; } } finally { if (transaction != null) { transaction.Commit(); } } if (defaultEventDescriptor != null) { eventBindingService.ShowCode(_component, defaultEventDescriptor); } } }
System.ComponentModel.EventDescriptor System.ComponentModel.ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(wrappee, true)); }
public virtual void DoDefaultAction() { IEventBindingService service = (IEventBindingService)this.GetService(typeof(IEventBindingService)); if (service != null) { ISelectionService service2 = (ISelectionService)this.GetService(typeof(ISelectionService)); if (service2 != null) { ICollection selectedComponents = service2.GetSelectedComponents(); EventDescriptor e = null; string str = null; IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); DesignerTransaction transaction = null; try { foreach (object obj2 in selectedComponents) { if (!(obj2 is IComponent)) { continue; } EventDescriptor defaultEvent = TypeDescriptor.GetDefaultEvent(obj2); PropertyDescriptor eventProperty = null; string str2 = null; bool flag = false; if (defaultEvent != null) { eventProperty = service.GetEventProperty(defaultEvent); } if ((eventProperty != null) && !eventProperty.IsReadOnly) { try { if ((host != null) && (transaction == null)) { transaction = host.CreateTransaction(System.Design.SR.GetString("ComponentDesignerAddEvent", new object[] { defaultEvent.Name })); } } catch (CheckoutException exception) { if (exception != CheckoutException.Canceled) { throw exception; } return; } str2 = (string)eventProperty.GetValue(obj2); if (str2 == null) { flag = true; str2 = service.CreateUniqueMethodName((IComponent)obj2, defaultEvent); } else { flag = true; foreach (string str3 in service.GetCompatibleMethods(defaultEvent)) { if (str2 == str3) { flag = false; break; } } } codemarkers.CodeMarker(CodeMarkerEvent.perfFXBindEventDesignToCode); if (flag && (eventProperty != null)) { eventProperty.SetValue(obj2, str2); } if (this.component == obj2) { e = defaultEvent; str = str2; } } } } catch (InvalidOperationException) { if (transaction != null) { transaction.Cancel(); transaction = null; } } finally { if (transaction != null) { transaction.Commit(); } } if ((str != null) && (e != null)) { service.ShowCode(this.component, e); } } } }
/// <include file='doc\ComponentDesigner.uex' path='docs/doc[@for="ComponentDesigner.DoDefaultAction"]/*' /> /// <devdoc> /// <para>Creates a method signature in the source code file for the default event on the component and navigates /// the user's cursor to that location in preparation to assign /// the default action.</para> /// </devdoc> public virtual void DoDefaultAction() { ISelectionService selectionService = (ISelectionService)GetService(typeof(ISelectionService)); ICollection components = selectionService.GetSelectedComponents(); // hmmmm, I sure could use some services. // IEventBindingService eps = (IEventBindingService)GetService(typeof(IEventBindingService)); EventDescriptor thisDefaultEvent = null; string thisHandler = null; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); DesignerTransaction t = null; try { foreach (object comp in components) { if (!(comp is IComponent)) { continue; } EventDescriptor defaultEvent = TypeDescriptor.GetDefaultEvent(comp); PropertyDescriptor defaultPropEvent = null; string handler = null; bool eventChanged = false; if (defaultEvent != null) { if (CompModSwitches.CommonDesignerServices.Enabled) { Debug.Assert(eps != null, "IEventBindingService not found"); } if (eps != null) { defaultPropEvent = eps.GetEventProperty(defaultEvent); } } // If we couldn't find a property for this event, or of the property is read only, then // abort. // if (defaultPropEvent == null || defaultPropEvent.IsReadOnly) { continue; } try { if (host != null && t == null) { t = host.CreateTransaction(SR.GetString(SR.ComponentDesignerAddEvent, defaultEvent.Name)); } } catch (CheckoutException cxe) { if (cxe == CheckoutException.Canceled) { return; } throw cxe; } // handler will be null if there is no explicit event hookup in the parsed init method handler = (string)defaultPropEvent.GetValue(comp); if (handler == null) { eventChanged = true; handler = eps.CreateUniqueMethodName((IComponent)comp, defaultEvent); } else { // ensure the handler is still there eventChanged = true; foreach (string compatibleMethod in eps.GetCompatibleMethods(defaultEvent)) { if (handler == compatibleMethod) { eventChanged = false; break; } } } // Save the new value... BEFORE navigating to it! // if (eventChanged && defaultPropEvent != null) { defaultPropEvent.SetValue(comp, handler); } if (component == comp) { thisDefaultEvent = defaultEvent; thisHandler = handler; } } } finally { if (t != null) { t.Commit(); } } // Now show the event code. // if (thisHandler != null && thisDefaultEvent != null) { eps.ShowCode(component, thisDefaultEvent); } }
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_wrappedObject)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_jsonObject, true)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_sourceType)); }
public EventDescriptor GetDefaultEvent() { var ed = TypeDescriptor.GetDefaultEvent(this, true); return(ed); }
public static EventDescriptor GetDefaultEvent(ISerializableControl component) { return(TypeDescriptor.GetDefaultEvent(component, NO_CUSTOM_TYPE_DESC)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(GetType())); }
public EventDescriptor GetDefaultEvent() => TypeDescriptor.GetDefaultEvent(this, true);
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(GetType())); }
public object GetDefaultEvent(object totest) { return(TypeDescriptor.GetDefaultEvent(totest)); }
/// <summary> /// Returns the default event for this instance of Asset. /// </summary> /// <returns>An EventDescriptor that represents the default event for this object, /// or null if this object does not have events.</returns> public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(m_asset, false)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { EventDescriptor ed = TypeDescriptor.GetDefaultEvent(this, true); return(ed); }
/// <summary> /// Creates a method signature in the source code file for the default event on the component and navigates /// the user's cursor to that location in preparation to assign the default action. /// </summary> public virtual void DoDefaultAction() { // If the event binding service is not available, there is nothing much we can do, so just return. if (!TryGetService(out IEventBindingService ebs) || !TryGetService(out ISelectionService selectionService)) { return; } ICollection components = selectionService.GetSelectedComponents(); EventDescriptor thisDefaultEvent = null; string thisHandler = null; IDesignerHost host = GetService <IDesignerHost>(); DesignerTransaction t = null; if (components is null) { return; } try { foreach (IComponent comp in components.OfType <IComponent>()) { EventDescriptor defaultEvent = TypeDescriptor.GetDefaultEvent(comp); PropertyDescriptor defaultPropEvent = null; bool eventChanged = false; if (defaultEvent != null) { defaultPropEvent = ebs.GetEventProperty(defaultEvent); } // If we couldn't find a property for this event, or of the property is read only, then abort. if (defaultPropEvent is null || defaultPropEvent.IsReadOnly) { continue; } try { if (host != null && t is null) { t = host.CreateTransaction(string.Format(SR.ComponentDesignerAddEvent, defaultEvent.Name)); } } catch (CheckoutException cxe) when(cxe == CheckoutException.Canceled) { return; } // handler will be null if there is no explicit event hookup in the parsed init method object result = defaultPropEvent.GetValue(comp); string handler = result as string; if (handler is null) { // Skip invalid properties. if (result != null) { continue; } eventChanged = true; handler = ebs.CreateUniqueMethodName((IComponent)comp, defaultEvent); } else { // ensure the handler is still there eventChanged = true; ICollection methods = ebs.GetCompatibleMethods(defaultEvent); if (methods != null) { foreach (string compatibleMethod in methods.OfType <string>()) { if (handler == compatibleMethod) { eventChanged = false; break; } } } } // Save the new value... BEFORE navigating to it! // s_codemarkers.CodeMarker(CodeMarkerEvent.perfFXBindEventDesignToCode); if (eventChanged) { defaultPropEvent.SetValue(comp, handler); } if (Component == comp) { thisDefaultEvent = defaultEvent; thisHandler = handler; } } } catch (InvalidOperationException) { t?.Cancel(); t = null; } finally { t?.Commit(); } // Now show the event code. if (thisHandler != null && thisDefaultEvent != null) { ebs.ShowCode(Component, thisDefaultEvent); } }
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(this, true)); }
public EventDescriptor GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_obj)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(this, true)); }
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent() { return(TypeDescriptor.GetDefaultEvent(_propertyListView, true)); }