using CollaborativePlatformMain.DFEntity.MessageSubUtil;
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.Project
{
    /// <summary>
    /// OperatingFloorPage.xaml 的交互逻辑
    /// </summary>
    public partial class OperatingFloorPage : Page
    {
        /// <summary>
        /// 父级窗体
        /// </summary>
        public HomepageForm HomepageForm;

        /// <summary>
        /// 第一层级
        /// </summary>
        public static string FirstData = "";

        /// <summary>
        /// 是否第一次展示窗体
        /// </summary>
        public static bool IsFirstShow = false;

        public OperatingFloorPage(HomepageForm homepageForm, string firstData, bool isFirstShow)
        {
            InitializeComponent();
            HomepageForm = homepageForm;
            FirstData = firstData;
            IsFirstShow = isFirstShow;
        }

        /// <summary>
        /// 建筑展示数据
        /// </summary>
        public ObservableCollection<OperatEntity> ArchOperaDatas = new ObservableCollection<OperatEntity>();

        /// <summary>
        /// 结构展示数据
        /// </summary>
        public ObservableCollection<OperatEntity> StruOperaDatas = new ObservableCollection<OperatEntity>();

        /// <summary>
        /// 给排水展示数据
        /// </summary>
        public ObservableCollection<OperatEntity> WaterOperaDatas = new ObservableCollection<OperatEntity>();

        /// <summary>
        /// 暖通展示数据
        /// </summary>
        public ObservableCollection<OperatEntity> WarmOperaDatas = new ObservableCollection<OperatEntity>();

        /// <summary>
        /// 电气展示数据
        /// </summary>
        public ObservableCollection<OperatEntity> EleOperaDatas = new ObservableCollection<OperatEntity>();


        /// <summary>
        /// 全专业窗体
        /// </summary>
        public FullProfessionPage FullProfessionPage;

        /// <summary>
        /// 窗体初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (IsFirstShow)
            {
                ArchOperaDatas = new ObservableCollection<OperatEntity>();
                OperatEntity operatEntity = new OperatEntity(FirstData, "", new ObservableCollection<OperatEntity>(), false);
                ArchOperaDatas.Add(operatEntity);

                WarmOperaDatas = new ObservableCollection<OperatEntity>();
                operatEntity = new OperatEntity(FirstData, "", new ObservableCollection<OperatEntity>(), false);
                WarmOperaDatas.Add(operatEntity);

                tr_threemodel.ItemsSource = null;
                tr_threemodel.ItemsSource = ArchOperaDatas;

                IsFirstShow = false;
            }

            FullProfessionPage = new FullProfessionPage(HomepageForm);
            FullProfessionPage.Width = 483;
            FullProfessionPage.Height = 370;
            frame_FullProdess.Navigate(FullProfessionPage);
        }

        private void tr_threemodel_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

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


        /// <summary>
        /// 全专业
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void all_Click(object sender, MouseButtonEventArgs e)
        {
            sp_Single.Visibility = Visibility.Collapsed;
            sp_AllSingle.Visibility = Visibility.Visible;
        }


        /// <summary>
        /// 上传图纸
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_Upload_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button.Content.ToString().Contains("上传"))
            {
                UploadDrawingForm uploadDrawingForm = new UploadDrawingForm(this, false);
                uploadDrawingForm.Show();
                button.Content = "更新图纸";
            }
            else
            {
                UploadDrawingForm uploadDrawingForm = new UploadDrawingForm(this, true);
                uploadDrawingForm.Show();
            }
        }

        /// <summary>
        /// 更新数据
        /// </summary>
        public void ReplaceData()
        {
            tr_threemodel.ItemsSource = null;
            tr_threemodel.ItemsSource = ArchOperaDatas;

            FullProfessionPage.tr_threemodel.ItemsSource = ArchOperaDatas;
        }

        /// <summary>
        /// 放大事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bt_openBig_Click(object sender, RoutedEventArgs e)
        {
            BigFullProfessiongForm bigFullProfessiongForm = new BigFullProfessiongForm(HomepageForm, FullProfessionPage,this);
            bigFullProfessiongForm.Show();

            HomepageForm.Hide();
        }
    }
}
