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 is used in xaml.")]
16 class ConnectorPointsToArrowMarginConverter : IMultiValueConverter
18 [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", Justification = "The class is only used internally and not accessible externally.")]
19 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
22 Thickness margin = new Thickness(0);
23 PointCollection points = values[0] as PointCollection;
24 RotateTransform transform = values[1] as RotateTransform;
25 int offset = int.Parse(parameter.ToString(), CultureInfo.InvariantCulture);
26 if (points != null && points.Count > 0)
28 margin.Left = points[points.Count - 1].X - offset;
29 margin.Top = points[points.Count - 1].Y - offset;
31 if (transform != null)
33 switch ((int)transform.Angle)
36 margin.Left -= offset;
42 margin.Left += offset;
52 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
54 throw FxTrace.Exception.AsError(new NotSupportedException());