Winify – Rev

Subversion Repositories:
Rev:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;
using ToastNotifications;
using Winify.Gotify;

namespace Winify
{
    public class NotificationManager : IDisposable
    {
        #region Private Delegates, Events, Enums, Properties, Indexers and Fields

        private readonly TaskScheduler _uiScheduler;

        #endregion

        #region Constructors, Destructors and Finalizers

        public NotificationManager(TaskScheduler uiScheduler) : this()
        {
            _uiScheduler = uiScheduler;
        }

        private NotificationManager()
        {
        }

        public void Dispose()
        {
        }

        #endregion

        #region Public Methods

        public void ShowNotification(GotifyNotificationEventArgs e, Announcements.Announcements notifications)
        {
            Task.Factory.StartNew(() =>
            {
                var settings =
                    notifications.Announcement.FirstOrDefault(
                        announcement => announcement.AppId == e.Notification.AppId);

                Notification notification;
                switch (settings == null)
                {
                    case true:
                        notification = new Notification($"{e.Notification.Title} ({e.Notification.AppId})",
                            e.Notification.Message, 5000, e.Image, FormAnimator.AnimationMethod.Slide,
                            FormAnimator.AnimationDirection.Up);
                        break;
                    default:
                        notification = new Notification($"{e.Notification.Title} ({e.Notification.AppId})",
                            e.Notification.Message, settings.LingerTime, e.Image, FormAnimator.AnimationMethod.Slide,
                            FormAnimator.AnimationDirection.Up);
                        break;
                }

                notification.Show();
            }, CancellationToken.None, TaskCreationOptions.None, _uiScheduler);
        }

        #endregion
    }
}

Generated by GNU Enscript 1.6.5.90.