[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / FreeFormEditing / ConnectorPointsToArrowMarginConverter.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 is used in xaml.")]
16     class ConnectorPointsToArrowMarginConverter : IMultiValueConverter
17     {
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)
20         {
21
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)
27             {
28                 margin.Left = points[points.Count - 1].X - offset;
29                 margin.Top = points[points.Count - 1].Y - offset;
30             }
31             if (transform != null)
32             {
33                 switch ((int)transform.Angle)
34                 {
35                     case 0:
36                         margin.Left -= offset;
37                         break;
38                     case 90:
39                         margin.Top -= offset;
40                         break;
41                     case 180:
42                         margin.Left += offset;
43                         break;
44                     case 270:
45                         margin.Top += offset;
46                         break;
47                 }
48             }
49             return margin;
50         }
51
52         public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
53         {
54             throw FxTrace.Exception.AsError(new NotSupportedException());
55         }
56     }
57 }