[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / ShowExpandedMultiValueConverter.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation
6 {
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;
13     using System.Windows;
14     using System.Activities.Presentation.View;
15     using System.Runtime;
16
17     [SuppressMessage(FxCop.Category.Naming, FxCop.Rule.IdentifiersShouldBeSpelledCorrectly,
18         Justification = "Following the naming of IMultiValueConverter")]
19     internal sealed class ShowExpandedMultiValueConverter : IMultiValueConverter
20     {
21
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)
24         {
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];
32
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))
39             {
40                 viewElement.PinState = false;
41             }
42             if (viewElement.IsAncestorOfRootDesigner)
43             {
44                 return true;
45             }
46             return ViewUtilities.ShouldShowExpanded(isRootDesigner, viewElement.DoesParentAlwaysExpandChild(),
47                 viewElement.DoesParentAlwaysCollapseChildren(), expandState, shouldExpandAll, shouldCollapseAll, viewElement.PinState);
48         }
49
50         public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
51         {
52             throw FxTrace.Exception.AsError(new NotSupportedException());
53         }
54
55     }
56 }