// We need these services to be present, but we cache references for efficiency // Whenever new designer host loaded etc, must reinitialise the services public void InitialiseServices () { //unregister old event handlers if (selectionService != null) selectionService.SelectionChanged -= new EventHandler(selectionService_SelectionChanged); //update references extenderListService = parentServices.GetService (typeof (IExtenderListService)) as IExtenderListService; selectionService = parentServices.GetService (typeof (ISelectionService)) as ISelectionService; changeService = parentServices.GetService (typeof (IComponentChangeService)) as IComponentChangeService; typeDescriptorFilterService = parentServices.GetService (typeof (ITypeDescriptorFilterService)) as ITypeDescriptorFilterService; //register event handlers if (selectionService != null) selectionService.SelectionChanged += new EventHandler (selectionService_SelectionChanged); if (changeService != null) { changeService.ComponentAdded += new ComponentEventHandler (changeService_ComponentAdded); changeService.ComponentRemoved += new ComponentEventHandler (changeService_ComponentRemoved); changeService.ComponentRename += new ComponentRenameEventHandler (changeService_ComponentRename); changeService.ComponentChanged += new ComponentChangedEventHandler (changeService_updateValues); /*TODO: should we also monitor these? changeService.ComponentAdding changeService.ComponentChanging changeService.ComponentRemoving */ } //get existing components for combo list IDesignerHost host = parentServices.GetService (typeof (IDesignerHost)) as IDesignerHost; if (host != null) foreach (IComponent comp in host.Container.Components) changeService_ComponentAdded(host.Container, new ComponentEventArgs (comp)); }
protected AttributeCollection GetAttributes(IComponent comp) { if (_attributes != null) { return(_attributes); } bool flag = true; ArrayList arrayList = new ArrayList(); object[] customAttributes = _infoType.GetCustomAttributes(inherit: false); for (int i = 0; i < customAttributes.Length; i++) { Attribute value = (Attribute)customAttributes[i]; arrayList.Add(value); } Type baseType = _infoType.BaseType; while (baseType != null && baseType != typeof(object)) { object[] customAttributes2 = baseType.GetCustomAttributes(inherit: false); for (int j = 0; j < customAttributes2.Length; j++) { Attribute value2 = (Attribute)customAttributes2[j]; arrayList.Add(value2); } baseType = baseType.BaseType; } Type[] interfaces = _infoType.GetInterfaces(); foreach (Type componentType in interfaces) { foreach (Attribute attribute2 in TypeDescriptor.GetAttributes(componentType)) { arrayList.Add(attribute2); } } Hashtable hashtable = new Hashtable(); for (int num = arrayList.Count - 1; num >= 0; num--) { Attribute attribute = (Attribute)arrayList[num]; hashtable[attribute.TypeId] = attribute; } if (comp != null && comp.Site != null) { ITypeDescriptorFilterService typeDescriptorFilterService = (ITypeDescriptorFilterService)comp.Site.GetService(typeof(ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterAttributes(comp, hashtable); } } Attribute[] array = new Attribute[hashtable.Values.Count]; hashtable.Values.CopyTo(array, 0); AttributeCollection attributeCollection = new AttributeCollection(array); if (flag) { _attributes = attributeCollection; } return(attributeCollection); }
public override EventDescriptorCollection GetEvents() { if (_events != null) { return(_events); } bool flag = true; EventInfo[] events = _component.GetType().GetEvents(); Hashtable hashtable = new Hashtable(); EventInfo[] array = events; foreach (EventInfo eventInfo in array) { hashtable[eventInfo.Name] = new ReflectionEventDescriptor(eventInfo); } if (_component.Site != null) { ITypeDescriptorFilterService typeDescriptorFilterService = (ITypeDescriptorFilterService)_component.Site.GetService(typeof(ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterEvents(_component, hashtable); } } ArrayList arrayList = new ArrayList(); arrayList.AddRange(hashtable.Values); EventDescriptorCollection eventDescriptorCollection = new EventDescriptorCollection(arrayList); if (flag) { _events = eventDescriptorCollection; } return(eventDescriptorCollection); }
public override PropertyDescriptorCollection GetProperties() { if (_properties != null) { return(_properties); } bool flag = true; PropertyInfo[] properties = _component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); Hashtable hashtable = new Hashtable(); for (int num = properties.Length - 1; num >= 0; num--) { hashtable[properties[num].Name] = new ReflectionPropertyDescriptor(properties[num]); } if (_component.Site != null) { ITypeDescriptorFilterService typeDescriptorFilterService = (ITypeDescriptorFilterService)_component.Site.GetService(typeof(ITypeDescriptorFilterService)); if (typeDescriptorFilterService != null) { flag = typeDescriptorFilterService.FilterProperties(_component, hashtable); } } PropertyDescriptor[] array = new PropertyDescriptor[hashtable.Values.Count]; hashtable.Values.CopyTo(array, 0); PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(array, readOnly: true); if (flag) { _properties = propertyDescriptorCollection; } return(propertyDescriptorCollection); }
// Loads a ButtonDesignerFilterService ITypeDescriptorFilterService // to add ColorCycleButtonDesigner designers to each button. private void LoadService() { // If no custom ITypeDescriptorFilterService is loaded, // loads it now. if (!serviceloaded) { // Stores the current ITypeDescriptorFilterService // to restore later. ITypeDescriptorFilterService tdfs = (ITypeDescriptorFilterService)this.Component.Site.GetService(typeof(ITypeDescriptorFilterService)); if (tdfs != null) { oldservice = tdfs; } // Retrieves an IDesignerHost interface to use to // remove and add services. IDesignerHost dh = (IDesignerHost)this.Component.Site.GetService(typeof(IDesignerHost)); if (dh == null) { throw new Exception("Could not obtain IDesignerHost interface."); } // Removes standard ITypeDescriptorFilterService. dh.RemoveService(typeof(ITypeDescriptorFilterService)); // Adds new custom ITypeDescriptorFilterService. dh.AddService(typeof(ITypeDescriptorFilterService), new ButtonDesignerFilterService()); serviceloaded = true; } }
void rep_DesignerLoaded(object sender, DesignerLoadedEventArgs e) { ITypeDescriptorFilterService svc = (ITypeDescriptorFilterService)e.DesignerHost.GetService(typeof(ITypeDescriptorFilterService)); CustomTypeDescriptorFilterService customSvc = new CustomTypeDescriptorFilterService(svc); e.DesignerHost.RemoveService(typeof(ITypeDescriptorFilterService)); e.DesignerHost.AddService(typeof(ITypeDescriptorFilterService), customSvc); }
public override void Initialize(IComponent component) { base.Initialize(component); this.inheritanceService = new InheritanceService(); ISite provider = component.Site; IContainer container = null; IDesignerHost host = (IDesignerHost)this.GetService(typeof(IDesignerHost)); IExtenderProviderService ex = (IExtenderProviderService)this.GetService(typeof(IExtenderProviderService)); if (ex != null) { this.designerExtenders = new DesignerExtenders(ex); } if (host != null) { this.eventHandlerService = new EventHandlerService(null); this.selectionUIService = new SelectionUIService(host); host.AddService(typeof(IInheritanceService), this.inheritanceService); host.AddService(typeof(IEventHandlerService), this.eventHandlerService); host.AddService(typeof(ISelectionUIService), this.selectionUIService); this.compositionUI = new CompositionUI(this, provider); host.AddService(typeof(ComponentTray), this.compositionUI); IComponentChangeService service2 = (IComponentChangeService)this.GetService(typeof(IComponentChangeService)); if (service2 != null) { service2.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded); service2.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved); } ISelectionService service3 = (ISelectionService)this.GetService(typeof(ISelectionService)); if (service3 != null) { service3.SetSelectedComponents(new object[] { component }, SelectionTypes.Auto); } } if (provider != null) { this.commandSet = new CompositionCommandSet(this.compositionUI, provider); container = provider.Container; } this.pbrsFwd = new PbrsForward(this.compositionUI, provider); this.inheritanceService.AddInheritedComponents(component, container); IServiceContainer service = (IServiceContainer)this.GetService(typeof(IServiceContainer)); if (service != null) { this.delegateFilterService = (ITypeDescriptorFilterService)this.GetService(typeof(ITypeDescriptorFilterService)); if (this.delegateFilterService != null) { service.RemoveService(typeof(ITypeDescriptorFilterService)); } service.AddService(typeof(ITypeDescriptorFilterService), this); } }
public object GetService(Type t) { if (t == typeof(ITypeDescriptorFilterService)) { if (innerFilter == null) { innerFilter = (ITypeDescriptorFilterService)((IDesignerSerializationManager)container).GetService(t); if (innerFilter == null) { innerFilter = this; } } return(this); } return(((IDesignerSerializationManager)container).GetService(t)); }
private void DesignMdiController_DesignPanelLoaded(object sender, DevExpress.XtraReports.UserDesigner.DesignerLoadedEventArgs e) { XRDesignPanel panel = (XRDesignPanel)sender; if (panel == null) { return; } IDesignerHost host = panel.GetService(typeof(IDesignerHost)) as IDesignerHost; if (host == null) { return; } ITypeDescriptorFilterService serv = host.GetService(typeof(ITypeDescriptorFilterService)) as ITypeDescriptorFilterService; host.RemoveService(typeof(ITypeDescriptorFilterService)); host.AddService(typeof(ITypeDescriptorFilterService), new TypeDescriptorFilterService(serv)); }
protected AttributeCollection GetAttributes(IComponent comp) { if (_attributes != null) { return(_attributes); } bool cache = true; object[] ats = _infoType.GetCustomAttributes(true); Hashtable t = new Hashtable(); // Filter the custom attributes, so that only the top // level of the same type are left. // for (int i = ats.Length - 1; i >= 0; i--) { t [((Attribute)ats[i]).TypeId] = ats[i]; } if (comp != null && comp.Site != null) { ITypeDescriptorFilterService filter = (ITypeDescriptorFilterService)comp.Site.GetService(typeof(ITypeDescriptorFilterService)); if (filter != null) { cache = filter.FilterAttributes(comp, t); } } ArrayList atts = new ArrayList(); atts.AddRange(t.Values); AttributeCollection attCol = new AttributeCollection(atts); if (cache) { _attributes = attCol; } return(attCol); }
public override EventDescriptorCollection GetEvents() { if (_events != null) { return(_events); } bool cache = true; EventInfo[] events = _component.GetType().GetEvents(); Hashtable t = new Hashtable(); foreach (EventInfo ev in events) { t [ev.Name] = new ReflectionEventDescriptor(ev); } if (_component.Site != null) { ITypeDescriptorFilterService filter = (ITypeDescriptorFilterService)_component.Site.GetService(typeof(ITypeDescriptorFilterService)); if (filter != null) { cache = filter.FilterEvents(_component, t); } } ArrayList atts = new ArrayList(); atts.AddRange(t.Values); EventDescriptorCollection attCol = new EventDescriptorCollection(atts); if (cache) { _events = attCol; } return(attCol); }
public override PropertyDescriptorCollection GetProperties() { if (_properties != null) { return(_properties); } bool cache = true; PropertyInfo[] props = _component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); Hashtable t = new Hashtable(); for (int i = props.Length - 1; i >= 0; i--) { t [props[i].Name] = new ReflectionPropertyDescriptor(props[i]); } if (_component.Site != null) { ITypeDescriptorFilterService filter = (ITypeDescriptorFilterService)_component.Site.GetService(typeof(ITypeDescriptorFilterService)); if (filter != null) { cache = filter.FilterProperties(_component, t); } } PropertyDescriptor[] descriptors = new PropertyDescriptor[t.Values.Count]; t.Values.CopyTo(descriptors, 0); PropertyDescriptorCollection attCol = new PropertyDescriptorCollection(descriptors, true); if (cache) { _properties = attCol; } return(attCol); }
public TypeDescriptorFilterService(ITypeDescriptorFilterService baseServ) { this.baseServ = baseServ; }
public CustomFilterService(ITypeDescriptorFilterService OldService) { this.OldService = OldService; }
public ExtendedTypeDescriptorFilterService(ITypeDescriptorFilterService originalService) { _originalService = originalService; }
internal bool IsValid(ITypeDescriptorFilterService filterService) { if (!object.ReferenceEquals(this._filterService, filterService)) { return false; } return true; }
public CustomTypeDescriptorFilterService(ITypeDescriptorFilterService svc) { this.svc = svc; }
internal FilterCacheItem(ITypeDescriptorFilterService filterService, ICollection filteredMembers) { _filterService = filterService; FilteredMembers = filteredMembers; }
public CustomFilterService(ITypeDescriptorFilterService OldService) { this.OldService = OldService; }
public override void Initialize(IComponent component) { base.Initialize(component); this.inheritanceService = new InheritanceService(); ISite provider = component.Site; IContainer container = null; IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost)); IExtenderProviderService ex = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService)); if (ex != null) { this.designerExtenders = new DesignerExtenders(ex); } if (host != null) { this.eventHandlerService = new EventHandlerService(null); this.selectionUIService = new SelectionUIService(host); host.AddService(typeof(IInheritanceService), this.inheritanceService); host.AddService(typeof(IEventHandlerService), this.eventHandlerService); host.AddService(typeof(ISelectionUIService), this.selectionUIService); this.compositionUI = new CompositionUI(this, provider); host.AddService(typeof(ComponentTray), this.compositionUI); IComponentChangeService service2 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService)); if (service2 != null) { service2.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded); service2.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved); } ISelectionService service3 = (ISelectionService) this.GetService(typeof(ISelectionService)); if (service3 != null) { service3.SetSelectedComponents(new object[] { component }, SelectionTypes.Auto); } } if (provider != null) { this.commandSet = new CompositionCommandSet(this.compositionUI, provider); container = provider.Container; } this.pbrsFwd = new PbrsForward(this.compositionUI, provider); this.inheritanceService.AddInheritedComponents(component, container); IServiceContainer service = (IServiceContainer) this.GetService(typeof(IServiceContainer)); if (service != null) { this.delegateFilterService = (ITypeDescriptorFilterService) this.GetService(typeof(ITypeDescriptorFilterService)); if (this.delegateFilterService != null) { service.RemoveService(typeof(ITypeDescriptorFilterService)); } service.AddService(typeof(ITypeDescriptorFilterService), this); } }
public ButtonDesignerFilterService(ITypeDescriptorFilterService oldService_) { // Stores any previous ITypeDescriptorFilterService to implement service chaining. this.oldService = oldService_; }
internal bool IsValid(ITypeDescriptorFilterService filterService) { if (!Object.ReferenceEquals(_filterService, filterService)) return false; return true; }
/// <include file='doc\CompositionDesigner.uex' path='docs/doc[@for="ComponentDocumentDesigner.Initialize"]/*' /> /// <devdoc> /// <para> /// Initializes the designer with the specified component.</para> /// </devdoc> public override void Initialize(IComponent component) { base.Initialize(component); inheritanceService = new InheritanceService(); ISite site = component.Site; IContainer container = null; IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost)); IExtenderProviderService exps = (IExtenderProviderService)GetService(typeof(IExtenderProviderService)); if (exps != null) { designerExtenders = new DesignerExtenders(exps); } Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found"); if (host != null) { eventHandlerService = new EventHandlerService(null); selectionUIService = new SelectionUIService(host); host.AddService(typeof(IInheritanceService), inheritanceService); host.AddService(typeof(IEventHandlerService), eventHandlerService); host.AddService(typeof(ISelectionUIService), selectionUIService); compositionUI = new CompositionUI(this, site); host.AddService(typeof(ComponentTray), compositionUI); IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService)); Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || cs != null, "IComponentChangeService not found"); if (cs != null) { cs.ComponentAdded += new ComponentEventHandler(OnComponentAdded); cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved); } // Select this component. // ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService)); if (ss != null) { ss.SetSelectedComponents(new object[] { component }, SelectionTypes.Normal); } } // Set up our menu command set // if (site != null) { commandSet = new CompositionCommandSet(compositionUI, site); container = site.Container; } this.pbrsFwd = new PbrsForward(compositionUI, site); // Hook up our inheritance service and do a scan for inherited components. // inheritanceService.AddInheritedComponents(component, container); // Hook yourself up to the ITypeDescriptorFilterService so we can hide the // location property on all components being added to the designer. // IServiceContainer serviceContainer = (IServiceContainer)GetService(typeof(IServiceContainer)); if (serviceContainer != null) { delegateFilterService = (ITypeDescriptorFilterService)GetService(typeof(ITypeDescriptorFilterService)); if (delegateFilterService != null) { serviceContainer.RemoveService(typeof(ITypeDescriptorFilterService)); } serviceContainer.AddService(typeof(ITypeDescriptorFilterService), this); } }