private void FolderSynchronizationFinished(object sender, FolderSynchronizationFinishedEventArgs e)
        {
            bool notificationsEnabled;
            if (this.FolderNotificationsEnabled != null && this.FolderNotificationsEnabled.TryGetValue(e.FolderId, out notificationsEnabled) && notificationsEnabled)
            {
                if (e.FileTransfers.Count == 0)
                {
                    if (this.ShowSynchronizedBalloonEvenIfNothingDownloaded &&
                        DateTime.UtcNow - this.syncThingManager.LastConnectivityEventTime > syncedDeadTime &&
                        DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                    {
                        this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, String.Format(Resources.TrayIcon_Balloon_FinishedSyncing_Message, e.FolderId), BalloonIcon.Info);
                    }
                }
                else if (e.FileTransfers.Count == 1)
                {
                    var fileTransfer = e.FileTransfers[0];
                    string msg = null;
                    if (fileTransfer.ActionType == ItemChangedActionType.Update)
                        msg = String.Format(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path));
                    else if (fileTransfer.ActionType == ItemChangedActionType.Delete)
                        msg = String.Format(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path));

                    if (msg != null)
                        this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, msg, BalloonIcon.Info);
                }
                else
                {
                    var updatedCount = e.FileTransfers.Where(x => x.ActionType == ItemChangedActionType.Update).Count();
                    var deletedCount = e.FileTransfers.Where(x => x.ActionType == ItemChangedActionType.Delete).Count();

                    var messageParts = new List<string>();

                    if (updatedCount > 0)
                        messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedFile, updatedCount));

                    if (deletedCount > 0)
                        messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedFile, deletedCount));

                    var text = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_Multiple, e.FolderId, messageParts);

                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, text, BalloonIcon.Info);
                }
            }
        }
        private void FolderSynchronizationFinished(object sender, FolderSynchronizationFinishedEventArgs e)
        {
            // If it only contains failed transfers we've seen before, then we don't care.
            // Otherwise we'll keep bugging the user (every minute) for a failing transfer. 
            // However, with this behaviour, we'll still remind them about the failure whenever something succeeds (or a new failure is added)
            if (e.FileTransfers.All(x => x.Error != null && !x.IsNewError))
                return;

            bool notificationsEnabled;
            if (this.FolderNotificationsEnabled != null && this.FolderNotificationsEnabled.TryGetValue(e.FolderId, out notificationsEnabled) && notificationsEnabled)
            {
                if (e.FileTransfers.Count == 0)
                {
                    if (this.ShowSynchronizedBalloonEvenIfNothingDownloaded &&
                        DateTime.UtcNow - this.syncThingManager.LastConnectivityEventTime > syncedDeadTime &&
                        DateTime.UtcNow - this.syncThingManager.StartedTime > syncedDeadTime)
                    {
                        this.taskbarIcon.HideBalloonTip();
                        this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, String.Format(Resources.TrayIcon_Balloon_FinishedSyncing_Message, e.FolderId), BalloonIcon.Info);
                    }
                }
                else if (e.FileTransfers.Count == 1)
                {
                    var fileTransfer = e.FileTransfers[0];
                    string msg = null;
                    if (fileTransfer.Error == null)
                    { 
                        if (fileTransfer.ActionType == ItemChangedActionType.Update)
                            msg = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path));
                        else if (fileTransfer.ActionType == ItemChangedActionType.Delete)
                            msg = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path));
                    }
                    else
                    {
                        if (fileTransfer.ActionType == ItemChangedActionType.Update)
                            msg = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_FailedToUpdateSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path), fileTransfer.Error);
                        else if (fileTransfer.ActionType == ItemChangedActionType.Delete)
                            msg = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_FailedToDeleteSingleFile, e.FolderId, Path.GetFileName(fileTransfer.Path), fileTransfer.Error);
                    }

                    if (msg != null)
                    {
                        this.taskbarIcon.HideBalloonTip();
                        this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, msg, BalloonIcon.Info);
                    }
                }
                else
                {
                    var updates = e.FileTransfers.Where(x => x.ActionType == ItemChangedActionType.Update).ToArray();
                    var deletes = e.FileTransfers.Where(x => x.ActionType == ItemChangedActionType.Delete).ToArray();

                    var messageParts = new List<string>();

                    if (updates.Length > 0)
                    {
                        var failureCount = updates.Count(x => x.Error != null);
                        if (failureCount > 0)
                            messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedFileWithFailures, updates.Length, failureCount));
                        else
                            messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_UpdatedFile, updates.Length));
                    }
                        

                    if (deletes.Length > 0)
                    {
                        var failureCount = deletes.Count(x => x.Error != null);
                        if (failureCount > 0)
                            messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedFileWithFailures, deletes.Length, failureCount));
                        else
                            messageParts.Add(Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_DeletedFile, deletes.Length));
                    }
                        
                    var text = Localizer.F(Resources.TrayIcon_Balloon_FinishedSyncing_Multiple, e.FolderId, messageParts);

                    this.taskbarIcon.HideBalloonTip();
                    this.taskbarIcon.ShowBalloonTip(Resources.TrayIcon_Balloon_FinishedSyncing_Title, text, BalloonIcon.Info);
                }
            }
        }