[corlib] Avoid unnecessary ephemeron array resizes
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / FreeFormEditing / ConnectorStartDotConverter.cs
1 //------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //------------------------------------------------------------
4
5 namespace System.Activities.Presentation.FreeFormEditing
6 {
7     using System;
8     using System.Windows;
9     using System.Windows.Data;
10     using System.Diagnostics.CodeAnalysis;
11
12     [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "The class is used in xaml.")]
13     class ConnectorStartDotConverter : IValueConverter
14     {
15         const double Radius = 5.0;
16         const double RadiusForHitTest = 10.0;
17
18         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
19         {
20             Point point = (Point)value;
21             bool[] parameters = (bool[])parameter;
22             double radius = Radius;
23             if (parameters[1])
24             {
25                 radius = RadiusForHitTest;
26             }
27             if (parameters[0]) // left point
28             {
29                 return new Point((point.X - radius), point.Y);
30             }
31             else // right point
32             {
33                 return new Point((point.X + radius), point.Y);
34             }
35         }
36
37         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
38         {
39             throw FxTrace.Exception.AsError(new NotSupportedException());
40         }
41     }
42 }