public override void StoreViewState(ModelItem modelItem, string key, object value) { if (modelItem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } if (key == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("key")); } object oldValue = null; Dictionary <string, object> viewState = WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue()); if (viewState == null) { viewState = new Dictionary <string, object>(); WorkflowViewStateService.SetViewState(modelItem.GetCurrentValue(), viewState); } viewState.TryGetValue(key, out oldValue); if (value != null) { viewState[key] = value; } else { RemoveViewState(modelItem, key); } if (this.ViewStateChanged != null && value != oldValue) { this.ViewStateChanged(this, new ViewStateChangedEventArgs(modelItem, key, value, oldValue)); } }
public override void Initialize(EditingContext context) { this.context = context; AttachedPropertiesService propertiesService = this.context.Services.GetService<AttachedPropertiesService>(); helpService = this.context.Services.GetService<IIntegratedHelpService>(); oldSelection = this.context.Items.GetValue<Selection>(); isPrimarySelectionProperty = new AttachedProperty<bool>() { Getter = (modelItem) => (this.context.Items.GetValue<Selection>().PrimarySelection == modelItem), Name = "IsPrimarySelection", OwnerType = typeof(Object) }; isSelectionProperty = new AttachedProperty<bool>() { Getter = (modelItem) => (((IList)this.context.Items.GetValue<Selection>().SelectedObjects).Contains(modelItem)), Name = "IsSelection", OwnerType = typeof(Object) }; propertiesService.AddProperty(isPrimarySelectionProperty); propertiesService.AddProperty(isSelectionProperty); if (this.context.Services.GetService<ViewService>() == null) { view = new System.Activities.Presentation.View.DesignerView(this.context); WorkflowViewService viewService = new WorkflowViewService(context); WorkflowViewStateService viewStateService = new WorkflowViewStateService(context); this.context.Services.Publish<ViewService>(viewService); this.context.Services.Publish<VirtualizedContainerService>(new VirtualizedContainerService(this.context)); this.context.Services.Publish<ViewStateService>(viewStateService); this.context.Services.Publish<DesignerView>(view); WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService(); annotationService.Initialize(this.context, view.scrollViewer); this.context.Services.Publish<AnnotationAdornerService>(annotationService); this.context.Services.Subscribe<ModelService>(delegate(ModelService modelService) { this.modelService = modelService; if (modelService.Root != null) { view.MakeRootDesigner(modelService.Root); } view.RestoreDesignerStates(); this.context.Items.Subscribe<Selection>(new SubscribeContextCallback<Selection>(OnItemSelected)); }); } if (helpService != null) { helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); } }
public override void Initialize(EditingContext context) { this.context = context; AttachedPropertiesService propertiesService = this.context.Services.GetService <AttachedPropertiesService>(); helpService = this.context.Services.GetService <IIntegratedHelpService>(); oldSelection = this.context.Items.GetValue <Selection>(); isPrimarySelectionProperty = new AttachedProperty <bool>() { Getter = (modelItem) => (this.context.Items.GetValue <Selection>().PrimarySelection == modelItem), Name = "IsPrimarySelection", OwnerType = typeof(Object) }; isSelectionProperty = new AttachedProperty <bool>() { Getter = (modelItem) => (((IList)this.context.Items.GetValue <Selection>().SelectedObjects).Contains(modelItem)), Name = "IsSelection", OwnerType = typeof(Object) }; propertiesService.AddProperty(isPrimarySelectionProperty); propertiesService.AddProperty(isSelectionProperty); if (this.context.Services.GetService <ViewService>() == null) { view = new System.Activities.Presentation.View.DesignerView(this.context); WorkflowViewService viewService = new WorkflowViewService(context); WorkflowViewStateService viewStateService = new WorkflowViewStateService(context); this.context.Services.Publish <ViewService>(viewService); this.context.Services.Publish <VirtualizedContainerService>(new VirtualizedContainerService(this.context)); this.context.Services.Publish <ViewStateService>(viewStateService); this.context.Services.Publish <DesignerView>(view); WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService(); annotationService.Initialize(this.context, view.scrollViewer); this.context.Services.Publish <AnnotationAdornerService>(annotationService); this.context.Services.Subscribe <ModelService>(delegate(ModelService modelService) { this.modelService = modelService; if (modelService.Root != null) { view.MakeRootDesigner(modelService.Root); } view.RestoreDesignerStates(); this.context.Items.Subscribe <Selection>(new SubscribeContextCallback <Selection>(OnItemSelected)); }); } if (helpService != null) { helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); } }
public override Dictionary <string, object> RetrieveAllViewState(ModelItem modelItem) { if (modelItem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } return(WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue())); }
public override object RetrieveViewState(ModelItem modelItem, string key) { if (modelItem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } if (key == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("key")); } object viewStateObj = null; Dictionary <string, object> viewState = WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue()); if (viewState != null) { viewState.TryGetValue(key, out viewStateObj); } return(viewStateObj); }
public override bool RemoveViewState(ModelItem modelItem, string key) { if (modelItem == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("modelItem")); } if (key == null) { throw FxTrace.Exception.AsError(new ArgumentNullException("key")); } bool itemRemoved = false; Dictionary <string, object> viewState = WorkflowViewStateService.GetViewState(modelItem.GetCurrentValue()); if (viewState != null && key != null && viewState.ContainsKey(key)) { itemRemoved = viewState.Remove(key); if (viewState.Keys.Count == 0) { AttachablePropertyServices.RemoveProperty(modelItem.GetCurrentValue(), ViewStateName); } } return(itemRemoved); }
public ViewStateChange(WorkflowViewStateService viewStateService) { this.viewStateService = viewStateService; }