private void OnSourceFoundResult(object sender, NotifyCollectionChangedEventArgs e) { if (mSearchResult != null) { System.Diagnostics.Debug.Fail("Search result already obtained"); return; } System.Diagnostics.Debug.Assert(e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Reset, //The collection will be initialised once, with Reset called. "Only expecting results to be added to the found results collection"); if (e.Action == NotifyCollectionChangedAction.Add) { System.Diagnostics.Debug.Assert(e.NewItems.Count == 1, "Expecting results to be added one at a time"); AlbumArt result = (AlbumArt)e.NewItems[0]; //Check if the result meets the required criteria var coverType = Common.MakeAllowedCoverType(result.CoverType); if ((coverType & Properties.Settings.Default.AllowedCoverTypes) == coverType) { //Album is of a type that's allowed //Both width and height must be bigger, so use the smallest of the two int size = (int)Math.Min(result.ImageWidth, result.ImageHeight); if (size == -1 || CheckImageSize(size)) //If the size is unspecified, or the specified size is within range { //Then download the full size image, and check it's size when done. //Have the source wait until the full size image is downloaded mWaitForFullSizeImage.Reset(); result.RetrieveFullSizeImage(OnResultImageDownloaded); } } } }
private void PreviewExec(object sender, ExecutedRoutedEventArgs e) { AlbumArt albumArt = mResultsViewer.GetSourceAlbumArt(e); if (albumArt != null) { albumArt.RetrieveFullSizeImage(); //Show persistant preview window var previewWindow = Common.NewPreviewWindow(this); previewWindow.AlbumArt = albumArt; //Bind to the presets context menu BindingOperations.SetBinding(previewWindow, ArtPreviewWindow.PresetsContextMenuProperty, new Binding() { Source = this, Path = new PropertyPath(PresetsContextMenuProperty), Mode = BindingMode.OneWay }); } }