1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //------------------------------------------------------------
6 namespace System.Activities.Presentation.FreeFormEditing
9 using System.Globalization;
11 using System.Windows.Data;
12 using System.Windows.Media;
13 using System.Diagnostics.CodeAnalysis;
15 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "The class in used in xaml.")]
16 class ConnectorLabelVisibilityConverter : IMultiValueConverter
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)
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)
27 int maxSegmentStartPoint;
28 if (DesignerGeometryHelper.LongestSegmentLength(connectorPoints, out maxSegmentStartPoint) > Connector.MinConnectorSegmentLengthForLabel)
30 connectorLabelVisibility = Visibility.Visible;
33 return connectorLabelVisibility;
36 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
38 throw FxTrace.Exception.AsError(new NotSupportedException());