using CollaborativePlatformMain.DFEntity.MessageSubUtil;
using CollaborativePlatformMain.Form.MessageSubPage.AddImage;
using CollaborativePlatformMain.Form.MessageSubPage.Legend;
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
{
///
/// SeconLegendPage.xaml 的交互逻辑
///
public partial class SeconLegendPage : Page
{
public HomepageForm HomepageForm;
public SeconLegendPage(HomepageForm homepageForm)
{
InitializeComponent();
HomepageForm = homepageForm;
}
///
/// 文件夹名称
///
public List LegendEntities = new List() {
new LegendEntity("门窗大样", @"/Image/folderImage.png"),
new LegendEntity("家具", @"/Image/folderImage.png"),
new LegendEntity("户型", @"/Image/folderImage.png"),
new LegendEntity("墙体大样", @"/Image/folderImage.png"),
new LegendEntity("新增", @"/Image/add.png"),
};
private void Window_Loaded(object sender, RoutedEventArgs e)
{
sv_legend.ItemsSource = null;
sv_legend.ItemsSource = LegendEntities;
}
///
/// 最后的文件夹分级名字
///
public string lastLegendName = "sp_add1";
///
/// 最后个数命名序号
///
public int Num = 1;
///
/// 是否存在页面
///
public Dictionary id_Pages = new Dictionary();
///
/// 新增文件夹分级
///
///
///
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
{
if (id_Pages.Where(x => x.Key == label.Content.ToString()).Count() == 0)
{
DetailedLegendPage detailedLegendForm = new DetailedLegendPage(this, HomepageForm, label.Content.ToString());
HomepageForm.seconLegendPage.Navigate(detailedLegendForm);
id_Pages.Add(label.Content.ToString(), detailedLegendForm);
}
else
{
HomepageForm.seconLegendPage.Navigate(id_Pages[label.Content.ToString()]);
}
}
}
///
/// 新增文件夹
///
///
public bool AddLegendMath(string legendName)
{
for (int i = 0; i < LegendEntities.Count; i++)
{
if (LegendEntities[i].Name.Equals(legendName))
{
MessageBox.Show("已具有相同名称文件夹");
return false;
}
}
//添加数据
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;
return true;
}
///
/// 点击事件
///
///
///
private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
}
}
}