using C4IT.FASD.Base;
using C4IT.MultiLanguage;

namespace FasdDesktopUi.Basics.Services.ProtocollService
{
    internal class QuickTipStepProtocollEntry : IProtocollEntry
    {
        private readonly cQuickTipElement _quickTipElementDefinition;
        private readonly bool _wasSuccessfull;

        public QuickTipStepProtocollEntry(cQuickTipElement quickTipElementDefinition, bool wasSuccessfull)
        {
            _quickTipElementDefinition = quickTipElementDefinition;
            _wasSuccessfull = wasSuccessfull;
        }

        public string GetAscii()
        {
            string currentLanguage = cMultiLanguageSupport.CurrentLanguage;
            try
            {
                cMultiLanguageSupport.CurrentLanguage = cF4SDCockpitXmlConfig.Instance.HealthCardConfig.ProtocollLanguage ?? currentLanguage;
                string ascii = _wasSuccessfull ? cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Successfull") : cMultiLanguageSupport.GetItem("QuickTips.Copy.ManualStep.Unsuccessfull");
                return string.Format(ascii, _quickTipElementDefinition?.Names?.GetValue());
            }
            finally
            {
                cMultiLanguageSupport.CurrentLanguage = currentLanguage;
            }
        }

        public string GetHtml()
            => GetAscii();
    }
}
