public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(DependencyProperty.UnsetValue); } BaseAngle b = value as BaseAngle; if (b is DegreeAngle) { return('d' + b.InternalValue.ToString("F2")); } else if (b is MilAngle) { return('m' + b.InternalValue.ToString("F0")); } else if (b is RadAngle) { return('r' + b.InternalValue.ToString()); } else { return('r' + b.RadiansValue.ToString()); } }
public Battery(string name, string callsign, Weapon bweapon, Coordinate coords, BaseAngle dir, string prefix, int start) { this.name = name; this.callsign = callsign; this.bWeapon = bweapon; this.coords = coords; this.dir = dir; this.prefix = prefix; this.start = start; // using initializer instead //this.observers = new ObservableCollection<KnownPoint>(); //this.knownpoints = new ObservableCollection<KnownPoint>(); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null) { return(DependencyProperty.UnsetValue); } string s = value as string; if (s == "") { return(DependencyProperty.UnsetValue); } BaseAngle val = null; val = DegreeAngle.TryParse(s); if (val == null) { val = RadAngle.TryParse(s); } if (val == null) { val = MilAngle.TryParse(s); } if (val == null) { double d; if (double.TryParse(s, NumberStyles.Float, NumberFormatInfo.InvariantInfo, out d)) { val = BaseAngle.Create <MilAngle>(double.Parse(s, NumberFormatInfo.InvariantInfo)); } } if (val == null) { return(DependencyProperty.UnsetValue); } else { return(val); } }