source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/InverseBooleanConverter.cs@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 2.6 KB
Line 
1// -----------------------------------------------------------------------
2// <copyright file="InverseBooleanConverter.cs" company="Microsoft">
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// </copyright>
5// -----------------------------------------------------------------------
6
7namespace Microsoft.Samples.Kinect.WebserverBasics
8{
9 using System;
10 using System.Windows.Data;
11
12 /// <summary>
13 /// Converts a boolean value to its inverse.
14 /// </summary>
15 [ValueConversion(typeof(bool), typeof(bool))]
16 public class InverseBooleanConverter : IValueConverter
17 {
18 #region IValueConverter Members
19
20 /// <summary>
21 /// Converts a value.
22 /// </summary>
23 /// <param name="value">
24 /// The value produced by the binding source.
25 /// </param>
26 /// <param name="targetType">
27 /// The type of the binding target property.
28 /// </param>
29 /// <param name="parameter">
30 /// The converter parameter to use.
31 /// </param>
32 /// <param name="culture">
33 /// The culture to use in the converter.
34 /// </param>
35 /// <returns>
36 /// A converted value. If the method returns null, the valid null value is used.
37 /// </returns>
38 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
39 {
40 if (targetType != typeof(bool))
41 {
42 throw new InvalidOperationException("The target must be a boolean");
43 }
44
45 return !(bool)value;
46 }
47
48 /// <summary>
49 /// Converts a value.
50 /// </summary>
51 /// <param name="value">
52 /// The value that is produced by the binding target.
53 /// </param>
54 /// <param name="targetType">
55 /// The type to convert to.
56 /// </param>
57 /// <param name="parameter">
58 /// The converter parameter to use.
59 /// </param>
60 /// <param name="culture">
61 /// The culture to use in the converter.
62 /// </param>
63 /// <returns>
64 /// A converted value. If the method returns null, the valid null value is used.
65 /// </returns>
66 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
67 {
68 if (targetType != typeof(bool))
69 {
70 throw new InvalidOperationException("The target must be a boolean");
71 }
72
73 return !(bool)value;
74 }
75
76 #endregion
77 }
78}
Note: See TracBrowser for help on using the repository browser.