using CollaborativePlatformMain.DFEntity.MessageSubUtil;
using CollaborativePlatformMain.Form.MessageSubPage.CreatLevel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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>
    /// SeconThreeDimensionalPage.xaml 的交互逻辑
    /// </summary>
    public partial class SeconThreeDimensionalPage : Page
    {
        /// <summary>
        /// 父级窗体
        /// </summary>
        public HomepageForm Homepage;

        /// <summary>
        /// 三维模型数据
        /// </summary>
        public List<ThreeModelEntity> ThreeModelEntities = new List<ThreeModelEntity>();

        /// <summary>
        /// 标高信息
        /// </summary>
        public ObservableCollection<LevelTableEntity> LevelTableEntities = new ObservableCollection<LevelTableEntity>();


        public SeconThreeDimensionalPage(HomepageForm homepage)
        {
            InitializeComponent();
            Homepage = homepage;
        }

        /// <summary>
        /// 窗体初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ThreeModelEntities = new List<ThreeModelEntity>();
            ThreeModelEntity threeModelEntity1 = new ThreeModelEntity("自动建模", new List<ThreeModelEntity>());
            ThreeModelEntity subData1 = new ThreeModelEntity("碰撞检查");
            ThreeModelEntity subData2 = new ThreeModelEntity("净高分析");
            ThreeModelEntity subData3 = new ThreeModelEntity("条文审查");
            ThreeModelEntity threeModelEntity2 = new ThreeModelEntity("模型应用", new List<ThreeModelEntity>() { subData1, subData2, subData3 });
            ThreeModelEntity threeModelEntity3 = new ThreeModelEntity("模型服务", new List<ThreeModelEntity>());
            ThreeModelEntities.Add(threeModelEntity1);
            ThreeModelEntities.Add(threeModelEntity2);
            ThreeModelEntities.Add(threeModelEntity3);

            tr_threemodel.ItemsSource = null;
            tr_threemodel.ItemsSource = ThreeModelEntities;


            //bt_autoModel.BorderThickness = new Thickness(0);
            //bt_modelUser.BorderThickness = new Thickness(0);
            //bt_modelEmploy.BorderThickness = new Thickness(0);
        }

        /// <summary>
        /// 自动建模
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_autoModel_Click(object sender, RoutedEventArgs e)
        {
            sp_autoModel.Visibility = Visibility.Visible;
            sp_modelUser.Visibility = Visibility.Collapsed;
            sp_modelEmploy.Visibility = Visibility.Collapsed;
        }

        /// <summary>
        /// 模型应用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_modelUser_Click(object sender, RoutedEventArgs e)
        {
            sp_autoModel.Visibility = Visibility.Collapsed;
            sp_modelUser.Visibility = Visibility.Visible;
            sp_modelEmploy.Visibility = Visibility.Collapsed;
        }

        /// <summary>
        /// 模型服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_modelEmploy_Click(object sender, RoutedEventArgs e)
        {
            sp_autoModel.Visibility = Visibility.Collapsed;
            sp_modelUser.Visibility = Visibility.Collapsed;
            sp_modelEmploy.Visibility = Visibility.Visible;
        }

        /// <summary>
        /// 创建标高体系
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_creatLevel_Click(object sender, RoutedEventArgs e)
        {
            CreatLevelForm creatLevelForm = new CreatLevelForm(this);
            creatLevelForm.Show();
        }

        /// <summary>
        /// 设置标高
        /// </summary>
        public void SetLevelData()
        {
            sp_creatLevel.Children.Clear();
            foreach (var levelTableEntity in LevelTableEntities)
            {
                Label label = new Label();
                label.Content = levelTableEntity.LevelNmae;
                label.BorderThickness = new Thickness(0);
                label.HorizontalAlignment = HorizontalAlignment.Left;
                //label.Width = 80;

                Button button = new Button();
                button.Content = "上传图纸";
                button.BorderThickness = new Thickness(0);
                button.Width = 80;
                button.HorizontalAlignment = HorizontalAlignment.Left;
                button.Click += new RoutedEventHandler(UploadDrawings);

                DockPanel dockPanel = new DockPanel();
                dockPanel.Children.Add(label);
                dockPanel.Children.Add(button);

                sp_creatLevel.Children.Add(dockPanel);
            }

        }

        /// <summary>
        /// 上传图纸-CAD截取
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UploadDrawings(object sender, RoutedEventArgs e)
        {

        }


        /// <summary>
        /// 上传图纸到服务器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void upDrawing_Click(object sender, RoutedEventArgs e)
        {
            int a = 1;
        }

        private void tr_threemodel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        /// <summary>
        /// 点击数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            string value = button.Content.ToString();
            if (value == "自动建模")
            {
                sp_autoModel.Visibility = Visibility.Visible;
                sp_modelUser.Visibility = Visibility.Collapsed;
                sp_modelEmploy.Visibility = Visibility.Collapsed;
            }
            else if (value == "模型应用")
            {
                sp_autoModel.Visibility = Visibility.Collapsed;
                sp_modelUser.Visibility = Visibility.Visible;
                sp_modelEmploy.Visibility = Visibility.Collapsed;
            }
            else if (value=="模型服务")
            {
                sp_autoModel.Visibility = Visibility.Collapsed;
                sp_modelUser.Visibility = Visibility.Collapsed;
                sp_modelEmploy.Visibility = Visibility.Visible;
            }
            else if (value == "碰撞检查")
            {
                sp_autoModel.Visibility = Visibility.Collapsed;
                sp_modelUser.Visibility = Visibility.Visible;
                sp_modelEmploy.Visibility = Visibility.Collapsed;
            }
            else if (value == "净高分析")
            {
                sp_autoModel.Visibility = Visibility.Collapsed;
                sp_modelUser.Visibility = Visibility.Visible;
                sp_modelEmploy.Visibility = Visibility.Collapsed;
            }
            else if (value == "条文审查")
            {
                sp_autoModel.Visibility = Visibility.Collapsed;
                sp_modelUser.Visibility = Visibility.Visible;
                sp_modelEmploy.Visibility = Visibility.Collapsed;
            }
        }


        /// <summary>
        /// 鼠标双击类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {

        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            TextBox textBox = new TextBox();
            textBox.Width = 80;
            textBox.Margin = new Thickness(0, 5, 0, 0);
            sp_objectName.Children.Add(textBox);

            Button button = new Button();
            button.Width = 80;
            button.Content = "上传";
            button.Margin = new Thickness(0, 5, 0, 0);
            sp_objectDraw.Children.Add(button);
        }
    }
}
