Esempio n. 1
0
        /// <summary>
        /// Generate message box HTML and set to data collector
        /// </summary>
        /// <param name="text">Text of a message box</param>
        /// <param name="status">Status of a message box</param>
        /// <param name="title">Title of a message box</param>
        public void Show(string?text, MessageBoxStatus status = MessageBoxStatus.Error, string?title = null)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException(nameof(text));
            }

            var templateFile = MessageBoxTemplatesPath;

            switch (status)
            {
            case MessageBoxStatus.Information:
                templateFile += "InfoMessageBox.tpl";
                break;

            case MessageBoxStatus.Error:
                templateFile += "ErrorMessageBox.tpl";
                break;

            case MessageBoxStatus.Ok:
                templateFile += "OkMessageBox.tpl";
                break;
            }

            var tpl = _templateFactory.Load(templateFile);

            tpl.Set("Message", text);
            tpl.Set("Title", string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);

            _dataCollector.Add(tpl.Get());
            _dataCollector.AddTitle(string.IsNullOrEmpty(title) ? _stringTable.GetItem("FormTitleMessageBox") : title);
        }