using CollaborativePlatformMain.DFEntity;
using CollaborativePlatformMain.Form.UserControlForm;
using CollaborativePlatformMain.Util;
using HandyControl.Controls;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.Eventing.Reader;
using System.Drawing.Printing;
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.Shapes;
using Window = System.Windows.Window;
using MessageBox = System.Windows.MessageBox;
using static System.Net.Mime.MediaTypeNames;
using CollaborativePlatformMain.Form.MessageSubPage;
using CollaborativePlatformMain.Form.MessageSubPage.CreatLevel;
using CollaborativePlatformMain.Form.MessageSubPage.Project;
using CollaborativePlatformMain.DFEntity.MessageSubUtil;

namespace CollaborativePlatformMain.Form
{
    /// <summary>
    /// HomepageForm.xaml 的交互逻辑
    /// </summary>
    public partial class HomepageForm : Window
    {
        public HomepageForm()
        {
            InitializeComponent();
        }

        #region 最左边消息

        /// <summary>
        /// 消息是否为初始化
        /// </summary>
        public bool IsSeconMessagePage = false;

        /// <summary>
        /// 消息窗体
        /// </summary>
        public SeconMessagePage SeconMessagePage = null;

        /// <summary>
        /// 消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void message_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Visible;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Collapsed;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Collapsed;

            SeconMessagePage = new SeconMessagePage(this);
            seconMessagePage.Navigate(SeconMessagePage);
            IsSeconMessagePage = true;


            //SwitchMethod(sender as MenuItem, true);
        }

        /// <summary>
        /// 项目是否初始化
        /// </summary>
        public bool IsSeconProjectPageShow = false;

        /// <summary>
        /// 项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void project_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Visible;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Collapsed;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Collapsed;

            if (!IsSeconProjectPageShow)
            {
                seconProjectPage.Navigate(new SeconProjectPage(this));
                IsSeconProjectPageShow = true;
            }
        }

        /// <summary>
        /// 联系人是否初始化
        /// </summary>
        public bool IsSeconContactsPage = false;

        /// <summary>
        /// 联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contacts_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Visible;
            dp_gallery.Visibility = Visibility.Visible;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Collapsed;

            if (!IsSeconContactsPage)
            {
                seconContactsPage.Navigate(new SeconContactsPage(this));
                IsSeconContactsPage = true;
            }
        }


        /// <summary>
        /// 图库大样图是否初始化
        /// </summary>
        public bool IsSeconLegendPage = false;

        /// <summary>
        /// 图库大样图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gallery_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Visible;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Collapsed;

            if (!IsSeconLegendPage)
            {
                seconLegendPage.Navigate(new SeconLegendPage(this));
                IsSeconLegendPage = true;
            }
        }

        /// <summary>
        /// 工具库是否初始化
        /// </summary>
        public bool IsSeconToolLibraryPage = false;

        /// <summary>
        /// 工具库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tool_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Collapsed;
            dp_tools.Visibility = Visibility.Visible;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Collapsed;

            if (!IsSeconToolLibraryPage)
            {
                seconToolsPage.Navigate(new SeconToolLibraryPage());
                IsSeconToolLibraryPage = true;
            }
        }

        /// <summary>
        /// 三维是否初始化
        /// </summary>
        public bool IsSeconThreeDimensionalPage = false;

        /// <summary>
        /// 三维
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void three_Click(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Collapsed;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Visible;
            dp_ArticleReview.Visibility = Visibility.Collapsed;
            if (!IsSeconThreeDimensionalPage)
            {
                seconThreeTools.Navigate(new SeconThreeDimensionalPage(this));
                IsSeconThreeDimensionalPage = true;
            }

        }

        /// <summary>
        /// 条文审查是否初始化
        /// </summary>
        public bool IsSeconArticleReviewPage = false;

        /// <summary>
        /// 条文审查
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MenuItem menuItem = sender as MenuItem;
            ModifyBackground(menuItem);
            dp_message.Visibility = Visibility.Collapsed;
            dp_project.Visibility = Visibility.Collapsed;
            dp_contacts.Visibility = Visibility.Collapsed;
            dp_gallery.Visibility = Visibility.Collapsed;
            dp_tools.Visibility = Visibility.Collapsed;
            dp_threetools.Visibility = Visibility.Collapsed;
            dp_ArticleReview.Visibility = Visibility.Visible;
            if (!IsSeconArticleReviewPage)
            {
                seconArticleReview.Navigate(new SeconArticleReviewPage());
                IsSeconArticleReviewPage = true;
            }
        }

        /// <summary>
        /// 设置最左测导航的颜色
        /// </summary>
        /// <param name="menuItem"></param>
        /// <param name="isHoShow"></param>
        public void ModifyBackground(MenuItem menuItem)
        {
            List<MenuItem> allMenuItems = CollaborationUtil.GetChildObjects<System.Windows.Controls.MenuItem>(mu_leftMenu);
            foreach (var baseMenuItem in allMenuItems)
            {
                if (baseMenuItem.Header.ToString() == menuItem.Header.ToString())
                {
                    baseMenuItem.Background = new SolidColorBrush(Colors.Beige);
                }
                else
                {
                    baseMenuItem.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1E9FFF"));
                }
            }
        }

        #endregion

        /// <summary>
        /// 青蓝小助手
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_qlxzs_Click(object sender, RoutedEventArgs e)
        {
            this.Visibility = Visibility.Collapsed;

            StandardizedAssistantForm assistantForm = new StandardizedAssistantForm(this);
            assistantForm.Show();
        }

       
    }
}
