void pictureSearchPopup_PictureSelected(object sender, EventArgs e)
        {
            PictureSearchUserControl psp = sender as PictureSearchUserControl;

            BitmapImage bi = psp.DownloadSelectedImage();

            if (bi != null)
            {
                string filename = GetCoverFilename();

                FileStream        stream  = new FileStream(filename, FileMode.Create);
                JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                encoder.QualityLevel = 30;
                encoder.Frames.Add(BitmapFrame.Create(bi));
                encoder.Save(stream);
                stream.Close();

                SetNewCoverFilename(filename);

                PictureSearchPopup popup = psp.Parent as PictureSearchPopup;
                if (popup != null)
                {
                    popup.IsOpen = false;
                }
            }
        }
        private void SearchImage()
        {
            PictureSearchPopup pictureSearchPopup = new PictureSearchPopup();

            pictureSearchPopup.PopupAnimation = System.Windows.Controls.Primitives.PopupAnimation.Fade;
            pictureSearchPopup.IsOpen         = true;
            pictureSearchPopup.Placement      = System.Windows.Controls.Primitives.PlacementMode.Bottom;

            Button searchPictureButton = VisualTreeExtensions.FindVisualChildByName <Button>(this, "SearchPictureButton");

            if (searchPictureButton != null)
            {
                pictureSearchPopup.PlacementTarget = searchPictureButton;
            }
            else
            {
                pictureSearchPopup.PlacementTarget = this;
            }
            pictureSearchPopup.Width            = 640;
            pictureSearchPopup.Height           = 200;
            pictureSearchPopup.StaysOpen        = false;
            pictureSearchPopup.PictureSelected += new EventHandler(pictureSearchPopup_PictureSelected);

            string searchText = GetSearchText();

            pictureSearchPopup.Search(searchText);
        }
        private void SearchImage()
        {
            PictureSearchPopup pictureSearchPopup = new PictureSearchPopup();

            pictureSearchPopup.PopupAnimation   = System.Windows.Controls.Primitives.PopupAnimation.Fade;
            pictureSearchPopup.IsOpen           = true;
            pictureSearchPopup.Placement        = System.Windows.Controls.Primitives.PlacementMode.Bottom;
            pictureSearchPopup.PlacementTarget  = this;
            pictureSearchPopup.Width            = 640;
            pictureSearchPopup.Height           = 200;
            pictureSearchPopup.StaysOpen        = false;
            pictureSearchPopup.PictureSelected += new EventHandler(pictureSearchPopup_PictureSelected);

            string searchText = GetSearchText();

            pictureSearchPopup.Search(searchText);
        }