using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Bellwether.Pages
{
    /// <summary>
    /// Interaction logic for ucHistoryHW.xaml
    /// </summary>
    public partial class ucHistoryHW : UserControl
    {
        private static Dictionary<PageType, string> PageFolderName
            = new Dictionary<PageType, string>() {
                { PageType.History, "History" },
                { PageType.Product, "Product" },
                { PageType.CSR, "CSR" },
            };

        public event EventHandler<PageType> GoPageRequested;

        private HistoryDLL.CyclicScroller uiHistory;
        private PageType currentPage;

        public ucHistoryHW(PageType type)
        {
            InitializeComponent();

            UpdateBtn(type);

            currentPage = type;
            Loaded += UcHistoryHW_Loaded;
        }

        private void UpdateBtn(PageType page)
        {
            uxHistoryCover.Visibility = page == PageType.History ? Visibility.Visible : Visibility.Collapsed;
            uxProductCover.Visibility = page == PageType.Product ? Visibility.Visible : Visibility.Collapsed;
            uxNewsCover.Visibility = page == PageType.CSR ? Visibility.Visible : Visibility.Collapsed;
        }

        private void UcHistoryHW_Loaded(object sender, RoutedEventArgs e)
        {
            var pageFolderName = PageFolderName[currentPage];
            HistoryDLL.GlobalFunction.historyWalldataFolderName = pageFolderName;
            uiHistory = new HistoryDLL.CyclicScroller(0);
            uxHwContainer.Children.Insert(0, uiHistory);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            GoPageRequested?.Invoke(this, PageType.FrontPage);
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            GoPageRequested?.Invoke(this, PageType.History);
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            GoPageRequested?.Invoke(this, PageType.Product);
        }

        private void Button3_Click(object sender, RoutedEventArgs e)
        {
            GoPageRequested?.Invoke(this, PageType.CSR);
        }
    }
}
