Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / FlowSwitchDesigner.xaml.cs / 1305376 / FlowSwitchDesigner.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.Presentation.PropertyEditing; using System.Activities.Presentation.View; using System.ComponentModel; using System.Windows; using System.Windows.Automation.Peers; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Media; partial class FlowSwitchDesigner { public static readonly DependencyProperty ExpressionButtonVisibilityProperty = DependencyProperty.Register("ExpressionButtonVisibility", typeof(Visibility), typeof(FlowSwitchDesigner)); public static readonly DependencyProperty ExpressionButtonColorProperty = DependencyProperty.Register("ExpressionButtonColor", typeof(Brush), typeof(FlowSwitchDesigner)); static readonly DependencyProperty ShowAllConditionsProperty = DependencyProperty.Register("ShowAllConditions", typeof(bool), typeof(FlowSwitchDesigner), new UIPropertyMetadata(new PropertyChangedCallback(OnShowAllConditionsChanged))); bool isPinned; bool expressionShown = false; public FlowSwitchDesigner() { InitializeComponent(); this.Loaded += (sender, e) => { //UnRegistering because of 137896: Inside tab control multiple Loaded events happen without an Unloaded event. this.ModelItem.PropertyChanged -= OnModelItemPropertyChanged; this.ModelItem.PropertyChanged += OnModelItemPropertyChanged; OnModelItemPropertyChanged(this.ModelItem, new PropertyChangedEventArgs("Expression")); SetupBinding(); }; this.Unloaded += (sender, e) => { this.ModelItem.PropertyChanged -= OnModelItemPropertyChanged; }; this.MouseEnter += (sender, e) => { Update(); }; this.MouseLeave += (sender, e) => { Update(); }; } void SetupBinding() { Binding showAllConditionsBinding = new Binding(); showAllConditionsBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(FlowchartDesigner), 1); showAllConditionsBinding.Path = new PropertyPath(FlowchartDesigner.ShowAllConditionsProperty); showAllConditionsBinding.Mode = BindingMode.OneWay; BindingOperations.SetBinding(this, FlowSwitchDesigner.ShowAllConditionsProperty, showAllConditionsBinding); } public Visibility ExpressionButtonVisibility { get { return (Visibility)GetValue(ExpressionButtonVisibilityProperty); } set { SetValue(ExpressionButtonVisibilityProperty, value); } } public Brush ExpressionButtonColor { get { return (Brush)GetValue(ExpressionButtonColorProperty); } set { SetValue(ExpressionButtonColorProperty, value); } } public bool ExpressionShown { get { return this.expressionShown; } } public static void RegisterMetadata(AttributeTableBuilder builder) { Type type = typeof(System.Activities.Statements.FlowSwitch<>); builder.AddCustomAttributes(type, new DesignerAttribute(typeof(FlowSwitchDesigner))); builder.AddCustomAttributes(type, type.GetProperty("Default"), BrowsableAttribute.No); builder.AddCustomAttributes(type, new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); Type flowSwitchLinkType = typeof(FlowSwitchLink<>); builder.AddCustomAttributes(flowSwitchLinkType, "Case", PropertyValueEditor.CreateEditorAttribute(typeof(FlowSwitchLinkCasePropertyEditor)), new EditorReuseAttribute(false)); } protected override AutomationPeer OnCreateAutomationPeer() { return new FlowchartExpressionAutomationPeer(this, base.OnCreateAutomationPeer()); } void OnExpressionButtonClicked(object sender, RoutedEventArgs e) { this.isPinned = !this.isPinned; } void OnModelItemPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Expression") { Update(); } } void Update() { Activity expressionActivity = this.ModelItem.Properties["Expression"].ComputedValue as Activity; string expressionString = ExpressionHelper.GetExpressionString(expressionActivity, this.ModelItem); bool expressionSpecified = !string.IsNullOrEmpty(expressionString); if (!expressionSpecified) { this.isPinned = false; } this.ExpressionButtonVisibility = expressionSpecified ? Visibility.Visible : Visibility.Collapsed; if (this.isPinned) { this.ExpressionButtonColor = WorkflowDesignerColors.FlowchartExpressionButtonPressedBrush; } else if (this.IsMouseOver) { this.ExpressionButtonColor = WorkflowDesignerColors.FlowchartExpressionButtonMouseOverBrush; } else { this.ExpressionButtonColor = WorkflowDesignerColors.FlowchartExpressionButtonBrush; } expressionShown = false; AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this); if (adornerLayer != null) { Adorner[] adorners = adornerLayer.GetAdorners(this); if (adorners != null) { foreach (Adorner adorner in adorners) { if (adorner is FlowchartExpressionAdorner) { adornerLayer.Remove(adorner); } } } if ((this.IsMouseOver && expressionSpecified) || this.isPinned) { expressionShown = true; adornerLayer.Add(new FlowchartExpressionAdorner(this)); } } } static void OnShowAllConditionsChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { if (e.NewValue != DependencyProperty.UnsetValue) { FlowSwitchDesigner designer = obj as FlowSwitchDesigner; designer.OnShowAllConditionsChanged((bool)e.NewValue); } } void OnShowAllConditionsChanged(bool isOpen) { this.isPinned = isOpen; Update(); } } } // 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
- XmlSchemaInfo.cs
- FixedSOMGroup.cs
- References.cs
- ContentOperations.cs
- TabletCollection.cs
- BoolExpressionVisitors.cs
- DesignOnlyAttribute.cs
- BufferedWebEventProvider.cs
- ValidatorCollection.cs
- Assembly.cs
- ProcessRequestArgs.cs
- HttpRequestCacheValidator.cs
- ToolStripMenuItem.cs
- RelatedView.cs
- SwitchElementsCollection.cs
- Events.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- FamilyTypefaceCollection.cs
- FtpCachePolicyElement.cs
- SecurityPermission.cs
- TypedTableHandler.cs
- Point3DAnimationBase.cs
- PeerObject.cs
- MarkupExtensionReturnTypeAttribute.cs
- MapPathBasedVirtualPathProvider.cs
- ItemsChangedEventArgs.cs
- LoadWorkflowAsyncResult.cs
- XmlEnumAttribute.cs
- AuthenticationModuleElementCollection.cs
- TemplateLookupAction.cs
- XslVisitor.cs
- EncryptedXml.cs
- CodeMethodReturnStatement.cs
- WinInet.cs
- UnionExpr.cs
- ControlUtil.cs
- CodeChecksumPragma.cs
- JsonReaderWriterFactory.cs
- BitmapEffectDrawingContextWalker.cs
- TemplateNameScope.cs
- DesignerInterfaces.cs
- Timeline.cs
- Effect.cs
- Empty.cs
- InternalConfigHost.cs
- ZoomPercentageConverter.cs
- PageFunction.cs
- BitmapEffectDrawingContent.cs
- CodeCompiler.cs
- TraceListener.cs
- FragmentQueryProcessor.cs
- DataGridViewIntLinkedList.cs
- XsdCachingReader.cs
- IgnorePropertiesAttribute.cs
- TextEncodedRawTextWriter.cs
- CodeCompiler.cs
- ColumnClickEvent.cs
- SubclassTypeValidator.cs
- PolicyImporterElement.cs
- BrushValueSerializer.cs
- MeasurementDCInfo.cs
- ColumnWidthChangingEvent.cs
- SamlSubject.cs
- ToggleButton.cs
- MetadataSource.cs
- ParameterModifier.cs
- KeyedCollection.cs
- XmlSchemaGroupRef.cs
- DbMetaDataColumnNames.cs
- RemotingException.cs
- AsyncOperationManager.cs
- WorkflowInstance.cs
- TreeNodeBindingCollection.cs
- ConnectionStringsExpressionBuilder.cs
- DashStyles.cs
- SafeNativeMethods.cs
- HeaderedItemsControl.cs
- XmlSerializationWriter.cs
- ExecutionContext.cs
- HyperLinkColumn.cs
- QueueException.cs
- ValueOfAction.cs
- ServiceModelConfigurationSection.cs
- SpnEndpointIdentityExtension.cs
- XPathArrayIterator.cs
- MetaForeignKeyColumn.cs
- NotImplementedException.cs
- PrintControllerWithStatusDialog.cs
- AnimationException.cs
- MembershipValidatePasswordEventArgs.cs
- SoapProcessingBehavior.cs
- TabControlAutomationPeer.cs
- StreamFormatter.cs
- RequestCachePolicyConverter.cs
- SetMemberBinder.cs
- MenuStrip.cs
- InputLangChangeRequestEvent.cs
- ClientTargetCollection.cs
- TcpSocketManager.cs
- Compilation.cs