static void ViewImageInternal(string path) { string ext = Path.GetExtension(path); if (ImageUrl.ValidExtensions.Contains(ext)) { WindowsUtils.OpenAssociatedProgram(path); } else { FormMessage.Error("Image Download", "Invalid file extension " + ext, FormMessage.OK); } }
public static void OpenExternalBrowser(string url) { if (string.IsNullOrWhiteSpace(url)) { return; } switch (UrlUtils.Check(url)) { case UrlUtils.CheckResult.Fine: if (FormGuide.CheckGuideUrl(url, out string hash)) { FormGuide.Show(hash); } else { string browserPath = Config.BrowserPath; if (browserPath == null || !File.Exists(browserPath)) { WindowsUtils.OpenAssociatedProgram(url); } else { try{ using (Process.Start(browserPath, url)){} }catch (Exception e) { Program.Reporter.HandleException("Error Opening Browser", "Could not open the browser.", true, e); } } } break; case UrlUtils.CheckResult.Tracking: if (Config.IgnoreTrackingUrlWarning) { goto case UrlUtils.CheckResult.Fine; } using (FormMessage form = new FormMessage("Blocked URL", "TweetDuck has blocked a tracking url due to privacy concerns. Do you want to visit it anyway?\n" + url, MessageBoxIcon.Warning)){ form.AddButton(FormMessage.No, DialogResult.No, ControlType.Cancel | ControlType.Focused); form.AddButton(FormMessage.Yes, DialogResult.Yes, ControlType.Accept); form.AddButton("Always Visit", DialogResult.Ignore); DialogResult result = form.ShowDialog(); if (result == DialogResult.Ignore) { Config.IgnoreTrackingUrlWarning = true; Config.Save(); } if (result == DialogResult.Ignore || result == DialogResult.Yes) { goto case UrlUtils.CheckResult.Fine; } } break; case UrlUtils.CheckResult.Invalid: FormMessage.Warning("Blocked URL", "A potentially malicious URL was blocked from opening:\n" + url, FormMessage.OK); break; } }