private static void ShortNameChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TripPlanTransitIcon thisControl = d as TripPlanTransitIcon; if (e.NewValue != null) { thisControl.NameOrDistanceBlock.Text = (string)e.NewValue; } else { thisControl.NameOrDistanceBlock.Text = thisControl.Distance.ToString("N0") + "m"; } }
private static void HorizontalOffsetChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TripPlanTransitIcon thisControl = d as TripPlanTransitIcon; if (d == null) { return; } if (e.NewValue is double) { double newOffset = (double)e.NewValue; thisControl.NameOrDistanceBlock.RenderTransform = new TranslateTransform { X = newOffset }; thisControl.TransitModeIcon.RenderTransform = new TranslateTransform { X = newOffset }; } }
private static void DistanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TripPlanTransitIcon thisControl = d as TripPlanTransitIcon; if (!String.IsNullOrWhiteSpace(thisControl.ShortName)) { return; } else { if (e.NewValue != null) { float distance = (float)e.NewValue; thisControl.NameOrDistanceBlock.Text = distance.ToString("N0") + "m"; } else { thisControl.NameOrDistanceBlock.Text = "???"; } } }