Beispiel #1
0
        private CameraView loadCameraView()
        {
            CameraView camItem = new CameraView();

            if (isShuffleOn || cameras.Count < 2)
            {
                camItem.Source.MaxHeight = ((Frame)Window.Current.Content).ActualHeight - 1;
            }
            else if (cameras.Count() < 4)
            {
                camItem.MaxWidth = ((Frame)Window.Current.Content).ActualWidth / cameras.Count - 1;
            }
            else
            {
                camItem.MaxWidth = ((Frame)Window.Current.Content).ActualWidth / 4 - 1;
            }
            grid.Children.Add(camItem);
            return(camItem);
        }
Beispiel #2
0
        public async void getImage(Camera camera, CameraView camView)
        {
            Image image = camView.Source;

            camView.Label.Text = camera.GetName();
            string     url       = "https://traffic.ottawa.ca/map/camera?id=" + camera.num;
            HttpClient outClient = new HttpClient();

            outClient.DefaultRequestHeaders.Add("Cookie", sessionId);

            byte[] img = await outClient.GetByteArrayAsync(url);

            InMemoryRandomAccessStream randomAccessStream = new InMemoryRandomAccessStream();
            DataWriter writer = new DataWriter(randomAccessStream.GetOutputStreamAt(0));

            writer.WriteBytes(img);
            await writer.StoreAsync();

            BitmapImage b = new BitmapImage();

            b.SetSource(randomAccessStream);

            image.Source = b;
            await Task.Delay(TimeSpan.FromMilliseconds(6000));

            if (isRunning)
            {
                if (isShuffleOn)
                {
                    camera = cameras[random.Next(0, cameras.Count)];
                }
                getImage(camera, camView);
            }
            else
            {
                Debug.WriteLine(url);
            }
        }