using CollaborativePlatformMain.DFEntity.MessageSubUtil;
using CollaborativePlatformMain.Form.MessageSubPage.AddImage;
using CollaborativePlatformMain.Util;
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>
    /// SeconLegendPage.xaml 的交互逻辑
    /// </summary>
    public partial class SeconLegendPage : Page
    {
        public SeconLegendPage()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 文件夹名称
        /// </summary>
        public List<LegendEntity> LegendEntities = new List<LegendEntity>(); 


        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LegendEntity legendEntity1 = new LegendEntity("门窗大样", @"/Image/folderImage.png");
            LegendEntity legendEntity2 = new LegendEntity("家具", @"/Image/folderImage.png");
            LegendEntity legendEntity3 = new LegendEntity("户型", @"/Image/folderImage.png");
            LegendEntity legendEntity4 = new LegendEntity("墙体大样", @"/Image/folderImage.png");
            LegendEntity legendEntity5 = new LegendEntity("新增", @"/Image/add.png");
            LegendEntities.Add(legendEntity1);
            LegendEntities.Add(legendEntity2);
            LegendEntities.Add(legendEntity3);
            LegendEntities.Add(legendEntity4);
            LegendEntities.Add(legendEntity5);


            sv_legend.ItemsSource = null;
            sv_legend.ItemsSource = LegendEntities;
        }

        /// <summary>
        /// 最后的文件夹分级名字
        /// </summary>
        public string lastLegendName = "sp_add1";

        /// <summary>
        /// 最后个数命名序号
        /// </summary>
        public int Num = 1;

        /// <summary>
        /// 新增文件夹分级
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
        {
            StackPanel stackPanel = sender as StackPanel;
            if (stackPanel == null) return;

            Label label = stackPanel.FindName("lb_legendName") as Label;
            if (label == null) return;

            if (label.Content.ToString() == "新增")
            {
                AddImageForm addImageForm = new AddImageForm(this);
                addImageForm.ShowDialog();
            }
            else
            {

            }
        }


        /// <summary>
        /// 新增文件夹
        /// </summary>
        /// <param name="legendName"></param>
        public void AddLegendMath(string legendName)
        {
            //添加数据
            LegendEntity legendEntity=new LegendEntity(legendName, @"/Image/folderImage.png");
            int index = LegendEntities.Count - 1;
            LegendEntities.Insert(index, legendEntity);

            sv_legend.ItemsSource = null;
            sv_legend.ItemsSource = LegendEntities;

        }

        /// <summary>
        /// 点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {

        }

    }
}
