mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Small changes reducing code, and to make the export window a bit nicer.
This commit is contained in:
parent
586082fe71
commit
4fae9d3d89
33 changed files with 198 additions and 217 deletions
|
@ -56,7 +56,8 @@ namespace Greenshot.Addon.Box
|
|||
public class BoxDestination : AbstractDestination
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly IBoxConfiguration _boxConfiguration;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly IBoxConfiguration _boxConfiguration;
|
||||
private readonly IBoxLanguage _boxLanguage;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
private readonly INetworkConfiguration _networkConfiguration;
|
||||
|
@ -73,8 +74,9 @@ namespace Greenshot.Addon.Box
|
|||
IBoxLanguage boxLanguage,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory,
|
||||
INetworkConfiguration networkConfiguration,
|
||||
IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
{
|
||||
IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_boxConfiguration = boxConfiguration;
|
||||
_boxLanguage = boxLanguage;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
|
@ -125,7 +127,7 @@ namespace Greenshot.Addon.Box
|
|||
exportInformation.ExportMade = true;
|
||||
exportInformation.Uri = uploadUrl;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Greenshot.Addon.Confluence
|
|||
IConfluenceConfiguration confluenceConfiguration,
|
||||
IConfluenceLanguage confluenceLanguage,
|
||||
Func<Owned<PleaseWaitForm>> pleaseWaitFormFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_confluenceConfiguration = confluenceConfiguration;
|
||||
|
@ -180,8 +180,8 @@ namespace Greenshot.Addon.Confluence
|
|||
exportInformation.ErrorMessage = errorMessage;
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
private bool Upload(ISurface surfaceToUpload, Content page, string filename, out string errorMessage)
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace Greenshot.Addon.Dropbox
|
|||
private readonly IDropboxConfiguration _dropboxPluginConfiguration;
|
||||
private readonly IDropboxLanguage _dropboxLanguage;
|
||||
private readonly IResourceProvider _resourceProvider;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
private OAuth2Settings _oAuth2Settings;
|
||||
private IHttpBehaviour _oAuthHttpBehaviour;
|
||||
|
@ -76,11 +77,12 @@ namespace Greenshot.Addon.Dropbox
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_dropboxPluginConfiguration = dropboxPluginConfiguration;
|
||||
_dropboxLanguage = dropboxLanguage;
|
||||
_resourceProvider = resourceProvider;
|
||||
_exportNotification = exportNotification;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
|
||||
_oAuth2Settings = new OAuth2Settings
|
||||
|
@ -140,7 +142,7 @@ namespace Greenshot.Addon.Dropbox
|
|||
}
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,17 +50,19 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
|
||||
private readonly ExternalCommandDefinition _externalCommandDefinition;
|
||||
private readonly IExternalCommandConfiguration _externalCommandConfiguration;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
|
||||
public ExternalCommandDestination(ExternalCommandDefinition defintion,
|
||||
IExternalCommandConfiguration externalCommandConfiguration,
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
{
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_externalCommandDefinition = defintion;
|
||||
_externalCommandConfiguration = externalCommandConfiguration;
|
||||
}
|
||||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Designation => "External " + _externalCommandDefinition.Name.Replace(',', '_');
|
||||
|
@ -108,8 +110,8 @@ namespace Greenshot.Addon.ExternalCommand
|
|||
}
|
||||
}
|
||||
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,6 +64,7 @@ namespace Greenshot.Addon.Flickr
|
|||
private readonly IFlickrConfiguration _flickrConfiguration;
|
||||
private readonly IFlickrLanguage _flickrLanguage;
|
||||
private readonly IResourceProvider _resourceProvider;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
private readonly OAuth1Settings _oAuthSettings;
|
||||
private readonly OAuth1HttpBehaviour _oAuthHttpBehaviour;
|
||||
|
@ -88,11 +89,12 @@ namespace Greenshot.Addon.Flickr
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_flickrConfiguration = flickrConfiguration;
|
||||
_flickrLanguage = flickrLanguage;
|
||||
_resourceProvider = resourceProvider;
|
||||
_exportNotification = exportNotification;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
|
||||
_oAuthSettings = new OAuth1Settings
|
||||
|
@ -147,8 +149,8 @@ namespace Greenshot.Addon.Flickr
|
|||
ExportMade = flickrUri != null,
|
||||
Uri = flickrUri
|
||||
};
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ namespace Greenshot.Addon.GooglePhotos
|
|||
private readonly IGooglePhotosLanguage _googlePhotosLanguage;
|
||||
private readonly INetworkConfiguration _networkConfiguration;
|
||||
private readonly IResourceProvider _resourceProvider;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
private readonly OAuth2Settings _oAuth2Settings;
|
||||
|
||||
|
@ -71,12 +72,13 @@ namespace Greenshot.Addon.GooglePhotos
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_googlePhotosConfiguration = googlePhotosConfiguration;
|
||||
_googlePhotosLanguage = googlePhotosLanguage;
|
||||
_networkConfiguration = networkConfiguration;
|
||||
_resourceProvider = resourceProvider;
|
||||
_exportNotification = exportNotification;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
|
||||
_oAuth2Settings = new OAuth2Settings
|
||||
|
@ -123,8 +125,8 @@ namespace Greenshot.Addon.GooglePhotos
|
|||
exportInformation.ExportMade = true;
|
||||
exportInformation.Uri = uploadUrl;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
private async Task<string> Upload(ISurface surfaceToUpload)
|
||||
|
|
|
@ -54,7 +54,8 @@ namespace Greenshot.Addon.Imgur
|
|||
public class ImgurDestination : AbstractDestination
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly IImgurConfiguration _imgurConfiguration;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly IImgurConfiguration _imgurConfiguration;
|
||||
private readonly IImgurLanguage _imgurLanguage;
|
||||
private readonly ImgurApi _imgurApi;
|
||||
private readonly ImgurHistoryViewModel _imgurHistoryViewModel;
|
||||
|
@ -70,9 +71,10 @@ namespace Greenshot.Addon.Imgur
|
|||
ImgurApi imgurApi,
|
||||
ImgurHistoryViewModel imgurHistoryViewModel,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory,
|
||||
IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
{
|
||||
_imgurConfiguration = imgurConfiguration;
|
||||
IResourceProvider resourceProvider) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_imgurConfiguration = imgurConfiguration;
|
||||
_imgurLanguage = imgurLanguage;
|
||||
_imgurApi = imgurApi;
|
||||
_imgurHistoryViewModel = imgurHistoryViewModel;
|
||||
|
@ -103,8 +105,8 @@ namespace Greenshot.Addon.Imgur
|
|||
ExportMade = uploadUrl != null,
|
||||
Uri = uploadUrl?.AbsoluteUri
|
||||
};
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Greenshot.Addon.Jira
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_jiraConfiguration = jiraConfiguration;
|
||||
_jiraLanguage = jiraLanguage;
|
||||
|
@ -239,8 +239,8 @@ namespace Greenshot.Addon.Jira
|
|||
}
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ namespace Greenshot.Addon.LegacyEditor
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
EditorFactory editorFactory,
|
||||
IEditorLanguage editorLanguage) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
IEditorLanguage editorLanguage) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_editorFactory = editorFactory;
|
||||
|
@ -130,9 +130,9 @@ namespace Greenshot.Addon.LegacyEditor
|
|||
exportInformation.ExportMade = true;
|
||||
}
|
||||
|
||||
ProcessExport(exportInformation, surface);
|
||||
// Workaround for the modified flag when using the editor.
|
||||
surface.Modified = modified;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
// Workaround for the modified flag when using the editor.
|
||||
surface.Modified = modified;
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Greenshot.Addon.Lutim {
|
|||
private readonly ILutimLanguage _lutimLanguage;
|
||||
private readonly LutimApi _lutimApi;
|
||||
private readonly IResourceProvider _resourceProvider;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
|
||||
public LutimDestination(ILutimConfiguration lutimConfiguration,
|
||||
|
@ -59,12 +60,13 @@ namespace Greenshot.Addon.Lutim {
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_lutimConfiguration = lutimConfiguration;
|
||||
_lutimLanguage = lutimLanguage;
|
||||
_lutimApi = lutimApi;
|
||||
_resourceProvider = resourceProvider;
|
||||
_exportNotification = exportNotification;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
}
|
||||
|
||||
|
@ -89,8 +91,8 @@ namespace Greenshot.Addon.Lutim {
|
|||
ExportMade = uploadUrl != null,
|
||||
Uri = uploadUrl
|
||||
};
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,8 +59,8 @@ namespace Greenshot.Addon.OCR
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
{
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_ocrConfiguration = ocrConfiguration;
|
||||
|
||||
var ocrDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_exePath = PluginUtils.GetExePath("EXCEL.EXE");
|
||||
|
@ -111,9 +111,9 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ExcelExporter.InsertIntoNewWorkbook(imageFile, surface.Screenshot.Size);
|
||||
}
|
||||
exportInformation.ExportMade = true;
|
||||
ProcessExport(exportInformation, surface);
|
||||
// Cleanup imageFile if we created it here, so less tmp-files are generated and left
|
||||
if (createdFile)
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
// Cleanup imageFile if we created it here, so less tmp-files are generated and left
|
||||
if (createdFile)
|
||||
{
|
||||
ImageOutput.DeleteNamedTmpFile(imageFile);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_officeConfiguration = officeConfiguration;
|
||||
_exportNotification = exportNotification;
|
||||
|
@ -198,8 +198,8 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
_officeConfiguration.EmailBCC, null);
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_exePath = PluginUtils.GetExePath("POWERPNT.EXE");
|
||||
|
@ -144,8 +144,8 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
exportInformation.ExportMade = PowerpointExporter.InsertIntoNewPresentation(tmpFile, imageSize, captureDetails.Title);
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,7 +58,7 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
_exePath = PluginUtils.GetExePath("WINWORD.EXE");
|
||||
|
@ -162,8 +162,8 @@ namespace Greenshot.Addon.Office.Destinations
|
|||
}
|
||||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,6 +63,7 @@ namespace Greenshot.Addon.OneDrive
|
|||
private readonly IOneDriveLanguage _oneDriveLanguage;
|
||||
private readonly IResourceProvider _resourceProvider;
|
||||
private readonly Func<CancellationTokenSource, Owned<PleaseWaitForm>> _pleaseWaitFormFactory;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly OAuth2Settings _oauth2Settings;
|
||||
private static readonly Uri GraphUri = new Uri("https://graph.microsoft.com");
|
||||
private static readonly Uri OneDriveUri = GraphUri.AppendSegments("v1.0", "me", "drive");
|
||||
|
@ -79,12 +80,13 @@ namespace Greenshot.Addon.OneDrive
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_oneDriveConfiguration = oneDriveConfiguration;
|
||||
_oneDriveLanguage = oneDriveLanguage;
|
||||
_resourceProvider = resourceProvider;
|
||||
_pleaseWaitFormFactory = pleaseWaitFormFactory;
|
||||
_exportNotification = exportNotification;
|
||||
// Configure the OAuth2 settings for OneDrive communication
|
||||
_oauth2Settings = new OAuth2Settings
|
||||
{
|
||||
|
@ -136,7 +138,7 @@ namespace Greenshot.Addon.OneDrive
|
|||
ExportMade = uploadUrl != null,
|
||||
Uri = uploadUrl?.AbsoluteUri
|
||||
};
|
||||
ProcessExport(exportInformation, surface);
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
@ -239,9 +241,11 @@ namespace Greenshot.Addon.OneDrive
|
|||
var localBehaviour = _oneDriveHttpBehaviour.ShallowClone();
|
||||
var oauthHttpBehaviour = OAuth2HttpBehaviourFactory.Create(oAuth2Settings, localBehaviour);
|
||||
oauthHttpBehaviour.MakeCurrent();
|
||||
var body = new OneDriveGetLinkRequest();
|
||||
body.Scope = oneDriveLinkType == OneDriveLinkType.@public ? "anonymous" : "organization";
|
||||
body.Type = "view";
|
||||
var body = new OneDriveGetLinkRequest
|
||||
{
|
||||
Scope = oneDriveLinkType == OneDriveLinkType.@public ? "anonymous" : "organization",
|
||||
Type = "view"
|
||||
};
|
||||
return await sharableLink.PostAsync<OneDriveGetLinkResponse>(body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace Greenshot.Addon.Photobucket
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_photobucketConfiguration = photobucketConfiguration;
|
||||
_photobucketLanguage = photobucketLanguage;
|
||||
|
@ -230,8 +230,8 @@ namespace Greenshot.Addon.Photobucket
|
|||
exportInformation.ExportMade = true;
|
||||
exportInformation.Uri = uploaded.Original;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace Greenshot.Addon.Tfs
|
|||
TfsClient tfsClient,
|
||||
Func<CancellationTokenSource, Owned<PleaseWaitForm>> pleaseWaitFormFactory,
|
||||
IResourceProvider resourceProvider,
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_tfsConfiguration = tfsConfiguration;
|
||||
_tfsLanguage = tfsLanguage;
|
||||
|
@ -165,7 +165,7 @@ namespace Greenshot.Addon.Tfs
|
|||
ExportMade = uploadUrl != null,
|
||||
Uri = uploadUrl?.AbsoluteUri
|
||||
};
|
||||
ProcessExport(exportInformation, surface);
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,12 @@ namespace Greenshot.Addons.Components
|
|||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly ICoreConfiguration _coreConfiguration;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Func<IDestination, ExportInformation, Owned<ExportNotificationViewModel>> _toastFactory;
|
||||
private readonly Func<IDestination, ExportInformation, ISurface, Owned<ExportNotificationViewModel>> _toastFactory;
|
||||
|
||||
public ExportNotification(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IEventAggregator eventAggregator,
|
||||
Func<IDestination, ExportInformation, Owned<ExportNotificationViewModel>> toastFactory)
|
||||
Func<IDestination, ExportInformation, ISurface, Owned<ExportNotificationViewModel>> toastFactory)
|
||||
{
|
||||
_coreConfiguration = coreConfiguration;
|
||||
_eventAggregator = eventAggregator;
|
||||
|
@ -56,15 +56,16 @@ namespace Greenshot.Addons.Components
|
|||
/// </summary>
|
||||
/// <param name="source">IDestination</param>
|
||||
/// <param name="exportInformation">ExportInformation</param>
|
||||
public void NotifyOfExport(IDestination source, ExportInformation exportInformation)
|
||||
/// <param name="exportedSurface">ISurface</param>
|
||||
public void NotifyOfExport(IDestination source, ExportInformation exportInformation, ISurface exportedSurface)
|
||||
{
|
||||
if (exportInformation == null || !_coreConfiguration.ShowTrayNotification || !exportInformation.ExportMade)
|
||||
if (exportInformation == null || !_coreConfiguration.ShowTrayNotification)
|
||||
{
|
||||
Log.Info().WriteLine("No notification due to ShowTrayNotification = {0} - or export made = {1}", _coreConfiguration.ShowTrayNotification, exportInformation?.ExportMade);
|
||||
Log.Info().WriteLine("No notification due to ShowTrayNotification = {0} - or export made = {1}", _coreConfiguration.ShowTrayNotification);
|
||||
return;
|
||||
}
|
||||
// Create the ViewModel "part"
|
||||
var message = _toastFactory(source, exportInformation);
|
||||
var message = _toastFactory(source, exportInformation, exportedSurface);
|
||||
// Prepare to dispose the view model parts automatically if it's finished
|
||||
void DisposeHandler(object sender, DeactivationEventArgs args)
|
||||
{
|
||||
|
|
|
@ -31,8 +31,6 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Autofac.Features.OwnedInstances;
|
||||
using Caliburn.Micro;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Common.Extensions;
|
||||
using Dapplo.Windows.Common.Structs;
|
||||
|
@ -42,7 +40,6 @@ using Dapplo.Windows.Extensions;
|
|||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Extensions;
|
||||
using Greenshot.Addons.Interfaces;
|
||||
using Greenshot.Addons.ViewModels;
|
||||
using Greenshot.Gfx;
|
||||
|
||||
#endregion
|
||||
|
@ -54,9 +51,6 @@ namespace Greenshot.Addons.Core
|
|||
/// </summary>
|
||||
public abstract class AbstractDestination : IDestination
|
||||
{
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Func<IDestination, Owned<ExportNotificationViewModel>> _toastFactory;
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
|
||||
protected IGreenshotLanguage GreenshotLanguage { get; }
|
||||
|
@ -64,10 +58,8 @@ namespace Greenshot.Addons.Core
|
|||
|
||||
protected AbstractDestination(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification)
|
||||
IGreenshotLanguage greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
CoreConfiguration = coreConfiguration;
|
||||
GreenshotLanguage = greenshotLanguage;
|
||||
Designation = GetType().GetDesignation();
|
||||
|
@ -241,39 +233,6 @@ namespace Greenshot.Addons.Core
|
|||
//if (disposing) {}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A small helper method to perform some default destination actions, like inform the surface of the export
|
||||
/// </summary>
|
||||
/// <param name="exportInformation"></param>
|
||||
/// <param name="surface"></param>
|
||||
public void ProcessExport(ExportInformation exportInformation, ISurface surface)
|
||||
{
|
||||
_exportNotification.NotifyOfExport(this, exportInformation);
|
||||
if (exportInformation != null && exportInformation.ExportMade)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(exportInformation.Uri))
|
||||
{
|
||||
surface.UploadUrl = exportInformation.Uri;
|
||||
surface.SendMessageEvent(this, SurfaceMessageTyp.UploadedUri, string.Format(GreenshotLanguage.ExportedTo, exportInformation.DestinationDescription));
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(exportInformation.Filepath))
|
||||
{
|
||||
surface.LastSaveFullPath = exportInformation.Filepath;
|
||||
surface.SendMessageEvent(this, SurfaceMessageTyp.FileSaved, string.Format(GreenshotLanguage.ExportedTo, exportInformation.DestinationDescription));
|
||||
}
|
||||
else
|
||||
{
|
||||
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, string.Format(GreenshotLanguage.ExportedTo, exportInformation.DestinationDescription));
|
||||
}
|
||||
surface.Modified = false;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(exportInformation?.ErrorMessage))
|
||||
{
|
||||
surface.SendMessageEvent(this, SurfaceMessageTyp.Error,
|
||||
string.Format(GreenshotLanguage.ExportedTo, exportInformation.DestinationDescription) + " " + exportInformation.ErrorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Description;
|
||||
|
|
|
@ -36,7 +36,13 @@ namespace Greenshot.Addons.Interfaces
|
|||
ExportMade = exportMade;
|
||||
}
|
||||
|
||||
public string DestinationDesignation { get; }
|
||||
public bool IsError => !string.IsNullOrEmpty(ErrorMessage);
|
||||
public bool IsOk => string.IsNullOrEmpty(ErrorMessage);
|
||||
|
||||
public bool IsFileExport => !string.IsNullOrEmpty(Filepath);
|
||||
public bool IsCloudExport => !string.IsNullOrEmpty(Uri);
|
||||
|
||||
public string DestinationDesignation { get; }
|
||||
|
||||
public string DestinationDescription { get; set; }
|
||||
|
||||
|
|
|
@ -21,8 +21,14 @@
|
|||
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Media;
|
||||
using Dapplo.CaliburnMicro.Toasts.ViewModels;
|
||||
using Dapplo.Log;
|
||||
using Dapplo.Windows.Extensions;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Core;
|
||||
using Greenshot.Addons.Interfaces;
|
||||
|
||||
namespace Greenshot.Addons.ViewModels
|
||||
|
@ -30,13 +36,52 @@ namespace Greenshot.Addons.ViewModels
|
|||
/// <inheritdoc />
|
||||
public class ExportNotificationViewModel : ToastBaseViewModel
|
||||
{
|
||||
public ExportNotificationViewModel(IDestination source, ExportInformation exportInformation)
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
public ExportNotificationViewModel(IDestination source, ExportInformation exportInformation, ISurface exportedSurface)
|
||||
{
|
||||
Information = exportInformation;
|
||||
Source = source;
|
||||
|
||||
using (var bitmap = exportedSurface.GetBitmapForExport())
|
||||
{
|
||||
ExportBitmapSource = bitmap.ToBitmapSource();
|
||||
}
|
||||
}
|
||||
|
||||
public ImageSource GreenshotIcon => GreenshotResources.GreenshotIconAsBitmapSource();
|
||||
|
||||
public ImageSource ExportBitmapSource { get; }
|
||||
|
||||
public IDestination Source { get; }
|
||||
|
||||
public ExportInformation Information { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Handle the click
|
||||
/// </summary>
|
||||
public void OpenExport()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Information.IsFileExport)
|
||||
{
|
||||
ExplorerHelper.OpenInExplorer(Information.Filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Information.IsCloudExport)
|
||||
{
|
||||
Process.Start(Information.Uri);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error().WriteLine(ex,"While opening {0}", Information.Uri);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,31 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:toastNotifications="clr-namespace:ToastNotifications.Core;assembly=ToastNotifications"
|
||||
xmlns:viewModels="clr-namespace:Greenshot.Addons.ViewModels"
|
||||
mc:Ignorable="d" Background="{DynamicResource AccentColorBrush}" Width="200" Padding="5"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d" Background="{DynamicResource AccentBaseColorBrush}" Width="300" Height="256" Padding="5"
|
||||
d:DataContext="{d:DesignInstance viewModels:ExportNotificationViewModel,IsDesignTimeCreatable=False}"
|
||||
d:DesignHeight="100" d:DesignWidth="200" HorizontalContentAlignment="Stretch" HorizontalAlignment="Right">
|
||||
<DockPanel LastChildFill="True">
|
||||
<Image Source="{Binding Source.DisplayIconWpf}" Width="64" VerticalAlignment="Top"/>
|
||||
<Label Content="{Binding Information.DestinationDescription}" VerticalAlignment="Center" FontWeight="Light" Foreground="White"/>
|
||||
</DockPanel>
|
||||
<toastNotifications:NotificationDisplayPart.Resources>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
|
||||
</toastNotifications:NotificationDisplayPart.Resources>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="32" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Top row -->
|
||||
<Image Source="{Binding GreenshotIcon}" Stretch="Uniform" RenderOptions.BitmapScalingMode="Fant" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0"/>
|
||||
<TextBlock Text="{Binding Information.DestinationDesignation}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Light" Foreground="{DynamicResource IdealForegroundColorBrush}" TextWrapping="WrapWithOverflow" Grid.Row="0" Grid.Column="1" />
|
||||
<Image Source="{Binding Source.DisplayIconWpf}" Stretch="Uniform" RenderOptions.BitmapScalingMode="Fant" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Row="0" Grid.Column="2"/>
|
||||
|
||||
<!-- Bottom row -->
|
||||
<TextBlock Text="{Binding Information.ErrorMessage}" VerticalAlignment="Center" FontWeight="Bold" Visibility="{Binding Information.IsError, Converter={StaticResource BooleanToVisibility}}" Foreground="Red" TextWrapping="WrapWithOverflow" Grid.Row="1" Grid.Column="1" />
|
||||
<Image cal:Message.Attach="[Event MouseDown] = [Action OpenExport()]" Source="{Binding ExportBitmapSource}" Visibility="{Binding Information.IsOk, Converter={StaticResource BooleanToVisibility}}" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Uniform" RenderOptions.BitmapScalingMode="Fant" UseLayoutRounding="True" Grid.Row="1" Grid.Column="1"/>
|
||||
</Grid>
|
||||
</toastNotifications:NotificationDisplayPart>
|
||||
|
|
|
@ -45,12 +45,15 @@ namespace Greenshot.Destinations
|
|||
[Destination("Clipboard", DestinationOrder.Clipboard)]
|
||||
public class ClipboardDestination : AbstractDestination
|
||||
{
|
||||
private readonly ExportNotification _exportNotification;
|
||||
|
||||
public ClipboardDestination(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
public override string Description => GreenshotLanguage.SettingsDestinationClipboard;
|
||||
|
@ -105,8 +108,8 @@ namespace Greenshot.Destinations
|
|||
// TODO: Change to general logic in ProcessExport
|
||||
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, "Error"); //GreenshotLanguage.editorclipboardfailed);
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,7 +42,8 @@ namespace Greenshot.Destinations
|
|||
[Destination("EMail", DestinationOrder.Email)]
|
||||
public class EmailDestination : AbstractDestination
|
||||
{
|
||||
private static readonly Bitmap MailIcon = GreenshotResources.GetBitmap("Email.Image");
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private static readonly Bitmap MailIcon = GreenshotResources.GetBitmap("Email.Image");
|
||||
private static bool _isActiveFlag;
|
||||
private static string _mapiClient;
|
||||
|
||||
|
@ -64,8 +65,9 @@ namespace Greenshot.Destinations
|
|||
public EmailDestination(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
public override string Description
|
||||
|
@ -112,8 +114,8 @@ namespace Greenshot.Destinations
|
|||
var exportInformation = new ExportInformation(Designation, Description);
|
||||
MapiMailMessage.SendImage(surface, captureDetails);
|
||||
exportInformation.ExportMade = true;
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,13 +45,15 @@ namespace Greenshot.Destinations
|
|||
[Destination("FileNoDialog", DestinationOrder.FileNoDialog)]
|
||||
public class FileDestination : AbstractDestination
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly ExportNotification _exportNotification;
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
|
||||
public FileDestination(
|
||||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
ExportNotification exportNotification) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
public override string Description => GreenshotLanguage.QuicksettingsDestinationFile;
|
||||
|
@ -125,8 +127,8 @@ namespace Greenshot.Destinations
|
|||
CoreConfiguration.OutputFileAsFullpath = fullPath;
|
||||
}
|
||||
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
|
||||
private string CreateNewFilename(ICaptureDetails captureDetails)
|
||||
|
|
|
@ -42,13 +42,15 @@ namespace Greenshot.Destinations
|
|||
public class FileWithDialogDestination : AbstractDestination
|
||||
{
|
||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||
private readonly ExportNotification _exportNotification;
|
||||
|
||||
public FileWithDialogDestination(ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
_exportNotification = exportNotification;
|
||||
}
|
||||
|
||||
public override string Description => _greenshotLanguage.SettingsDestinationFileas;
|
||||
|
@ -69,8 +71,8 @@ namespace Greenshot.Destinations
|
|||
captureDetails.Filename = savedTo;
|
||||
CoreConfiguration.OutputFileAsFullpath = savedTo;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ namespace Greenshot.Destinations
|
|||
ICoreConfiguration coreConfiguration,
|
||||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_destinationHolder = destinationHolder;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace Greenshot.Destinations
|
|||
IGreenshotLanguage greenshotLanguage,
|
||||
ExportNotification exportNotification,
|
||||
Func<ISurface, ICaptureDetails, Owned<PrintHelper>> printHelperFactory
|
||||
) : base(coreConfiguration, greenshotLanguage, exportNotification)
|
||||
{
|
||||
) : base(coreConfiguration, greenshotLanguage)
|
||||
{
|
||||
_greenshotLanguage = greenshotLanguage;
|
||||
_exportNotification = exportNotification;
|
||||
_printHelperFactory = printHelperFactory;
|
||||
|
@ -161,8 +161,8 @@ namespace Greenshot.Destinations
|
|||
exportInformation.ExportMade = true;
|
||||
}
|
||||
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
_exportNotification.NotifyOfExport(this, exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -561,77 +561,6 @@ namespace Greenshot.Helpers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If a balloon tip is show for a taken capture, this handles the click on it
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OpenCaptureOnClick(object sender, EventArgs e)
|
||||
{
|
||||
if (!(MainForm.Instance.NotifyIcon.Tag is SurfaceMessageEventArgs eventArgs))
|
||||
{
|
||||
Log.Warn().WriteLine("OpenCaptureOnClick called without SurfaceMessageEventArgs");
|
||||
RemoveEventHandler(sender, e);
|
||||
return;
|
||||
}
|
||||
var surface = eventArgs.Surface;
|
||||
if (surface != null)
|
||||
{
|
||||
switch (eventArgs.MessageType)
|
||||
{
|
||||
case SurfaceMessageTyp.FileSaved:
|
||||
ExplorerHelper.OpenInExplorer(surface.LastSaveFullPath);
|
||||
break;
|
||||
case SurfaceMessageTyp.UploadedUri:
|
||||
Process.Start(surface.UploadUrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.Debug().WriteLine("Deregistering the BalloonTipClicked");
|
||||
RemoveEventHandler(sender, e);
|
||||
}
|
||||
|
||||
private void RemoveEventHandler(object sender, EventArgs e)
|
||||
{
|
||||
MainForm.Instance.NotifyIcon.BalloonTipClicked -= OpenCaptureOnClick;
|
||||
MainForm.Instance.NotifyIcon.BalloonTipClosed -= RemoveEventHandler;
|
||||
MainForm.Instance.NotifyIcon.Tag = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is the SufraceMessageEvent receiver
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="eventArgs"></param>
|
||||
private void SurfaceMessageReceived(object sender, SurfaceMessageEventArgs eventArgs)
|
||||
{
|
||||
if (string.IsNullOrEmpty(eventArgs?.Message))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MainForm.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (eventArgs.MessageType)
|
||||
{
|
||||
case SurfaceMessageTyp.Error:
|
||||
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Error);
|
||||
break;
|
||||
case SurfaceMessageTyp.Info:
|
||||
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
|
||||
break;
|
||||
case SurfaceMessageTyp.FileSaved:
|
||||
case SurfaceMessageTyp.UploadedUri:
|
||||
// Show a balloon and register an event handler to open the "capture" for if someone clicks the balloon.
|
||||
MainForm.Instance.NotifyIcon.BalloonTipClicked += OpenCaptureOnClick;
|
||||
MainForm.Instance.NotifyIcon.BalloonTipClosed += RemoveEventHandler;
|
||||
// Store for later usage
|
||||
MainForm.Instance.NotifyIcon.Tag = eventArgs;
|
||||
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", eventArgs.Message, ToolTipIcon.Info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process the actuall capture
|
||||
|
@ -680,11 +609,6 @@ namespace Greenshot.Helpers
|
|||
surface.SetCapture(_capture);
|
||||
surface.Modified = !outputMade;
|
||||
|
||||
// Register notify events if this is wanted
|
||||
if (CoreConfig.ShowTrayNotification && !CoreConfig.HideTrayicon)
|
||||
{
|
||||
surface.SurfaceMessage += SurfaceMessageReceived;
|
||||
}
|
||||
// Let the processors do their job
|
||||
foreach (var processor in _processors)
|
||||
{
|
||||
|
|
|
@ -50,8 +50,7 @@ namespace Greenshot.Ui.Notifications.ViewModels
|
|||
|
||||
public string Message => string.Format(_greenshotLanguage.UpdateFound, LatestVersion);
|
||||
|
||||
public ImageSource Icon => GreenshotResources.GreenshotIconAsBitmapSource();
|
||||
|
||||
public ImageSource GreenshotIcon => GreenshotResources.GreenshotIconAsBitmapSource();
|
||||
|
||||
/// <summary>
|
||||
/// Handle the click
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<ColumnDefinition Width="64" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image Source="{Binding Icon}" Width="64" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0"/>
|
||||
<Image Source="{Binding GreenshotIcon}" Width="64" VerticalAlignment="Top" Grid.Row="0" Grid.Column="0"/>
|
||||
<TextBlock Text="{Binding Message}" VerticalAlignment="Center" FontWeight="Light" Foreground="{DynamicResource IdealForegroundColorBrush}" TextWrapping="WrapWithOverflow" Grid.Row="0" Grid.Column="1" />
|
||||
<Button Style="{DynamicResource SquareButtonStyle}" Focusable="False" cal:Message.Attach="[Action OpenDownloads()]" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
|
||||
<TextBlock>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue