[corlib] Update ValueTuple implementation
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / FreeFormEditing / ConnectorLabelVisibilityConverter.cs
1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //------------------------------------------------------------
4
5
6 namespace System.Activities.Presentation.FreeFormEditing
7 {
8     using System;
9     using System.Globalization;
10     using System.Windows;
11     using System.Windows.Data;
12     using System.Windows.Media;
13     using System.Diagnostics.CodeAnalysis;
14
15     [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "The class in used in xaml.")]
16     class ConnectorLabelVisibilityConverter : IMultiValueConverter
17     {
18
19         [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "The class is only used internally and not accessible externally.")]
20         public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
21         {
22             Visibility connectorLabelVisibility = Visibility.Collapsed;
23             string labelText = values[0] as string;
24             PointCollection connectorPoints = values[1] as PointCollection;
25             if (!String.IsNullOrEmpty(labelText) && connectorPoints != null)
26             {
27                 int maxSegmentStartPoint;
28                 if (DesignerGeometryHelper.LongestSegmentLength(connectorPoints, out maxSegmentStartPoint) > Connector.MinConnectorSegmentLengthForLabel)
29                 {
30                     connectorLabelVisibility = Visibility.Visible;
31                 }
32             }
33             return connectorLabelVisibility;
34         }
35
36         public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
37         {
38             throw FxTrace.Exception.AsError(new NotSupportedException());
39         }
40
41     }
42 }