﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using eSDK_TP_Demo_CS_CSharp.FunctionPage;
using com.huawei.esdk.tp.professional.DataType;
using System.Collections;

namespace eSDK_TP_Demo_CS_CSharp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private string falg = string.Empty;

        public static bool ScheduleConf_Loaded = true;
        public static bool AddSiteToConf_Loaded = true;
        public static bool ConnectSites_Loaded = true;
        public static bool SetBroadcastSite_Loaded = true;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            
            Dictionary<int, string> languageCombxDic = new Dictionary<int, string>()
            {
                {0,"中 文"},
                {1,"English"}
            };

            this.LanguageCombx.ItemsSource = languageCombxDic;
            this.LanguageCombx.SelectedValuePath = "Key";
            this.LanguageCombx.DisplayMemberPath = "Value";
            this.LanguageCombx.SelectedValue = 0;

            this.ScheduleConf_Description.Content = new ScheduleConf_Description();
            this.ScheduleConf_Execution.Content = new ScheduleConf_UI();
            this.ScheduleConf_SourceCode.Content = new ScheduleConf_Code();

            this.AddSiteToConf_Description.Content = new AddSiteToConf_Description();
            this.AddSiteToConf_Execution.Content = new AddSiteToConf_UI();
            this.AddSiteToConf_SourceCode.Content = new AddSiteToConf_Code();

            this.ConnectSites_Description.Content = new ConnectSites_Description();
            this.ConnectSites_Execution.Content = new ConnectSites_UI();
            this.ConnectSites_SourceCode.Content = new ConnectSites_Code();

            this.SetBroadcastSite_Description.Content = new setBroadcastSite_Description();
            this.SetBroadcastSite_Execution.Content = new setBroadcastSite_UI();
            this.SetBroadcastSite_SourceCode.Content = new setBroadcastSite_Code();
        }

        private void ScheduleConfEx_Click(object sender, RoutedEventArgs e)
        {
            if (!falg.Equals("ScheduleConf"))
            {
                falg = "ScheduleConf";
                this.TabControl_ScheduleConf.Visibility = Visibility.Visible;
                this.TabControl_AddSiteToConf.Visibility = Visibility.Collapsed;
                this.TabControl_ConnectSites.Visibility = Visibility.Collapsed;
                this.TabControl_SetBroadcastSite.Visibility = Visibility.Collapsed;
            }
        }

        private void AddSiteToConfEx_Click(object sender, RoutedEventArgs e)
        {
            if (!falg.Equals("AddSiteToConf"))
            {
                falg = "AddSiteToConf";
                AddSiteToConf_Loaded = false;
                this.TabControl_ScheduleConf.Visibility = Visibility.Collapsed;
                this.TabControl_AddSiteToConf.Visibility = Visibility.Visible;
                this.TabControl_ConnectSites.Visibility = Visibility.Collapsed;
                this.TabControl_SetBroadcastSite.Visibility = Visibility.Collapsed;
            }
        }

        private void ConnectSitesEx_Click(object sender, RoutedEventArgs e)
        {
            if (!falg.Equals("ConnectSites"))
            {
                falg = "ConnectSites";
                this.TabControl_ScheduleConf.Visibility = Visibility.Collapsed;
                this.TabControl_AddSiteToConf.Visibility = Visibility.Collapsed;
                this.TabControl_ConnectSites.Visibility = Visibility.Visible;
                this.TabControl_SetBroadcastSite.Visibility = Visibility.Collapsed;
            }
        }

        private void SetBroadcastSiteEx_Click(object sender, RoutedEventArgs e)
        {
            if (!falg.Equals("SetBroadcastSite"))
            {
                falg = "SetBroadcastSite";
                this.TabControl_ScheduleConf.Visibility = Visibility.Collapsed;
                this.TabControl_AddSiteToConf.Visibility = Visibility.Collapsed;
                this.TabControl_ConnectSites.Visibility = Visibility.Collapsed;
                this.TabControl_SetBroadcastSite.Visibility = Visibility.Visible;
            }
        }

        private void Language_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string uriStr = string.Empty;
            if (1 == this.LanguageCombx.SelectedIndex)
                uriStr = "/Lang/en_US.xaml";
            else
                uriStr = "/Lang/zh_CN.xaml";
            Application.Current.Resources.MergedDictionaries[0] = new ResourceDictionary()
                {
                    Source = new Uri(uriStr, UriKind.RelativeOrAbsolute)
                };
            this.TabControl_ScheduleConf.Items.Refresh();
        }

        private void WindowSize_Changed(object sender, SizeChangedEventArgs e)
        {
            this.mainLine.X2 = this.LineWidth.ActualWidth;
        }
    }
}
