comparison MetroWpf/MetroWpf.Xaml/Converters/RotationAngleToSimplePositiveAngleConverter.cs @ 15:060f02cd4591

Initial commit, pre airport work
author stevenh7776 stevenhollidge@hotmail.com
date Mon, 12 Mar 2012 23:05:21 +0800
parents
children
comparison
equal deleted inserted replaced
14:741981715d94 15:060f02cd4591
1 //-----------------------------------------------------------------------
2 // <copyright file="RotationAngleToSimplePositiveAngleConverter.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 // <summary>
6 // IValueConverter to convert an angle, in degrees, to a 'simple' angle.
7 // </summary>
8 //-----------------------------------------------------------------------
9
10 namespace MetroWpf.Xaml.Converters
11 {
12 using System;
13 using System.Windows.Data;
14
15 /// <summary>
16 /// IValueConverter to convert an angle, in degrees, to a 'simple' angle, that is, an angle which lies between 0 and 360 degrees.
17 /// </summary>
18 public class RotationAngleToSimplePositiveAngleConverter : IValueConverter
19 {
20 /// <summary>
21 /// Converts an angle, in degrees, to a 'simple' angle, that is, an angle which lies between 0 and 360 degrees.
22 /// </summary>
23 /// <param name="value">The original angle, in degrees.</param>
24 /// <param name="targetType">The target type of the conversion.</param>
25 /// <param name="parameter">The converter parameter.</param>
26 /// <param name="culture">The application culture.</param>
27 /// <returns>An angle between 0 and 360 degrees.</returns>
28 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
29 {
30 object convertedValue = null;
31 try
32 {
33 double angle = System.Convert.ToDouble(value, culture);
34 angle = angle % 360;
35 if (angle < 0)
36 {
37 angle += 360.0;
38 }
39
40 convertedValue = angle;
41 }
42 catch (InvalidCastException)
43 {
44 //ClientManager.ServiceProvider.Logger.Warning(e.Message);
45 }
46
47 return convertedValue;
48 }
49
50 /// <summary>
51 /// Converts back to the original angle. Not implemented.
52 /// </summary>
53 /// <param name="value">The simple angle, in degrees.</param>
54 /// <param name="targetType">The target type of the conversion.</param>
55 /// <param name="parameter">The converter parameter.</param>
56 /// <param name="culture">The application culture.</param>
57 /// <returns>An angle in degrees.</returns>
58 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
59 {
60 throw new NotImplementedException();
61 }
62 }
63 }