using CollaborativePlatformMain.DFEntity.MessageSubUtil;
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.Shapes;

namespace CollaborativePlatformMain.Form.MessageSubPage
{
    /// <summary>
    /// SeconMessagePage.xaml 的交互逻辑
    /// </summary>
    public partial class SeconMessagePage : Page
    {
        /// <summary>
        /// 父级窗体
        /// </summary>
        public HomepageForm Homepage;

        /// <summary>
        ///  有参构造
        /// </summary>
        /// <param name="homepageForm">父级窗体</param>
        public SeconMessagePage(HomepageForm homepageForm)
        {
            InitializeComponent();
            Homepage = homepageForm;
        }


        public List<MessageData> tongzhis1 = new List<MessageData>();
        public List<MessageData> tongzhis2 = new List<MessageData>();

        public List<MessageData> xiangmu1 = new List<MessageData>();
        public List<MessageData> xiangmu2 = new List<MessageData>();

        public List<MessageData> xitong1 = new List<MessageData>();
        public List<MessageData> xitong2 = new List<MessageData>();




        /// <summary>
        /// 窗体初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List<string> secondaryNodes = new List<string>() { "通知公告", "项目", "系统" };

            for (int i = 0; i < secondaryNodes.Count; i++)
            {


                if (i == 0)
                {
                    List<string> projects = new List<string>() { "国博城项目总消息", "北京大兴项目总消息", "绿地项目总消息" };

                    MessageData messageData = new MessageData();
                    messageData.SeconNode = secondaryNodes[i];
                    messageData.ThreeNodes = projects;
                    tongzhis1.Add(messageData);

                    for (int j = 0; j < projects.Count; j++)
                    {
                        MessageData threeData = new MessageData();
                        threeData.SeconNode = projects[j];
                        if (j == 0)
                        {
                            List<string> nodes = new List<string>() { "按甲方要求,国博城项目务必在4月15号之前完成报审版。" };
                            threeData.ThreeNodes = nodes;
                        }
                        else if (j == 1)
                        {
                            List<string> nodes = new List<string>() { "按甲方要求,北京大兴项目务必在4月22号之前完成报审版。" };
                            threeData.ThreeNodes = nodes;
                        }
                        else if (j == 2)
                        {
                            List<string> nodes = new List<string>() { "按甲方要求,绿地项目务必在4月30号之前完成报审版。" };
                            threeData.ThreeNodes = nodes;
                        }
                        tongzhis2.Add(threeData);
                    }
                }
                else if (i == 1)
                {
                    List<string> projects = new List<string>() { "国博城项目建筑图纸更新", "北京大兴项目结构图纸更新", "绿地项目人防图纸更新" };

                    MessageData messageData = new MessageData();
                    messageData.SeconNode = secondaryNodes[i];
                    messageData.ThreeNodes = projects;
                    xiangmu1.Add(messageData);

                    for (int j = 0; j < projects.Count; j++)
                    {
                        MessageData threeData = new MessageData();
                        threeData.SeconNode = projects[j];
                        if (j == 0)
                        {
                            List<string> nodes = new List<string>() { "国博城项目建筑1#楼3层更新。" };
                            threeData.ThreeNodes = nodes;
                        }
                        else if (j == 1)
                        {
                            List<string> nodes = new List<string>() { "北京大兴项目结构2#楼1层墙柱平法图更新。" };
                            threeData.ThreeNodes = nodes;
                        }
                        else if (j == 2)
                        {
                            List<string> nodes = new List<string>() { "绿地项目地下人防图更新。" };
                            threeData.ThreeNodes = nodes;
                        }
                        xiangmu2.Add(threeData);
                    }
                }
                else if (i == 2)
                {
                    List<string> projects = new List<string>() { "系统更新", "停服升级" };

                    MessageData messageData = new MessageData();
                    messageData.SeconNode = secondaryNodes[i];
                    messageData.ThreeNodes = projects;
                    xitong1.Add(messageData);

                    for (int j = 0; j < projects.Count; j++)
                    {
                        MessageData threeData = new MessageData();
                        threeData.SeconNode = projects[j];
                        if (j == 0)
                        {
                            List<string> nodes = new List<string>() { "交互平台版本更新至2.0版本",
                                                                      "  本次更新了:",
                                                                      "    1.主界面消息分组。",
                                                                      "    2.修改了登陆界面。",
                                                                      "   请及时更新！！",};
                            threeData.ThreeNodes = nodes;
                        }
                        else if (j == 1)
                        {
                            List<string> nodes = new List<string>() { "交互平台版本将在4月13日8点20分至4月13日8点50分进行停服更新",
                                                                       "本次停服更新不会导致您的数据丢失。"};
                            threeData.ThreeNodes = nodes;
                        }
                        xitong2.Add(threeData);
                    }
                }
            }

            me_message.Children.Clear();
            foreach (var item in tongzhis2)
            {
                Button button = new Button();
                button.Content = item.SeconNode;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                button.Tag = item;
                button.Click += new RoutedEventHandler(messageBtnClick);
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                me_message.Children.Add(button);
            }
        }

        /// <summary>
        /// 二级菜单选中的元素
        /// </summary>
        public static string SelectNode = "";

        /// <summary>
        /// 通知公告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_announcementClick(object sender, RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;
            if (menu == null) return;

            me_message.Children.Clear();
            foreach (var item in tongzhis2)
            {
                Button button = new Button();
                button.Content = item.SeconNode;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                button.Background= Brushes.WhiteSmoke;
                button.Visibility = Visibility.Visible;
                button.Click += new RoutedEventHandler(messageBtnClick);
                button.Tag = item;
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                me_message.Children.Add(button);
            }

            SelectNode = menu.Header.ToString();
        }

        /// <summary>
        /// 项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_projectClick(object sender, RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;
            if (menu == null) return;

            me_message.Children.Clear();
            foreach (var item in xiangmu2)
            {
                Button button = new Button();
                button.Content = item.SeconNode;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                button.Tag = item;
                button.Click += new RoutedEventHandler(messageBtnClick);
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                me_message.Children.Add(button);
            }

            SelectNode = menu.Header.ToString();
        }

        /// <summary>
        /// 系统
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_systemClick(object sender, RoutedEventArgs e)
        {
            MenuItem menu = sender as MenuItem;
            if (menu == null) return;

            me_message.Children.Clear();
            foreach (var item in xitong2)
            {
                Button button = new Button();
                button.Content = item.SeconNode;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                button.Tag = item;
                button.Click += new RoutedEventHandler(messageBtnClick);
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                me_message.Children.Add(button);
            }

            SelectNode = menu.Header.ToString();
        }


        /// <summary>
        /// 具体消息按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void messageBtnClick(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            MessageData announcement = button.Tag as MessageData;
            if (announcement == null) return;
            List<string> specificContent = announcement.ThreeNodes;

            me_right.Children.Clear();
            foreach (var specificConten in specificContent)
            {
                TextBlock textBlock = new TextBlock();
                textBlock.Text = specificConten;
                textBlock.FontSize = 15;
                textBlock.FontFamily = new FontFamily("黑体");
                me_right.Children.Add(textBlock);
            }

            if (SelectNode.Equals("项目"))
            {
                DockPanel dockPanel = new DockPanel();
                dockPanel.Margin = new Thickness(0, 10, 30, 0);
                dockPanel.HorizontalAlignment = HorizontalAlignment.Right;

                TextBlock textBlock = new TextBlock();
                textBlock.Text = "查看";
                textBlock.FontSize = 13;
                textBlock.Foreground = new SolidColorBrush(Colors.Green);
                textBlock.TextDecorations = TextDecorations.Underline;
                textBlock.Margin = new Thickness(0, 0, 10, 0);
                textBlock.FontFamily = new FontFamily("黑体");
                //textBlock.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(Message_Look);

                dockPanel.Children.Add(textBlock);

                TextBlock textBlock2 = new TextBlock();
                textBlock2.Text = "忽略";
                textBlock2.FontSize = 13;
                textBlock2.FontFamily = new FontFamily("黑体");
                textBlock2.Foreground = new SolidColorBrush(Colors.Green);
                textBlock2.TextDecorations = TextDecorations.Underline;
                //textBlock2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(Message_Ignore);

                dockPanel.Children.Add(textBlock2);
                me_right.Children.Add(dockPanel);
            }
        }


    }
}
