Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / AssignDesigner.xaml.cs / 1305376 / AssignDesigner.xaml.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Core.Presentation { using System.Activities.Presentation; using System.Activities.Presentation.Metadata; using System.Activities.Statements; using System.ComponentModel; using System.Activities.Presentation.Model; using System.Runtime; using Microsoft.VisualBasic.Activities; using System.Reflection; partial class AssignDesigner { const string ToPropertyName = "To"; const string ValuePropertyName = "Value"; PropertyChangedEventHandler modelItemPropertyChangedHandler; public AssignDesigner() { this.InitializeComponent(); } PropertyChangedEventHandler ModelItemPropertyChangedHandler { get { if (this.modelItemPropertyChangedHandler == null) { this.modelItemPropertyChangedHandler = new PropertyChangedEventHandler(modelItem_PropertyChanged); } return this.modelItemPropertyChangedHandler; } } protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); this.Unloaded += (sender, eventArgs) => { AssignDesigner designer = sender as AssignDesigner; if (designer != null && designer.ModelItem != null) { designer.ModelItem.PropertyChanged -= designer.ModelItemPropertyChangedHandler; } }; } internal static void RegisterMetadata(AttributeTableBuilder builder) { Type assignType = typeof(Assign); builder.AddCustomAttributes(assignType, new DesignerAttribute(typeof(AssignDesigner))); builder.AddCustomAttributes(assignType, new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); ArgumentFixer.RegisterArgumentFixer( new ActivityArgumentFixer( (assign, isLocation) => isLocation ? (Argument)assign.To : (Argument)assign.Value, (assign, argument) => { if (argument is InArgument) { assign.Value = (InArgument)argument; } else { assign.To = (OutArgument)argument; } })); } protected override void OnModelItemChanged(object newItem) { ModelItem modelItem = newItem as ModelItem; if (modelItem != null) { modelItem.PropertyChanged += ModelItemPropertyChangedHandler; } base.OnModelItemChanged(newItem); } void modelItem_PropertyChanged(object sender, PropertyChangedEventArgs e) { //if the To argument has changed, we may need to update the Value argument's type if (e.PropertyName == ToPropertyName) { Fx.Assert(this.ModelItem != null, "modelItem could not be null if we recent property changed event from it"); ModelProperty valueProperty = this.ModelItem.Properties[ValuePropertyName]; ModelProperty toProperty = this.ModelItem.Properties[ToPropertyName]; Fx.Assert(valueProperty != null, "Value model property could not be null"); Fx.Assert(toProperty != null, "To model property could not be null"); Argument value = valueProperty.ComputedValue as Argument; Argument to = toProperty.ComputedValue as Argument; if (value != null) { Type targetType = to == null? typeof(object) : to.ArgumentType; if (value.ArgumentType != targetType) { valueProperty.SetValue(MorphHelpers.MorphArgument(valueProperty.Value, targetType)); } } } } } } // 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
- XPathParser.cs
- SpinWait.cs
- SystemInfo.cs
- DataGridViewColumnCollectionEditor.cs
- HttpUnhandledOperationInvoker.cs
- SoapAttributes.cs
- SessionSwitchEventArgs.cs
- MemberDescriptor.cs
- QuadraticBezierSegment.cs
- TextRenderer.cs
- lengthconverter.cs
- ConnectionManagementElement.cs
- InfoCardBaseException.cs
- ReadOnlyCollectionBase.cs
- WmlLinkAdapter.cs
- parserscommon.cs
- Publisher.cs
- NavigationPropertyEmitter.cs
- WorkflowViewStateService.cs
- Win32MouseDevice.cs
- ISAPIWorkerRequest.cs
- MemoryRecordBuffer.cs
- EntityContainerAssociationSet.cs
- _emptywebproxy.cs
- ScriptRegistrationManager.cs
- HeaderedContentControl.cs
- ObjectSet.cs
- RenderDataDrawingContext.cs
- HttpsTransportElement.cs
- FontInfo.cs
- AssemblyAttributesGoHere.cs
- BufferModeSettings.cs
- SamlNameIdentifierClaimResource.cs
- DBConcurrencyException.cs
- ButtonAutomationPeer.cs
- FormatterServices.cs
- SafeHandles.cs
- HttpResponseHeader.cs
- XDRSchema.cs
- DataGridViewButtonColumn.cs
- TimeStampChecker.cs
- GridViewCommandEventArgs.cs
- UriTemplateHelpers.cs
- DefaultParameterValueAttribute.cs
- Axis.cs
- ClientScriptItem.cs
- UrlMappingCollection.cs
- XhtmlTextWriter.cs
- FixedSOMElement.cs
- PolyLineSegmentFigureLogic.cs
- SQLBytesStorage.cs
- LogConverter.cs
- DictionaryKeyPropertyAttribute.cs
- SignatureHelper.cs
- MasterPageBuildProvider.cs
- BamlTreeMap.cs
- ScrollEvent.cs
- InternalMappingException.cs
- CompilerLocalReference.cs
- SqlCacheDependencyDatabaseCollection.cs
- AQNBuilder.cs
- HttpCookiesSection.cs
- TaiwanCalendar.cs
- ToolboxComponentsCreatedEventArgs.cs
- DefaultBinder.cs
- ImageClickEventArgs.cs
- PrintPreviewGraphics.cs
- SafeHandles.cs
- EventItfInfo.cs
- mediapermission.cs
- RegexCompiler.cs
- HostedElements.cs
- DataGridViewRowsRemovedEventArgs.cs
- baseaxisquery.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- BaseDataBoundControl.cs
- ConfigurationErrorsException.cs
- DesignerView.xaml.cs
- XhtmlBasicObjectListAdapter.cs
- MobileListItem.cs
- XPathSelectionIterator.cs
- HttpStreamMessage.cs
- AttachmentCollection.cs
- CLSCompliantAttribute.cs
- SQLDateTimeStorage.cs
- HTMLTextWriter.cs
- LoginUtil.cs
- MouseWheelEventArgs.cs
- LicenseException.cs
- DataStreamFromComStream.cs
- sqlmetadatafactory.cs
- XmlReader.cs
- PrintDialog.cs
- ClientData.cs
- EnumerableCollectionView.cs
- TextRangeProviderWrapper.cs
- MediaElementAutomationPeer.cs
- BitConverter.cs
- ColorConvertedBitmap.cs
- Privilege.cs