Microscopic Traffic Simulator
FromBoolToStar.cs
Go to the documentation of this file.
1 using System;
2 using System.Windows.Data;
3 
4 namespace Microscopic_Traffic_Simulator.Converters
5 {
9  class FromBoolToStar : IValueConverter
10  {
19  public object Convert(object value, Type targetType, object parameter,
20  System.Globalization.CultureInfo culture)
21  {
22  if ((bool)value)
23  return string.Empty;
24  else
25  return "*";
26  }
27 
36  public object ConvertBack(object value, Type targetType, object parameter,
37  System.Globalization.CultureInfo culture)
38  {
39  if ((string)value == string.Empty)
40  return true;
41  else if ((string)value == "*")
42  return false;
43  else
44  throw new ApplicationException(App.FindStringResource("UnexpectedErrorMessage"));
45  }
46  }
47 }
object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Convert bool status to string or string "*".
GUIInteractions logic for App.xaml
Definition: App.xaml.cs:17
object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
Convert empty string or string "*" to bool status.