/// <summary> /// Takes the current image URL and saves the corresponding Image into a folder called Imgurandom in your Pictures. /// </summary> /// <param name="_s">Unused. Merely here to fulfill delegate parameters.</param> /// <param name="_e">Unused. Merely here to fulfill delegate parameters.</param> public void SaveImage(object _s, object _e) { string p = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Imgurandom"); Directory.CreateDirectory(p); // Wont do anything if already exists. string filename = CurrentImageURL.Replace("https://i.imgur.com/", "").Replace(".png", "").Replace("gifv", ""); p = Path.Combine(p, filename + ".png"); try { using (WebClient wc = new WebClient()) { wc.DownloadFile(CurrentImageURL, p); MessageBox.Show("Download complete. It will be in MyPictures/Imgurandom", "That image", MessageBoxButton.OK, MessageBoxImage.Information); } } catch { MessageBox.Show("Something went wrong. Are you running this program in admin mode?", "That image", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Takes the current image URL and opens it as a gifv in your browser, since this does not support GIFV /// </summary> /// <param name="_s">Unused. Merely here to fulfill delegate parameters.</param> /// <param name="_e">Unused. Merely here to fulfill delegate parameters.</param> public void OpenAsGif(object _s, object _e) { System.Diagnostics.Process.Start(CurrentImageURL.Replace(".png", ".gifv")); }