Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Core.Presentation / System / Activities / Core / Presentation / FlowDecisionDesigner.xaml.cs / 1305376 / FlowDecisionDesigner.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.View; using System.Activities.Statements; 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 FlowDecisionDesigner { public static readonly DependencyProperty ExpressionButtonVisibilityProperty = DependencyProperty.Register("ExpressionButtonVisibility", typeof(Visibility), typeof(FlowDecisionDesigner)); public static readonly DependencyProperty ExpressionButtonColorProperty = DependencyProperty.Register("ExpressionButtonColor", typeof(Brush), typeof(FlowDecisionDesigner)); static readonly DependencyProperty ShowAllConditionsProperty = DependencyProperty.Register("ShowAllConditions", typeof(bool), typeof(FlowDecisionDesigner), new UIPropertyMetadata(new PropertyChangedCallback(OnShowAllConditionsChanged))); bool isPinned; bool expressionShown = false; public FlowDecisionDesigner() { 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("Condition")); 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, FlowDecisionDesigner.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(FlowDecision); builder.AddCustomAttributes(type, new DesignerAttribute(typeof(FlowDecisionDesigner))); builder.AddCustomAttributes(type, type.GetProperty("True"), BrowsableAttribute.No); builder.AddCustomAttributes(type, type.GetProperty("False"), BrowsableAttribute.No); builder.AddCustomAttributes(type, new ActivityDesignerOptionsAttribute { AllowDrillIn = false }); builder.AddCustomAttributes(type, new FeatureAttribute(typeof(FlowDecisionLabelFeature))); } protected override AutomationPeer OnCreateAutomationPeer() { return new FlowchartExpressionAutomationPeer(this, base.OnCreateAutomationPeer()); } void OnExpressionButtonClicked(object sender, RoutedEventArgs e) { this.isPinned = !this.isPinned; Update(); } void OnModelItemPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Condition") { Update(); } } void Update() { Activity expressionActivity = this.ModelItem.Properties["Condition"].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) { FlowDecisionDesigner designer = obj as FlowDecisionDesigner; 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
- OracleString.cs
- DiagnosticsConfiguration.cs
- MessageQueueEnumerator.cs
- LocalizabilityAttribute.cs
- ErrorFormatter.cs
- XmlSchemaSimpleTypeList.cs
- PropertyGridDesigner.cs
- IfJoinedCondition.cs
- ImageFormat.cs
- CmsUtils.cs
- TextFormatterHost.cs
- GridViewCellAutomationPeer.cs
- FlowDocumentFormatter.cs
- XmlSchemaAny.cs
- XPathAncestorIterator.cs
- StrongNameUtility.cs
- Point3DAnimation.cs
- HttpCacheVaryByContentEncodings.cs
- LZCodec.cs
- DataGridViewComboBoxCell.cs
- SimpleBitVector32.cs
- OdbcInfoMessageEvent.cs
- FacetEnabledSchemaElement.cs
- CommandTreeTypeHelper.cs
- ZipPackagePart.cs
- BrowserCapabilitiesFactoryBase.cs
- DesignerAttribute.cs
- WmlPanelAdapter.cs
- PasswordRecoveryDesigner.cs
- SchemaImporterExtension.cs
- TrackBar.cs
- MemberDomainMap.cs
- DetailsViewDeletedEventArgs.cs
- Inline.cs
- SqlPersistenceWorkflowInstanceDescription.cs
- ComponentResourceManager.cs
- Stack.cs
- WebResourceAttribute.cs
- ServiceDesigner.xaml.cs
- XmlSchemaSimpleTypeRestriction.cs
- LinearKeyFrames.cs
- Choices.cs
- DataControlExtensions.cs
- DataGridHeaderBorder.cs
- IndicFontClient.cs
- UriTemplatePathPartiallyEquivalentSet.cs
- ChannelSettingsElement.cs
- ServiceModelActivity.cs
- LinqMaximalSubtreeNominator.cs
- OdbcFactory.cs
- IListConverters.cs
- ResourceSet.cs
- BindingListCollectionView.cs
- EventHandlerList.cs
- AppearanceEditorPart.cs
- Model3D.cs
- EncoderExceptionFallback.cs
- PrePrepareMethodAttribute.cs
- RemoteWebConfigurationHostServer.cs
- BufferedGraphicsContext.cs
- WrappedKeySecurityTokenParameters.cs
- SafeNativeMethodsOther.cs
- ExtentKey.cs
- NamespaceImport.cs
- AudioFormatConverter.cs
- Interlocked.cs
- ListBindingHelper.cs
- DataGridViewBindingCompleteEventArgs.cs
- PartialCachingControl.cs
- AudienceUriMode.cs
- FixedSOMGroup.cs
- SplitterDesigner.cs
- ErasingStroke.cs
- RegexCompilationInfo.cs
- OpenTypeLayout.cs
- ComponentChangedEvent.cs
- DbConnectionInternal.cs
- DataGridViewImageCell.cs
- XPathNodeHelper.cs
- InheritanceContextHelper.cs
- ClassHandlersStore.cs
- StyleTypedPropertyAttribute.cs
- XmlObjectSerializerWriteContextComplex.cs
- WindowsEditBox.cs
- ProcessHostConfigUtils.cs
- AbstractDataSvcMapFileLoader.cs
- LambdaCompiler.cs
- SHA512.cs
- ProfileBuildProvider.cs
- ConcurrentQueue.cs
- GridItemPattern.cs
- DocumentCollection.cs
- ChannelFactoryBase.cs
- FileSystemWatcher.cs
- ComponentRenameEvent.cs
- ToolStripContentPanel.cs
- UnaryNode.cs
- ZoomingMessageFilter.cs
- Point.cs
- CompModHelpers.cs