public static void DownloadThumbnail(this IBeatmapItem bmItem, BeatmapItemExtensionHelper hmExHelp)
        {
            hmExHelp.Target.Source = new BitmapImage(new Uri("../Resources/ProgressThumbnail.png", UriKind.Relative));
            Directory.CreateDirectory(GlobalVar.appTempPath + "/Cache/Thumbnails".Replace('/', Path.DirectorySeparatorChar));
            hmExHelp.Host.UI_SetStatus(GlobalVar._e("MainWindow_downloadingThumbnail").Replace("%0", Convert.ToString(bmItem.Beatmap.Id)), true);
            WebClient thumbClient = new WebClient();

            thumbClient.DownloadFileCompleted += hmExHelp.WebClient_DownloadThumbnailCompleted;
            thumbClient.DownloadFileAsync(new Uri("https://b.ppy.sh/thumb/" + bmItem.Beatmap.Id + ".jpg"), GlobalVar.appTempPath + "/Cache/Thumbnails/".Replace('/', Path.DirectorySeparatorChar) + bmItem.Beatmap.Id + ".jpg");
        }
        public static bool LoadThumbnail(this IBeatmapItem bmItem, Image target, MainWindow host, bool enableBmdp = true, bool enableThumbDownload = true)
        {
            if (!string.IsNullOrEmpty(bmItem.Beatmap.ThumbnailPath))
            {
                try {
                    target.Source = new BitmapImage(new Uri(bmItem.Beatmap.ThumbnailPath));

                    if (enableBmdp)
                    {
                        target.ToolTip    = GlobalVar._e("MainWindow_openBeatmapDetailPanel");
                        target.MouseDown += host.BmDP_Show;
                    }
                    return(true);
                } catch (NotSupportedException) {
                }
            }

            // If successfull, already returned at this point
            if (enableThumbDownload)
            {
                target.Source  = new BitmapImage(new Uri("../../Resources/DownloadThumbnail.png", UriKind.Relative));
                target.ToolTip = GlobalVar._e("MainWindow_downladThumbnail");

                var bmExHelp = new BeatmapItemExtensionHelper(bmItem, target, host);
                target.MouseLeftButtonUp  += bmExHelp.EventHandler_DownloadThumb;
                target.MouseRightButtonUp += host.BmDP_Show;
            }
            else
            {
                target.Source = new BitmapImage(new Uri("../../Resources/NoThumbnail.png", UriKind.Relative));

                if (enableBmdp)
                {
                    target.ToolTip    = GlobalVar._e("MainWindow_openBeatmapDetailPanel");
                    target.MouseDown += host.BmDP_Show;
                }
            }
            return(false);
        }
 public BeatmapItemExtensionHelper(IBeatmapItem bmItem, Image target, MainWindow host)
 {
     BmItem = bmItem;
     Target = target;
     Host   = host;
 }