SeconLegendPage.xaml.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using CollaborativePlatformMain.Form.MessageSubPage.AddImage;
  3. using CollaborativePlatformMain.Form.MessageSubPage.Legend;
  4. using CollaborativePlatformMain.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Shapes;
  18. namespace CollaborativePlatformMain.Form.MessageSubPage
  19. {
  20. /// <summary>
  21. /// SeconLegendPage.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class SeconLegendPage : Page
  24. {
  25. public HomepageForm HomepageForm;
  26. public SeconLegendPage(HomepageForm homepageForm)
  27. {
  28. InitializeComponent();
  29. HomepageForm = homepageForm;
  30. }
  31. /// <summary>
  32. /// 文件夹名称
  33. /// </summary>
  34. public List<LegendEntity> LegendEntities = new List<LegendEntity>() {
  35. new LegendEntity("门窗大样", @"/Image/folderImage.png"),
  36. new LegendEntity("家具", @"/Image/folderImage.png"),
  37. new LegendEntity("户型", @"/Image/folderImage.png"),
  38. new LegendEntity("墙体大样", @"/Image/folderImage.png"),
  39. new LegendEntity("新增", @"/Image/add.png"),
  40. };
  41. private void Window_Loaded(object sender, RoutedEventArgs e)
  42. {
  43. sv_legend.ItemsSource = null;
  44. sv_legend.ItemsSource = LegendEntities;
  45. }
  46. /// <summary>
  47. /// 最后的文件夹分级名字
  48. /// </summary>
  49. public string lastLegendName = "sp_add1";
  50. /// <summary>
  51. /// 最后个数命名序号
  52. /// </summary>
  53. public int Num = 1;
  54. /// <summary>
  55. /// 是否存在页面
  56. /// </summary>
  57. public Dictionary<string, Page> id_Pages = new Dictionary<string, Page>();
  58. /// <summary>
  59. /// 新增文件夹分级
  60. /// </summary>
  61. /// <param name="sender"></param>
  62. /// <param name="e"></param>
  63. private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
  64. {
  65. StackPanel stackPanel = sender as StackPanel;
  66. if (stackPanel == null) return;
  67. Label label = stackPanel.FindName("lb_legendName") as Label;
  68. if (label == null) return;
  69. if (label.Content.ToString() == "新增")
  70. {
  71. AddImageForm addImageForm = new AddImageForm(this);
  72. addImageForm.ShowDialog();
  73. }
  74. else
  75. {
  76. if (id_Pages.Where(x => x.Key == label.Content.ToString()).Count() == 0)
  77. {
  78. DetailedLegendPage detailedLegendForm = new DetailedLegendPage(this, HomepageForm, label.Content.ToString());
  79. HomepageForm.seconLegendPage.Navigate(detailedLegendForm);
  80. id_Pages.Add(label.Content.ToString(), detailedLegendForm);
  81. }
  82. else
  83. {
  84. HomepageForm.seconLegendPage.Navigate(id_Pages[label.Content.ToString()]);
  85. }
  86. }
  87. }
  88. /// <summary>
  89. /// 新增文件夹
  90. /// </summary>
  91. /// <param name="legendName"></param>
  92. public bool AddLegendMath(string legendName)
  93. {
  94. for (int i = 0; i < LegendEntities.Count; i++)
  95. {
  96. if (LegendEntities[i].Name.Equals(legendName))
  97. {
  98. MessageBox.Show("已具有相同名称文件夹");
  99. return false;
  100. }
  101. }
  102. //添加数据
  103. LegendEntity legendEntity = new LegendEntity(legendName, @"/Image/folderImage.png");
  104. int index = LegendEntities.Count - 1;
  105. LegendEntities.Insert(index, legendEntity);
  106. sv_legend.ItemsSource = null;
  107. sv_legend.ItemsSource = LegendEntities;
  108. return true;
  109. }
  110. /// <summary>
  111. /// 点击事件
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  116. {
  117. }
  118. }
  119. }