public override void PaintLabel(System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { base.PaintLabel(g, rect, clipRect, selected, paintFullLabel); IPropertyValueUIService propValSvc = this.PropertyValueUIService; if (propValSvc == null) { return; } pvUIItems = propValSvc.GetPropertyUIValueItems(this, propertyInfo); if (pvUIItems != null) { if (uiItemRects == null || uiItemRects.Length != pvUIItems.Length) { uiItemRects = new Rectangle[pvUIItems.Length]; } for (int i = 0; i < pvUIItems.Length; i++) { uiItemRects[i] = new Rectangle(rect.Right - ((IMAGE_SIZE + 1) * (i + 1)), (rect.Height - IMAGE_SIZE) / 2, IMAGE_SIZE, IMAGE_SIZE); g.DrawImage(pvUIItems[i].Image, uiItemRects[i]); } GridEntryHost.LabelPaintMargin = (IMAGE_SIZE + 1) * pvUIItems.Length; } }
void IDisposable.Dispose() { WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (view != null) { if (this.refreshTypesHandler != null) { view.Idle -= this.refreshTypesHandler; } if (this.refreshDesignerActionsHandler != null) { view.Idle -= this.refreshDesignerActionsHandler; } if (this.refreshTasksHandler != null) { view.Idle -= this.refreshTasksHandler; } } this.refreshTypesHandler = null; this.refreshDesignerActionsHandler = null; this.refreshTasksHandler = null; IExtendedUIService service = this.serviceProvider.GetService(typeof(IExtendedUIService)) as IExtendedUIService; if (service != null) { service.RemoveDesignerActions(); } IPropertyValueUIService service2 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service2 != null) { service2.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments)); } IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service3 != null) { service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged); } ISelectionService service4 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (service4 != null) { service4.SelectionChanged -= new EventHandler(this.OnSelectionChanged); } ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (provider != null) { provider.TypesChanged -= new EventHandler(this.OnTypeSystemTypesChanged); } IDesignerEventService service5 = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService; if (service5 != null) { service5.ActiveDesignerChanged -= new ActiveDesignerEventHandler(this.OnActiveDesignerChanged); } this.serviceProvider.LoadComplete -= new EventHandler(this.OnDesignerReloaded); }
public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider) { this.serviceProvider = serviceProvider; this.serviceProvider.LoadComplete += new EventHandler(this.OnDesignerReloaded); IDesignerEventService service = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService; if (service != null) { service.ActiveDesignerChanged += new ActiveDesignerEventHandler(this.OnActiveDesignerChanged); } ITypeProvider provider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (provider != null) { provider.TypesChanged += new EventHandler(this.OnTypeSystemTypesChanged); } ISelectionService service2 = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (service2 != null) { service2.SelectionChanged += new EventHandler(this.OnSelectionChanged); } IComponentChangeService service3 = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (service3 != null) { service3.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged); } IPropertyValueUIService service4 = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service4 != null) { service4.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnPropertyGridAdornments)); } }
protected virtual void Dispose(bool disposing) { if (disposing) { IPropertyValueUIService service = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService)); if (service != null) { service.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.OnGetUIValueItem)); } IServiceContainer container = (IServiceContainer)this.GetService(typeof(IServiceContainer)); if (container != null) { if (this._urlResolutionService != null) { container.RemoveService(typeof(IUrlResolutionService)); } container.RemoveService(typeof(IImplicitResourceProvider)); if (this._designerActionService != null) { this._designerActionService.Dispose(); } this._designerActionUIService.Dispose(); } this._urlResolutionService = null; this._component = null; } }
public virtual void Initialize(IComponent component) { ControlDesigner.VerifyInitializeArgument(component, typeof(TemplateControl)); this._component = component; IServiceContainer container = (IServiceContainer)this.GetService(typeof(IServiceContainer)); if (container != null) { this._urlResolutionService = this.CreateUrlResolutionService(); if (this._urlResolutionService != null) { container.AddService(typeof(IUrlResolutionService), this._urlResolutionService); } this._designerActionService = this.CreateDesignerActionService(this._component.Site); this._designerActionUIService = new DesignerActionUIService(this._component.Site); ServiceCreatorCallback callback = new ServiceCreatorCallback(this.OnCreateService); container.AddService(typeof(IImplicitResourceProvider), callback); } IPropertyValueUIService service = (IPropertyValueUIService)this.GetService(typeof(IPropertyValueUIService)); if (service != null) { service.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnGetUIValueItem)); } }
private void AddPropertyValueUIHandler() { IPropertyValueUIService uiService = (IPropertyValueUIService)Host.GetService(typeof(IPropertyValueUIService)); if (uiService != null) { uiService.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.InheritedPropertyValueUIHandler)); } }
/// <include file='doc\GroupBoxDesigner.uex' path='docs/doc[@for="GroupBoxDesigner.Initialize"]/*' /> /// <devdoc> /// Initializes the designer with the given component. The designer can /// get the component's site and request services from it in this call. /// </devdoc> public override void Initialize(IComponent component) { base.Initialize(component); IPropertyValueUIService pvUISvc = (IPropertyValueUIService)component.Site.GetService(typeof(IPropertyValueUIService)); if (pvUISvc != null) { pvUISvc.AddPropertyValueUIHandler(new PropertyValueUIHandler(this.OnGetUIValueItem)); } }
public WorkflowDesignerEventsCoordinator(IDesignerLoaderHost serviceProvider) { this.serviceProvider = serviceProvider; this.serviceProvider.LoadComplete += new EventHandler(OnDesignerReloaded); //Listen to the events so that we are sure that we appropriately refresh the designer actions and tasks when the types //change IDesignerEventService designerEventService = this.serviceProvider.GetService(typeof(IDesignerEventService)) as IDesignerEventService; if (designerEventService != null) { designerEventService.ActiveDesignerChanged += new ActiveDesignerEventHandler(OnActiveDesignerChanged); } ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) { typeProvider.TypesChanged += new EventHandler(OnTypeSystemTypesChanged); } ISelectionService selectionService = this.serviceProvider.GetService(typeof(ISelectionService)) as ISelectionService; if (selectionService != null) { selectionService.SelectionChanged += new EventHandler(OnSelectionChanged); } IComponentChangeService componentChangedService = this.serviceProvider.GetService(typeof(IComponentChangeService)) as IComponentChangeService; if (componentChangedService != null) { componentChangedService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged); } IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (propertyValueService != null) { propertyValueService.AddPropertyValueUIHandler(new PropertyValueUIHandler(OnPropertyGridAdornments)); } }
private void OnRefreshDesignerActions(object sender, EventArgs e) { //NOTE: Make sure that we dont invalidate the workflow here. Workflow will be invalidated when' //the designer actions are refreshed on idle thread. Putting invalidation logic here causes the validation //to go haywire as before the idle message comes in we start getting to DesignerActions thru the paiting //logic to show smart tags. This causes problems and ConfigErrors appear everywhere on designer intermittently //PROBLEM: ConfigErrors appearing on the entire design surface //This is due to a race condition between the validation triggered during painting //logic and validation triggered when we try to access the DesignerActions from RefreshTask handler //In the validation logic we try to get to the types while doing so we Refresh the code compile unit //in typesystem which in turn triggers CodeDomLoader.Refresh. In this we remove types, call refresh handler //and add new types. While doing this after the remove types but before addtypes, call is made to the drawing //logic in which we try to grab the designer actions which triggers another set of validations hence now we //always call UpdateWindow after invalidatewindow so that the validation will always get triggered on painting thread. //NOTE: PLEASE DO NOT CHANGE SEQUENCE IN WHICH THE FOLLOWING HANDLERS ARE ADDED //THE PROBLEM CAN BE ALSO FIXED BY TRIGGERING VALIDATION IN RefreshDesignerActions ITSELF //FOR NOW THE REFRESH FIX WILL CAUSE MINIMAL IMPACT IN THE LIGHT OF M3 WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (this.refreshDesignerActionsHandler != null) { if (workflowView != null) { workflowView.Idle -= this.refreshDesignerActionsHandler; } this.refreshDesignerActionsHandler = null; } DesignerHelpers.RefreshDesignerActions(this.serviceProvider); IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (propertyValueService != null) { propertyValueService.NotifyPropertyValueUIItemsChanged(); } RefreshTasks(); }
private void OnRefreshDesignerActions(object sender, EventArgs e) { WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (this.refreshDesignerActionsHandler != null) { if (view != null) { view.Idle -= this.refreshDesignerActionsHandler; } this.refreshDesignerActionsHandler = null; } DesignerHelpers.RefreshDesignerActions(this.serviceProvider); IPropertyValueUIService service = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service != null) { service.NotifyPropertyValueUIItemsChanged(); } this.RefreshTasks(); }
public override void PaintLabel(System.Drawing.Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { base.PaintLabel(g, rect, clipRect, selected, paintFullLabel); IPropertyValueUIService propValSvc = this.PropertyValueUIService; if (propValSvc == null) { return; } pvUIItems = propValSvc.GetPropertyUIValueItems(this, propertyInfo); if (pvUIItems != null) { if (uiItemRects == null || uiItemRects.Length != pvUIItems.Length) { uiItemRects = new Rectangle[pvUIItems.Length]; } if (!isScalingInitialized) { if (DpiHelper.IsScalingRequired) { scaledImageSizeX = DpiHelper.LogicalToDeviceUnitsX(IMAGE_SIZE); scaledImageSizeY = DpiHelper.LogicalToDeviceUnitsY(IMAGE_SIZE); } isScalingInitialized = true; } for (int i = 0; i < pvUIItems.Length; i++) { uiItemRects[i] = new Rectangle(rect.Right - ((scaledImageSizeX + 1) * (i + 1)), (rect.Height - scaledImageSizeY) / 2, scaledImageSizeX, scaledImageSizeY); g.DrawImage(pvUIItems[i].Image, uiItemRects[i]); } GridEntryHost.LabelPaintMargin = (scaledImageSizeX + 1) * pvUIItems.Length; } }
public override void PaintLabel(Graphics g, Rectangle rect, Rectangle clipRect, bool selected, bool paintFullLabel) { base.PaintLabel(g, rect, clipRect, selected, paintFullLabel); IPropertyValueUIService propertyValueUIService = this.PropertyValueUIService; if (propertyValueUIService != null) { this.pvUIItems = propertyValueUIService.GetPropertyUIValueItems(this, this.propertyInfo); if (this.pvUIItems != null) { if ((this.uiItemRects == null) || (this.uiItemRects.Length != this.pvUIItems.Length)) { this.uiItemRects = new Rectangle[this.pvUIItems.Length]; } for (int i = 0; i < this.pvUIItems.Length; i++) { this.uiItemRects[i] = new Rectangle(rect.Right - (9 * (i + 1)), (rect.Height - 8) / 2, 8, 8); g.DrawImage(this.pvUIItems[i].Image, this.uiItemRects[i]); } this.GridEntryHost.LabelPaintMargin = 9 * this.pvUIItems.Length; } } }
private void OnRefreshTypes(object sender, EventArgs e) { ITypeProvider typeProvider; if (this.refreshTypesHandler != null) { WorkflowView view = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (view != null) { view.Idle -= this.refreshTypesHandler; } this.refreshTypesHandler = null; } IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; Activity seedActivity = (host != null) ? (host.RootComponent as Activity) : null; if (seedActivity != null) { typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) { Walker walker = new Walker(); walker.FoundProperty += delegate(Walker w, WalkerEventArgs args) { if (((args.CurrentValue != null) && (args.CurrentProperty != null)) && ((args.CurrentProperty.PropertyType == typeof(Type)) && (args.CurrentValue is Type))) { Type type = typeProvider.GetType(((Type)args.CurrentValue).FullName); if (type != null) { args.CurrentProperty.SetValue(args.CurrentPropertyOwner, type, null); if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); } } } else if (((args.CurrentProperty == null) && (args.CurrentValue is DependencyObject)) && !(args.CurrentValue is Activity)) { walker.WalkProperties(args.CurrentActivity, args.CurrentValue); } }; walker.FoundActivity += delegate(Walker w, WalkerEventArgs args) { if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); ActivityDesigner designer = ActivityDesigner.GetDesigner(args.CurrentActivity); if (designer != null) { designer.RefreshDesignerActions(); } InvokeWorkflowDesigner designer2 = designer as InvokeWorkflowDesigner; if (designer2 != null) { designer2.RefreshTargetWorkflowType(); } } }; walker.Walk(seedActivity); } IPropertyValueUIService service = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (service != null) { service.NotifyPropertyValueUIItemsChanged(); } this.RefreshTasks(); this.RefreshDesignerActions(); } }
private void OnRefreshTypes(object sender, EventArgs e) { if (this.refreshTypesHandler != null) { WorkflowView workflowView = this.serviceProvider.GetService(typeof(WorkflowView)) as WorkflowView; if (workflowView != null) { workflowView.Idle -= this.refreshTypesHandler; } this.refreshTypesHandler = null; } IDesignerHost designerHost = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost; Activity rootActivity = (designerHost != null) ? designerHost.RootComponent as Activity : null; if (rootActivity == null) { return; } //Now Refresh the types as well as the designer actions ITypeProvider typeProvider = this.serviceProvider.GetService(typeof(ITypeProvider)) as ITypeProvider; if (typeProvider != null) { Walker walker = new Walker(); walker.FoundProperty += delegate(Walker w, WalkerEventArgs args) { if (args.CurrentValue != null && args.CurrentProperty != null && args.CurrentProperty.PropertyType == typeof(System.Type) && args.CurrentValue is System.Type) { Type updatedType = typeProvider.GetType(((Type)args.CurrentValue).FullName); if (updatedType != null) { args.CurrentProperty.SetValue(args.CurrentPropertyOwner, updatedType, null); if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); } } } else if (args.CurrentProperty == null && args.CurrentValue is DependencyObject && !(args.CurrentValue is Activity)) { walker.WalkProperties(args.CurrentActivity, args.CurrentValue); } }; walker.FoundActivity += delegate(Walker w, WalkerEventArgs args) { if (args.CurrentActivity != null) { TypeDescriptor.Refresh(args.CurrentActivity); ActivityDesigner activityDesigner = ActivityDesigner.GetDesigner(args.CurrentActivity); if (activityDesigner != null) { activityDesigner.RefreshDesignerActions(); } InvokeWorkflowDesigner invokeWorkflowDesigner = activityDesigner as InvokeWorkflowDesigner; if (invokeWorkflowDesigner != null) { invokeWorkflowDesigner.RefreshTargetWorkflowType(); } } }; walker.Walk(rootActivity); } IPropertyValueUIService propertyValueService = this.serviceProvider.GetService(typeof(IPropertyValueUIService)) as IPropertyValueUIService; if (propertyValueService != null) { propertyValueService.NotifyPropertyValueUIItemsChanged(); } RefreshTasks(); RefreshDesignerActions(); }