DetailedLegendPage.xaml.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using CollaborativePlatformMain.Form.MessageSubPage.AddImage;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. namespace CollaborativePlatformMain.Form.MessageSubPage.Legend
  17. {
  18. /// <summary>
  19. /// DetailedLegendForm.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class DetailedLegendPage : Page
  22. {
  23. /// <summary>
  24. /// 父级窗体
  25. /// </summary>
  26. public SeconLegendPage SeconLegendPage;
  27. /// <summary>
  28. /// 数据信息
  29. /// </summary>
  30. public List<LegendEntity> LegendEntities = new List<LegendEntity>();
  31. public Dictionary<string, List<LegendEntity>> KeyValuePairs = new Dictionary<string, List<LegendEntity>>()
  32. {
  33. {"门窗大样",new List<LegendEntity>(){
  34. new LegendEntity("双开门", @"/Image/folderImage.png"),
  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. } },
  40. {"家具",new List<LegendEntity>(){
  41. new LegendEntity("床", @"/Image/folderImage.png"),
  42. new LegendEntity("沙发", @"/Image/folderImage.png"),
  43. new LegendEntity("衣柜", @"/Image/folderImage.png"),
  44. new LegendEntity("玄关柜", @"/Image/folderImage.png"),
  45. } },
  46. {"户型",new List<LegendEntity>(){
  47. new LegendEntity("一居室", @"/Image/folderImage.png"),
  48. new LegendEntity("二居室", @"/Image/folderImage.png"),
  49. } },
  50. {"墙体大样",new List<LegendEntity>(){
  51. new LegendEntity("墙体大样图1", @"/Image/folderImage.png"),
  52. new LegendEntity("墙体大样图2", @"/Image/folderImage.png"),
  53. } },
  54. };
  55. /// <summary>
  56. /// 父级窗体选中标签
  57. /// </summary>
  58. public string LegendName = "";
  59. /// <summary>
  60. /// 首级页面
  61. /// </summary>
  62. public HomepageForm HomepageForm;
  63. public DetailedLegendPage(SeconLegendPage seconLegendPage, HomepageForm homepageForm, string legendName)
  64. {
  65. InitializeComponent();
  66. LegendName = legendName;
  67. HomepageForm = homepageForm;
  68. SeconLegendPage = seconLegendPage;
  69. }
  70. private void StackPanel_MouseDown(object sender, MouseButtonEventArgs e)
  71. {
  72. StackPanel stackPanel = sender as StackPanel;
  73. if (stackPanel == null) return;
  74. Label label = stackPanel.FindName("lb_legendName") as Label;
  75. if (label == null) return;
  76. if (label.Content.ToString() == "新增")
  77. {
  78. AddImageForm addImageForm = new AddImageForm(this);
  79. addImageForm.ShowDialog();
  80. }
  81. else
  82. {
  83. }
  84. }
  85. /// <summary>
  86. /// 新增文件夹
  87. /// </summary>
  88. /// <param name="legendName"></param>
  89. public bool AddLegendMath(string legendName)
  90. {
  91. for (int i = 0; i < LegendEntities.Count; i++)
  92. {
  93. if (LegendEntities[i].Name.Equals(legendName))
  94. {
  95. MessageBox.Show("已具有相同名称文件夹");
  96. return false;
  97. }
  98. }
  99. //添加数据
  100. LegendEntity legendEntity = new LegendEntity(legendName, @"/Image/folderImage.png");
  101. int index = LegendEntities.Count - 1;
  102. LegendEntities.Insert(index, legendEntity);
  103. sv_legend.ItemsSource = null;
  104. sv_legend.ItemsSource = LegendEntities;
  105. return true;
  106. }
  107. private void Window_Loaded(object sender, RoutedEventArgs e)
  108. {
  109. if (LegendName.Equals("门窗大样"))
  110. {
  111. this.Title = "门窗大样";
  112. LegendEntities = KeyValuePairs["门窗大样"];
  113. }
  114. else if (LegendName.Equals("家具"))
  115. {
  116. this.Title = "家具";
  117. LegendEntities = KeyValuePairs["家具"];
  118. }
  119. else if (LegendName.Equals("户型"))
  120. {
  121. this.Title = "户型";
  122. LegendEntities = KeyValuePairs["户型"];
  123. }
  124. else if (LegendName.Equals("墙体大样"))
  125. {
  126. this.Title = "墙体大样";
  127. LegendEntities = KeyValuePairs["墙体大样"];
  128. }
  129. if (LegendEntities.Where(x => x.Name.Equals("新增")).Count() == 0)
  130. {
  131. LegendEntity insertLegend = new LegendEntity("新增", @"/Image/add.png");
  132. LegendEntities.Add(insertLegend);
  133. }
  134. sv_legend.ItemsSource = null;
  135. sv_legend.ItemsSource = LegendEntities;
  136. }
  137. private void returnBackBu_Click(object sender, RoutedEventArgs e)
  138. {
  139. HomepageForm.seconLegendPage.Navigate(SeconLegendPage);
  140. }
  141. }
  142. }