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.Controls;

using C4IT.Logging;

using FasdDesktopUi.Basics.Models;
using FasdDesktopUi.Basics.UserControls;

using static C4IT.Logging.cLogManager;

namespace FasdDesktopUi.Basics.UiActions
{
    public class cSubMenuAction : cUiActionBase
    {
        public bool UseTempData { get; private set; }
        public List<cMenuDataBase> SubMenuData { get; set; }

        public cSubMenuAction(bool UseTempData)
        {
            this.UseTempData = UseTempData;
        }

        public override async Task<bool> RunUiActionAsync(object sender, UIElement UiLocation, bool isDetailedLayout, cSupportCaseDataProvider dataProvider)
        {
            try
            {
                if (!(UiLocation is QuickActionSelector quickActionSelector))
                    return false;

                quickActionSelector.Visibility = Visibility.Visible;
                quickActionSelector.TempQuickActionSelectorHeading = UseTempData ? quickActionSelector.QuickActionSelectorHeading : null;
                quickActionSelector.TempQuickActionList = UseTempData ? quickActionSelector.QuickActionList : null;

                quickActionSelector.QuickActionSelectorHeading = Name;
                quickActionSelector.QuickActionList = SubMenuData;

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

            await Task.CompletedTask;
            return false;
        }
    }
}
