using C4IT.FASD.Base;
using C4IT.Logging;
using C4IT.MultiLanguage;
using F4SD_AdaptableIcon.Enums;
using FasdDesktopUi.Basics.Services.ProtocollService;
using FasdDesktopUi.Basics.UserControls;
using FasdDesktopUi.Basics.UserControls.AdaptableIcon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using static C4IT.Logging.cLogManager;

namespace FasdDesktopUi.Basics.UiActions
{
    public class cCopyQuickActionProtocolAction : cUiActionBase
    {
        public override async Task<bool> RunUiActionAsync(object sender, UIElement UiLocation, bool isDetailedLayout, cSupportCaseDataProvider dataProvider)
        {
            try
            {
                if (dataProvider is null)
                    return false;

                var protocolItems = F4SDProtocoll.Instance.GetAllAsDataObject(false); // dataProvider.QuickActionProtocollHelper.GetFullProtocollQuickActionResult();

                if (protocolItems is null || string.IsNullOrWhiteSpace(protocolItems.GetText()))
                    protocolItems.SetText(cMultiLanguageSupport.GetItem("QuickAction.Copy.Protocol.Empty"));

                System.Windows.Forms.Clipboard.SetDataObject(protocolItems, true);

                if (sender is CustomMenuItem senderElement)
                    await cUtility.ChangeIconToCheckAsync(senderElement.MenuItemIcon);

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

            return false;
        }
    }
}
