1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation
7 using System.Diagnostics;
8 using System.Diagnostics.CodeAnalysis;
9 using System.Globalization;
10 using System.Windows.Data;
11 using System.Activities.Presentation.Model;
12 using System.Activities.Presentation.Internal.PropertyEditing.Model;
14 using System.Activities.Presentation.View;
17 [SuppressMessage(FxCop.Category.Naming, FxCop.Rule.IdentifiersShouldBeSpelledCorrectly,
18 Justification = "Following the naming of IMultiValueConverter")]
19 internal sealed class ShowExpandedMultiValueConverter : IMultiValueConverter
22 //Calculates whether ShowExpanded for a given WorklfowViewElement should be true or false.
23 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
25 ModelItem modelItem = (ModelItem)values[0];
26 bool isRootDesigner = (bool)values[1];
27 bool shouldExpandAll = (bool)values[2];
28 bool shouldCollapseAll = (bool)values[3];
29 bool expandState = (bool)values[4];
30 bool pinState = (bool)values[5];
31 WorkflowViewElement viewElement = (WorkflowViewElement)values[6];
33 //Pinstate should be false in following cases (Designer should be unpinned in following cases):
34 //1. ExpandAll is not enabled.
35 //2. ExpandAll is enabled and ExpandState is true.
36 //Similarly for Collapse All.
37 if ((!shouldExpandAll || expandState)
38 && (!shouldCollapseAll || !expandState))
40 viewElement.PinState = false;
42 if (viewElement.IsAncestorOfRootDesigner)
46 return ViewUtilities.ShouldShowExpanded(isRootDesigner, viewElement.DoesParentAlwaysExpandChild(),
47 viewElement.DoesParentAlwaysCollapseChildren(), expandState, shouldExpandAll, shouldCollapseAll, viewElement.PinState);
50 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
52 throw FxTrace.Exception.AsError(new NotSupportedException());