예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            image.Source  = new BitmapImage(new Uri("/mapa.png", UriKind.Relative));
            image.Stretch = Stretch.Fill;

            LoadVehicles();
            UpdateVehicles();
            timer        = new SimpleTimer(TimeSpan.FromSeconds(1), (s, e) => LoadVehicles());
            SizeChanged += (s, e) => UpdateVehicles();
        }
예제 #2
0
 private void UpdateVehicles()
 {
     platno.Children.Clear();
     foreach (var vehicle in vehicles)
     {
         var e = new Vehicle(vehicle.IsTram() ? Brushes.Red : vehicle.IsBus() ? Brushes.Blue : Brushes.GreenYellow, vehicle.bearing);
         e.MouseDown += (s, arg) => {
             vehicle_caption.Visibility = Visibility.Visible;
             var vi = (from v in vehicles where v.vehicleId == vehicle.vehicleId select v).First();
             vehicle_caption.Content = "Číslo vozu: " + vi.vehicleId + " Linka: " + vi.route + " Cíl: " + vi.headsign + " Počet vozů: " + ((vi.consist ?? "").Count(c => c == '+') + 1);
             hider?.Stop();
             hider = new SimpleTimer(TimeSpan.FromSeconds(4), (es, earg) => { vehicle_caption.Visibility = Visibility.Hidden; hider.Stop(); });
         };
         Canvas.SetLeft(e, vehicle.RelativeX(west, east) * platno.Width);
         Canvas.SetTop(e, vehicle.RelativeY(north, south) * platno.Height);
         platno.Children.Add(e);
     }
 }