using CollaborativePlatformMain.DFEntity;
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
{
    /// <summary>
    /// FloorDrawingForm.xaml 的交互逻辑
    /// </summary>
    public partial class FloorDrawingForm : Window
    {
        /// <summary>
        /// 父级窗体
        /// </summary>
        public UploadDrawingForm UploadDrawingForm;

        /// <summary>
        /// 窗体数据
        /// </summary>
        public List<FloorLayerData> FloorDatas = new List<FloorLayerData>();

        /// <summary>
        /// 楼层管理器
        /// </summary>
        public FloorDrawingForm(UploadDrawingForm uploadDrawingForm)
        {
            InitializeComponent();
            UploadDrawingForm = uploadDrawingForm;
        }

        /// <summary>
        /// 窗体初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Dictionary<int, string> keyValuePairs = new Dictionary<int, string>();
            keyValuePairs.Add(0, "墙体");
            keyValuePairs.Add(1, "门窗");
            keyValuePairs.Add(2, "房间标签");
            keyValuePairs.Add(3, "车位");

            int num = 1;
            for (int i = 0; i < 5; i++)
            {
                List<FloorLayerData> layerDatas = new List<FloorLayerData>();
                for (int j = 0; j < 4; j++)
                {
                    FloorLayerData layerData = new FloorLayerData(keyValuePairs[j]);
                    layerDatas.Add(layerData);
                    num++;
                }

                FloorDatas.Add(new FloorLayerData("F" + i, layerDatas));
            }

            sv_floor.ItemsSource = null;
            sv_floor.ItemsSource = FloorDatas;
        }

        /// <summary>
        /// 窗体关闭事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Closed(object sender, EventArgs e)
        {
            UploadDrawingForm.Visibility = Visibility.Visible;
        }

        /// <summary>
        /// 楼层鼠标点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tb_FloorName_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBlock textBlock = sender as TextBlock;
            if (textBlock == null) return;
            FloorLayerData floorLayerData = textBlock.DataContext as FloorLayerData;
            if (floorLayerData == null) return;

            sv_layer.ItemsSource = null;
            sv_layer.ItemsSource = floorLayerData.SubDatas;
        }

        /// <summary>
        /// 图层鼠标点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void tb_LayerName_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {

        }

        /// <summary>
        /// 确定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_determine_Click(object sender, RoutedEventArgs e)
        {
            UploadDrawingForm.ArchLayerDatas = FloorDatas;
            UploadDrawingForm.bt_xaunze.Background = Brushes.Green;

            Dictionary<int, string> keyValuePairs = new Dictionary<int, string>();
            keyValuePairs.Add(0, "风管");
            keyValuePairs.Add(1, "风机");
            keyValuePairs.Add(2, "风口");
            keyValuePairs.Add(3, "水管");

            List<FloorLayerData> warmDatas = new List<FloorLayerData>();
            int num = 1;
            for (int i = 0; i < 5; i++)
            {
                List<FloorLayerData> layerDatas = new List<FloorLayerData>();
                for (int j = 0; j < 4; j++)
                {
                    FloorLayerData layerData = new FloorLayerData(keyValuePairs[j]);
                    layerDatas.Add(layerData);
                    num++;
                }

                warmDatas.Add(new FloorLayerData("F" + i, layerDatas));
            }
            UploadDrawingForm.WarmLayerDatas = warmDatas;


            this.Close();
        }
    }
}
