using System;
using System.Drawing;
using Elfisa.UI.Notifications;

namespace Электронная_Фармация.Classes
{
    public static class ToastNotification
    {
        public static void ShowSuccess(string message)
        {
            Show(ToastType.Success, message);
        }

        public static void ShowError(string message)
        {
            Show(ToastType.Error, message);
        }

        public static void ShowCustom(string message, Color bgColor, Color textColor)
        {
            var type = ToastType.Info;
            if (bgColor.R > 200 && bgColor.G < 120)
            {
                type = ToastType.Error;
            }
            else if (bgColor.G > 180 && bgColor.R < 120)
            {
                type = ToastType.Success;
            }
            else if (bgColor.R > 180 && bgColor.G > 120)
            {
                type = ToastType.Warning;
            }

            Show(type, message);
        }

        public static void RemoveNotification(HelpForms.NotificationForm notification)
        {
            notification?.Close();
        }

        private static void Show(ToastType type, string message)
        {
            if (AppServices.Toast != null)
            {
                AppServices.Toast.Show("Электронная Фармация", message, type);
                return;
            }

            System.Windows.Forms.MessageBox.Show(message);
        }
    }
}
