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.Reflection.Metadata;
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.Media.Media3D;
using System.Windows.Shapes;
using static System.Net.Mime.MediaTypeNames;
using System.Xml.Linq;
using Window = System.Windows.Window;
using MessageBox = System.Windows.MessageBox;
using System.Resources;
using System.Windows.Interop;
using CollaborativePlatformProject.CollaborationPlatform.Entity;
using CollaborativePlatformProject.CollaborationPlatform.Util;
using CollaborativePlatformProject.FormLibrary.CheckboxButton;
using HandyControl.Interactivity;

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

        #region 最左边消息

        /// <summary>
        /// 消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void message_Click(object sender, MouseButtonEventArgs e)
        {
            SwitchMethod(sender as MenuItem, true);
        }

        /// <summary>
        /// 项目下TreeView绑定的数据
        /// </summary>
        private List<TreeViewBind> treeViewBinds = new List<TreeViewBind>();

        /// <summary>
        /// 项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void project_Click(object sender, MouseButtonEventArgs e)
        {
            SwitchMethod(sender as MenuItem, false);
            treeViewBinds = new List<TreeViewBind>();

            treeViewBinds.Add(
                new TreeViewBind("小学项目",
                    new List<TreeViewBind>()
                    {
                        new TreeViewBind("一号楼",
                            new List<TreeViewBind>()
                            {
                                new TreeViewBind("项目信息"),
                                new TreeViewBind("团队成员"),
                                new TreeViewBind("工作台", true),
                                new TreeViewBind("自定义"),
                                new TreeViewBind("+")
                            }),
                        new TreeViewBind("二号楼",
                            new List<TreeViewBind>()
                            {
                                new TreeViewBind("项目信息"),
                                new TreeViewBind("团队成员"),
                                new TreeViewBind("工作台", true),
                                new TreeViewBind("自定义"),
                                new TreeViewBind("+")
                            }),
                        new TreeViewBind("三号楼",
                            new List<TreeViewBind>()
                            {
                                new TreeViewBind("项目信息"),
                                new TreeViewBind("团队成员"),
                                new TreeViewBind("工作台", true),
                                new TreeViewBind("自定义"),
                                new TreeViewBind("+")
                            })
                    }));

            tr_vw.ItemsSource = null;
            tr_vw.ItemsSource = treeViewBinds;
        }

        /// <summary>
        /// 联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void contacts_Click(object sender, MouseButtonEventArgs e)
        {
            SwitchMethod(sender as MenuItem, false);

            List<string> sLists = new List<string>() { "建筑负责人", "结构负责人", "给排水负责人" };
            sp_contacts.Children.Clear();
            foreach (string s in sLists)
            {
                Button button = new Button();
                button.Content = s;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                //button.Click += new RoutedEventHandler(toolnavigation_Click);
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                sp_contacts.Children.Add(button);
            }
        }

        /// <summary>
        /// 图库大样图
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gallery_Click(object sender, MouseButtonEventArgs e)
        {
            SwitchMethod(sender as MenuItem, false);
        }

        /// <summary>
        /// 工具库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tool_Click(object sender, MouseButtonEventArgs e)
        {
            SwitchMethod(sender as MenuItem, false);

            List<string> sLists = new List<string>() { "平台图纸治理", "块处理", "大样处理", "图纸对比", "二维审查", "三维" };
            sp_tools.Children.Clear();
            foreach (string s in sLists)
            {
                Button button = new Button();
                button.Content = s;
                button.BorderThickness = new Thickness(0);
                button.Width = 180;
                button.Height = 30;
                button.Click += new RoutedEventHandler(toolnavigation_Click);
                button.HorizontalContentAlignment = HorizontalAlignment.Left;
                sp_tools.Children.Add(button);
            }

            if (ToolsForm == null)
            {
                ToolsForm = new ToolsForm(this, ToolLists);
                ToolsForm.Show();
            }
        }

        /// <summary>
        /// 设置最左测导航的颜色和上边导航的显隐
        /// </summary>
        /// <param name="menuItem"></param>
        /// <param name="isHoShow"></param>
        public void SwitchMethod(MenuItem menuItem, bool isHoShow)
        {
            if (isHoShow)
            {
                sp_hzNavigation.Visibility = Visibility.Visible;
            }
            else
            {
                sp_hzNavigation.Visibility = Visibility.Collapsed;
            }

            List<MenuItem> mis = CollaborationUtil.GetChildObjects<System.Windows.Controls.MenuItem>(mu_leftMenu);

            foreach (MenuItem mi in mis)
            {
                mi.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#1E9FFF"));
                if (mi.Header.ToString().Replace(" ", "").Equals("消息"))
                {
                    dp_message.Visibility = Visibility.Collapsed;
                }
                else if (mi.Header.ToString().Replace(" ", "").Equals("项目"))
                {
                    dp_project.Visibility = Visibility.Collapsed;
                }
                else if (mi.Header.ToString().Replace(" ", "").Equals("工具库"))
                {
                    dp_tools.Visibility = Visibility.Collapsed;
                }
                else if (mi.Header.ToString().Replace(" ", "").Equals("联系人"))
                {
                    dp_contacts.Visibility = Visibility.Collapsed;
                }
            }

            if (menuItem.Header.ToString().Replace(" ", "").Equals("消息"))
            {
                dp_message.Visibility = Visibility.Visible;
            }
            else if (menuItem.Header.ToString().Replace(" ", "").Equals("项目"))
            {
                dp_project.Visibility = Visibility.Visible;
            }
            else if (menuItem.Header.ToString().Replace(" ", "").Equals("工具库"))
            {
                dp_tools.Visibility = Visibility.Visible;
            }
            else if (menuItem.Header.ToString().Replace(" ", "").Equals("联系人"))
            {
                dp_contacts.Visibility = Visibility.Visible;
            }

            menuItem.Background = new SolidColorBrush(Colors.Beige);
            me_message.Children.Clear();
        }

        #endregion

        #region 工具中间按钮

        private ObservableCollection<CBButtonControlsData> ToolLists = new ObservableCollection<CBButtonControlsData>();

        /// <summary>
        /// 功能名字对应的功能数据
        /// </summary>
        private Dictionary<string, ObservableCollection<CBButtonControlsData>> ToolName_ToolDatas = new Dictionary<string, ObservableCollection<CBButtonControlsData>>()
        {
            {
                "平台图纸治理",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("功能1",false,""),
                    new CBButtonControlsData("功能2",false,""),
                    new CBButtonControlsData("功能3",false,""),
                    new CBButtonControlsData("功能4",false,""),
                    new CBButtonControlsData("功能5",false,""),
                    new CBButtonControlsData("功能6",false,""),
                    new CBButtonControlsData("功能7",false,""),
                    new CBButtonControlsData("功能8",false,""),
                }
            },
            {
                "块处理",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("处理1",false,""),
                    new CBButtonControlsData("处理2",false,""),
                    new CBButtonControlsData("处理3",false,""),
                    new CBButtonControlsData("处理4",false,""),
                    new CBButtonControlsData("处理5",false,""),
                    new CBButtonControlsData("处理6",false,""),
                    new CBButtonControlsData("处理7",false,""),
                    new CBButtonControlsData("处理8",false,""),
                }
            },
            {
                "大样处理",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("大样1",false,""),
                    new CBButtonControlsData("大样2",false,""),
                    new CBButtonControlsData("大样3",false,""),
                    new CBButtonControlsData("大样4",false,""),
                    new CBButtonControlsData("大样5",false,""),
                    new CBButtonControlsData("大样6",false,""),
                    new CBButtonControlsData("大样7",false,""),
                    new CBButtonControlsData("大样8",false,""),
                }
            },
            {
                "图纸对比",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("图纸对比",false,"")
                }
            },
            {
                "二维审查",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("二维审查",false,"")
                }
            }, {
                "三维",new ObservableCollection<CBButtonControlsData>()
                {
                    new CBButtonControlsData("三维",false,"")
                }
            },
        };

        private void toolnavigation_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null && ToolName_ToolDatas.ContainsKey(button.Content.ToString()))
            {
                ObservableCollection<CBButtonControlsData> cbButtonControls = ToolName_ToolDatas[button.Content.ToString()];

                wp_tools.Children.Clear();

                foreach (var cbButtonControl in cbButtonControls)
                {
                    wp_tools.Children.Add(new CBButtonControls(cbButtonControl));
                }
            }
        }

        /// <summary>
        /// 添加漂浮工具
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_addTools(object sender, RoutedEventArgs e)
        {
            foreach (var tool in ToolName_ToolDatas)
            {
                foreach (var value in tool.Value)
                {
                    if (!value.CbIsCheck)
                    {
                        if (ToolLists.Where(x => x.Guid.Equals(value.Guid)).Count() > 0)
                        {
                            for (int i = 0; i < ToolLists.Count; i++)
                            {
                                if (ToolLists[i].Guid.Equals(value.Guid))
                                {
                                    ToolLists.RemoveAt(i);
                                    i--;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (ToolLists.Where(x => x.Guid.Equals(value.Guid)).Count() > 0) continue;
                        ToolLists.Add(value);
                    }
                }
            }
        }

        /// <summary>
        /// 悬浮窗窗体
        /// </summary>
        public ToolsForm ToolsForm;

        /// <summary>
        /// 悬浮窗
        /// </summary>
        private ObservableCollection<LVProjectInfoEntity> ToolDatas = new ObservableCollection<LVProjectInfoEntity>()
        {
            new LVProjectInfoEntity("图纸对比", ""),
            new LVProjectInfoEntity("超模全解析", ""),
            new LVProjectInfoEntity("超模数字化建模", "")
        };

        #endregion

        #region 中间的按钮

        private void General_Click(object sender, MouseButtonEventArgs e)
        {
        }

        #endregion

        #region 横向通知消息栏

        private List<Button> menuItems = new List<Button>();

        /// <summary>
        /// 通知公告数据
        /// </summary>
        private List<NotificationAnnouncement> notificationDatas = new List<NotificationAnnouncement>();

        /// <summary>
        /// 通知公告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_announcementClick(object sender, RoutedEventArgs e)
        {
            notificationDatas = new List<NotificationAnnouncement>();

            for (int i = 0; i < new List<string>() { "国博城项目建筑图纸更新", "北京大兴项目结构图纸更新", "绿地项目人防图纸更新" }.Count; i++)
            {
                NotificationAnnouncement notificationAnnouncement = new NotificationAnnouncement();
                notificationAnnouncement.MessageCategory = "通知公告";

                if (i == 0)
                {
                    notificationAnnouncement.Content = "国博城项目总消息";
                    notificationAnnouncement.SpecificContent = "按甲方要求,国博城项目务必在4月15号之前完成报审版。";
                }
                else if (i == 1)
                {
                    notificationAnnouncement.Content = "北京大兴项目总消息";
                    notificationAnnouncement.SpecificContent = "按甲方要求,北京大兴项目务必在4月22号之前完成报审版。";
                }
                else if (i == 2)
                {
                    notificationAnnouncement.Content = "绿地项目总消息";
                    notificationAnnouncement.SpecificContent = "按甲方要求,绿地项目务必在4月30号之前完成报审版。";
                }

                notificationDatas.Add(notificationAnnouncement);
            }

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

        /// <summary>
        /// 项目
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_projectClick(object sender, RoutedEventArgs e)
        {
            notificationDatas = new List<NotificationAnnouncement>();
            foreach (var xiangmu in new List<string>() { "国博城项目建筑图纸更新", "北京大兴项目结构图纸更新", "绿地项目人防图纸更新" })
            {
                NotificationAnnouncement notificationAnnouncement = new NotificationAnnouncement();
                notificationAnnouncement.Content = xiangmu;
                notificationAnnouncement.MessageCategory = "项目消息";

                if (xiangmu.Equals("国博城项目建筑图纸更新"))
                {
                    notificationAnnouncement.SpecificContent = "国博城项目建筑1#楼3层更新。";
                }
                else if (xiangmu.Equals("北京大兴项目结构图纸更新"))
                {
                    notificationAnnouncement.SpecificContent = "北京大兴项目结构2#楼1层墙柱平法图更新。";
                }
                else if (xiangmu.Equals("绿地项目人防图纸更新"))
                {
                    notificationAnnouncement.SpecificContent = "绿地项目地下人防图更新。";
                }

                notificationDatas.Add(notificationAnnouncement);
            }

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

        /// <summary>
        /// 系统
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void me_systemClick(object sender, RoutedEventArgs e)
        {
            NotificationAnnouncement notificationAnnouncement = new NotificationAnnouncement();
            notificationAnnouncement.Content = "系统更新";
            notificationAnnouncement.SpecificContent = "交互平台版本更新至2.0版本/n   本次更新了:/n    1.主界面消息分组。/n    2.修改了登陆界面。/n   请及时更新！！";
            notificationAnnouncement.MessageCategory = "系统消息";
            NotificationAnnouncement notificationAnnouncement2 = new NotificationAnnouncement();
            notificationAnnouncement2.Content = "停服升级";
            notificationAnnouncement2.SpecificContent = "交互平台版本将在4月13日8点20分至4月13日8点50分进行停服更新/n本次停服更新不会导致您的数据丢失。";
            notificationAnnouncement2.MessageCategory = "系统消息";
            notificationDatas = new List<NotificationAnnouncement>()
            {
                notificationAnnouncement,
                notificationAnnouncement2
        };

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

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

            NotificationAnnouncement announcement = button.Tag as NotificationAnnouncement;

            List<string> specificContent = announcement.SpecificContent.Split("/n").ToList();

            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 (announcement.MessageCategory.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("黑体");

                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;
                dockPanel.Children.Add(textBlock2);
                me_right.Children.Add(dockPanel);
            }
        }

        #endregion

        #region 项目中间部分

        /// <summary>
        /// 项目信息示例
        /// </summary>
        private ObservableCollection<LVProjectInfoEntity> lvProjects = new ObservableCollection<LVProjectInfoEntity>()
        {
            new LVProjectInfoEntity("项目名称：", "北京大兴项目"),
            new LVProjectInfoEntity("项目业态：", "住宅"),
            new LVProjectInfoEntity("项目地址：", "山东省济南市"),
            new LVProjectInfoEntity("项目团队：", "项目团队")
        };

        /// <summary>
        /// 项目信息示例
        /// </summary>
        private ObservableCollection<LVTeamMembersEntity> lvTeamMemberss = new ObservableCollection<LVTeamMembersEntity>()
        {
            new LVTeamMembersEntity("主管：", "李明"),
            new LVTeamMembersEntity("建筑组员：", "李明"),
            new LVTeamMembersEntity("结构组员：", "张修"),
            new LVTeamMembersEntity("给排水组员：", "邢华"),
            new LVTeamMembersEntity("暖通组员：", "杨程"),
            new LVTeamMembersEntity("电气组员：", "欧瑞"),
        };

        /// <summary>
        /// 项目TreeView
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tv_projectLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            #region 隐藏所有的无用控件

            lv_projectInfo.Visibility = Visibility.Collapsed;
            sp_info.Visibility = Visibility.Collapsed;
            sp_work.Visibility = Visibility.Collapsed;
            sp_addPro.Visibility = Visibility.Collapsed;

            #endregion

            TreeViewBind treeView = tr_vw.SelectedItem as TreeViewBind;
            if (treeView == null) return;

            string name = treeView.Name;

            if (name.Equals("项目信息"))
            {
                sp_info.Visibility = Visibility.Visible;
                lv_projectInfo.Visibility = Visibility.Visible;
                lv_projectInfo.ItemsSource = null;
                lv_projectInfo.ItemsSource = lvProjects;
            }
            else if (name.Equals("团队成员"))
            {
                sp_info.Visibility = Visibility.Visible;
                lv_projectInfo.Visibility = Visibility.Visible;
                lv_projectInfo.ItemsSource = null;
                lv_projectInfo.ItemsSource = lvTeamMemberss;
            }
            else if (name.Equals("工作台"))
            {
                sp_work.Visibility = Visibility.Visible;
                tr_is.ItemsSource = null;
                if (!treeView.IsPro)
                {
                    List<TreeViewBind> TreeViewDatas = new List<TreeViewBind>();

                    TreeViewDatas.Add(new TreeViewBind("小学项目", new List<TreeViewBind>() { new TreeViewBind("新建图纸") }));

                    this.tr_is.ItemsSource = TreeViewDatas;
                }
                else
                {
                    this.tr_is.ItemsSource = TreeViewDatas;
                }
            }
            else if (name.Equals("自定义"))
            {
            }
        }

        /// <summary>
        /// lv内修改按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_lv_update(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            LVProjectInfoEntity lvProjectInfo = button.Tag as LVProjectInfoEntity;
            if (lvProjectInfo != null)
            {
            }
        }

        /// <summary>
        /// 上传图纸
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            TreeViewBind treeViewBind = TreeViewDatas.First(s => s.Name.Equals("小学项目 一号楼"));
            UploadDrawingForm upWindow = new UploadDrawingForm(TreeViewDatas);

            foreach (var item in treeViewBind.Children)
            {
                if (item.Name.Equals("上传新图")) continue;
                upWindow.str.Add(item.Name);
            }

            upWindow.ShowDialog();

            this.tr_is.ItemsSource = null;
            this.tr_is.ItemsSource = TreeViewDatas;
        }

        #region 工作台

        /// <summary>
        ///  工作台数据绑定
        /// </summary>
        public static ObservableCollection<TreeViewBind> TreeViewDatas = new ObservableCollection<TreeViewBind>()
        {
            new TreeViewBind("小学项目 一号楼",
                new List<TreeViewBind>()
                {
                    new TreeViewBind("上传图纸")
                })
        };

        /// <summary>
        /// 版本名称
        /// </summary>
        private List<string> ProVersions = new List<string>();

        /// <summary>
        /// 本专业
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pre_Click(object sender, MouseButtonEventArgs e)
        {
            tr_all.Visibility = Visibility.Collapsed;
            tr_is.Visibility = Visibility.Visible;
            bt_proBig.Visibility = Visibility.Collapsed;
        }

        /// <summary>
        /// 全专业
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void all_Click(object sender, MouseButtonEventArgs e)
        {
            tr_is.Visibility = Visibility.Collapsed;
            tr_all.Visibility = Visibility.Visible;
            tv_building.ItemsSource = null;
            tv_building.ItemsSource = TreeViewDatas;
            bt_proBig.Visibility = Visibility.Visible;
        }

        /// <summary>
        /// treeview点击
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tr_is_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            TreeViewBind treeView = tr_is.SelectedItem as TreeViewBind;

            //切换展开和下拉
            if (treeView == null)
            {
                return;
            }
            if (tr_is.ItemContainerGenerator.ContainerFromItem(treeView) is TreeViewItem currentItem)
            {
                if (!currentItem.IsExpanded)
                {
                    currentItem.IsExpanded = true;
                }
                else
                {
                    currentItem.IsExpanded = false;
                }
            }

            if (treeView.Name.Contains("更新图纸"))
            {
                TreeViewBind treeViewBind = TreeViewDatas.First(s => s.Name.Equals("小学项目 一号楼"));
                UploadDrawingForm upWindow = new UploadDrawingForm(TreeViewDatas);

                foreach (var item in treeViewBind.Children)
                {
                    if (item.Name.Equals("治理图纸")) break;
                    upWindow.str.Add(item.Name);
                }
                upWindow.ShowDialog();
                string t7 = DateTime.Now.ToShortTimeString();
                string t3 = DateTime.Now.ToLongDateString() + t7;

                string proVersion = "";

                if (ProVersions.Contains(t3 + "版本"))
                {
                    int proVersionIndex = 0;

                    for (int i = 0; i < 100; i++)
                    {
                        int j = i + 1;

                        if (ProVersions.Contains(t3 + "（" + j + "）" + "版本"))
                        {
                            continue;
                        }
                        else
                        {
                            proVersionIndex = i + 1;
                            break;
                        }
                    }

                    proVersion = t3 + "（" + proVersionIndex + "）" + "版本";
                }
                else
                {
                    proVersion = t3 + "版本";
                }

                ProVersions.Add(proVersion);
                TreeViewBind TreeViewBind1 = new TreeViewBind(proVersion, new List<TreeViewBind>()
                    {
                        new TreeViewBind("原图"),
                        new TreeViewBind("对比图"),
                        new TreeViewBind("治理图纸", new List<TreeViewBind>()
                        {
                            new TreeViewBind("F1"),
                            new TreeViewBind("F2",
                                new List<TreeViewBind>()
                                {
                                    new TreeViewBind("墙柱"),
                                    new TreeViewBind("门窗"),
                                    new TreeViewBind("功能区标签"),
                                    new TreeViewBind("未命名")
                                })
                        })
                    });

                int index = CollaborationUtil.GetIndexByTreeView("更新图纸", TreeViewDatas.FirstOrDefault().Children);
                TreeViewDatas.FirstOrDefault().Children.Insert(index, TreeViewBind1);

                this.tr_is.ItemsSource = null;
                this.tr_is.ItemsSource = TreeViewDatas;
            }
            else if (treeView.Name.Contains("上传图纸"))
            {
                string t7 = DateTime.Now.ToShortTimeString();
                string t3 = DateTime.Now.ToLongDateString() + t7;

                ProVersions.Add(t3 + "版本");
                TreeViewBind TreeViewBind1 = new TreeViewBind(t3 + "版本", new List<TreeViewBind>()
                {
                    new TreeViewBind("原图"),
                    new TreeViewBind("治理图纸", new List<TreeViewBind>()
                    {
                        new TreeViewBind("F1"),
                        new TreeViewBind("F2",
                            new List<TreeViewBind>()
                            {
                                new TreeViewBind("墙柱"),
                                new TreeViewBind("门窗"),
                                new TreeViewBind("功能区标签"),
                                new TreeViewBind("未命名")
                            })
                    })
                });
                TreeViewDatas.FirstOrDefault().Children.Insert(0, TreeViewBind1);
                TreeViewDatas.FirstOrDefault().Children.Add(new TreeViewBind("更新图纸"));

                for (int i = 0; i < TreeViewDatas.FirstOrDefault().Children.Count; i++)
                {
                    if (TreeViewDatas.FirstOrDefault().Children[i].Name.Equals("上传图纸"))
                    {
                        TreeViewDatas.FirstOrDefault().Children.RemoveAt(i);
                        i--;
                        break;
                    }
                }

                tr_is.ItemsSource = null;
                tr_is.ItemsSource = TreeViewDatas;
            }
        }

        /// <summary>
        /// 放大
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_proBigClick(object sender, RoutedEventArgs e)
        {
            ProjectForm projectForm = new ProjectForm(this, TreeViewDatas);

            this.Hide();
            projectForm.ShowDialog();
            this.Show();
        }

        #endregion

        #region 新增项目

        private void bt_addPro(object sender, RoutedEventArgs e)
        {
            #region 隐藏所有的无用控件

            lv_projectInfo.Visibility = Visibility.Collapsed;
            sp_info.Visibility = Visibility.Collapsed;
            sp_work.Visibility = Visibility.Collapsed;

            #endregion

            sp_addPro.Visibility = Visibility.Visible;
        }

        private void close_Click(object sender, RoutedEventArgs e)
        {
            gd_top.Visibility = Visibility.Collapsed;
        }

        private void bd_Initialized(object sender, EventArgs e)
        {
        }

        private void st_Initialized(object sender, EventArgs e)
        {
        }

        private void wt_Initialized(object sender, EventArgs e)
        {
        }

        private void wm_Initialized(object sender, EventArgs e)
        {
        }

        private void ele_Initialized(object sender, EventArgs e)
        {
        }

        private void submit_Click(object sender, RoutedEventArgs e)
        {
        }

        private void saveFile_Click(object sender, RoutedEventArgs e)
        {
        }

        private void savePage_Click(object sender, RoutedEventArgs e)
        {
        }

        private void ele_Click(object sender, RoutedEventArgs e)
        {
        }

        private void wm_Click(object sender, RoutedEventArgs e)
        {
        }

        private void wt_Click(object sender, RoutedEventArgs e)
        {
        }

        private void st_Click(object sender, RoutedEventArgs e)
        {
        }

        private void bd_Click(object sender, RoutedEventArgs e)
        {
        }

        #endregion

        #endregion
    }
}