Introduced a very simple "singleton" service-locator, which allowed for a removal of specific implementations which were very limited. With this it's easier to access dependencies.

This commit is contained in:
Krom, Robertus 2020-02-18 13:48:40 +01:00
commit 80d8f51fc5
53 changed files with 744 additions and 1230 deletions

View file

@ -88,9 +88,11 @@ namespace Greenshot.Experimental {
_latestGreenshot = null;
ProcessRssInfo(currentVersion);
if (_latestGreenshot != null) {
MainForm.Instance.NotifyIcon.BalloonTipClicked += HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed += CleanupBalloonTipClick;
MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, "'" + _latestGreenshot.File + "'"), ToolTipIcon.Info);
var notifyIcon = SimpleServiceProvider.Current.GetInstance<NotifyIcon>();
notifyIcon.BalloonTipClicked += HandleBalloonTipClick;
notifyIcon.BalloonTipClosed += CleanupBalloonTipClick;
notifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, "'" + _latestGreenshot.File + "'"), ToolTipIcon.Info);
}
} catch (Exception e) {
Log.Error("An error occured while checking for updates, the error will be ignored: ", e);
@ -99,8 +101,9 @@ namespace Greenshot.Experimental {
}
private static void CleanupBalloonTipClick(object sender, EventArgs e) {
MainForm.Instance.NotifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
MainForm.Instance.NotifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
var notifyIcon = SimpleServiceProvider.Current.GetInstance<NotifyIcon>();
notifyIcon.BalloonTipClicked -= HandleBalloonTipClick;
notifyIcon.BalloonTipClosed -= CleanupBalloonTipClick;
}
private static void HandleBalloonTipClick(object sender, EventArgs e) {