Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / View / WorkflowViewManager.cs / 1407647 / WorkflowViewManager.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.View { using System.Windows; using System.Windows.Media; using System.Windows.Media.Effects; using System.Windows.Documents; using System.Activities.Presentation; using System.Activities.Presentation.View; using System.Activities.Presentation.Hosting; using System.Activities.Presentation.Model; using System.Activities.Presentation.Documents; using System.Activities.Presentation.Services; using System.Collections.ObjectModel; using System.Collections; using System.Collections.Generic; using System.Runtime; using System.ComponentModel.Design; internal class WorkflowViewManager : ViewManager { const string KeywordForWorkflowDesignerHomePage = "DefaultWorkflowDesigner"; EditingContext context; Selection oldSelection; ModelService modelService; System.Activities.Presentation.View.DesignerView view; AttachedPropertyisPrimarySelectionProperty; AttachedProperty isSelectionProperty; IIntegratedHelpService helpService; public override System.Windows.Media.Visual View { get { return view; } } public override void Initialize(EditingContext context) { this.context = context; AttachedPropertiesService propertiesService = this.context.Services.GetService (); helpService = this.context.Services.GetService (); oldSelection = this.context.Items.GetValue (); isPrimarySelectionProperty = new AttachedProperty () { Getter = (modelItem) => (this.context.Items.GetValue ().PrimarySelection == modelItem), Name = "IsPrimarySelection", OwnerType = typeof(Object) }; isSelectionProperty = new AttachedProperty () { Getter = (modelItem) => (((IList)this.context.Items.GetValue ().SelectedObjects).Contains(modelItem)), Name = "IsSelection", OwnerType = typeof(Object) }; propertiesService.AddProperty(isPrimarySelectionProperty); propertiesService.AddProperty(isSelectionProperty); if (this.context.Services.GetService () == 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); this.context.Services.Publish (new VirtualizedContainerService(this.context)); this.context.Services.Publish (viewStateService); this.context.Services.Publish (view); this.context.Services.Subscribe (delegate(ModelService modelService) { this.modelService = modelService; if (modelService.Root != null) { view.MakeRootDesigner(modelService.Root); } view.RestoreDesignerStates(); this.context.Items.Subscribe (new SubscribeContextCallback (OnItemSelected)); }); } if (helpService != null) { helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); } } internal static string GetF1HelpTypeKeyword(Type type) { Fx.Assert(type != null, "type is null"); if (type.IsGenericType) { Type genericTypeDefinition = type.GetGenericTypeDefinition(); return genericTypeDefinition.FullName; } return type.FullName; } void OnItemSelected(Selection newSelection) { Fx.Assert(newSelection != null, "newSelection is null"); IList newSelectionObjects = newSelection.SelectedObjects as IList ; IList oldSelectionObjects = oldSelection.SelectedObjects as IList ; //Call notifyPropertyChanged for IsPrimarySelection attached property. if (newSelection.PrimarySelection != null && !newSelection.PrimarySelection.Equals(oldSelection.PrimarySelection)) { isPrimarySelectionProperty.NotifyPropertyChanged(oldSelection.PrimarySelection); isPrimarySelectionProperty.NotifyPropertyChanged(newSelection.PrimarySelection); } else if (newSelection.PrimarySelection == null) { isPrimarySelectionProperty.NotifyPropertyChanged(oldSelection.PrimarySelection); } //call NotifyPropertyChanged for IsSelection property on ModelItems that were added or removed from selection. HashSet selectionChangeSet = new HashSet (oldSelectionObjects); selectionChangeSet.SymmetricExceptWith(newSelectionObjects); foreach (ModelItem selectionChangeMI in selectionChangeSet) { isSelectionProperty.NotifyPropertyChanged(selectionChangeMI); } if (helpService != null) { if (oldSelection.PrimarySelection != null) { helpService.RemoveContextAttribute(string.Empty, GetF1HelpTypeKeyword(oldSelection.PrimarySelection.ItemType)); } if (newSelection.PrimarySelection != null) { helpService.AddContextAttribute(string.Empty, GetF1HelpTypeKeyword(newSelection.PrimarySelection.ItemType), HelpKeywordType.F1Keyword); } } oldSelection = newSelection; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Presentation.View { using System.Windows; using System.Windows.Media; using System.Windows.Media.Effects; using System.Windows.Documents; using System.Activities.Presentation; using System.Activities.Presentation.View; using System.Activities.Presentation.Hosting; using System.Activities.Presentation.Model; using System.Activities.Presentation.Documents; using System.Activities.Presentation.Services; using System.Collections.ObjectModel; using System.Collections; using System.Collections.Generic; using System.Runtime; using System.ComponentModel.Design; internal class WorkflowViewManager : ViewManager { const string KeywordForWorkflowDesignerHomePage = "DefaultWorkflowDesigner"; EditingContext context; Selection oldSelection; ModelService modelService; System.Activities.Presentation.View.DesignerView view; AttachedProperty isPrimarySelectionProperty; AttachedProperty isSelectionProperty; IIntegratedHelpService helpService; public override System.Windows.Media.Visual View { get { return view; } } public override void Initialize(EditingContext context) { this.context = context; AttachedPropertiesService propertiesService = this.context.Services.GetService (); helpService = this.context.Services.GetService (); oldSelection = this.context.Items.GetValue (); isPrimarySelectionProperty = new AttachedProperty () { Getter = (modelItem) => (this.context.Items.GetValue ().PrimarySelection == modelItem), Name = "IsPrimarySelection", OwnerType = typeof(Object) }; isSelectionProperty = new AttachedProperty () { Getter = (modelItem) => (((IList)this.context.Items.GetValue ().SelectedObjects).Contains(modelItem)), Name = "IsSelection", OwnerType = typeof(Object) }; propertiesService.AddProperty(isPrimarySelectionProperty); propertiesService.AddProperty(isSelectionProperty); if (this.context.Services.GetService () == 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); this.context.Services.Publish (new VirtualizedContainerService(this.context)); this.context.Services.Publish (viewStateService); this.context.Services.Publish (view); this.context.Services.Subscribe (delegate(ModelService modelService) { this.modelService = modelService; if (modelService.Root != null) { view.MakeRootDesigner(modelService.Root); } view.RestoreDesignerStates(); this.context.Items.Subscribe (new SubscribeContextCallback (OnItemSelected)); }); } if (helpService != null) { helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); } } internal static string GetF1HelpTypeKeyword(Type type) { Fx.Assert(type != null, "type is null"); if (type.IsGenericType) { Type genericTypeDefinition = type.GetGenericTypeDefinition(); return genericTypeDefinition.FullName; } return type.FullName; } void OnItemSelected(Selection newSelection) { Fx.Assert(newSelection != null, "newSelection is null"); IList newSelectionObjects = newSelection.SelectedObjects as IList ; IList oldSelectionObjects = oldSelection.SelectedObjects as IList ; //Call notifyPropertyChanged for IsPrimarySelection attached property. if (newSelection.PrimarySelection != null && !newSelection.PrimarySelection.Equals(oldSelection.PrimarySelection)) { isPrimarySelectionProperty.NotifyPropertyChanged(oldSelection.PrimarySelection); isPrimarySelectionProperty.NotifyPropertyChanged(newSelection.PrimarySelection); } else if (newSelection.PrimarySelection == null) { isPrimarySelectionProperty.NotifyPropertyChanged(oldSelection.PrimarySelection); } //call NotifyPropertyChanged for IsSelection property on ModelItems that were added or removed from selection. HashSet selectionChangeSet = new HashSet (oldSelectionObjects); selectionChangeSet.SymmetricExceptWith(newSelectionObjects); foreach (ModelItem selectionChangeMI in selectionChangeSet) { isSelectionProperty.NotifyPropertyChanged(selectionChangeMI); } if (helpService != null) { if (oldSelection.PrimarySelection != null) { helpService.RemoveContextAttribute(string.Empty, GetF1HelpTypeKeyword(oldSelection.PrimarySelection.ItemType)); } if (newSelection.PrimarySelection != null) { helpService.AddContextAttribute(string.Empty, GetF1HelpTypeKeyword(newSelection.PrimarySelection.ItemType), HelpKeywordType.F1Keyword); } } oldSelection = newSelection; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebPartDisplayModeCancelEventArgs.cs
- SimpleType.cs
- EntityDataSourceStatementEditorForm.cs
- ModuleConfigurationInfo.cs
- TransactionFlowAttribute.cs
- Helpers.cs
- HtmlTableCellCollection.cs
- ControlBuilderAttribute.cs
- WebPartUtil.cs
- WFItemsToSpacerVisibility.cs
- FileSystemEnumerable.cs
- OutputCacheSettings.cs
- PeerCustomResolverSettings.cs
- CommandID.cs
- BlobPersonalizationState.cs
- PartitionResolver.cs
- _NegotiateClient.cs
- UniqueConstraint.cs
- DataGridViewCellValueEventArgs.cs
- GAC.cs
- ListViewDeletedEventArgs.cs
- XmlStringTable.cs
- ParameterReplacerVisitor.cs
- QueryCacheEntry.cs
- HttpCookie.cs
- BufferModesCollection.cs
- DataTableNewRowEvent.cs
- HtmlGenericControl.cs
- FunctionUpdateCommand.cs
- TypefaceMap.cs
- OleDbEnumerator.cs
- TraceContextRecord.cs
- SystemNetworkInterface.cs
- TextParagraphProperties.cs
- UnitySerializationHolder.cs
- CompilerErrorCollection.cs
- EndOfStreamException.cs
- X509SecurityTokenAuthenticator.cs
- SettingsPropertyNotFoundException.cs
- HtmlTableRowCollection.cs
- UIElementParaClient.cs
- ListCollectionView.cs
- DataGridHeaderBorder.cs
- SurrogateEncoder.cs
- ManagedFilter.cs
- SQLChars.cs
- DrawingAttributesDefaultValueFactory.cs
- PointAnimation.cs
- DbConnectionPoolGroupProviderInfo.cs
- ResourcePart.cs
- ValidatorCollection.cs
- InputScopeAttribute.cs
- DesignerFrame.cs
- EntityDataSourceViewSchema.cs
- BezierSegment.cs
- PrivilegedConfigurationManager.cs
- ClientBuildManagerCallback.cs
- QuestionEventArgs.cs
- WebScriptMetadataMessageEncoderFactory.cs
- XmlUTF8TextWriter.cs
- EntityAdapter.cs
- RemotingService.cs
- OrderedDictionary.cs
- FontDifferentiator.cs
- Stack.cs
- WindowsImpersonationContext.cs
- DataKeyArray.cs
- MessagingDescriptionAttribute.cs
- DispatcherHooks.cs
- SrgsRulesCollection.cs
- InstanceDataCollection.cs
- ServiceReference.cs
- SubpageParaClient.cs
- HwndSourceKeyboardInputSite.cs
- CodeParameterDeclarationExpression.cs
- ClientConfigurationHost.cs
- EntityClassGenerator.cs
- CircleHotSpot.cs
- WSHttpTransportSecurityElement.cs
- DataColumnCollection.cs
- ZoomComboBox.cs
- XmlTextReaderImpl.cs
- SingleAnimation.cs
- SingletonInstanceContextProvider.cs
- Library.cs
- DependentList.cs
- SendActivityValidator.cs
- SettingsBindableAttribute.cs
- DiscreteKeyFrames.cs
- CompositeScriptReference.cs
- WorkerRequest.cs
- SmtpException.cs
- EnvelopedSignatureTransform.cs
- FixedFlowMap.cs
- DispatcherEventArgs.cs
- ServiceNameCollection.cs
- ToolStripGripRenderEventArgs.cs
- TcpAppDomainProtocolHandler.cs
- PerformanceCounterCategory.cs
- MaskDescriptors.cs