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(); }
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(); }