mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-23 20:34:07 +02:00
Prevent an unlikely crash when showing an error message in context menu
This commit is contained in:
parent
a3e9b15a8a
commit
3cb0f90706
@ -129,7 +129,7 @@ public virtual bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser br
|
|||||||
SetClipboardText(control, TwitterUtils.GetMediaLink(LastLink.GetMediaSource(parameters), ImageQuality));
|
SetClipboardText(control, TwitterUtils.GetMediaLink(LastLink.GetMediaSource(parameters), ImageQuality));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MenuViewImage:
|
case MenuViewImage: {
|
||||||
void ViewImage(string path){
|
void ViewImage(string path){
|
||||||
string ext = Path.GetExtension(path);
|
string ext = Path.GetExtension(path);
|
||||||
|
|
||||||
@ -144,37 +144,54 @@ void ViewImage(string path){
|
|||||||
string url = LastLink.GetMediaSource(parameters);
|
string url = LastLink.GetMediaSource(parameters);
|
||||||
string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url) ?? Path.GetRandomFileName());
|
string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url) ?? Path.GetRandomFileName());
|
||||||
|
|
||||||
if (File.Exists(file)){
|
control.InvokeAsyncSafe(() => {
|
||||||
ViewImage(file);
|
if (File.Exists(file)){
|
||||||
}
|
|
||||||
else{
|
|
||||||
control.InvokeAsyncSafe(analytics.AnalyticsFile.ViewedImages.Trigger);
|
|
||||||
|
|
||||||
BrowserUtils.DownloadFileAsync(TwitterUtils.GetMediaLink(url, ImageQuality), file, () => {
|
|
||||||
ViewImage(file);
|
ViewImage(file);
|
||||||
}, ex => {
|
}
|
||||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
else{
|
||||||
});
|
analytics.AnalyticsFile.ViewedImages.Trigger();
|
||||||
}
|
|
||||||
|
BrowserUtils.DownloadFileAsync(TwitterUtils.GetMediaLink(url, ImageQuality), file, () => {
|
||||||
|
ViewImage(file);
|
||||||
|
}, ex => {
|
||||||
|
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MenuSaveMedia: {
|
||||||
|
bool isVideo = LastLink.IsVideo;
|
||||||
|
string url = LastLink.GetMediaSource(parameters);
|
||||||
|
string username = LastChirp.Authors.LastOrDefault();
|
||||||
|
|
||||||
|
control.InvokeAsyncSafe(() => {
|
||||||
|
if (isVideo){
|
||||||
|
TwitterUtils.DownloadVideo(url, username);
|
||||||
|
analytics.AnalyticsFile.DownloadedVideos.Trigger();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
TwitterUtils.DownloadImage(url, username, ImageQuality);
|
||||||
|
analytics.AnalyticsFile.DownloadedImages.Trigger();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MenuSaveMedia:
|
case MenuSaveTweetImages: {
|
||||||
if (LastLink.IsVideo){
|
string[] urls = LastChirp.Images;
|
||||||
control.InvokeAsyncSafe(analytics.AnalyticsFile.DownloadedVideos.Trigger);
|
string username = LastChirp.Authors.LastOrDefault();
|
||||||
TwitterUtils.DownloadVideo(LastLink.GetMediaSource(parameters), LastChirp.Authors.LastOrDefault());
|
|
||||||
}
|
control.InvokeAsyncSafe(() => {
|
||||||
else{
|
TwitterUtils.DownloadImages(urls, username, ImageQuality);
|
||||||
control.InvokeAsyncSafe(analytics.AnalyticsFile.DownloadedImages.Trigger);
|
analytics.AnalyticsFile.DownloadedImages.Trigger();
|
||||||
TwitterUtils.DownloadImage(LastLink.GetMediaSource(parameters), LastChirp.Authors.LastOrDefault(), ImageQuality);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case MenuSaveTweetImages:
|
|
||||||
control.InvokeAsyncSafe(analytics.AnalyticsFile.DownloadedImages.Trigger);
|
|
||||||
TwitterUtils.DownloadImages(LastChirp.Images, LastChirp.Authors.LastOrDefault(), ImageQuality);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MenuReadApplyROT13:
|
case MenuReadApplyROT13:
|
||||||
string selection = parameters.SelectionText;
|
string selection = parameters.SelectionText;
|
||||||
|
Loading…
Reference in New Issue
Block a user