// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.




using System;
using System.IO;
using Hiperscan.Unix;
using Microsoft.Win32;

namespace Hiperscan.Extensions.ApoIdent
{
    public static class ImportantCustomerInfo
    {
        public static event EventHandler InfoShown = null;

        public static void ShowInfo()
        {
            if (ImportantCustomerInfo.IsActive == false)
                return;

            if (ImportantCustomerInfo.Condition() == false)
                return;

            ImportantCustomerInfo.InfoShown?.Invoke(ImportantCustomerInfo.Message, EventArgs.Empty);

            return;
        }

        public static void MarkAsRead()
        {
            try
            {
                string file = Path.Combine(FilesAndDirs.ConfigDir, ImportantCustomerInfo.InfoId);

                if (File.Exists(file))
                    return;

                File.Create(file);
            }
            catch(Exception)
            {

            }
        }


        //Change here the condition
        private static bool Condition()
        {
            try
            {
                string file = Path.Combine(FilesAndDirs.ConfigDir, ImportantCustomerInfo.InfoId);

                if (File.Exists(file))
                    return false;
                //Write here your own condition

                return true;
            }
            catch (Exception)
            {
                return true;
            }
        }

        //set to true for the case that esists an important customer info
        private static bool IsActive { get; set; } = true;

        //set a related id for an advice
        private static string InfoId { get; set; } = "New_Features_2_4";

        //write here the advice text
        private static string Message { get; } = Catalog.GetString(
            "<b>New Version 2.4</b>\n\n" +
            "Following new features are already preset. You can deactivate them again in the settings.\n\n" +
        "\t-  \"Complementary tests / Identity tests\" as mandatory\n" +
        "\t-  Output of parts of the validation document in the measuring protocol");
    }
}
