Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / CaseDesigner.xaml.cs / 1305376 / CaseDesigner.xaml.cs
//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //--------------------------------------------------------------- namespace System.Activities.Core.Presentation { using System.Activities.Presentation; using System.Activities.Presentation.View; using System.Activities.Presentation.Metadata; using System.Activities.Presentation.Model; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; partial class CaseDesigner { public CaseDesigner() { this.InitializeComponent(); this.Loaded += (sender, e) => { Selection selection = this.Context.Items.GetValue(); if (selection != null) { ModelItem primarySelection = selection.PrimarySelection; this.ExpandState = SwitchDesigner.IsDescendantOfCase(this.ModelItem, primarySelection); if (this.ExpandState) { // If current focus is at another part, we need to focus this designer // to trigger selection changed, then this part will expand and another // expanded part will collapse. Then we focus on the activity it contains // if there is one. Keyboard.Focus((IInputElement)this.ModelItem.View); if (primarySelection.View != null && this.ModelItem != primarySelection) { Keyboard.Focus((IInputElement)primarySelection.View); } } } }; } // When the CaseDesigner is collapsed, its CaseKeyBox will be disabled. Thus CaseKeyBox.RegainFocus() doesn't // work in such situation, we must re-focus the CaseDesigner to expand it first to re-enable the CaseKeyBox. // This situation happens when inputting and invalid case key value and clicking on another Case or Default in // the same parent SwitchDesigner. public Action FocusSelf { get { return (ckb) => { Keyboard.Focus((IInputElement)this); }; } } public static void RegisterMetadata(AttributeTableBuilder builder) { Type type = typeof(ModelItemKeyValuePair<,>); builder.AddCustomAttributes(type, new DesignerAttribute(typeof(CaseDesigner))); builder.AddCustomAttributes(type, type.GetProperty("Value"), BrowsableAttribute.No); builder.AddCustomAttributes(type, new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); } void AttachDisplayName() { AttachedPropertiesService attachedPropertiesService = this.Context.Services.GetService (); Fx.Assert(attachedPropertiesService != null, "AttachedPropertiesService is not available."); Type modelItemType = this.ModelItem.ItemType; foreach (AttachedProperty property in attachedPropertiesService.GetAttachedProperties(modelItemType)) { if (property.Name == "DisplayName" && property.OwnerType == modelItemType) { return; } } AttachedProperty displayNameProperty = new AttachedProperty { Name = "DisplayName", OwnerType = modelItemType, Getter = (modelItem) => { return "Case"; } }; attachedPropertiesService.AddProperty(displayNameProperty); } protected override void OnModelItemChanged(object newItem) { base.OnModelItemChanged(newItem); this.AttachDisplayName(); } protected override void OnMouseDown(MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && e.ClickCount == 2) { SwitchTryCatchDesignerHelper.MakeParentRootDesigner (this); e.Handled = true; } else if (e.LeftButton == MouseButtonState.Pressed) { Keyboard.Focus(this); e.Handled = true; } else if (e.RightButton == MouseButtonState.Pressed) { if (this.ShowExpanded) { Keyboard.Focus(this); } e.Handled = true; } } protected override void OnMouseUp(MouseButtonEventArgs e) { // avoid context menu upon right-click when it's collapsed if (!this.ShowExpanded && e.RightButton == MouseButtonState.Released) { e.Handled = true; } } } } // 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
- ListViewItem.cs
- RSAOAEPKeyExchangeFormatter.cs
- CacheModeValueSerializer.cs
- CachedRequestParams.cs
- InkSerializer.cs
- ColumnClickEvent.cs
- UiaCoreProviderApi.cs
- MultipartContentParser.cs
- UriTemplateHelpers.cs
- ComboBoxRenderer.cs
- ListViewItemEventArgs.cs
- SchemaNamespaceManager.cs
- DashStyle.cs
- GeneralTransform3DTo2DTo3D.cs
- MetafileHeaderWmf.cs
- SymLanguageVendor.cs
- TabPage.cs
- CommandSet.cs
- PinnedBufferMemoryStream.cs
- UserControl.cs
- CodeTypeMember.cs
- StylusLogic.cs
- IPAddressCollection.cs
- PolyQuadraticBezierSegment.cs
- ReachSerializableProperties.cs
- DataObjectPastingEventArgs.cs
- DynamicDataResources.Designer.cs
- ApplicationHost.cs
- _NegotiateClient.cs
- TypeExtensionConverter.cs
- SqlServices.cs
- Trace.cs
- X509CertificateTrustedIssuerElementCollection.cs
- SchemaElementDecl.cs
- ExceptionHandlersDesigner.cs
- ImplicitInputBrush.cs
- NonVisualControlAttribute.cs
- SoapReflectionImporter.cs
- SystemIPAddressInformation.cs
- PluralizationService.cs
- TransformerInfoCollection.cs
- ToolStripGripRenderEventArgs.cs
- DbParameterHelper.cs
- IISUnsafeMethods.cs
- ScriptManagerProxy.cs
- BindingExpressionUncommonField.cs
- DataColumnMappingCollection.cs
- TextSearch.cs
- ListView.cs
- ScrollItemPattern.cs
- RecognizeCompletedEventArgs.cs
- XmlUrlEditor.cs
- PeerCredentialElement.cs
- DependencyObjectPropertyDescriptor.cs
- XmlSerializerAssemblyAttribute.cs
- PrintPageEvent.cs
- XmlRootAttribute.cs
- DefaultAssemblyResolver.cs
- Collection.cs
- metadatamappinghashervisitor.cs
- SessionSwitchEventArgs.cs
- LineVisual.cs
- ConditionalWeakTable.cs
- RegisteredDisposeScript.cs
- DataControlPagerLinkButton.cs
- ListBoxAutomationPeer.cs
- OdbcError.cs
- ResourcePool.cs
- CalendarData.cs
- MailWriter.cs
- PointIndependentAnimationStorage.cs
- ContentPropertyAttribute.cs
- ConfigXmlElement.cs
- DbParameterCollectionHelper.cs
- MaterialGroup.cs
- PointF.cs
- ApplicationTrust.cs
- ToolStripProgressBar.cs
- HTMLTextWriter.cs
- TextMessageEncodingBindingElement.cs
- RequestQueryParser.cs
- SmiConnection.cs
- ConfigurationSectionGroup.cs
- DynamicMethod.cs
- TypeSystemHelpers.cs
- ConfigurationStrings.cs
- RayHitTestParameters.cs
- NullExtension.cs
- PageAsyncTaskManager.cs
- WebSysDescriptionAttribute.cs
- SamlAdvice.cs
- QueryStringParameter.cs
- ValidationService.cs
- AssemblyFilter.cs
- MetadataPropertyAttribute.cs
- Int64.cs
- PeerApplicationLaunchInfo.cs
- FileCodeGroup.cs
- PersistChildrenAttribute.cs
- SQLDoubleStorage.cs