public MainWindow()
 {
     InitializeComponent();
     this.KeyDown    += new KeyEventHandler(MainWindow_KeyDown);
     _model           = new StreetviewDownloaderModel();
     this.DataContext = _model;
 }
        private void DisplayThumbnails(string panoId, string cachePathBase)
        {
            StreetviewDownloaderModel _model = new StreetviewDownloaderModel
            {
                PanoID = panoId
            };

            // Clear previous items
            thumbnails.Children.Clear();

            //Set up downloader...
            Downloader.Downloader imageDownloader = new Downloader.Downloader(cachePathBase);

            System.Drawing.Image bigImage   = imageDownloader.GetFullImage(panoId, 2, null);
            panorama             panoObject = _model.DownloadPanoramaInfo(panoId);

            decimal panoYaw = panoObject.projection_properties.pano_yaw_deg;

            System.Drawing.Image smallImage = new System.Drawing.Bitmap(720, 360);
            using (Graphics g = Graphics.FromImage(smallImage)) {
                g.DrawImage(bigImage, 0, 0, smallImage.Width, smallImage.Height);
            }

            // Get all the thumbnails
            foreach (var annotation in panoObject.annotation_properties.OrderBy(item => item.yaw_deg))
            {
                var button   = new System.Windows.Controls.Button();
                var thumbImg = new System.Windows.Controls.Image();

                //headingDelta >= 2 || headingDelta <= -2
                System.Drawing.Image thumbnail = imageDownloader.ManipulateImage(smallImage, panoYaw, annotation.yaw_deg, 90);

                thumbImg.Source = ImageConverter(thumbnail);
                thumbImg.Width  = 180;

                button.Content = thumbImg;
                button.Click  += (object sender, RoutedEventArgs e) =>
                {
                    foreach (Button thumbButton in thumbnails.Children)
                    {
                        thumbButton.BorderThickness = new Thickness(1);
                        thumbButton.BorderBrush     = System.Windows.Media.Brushes.Gray;
                    }

                    button.BorderThickness = new Thickness(2);
                    button.BorderBrush     = System.Windows.Media.Brushes.Yellow;

                    DesiredHeading = annotation.yaw_deg;
                };
                thumbnails.Children.Add(button);
            }
        }