SeconProjectPage.xaml.cs 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using CollaborativePlatformMain.Form.MessageSubPage.Project;
  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
  17. {
  18. /// <summary>
  19. /// SeconProjectPage.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class SeconProjectPage : Page
  22. {
  23. /// <summary>
  24. /// 父级窗体
  25. /// </summary>
  26. public HomepageForm HomepageForm;
  27. /// <summary>
  28. /// 项目信息
  29. /// </summary>
  30. public List<ProjectEntity> ProjectEntities = new List<ProjectEntity>();
  31. public SeconProjectPage(HomepageForm homepageForm)
  32. {
  33. InitializeComponent();
  34. HomepageForm = homepageForm;
  35. }
  36. /// <summary>
  37. /// 窗体初始化
  38. /// </summary>
  39. /// <param name="sender"></param>
  40. /// <param name="e"></param>
  41. private void Window_Loaded(object sender, RoutedEventArgs e)
  42. {
  43. }
  44. /// <summary>
  45. /// 新增项目
  46. /// </summary>
  47. /// <param name="sender"></param>
  48. /// <param name="e"></param>
  49. private void bt_addPro(object sender, RoutedEventArgs e)
  50. {
  51. sp_newProject.Visibility = Visibility.Visible;
  52. sp_ProjectInfo.Visibility = Visibility.Collapsed;
  53. sp_temp.Visibility = Visibility.Collapsed;
  54. sp_staging.Visibility = Visibility.Collapsed;
  55. sp_custom.Visibility = Visibility.Collapsed;
  56. threeNewProject.Navigate(new NewProjrctPage(this));
  57. }
  58. /// <summary>
  59. /// 刷新数据
  60. /// </summary>
  61. public void FlushData()
  62. {
  63. tr_vw.ItemsSource = null;
  64. tr_vw.ItemsSource = ProjectEntities;
  65. }
  66. public Dictionary<string, Page> id_Pages = new Dictionary<string, Page>();
  67. public static Dictionary<string, FullProfessionPage> floor_quanPages = new Dictionary<string, FullProfessionPage>();
  68. /// <summary>
  69. /// treeview点击事件
  70. /// </summary>
  71. /// <param name="sender"></param>
  72. /// <param name="e"></param>
  73. private void tv_projectLeftButtonUp(object sender, MouseButtonEventArgs e)
  74. {
  75. ProjectEntity selData = tr_vw.SelectedItem as ProjectEntity;
  76. if (selData == null) return;
  77. string node = selData.ProjectName;
  78. if (node == "项目信息")
  79. {
  80. sp_newProject.Visibility = Visibility.Collapsed;
  81. sp_ProjectInfo.Visibility = Visibility.Visible;
  82. sp_temp.Visibility = Visibility.Collapsed;
  83. sp_staging.Visibility = Visibility.Collapsed;
  84. sp_custom.Visibility = Visibility.Collapsed;
  85. if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0)
  86. {
  87. ProjectInfoPage projectInfoPage = new ProjectInfoPage(selData.SubData);
  88. threeProInfoPage.Navigate(projectInfoPage);
  89. id_Pages.Add(selData.Id, projectInfoPage);
  90. }
  91. else
  92. {
  93. threeProInfoPage.Navigate(id_Pages[selData.Id]);
  94. }
  95. }
  96. else if (node == "团队成员")
  97. {
  98. sp_newProject.Visibility = Visibility.Collapsed;
  99. sp_ProjectInfo.Visibility = Visibility.Collapsed;
  100. sp_temp.Visibility = Visibility.Visible;
  101. sp_staging.Visibility = Visibility.Collapsed;
  102. sp_custom.Visibility = Visibility.Collapsed;
  103. if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0)
  104. {
  105. TempPage tempPage = new TempPage();
  106. threeTempPage.Navigate(tempPage);
  107. id_Pages.Add(selData.Id, tempPage);
  108. }
  109. else
  110. {
  111. threeTempPage.Navigate(id_Pages[selData.Id]);
  112. }
  113. }
  114. else if (node == "工作台")
  115. {
  116. sp_newProject.Visibility = Visibility.Collapsed;
  117. sp_ProjectInfo.Visibility = Visibility.Collapsed;
  118. sp_temp.Visibility = Visibility.Collapsed;
  119. sp_staging.Visibility = Visibility.Visible;
  120. sp_custom.Visibility = Visibility.Collapsed;
  121. if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0)
  122. {
  123. string firstData = "";
  124. GetFirstName(ProjectEntities, selData, ref firstData);
  125. OperatingFloorPage operatingFloorPage = new OperatingFloorPage(HomepageForm, firstData, true);
  126. threeStagingPage.Navigate(operatingFloorPage);
  127. id_Pages.Add(selData.Id, operatingFloorPage);
  128. }
  129. else
  130. {
  131. threeStagingPage.Navigate(id_Pages[selData.Id]);
  132. }
  133. }
  134. else if (node == "自定义")
  135. {
  136. sp_newProject.Visibility = Visibility.Collapsed;
  137. sp_ProjectInfo.Visibility = Visibility.Collapsed;
  138. sp_temp.Visibility = Visibility.Collapsed;
  139. sp_staging.Visibility = Visibility.Collapsed;
  140. sp_custom.Visibility = Visibility.Visible;
  141. if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0)
  142. {
  143. //OperatingFloorPage operatingFloorPage = new OperatingFloorPage(Node);
  144. //threeCustomPage.Navigate(operatingFloorPage);
  145. //id_Pages.Add(selData.Id, operatingFloorPage);
  146. }
  147. else
  148. {
  149. threeCustomPage.Navigate(id_Pages[selData.Id]);
  150. }
  151. }
  152. }
  153. /// <summary>
  154. /// 获取当前选中的项目名称及楼栋名称
  155. /// </summary>
  156. /// <returns></returns>
  157. public bool GetFirstName(List<ProjectEntity> projectEntities, ProjectEntity selData, ref string firstData)
  158. {
  159. foreach (var project in projectEntities)
  160. {
  161. if (project.Id == selData.Id)
  162. {
  163. return true;
  164. }
  165. else
  166. {
  167. bool isSel = GetFirstName(project.SubBuildNodes, selData, ref firstData);
  168. if (isSel)
  169. {
  170. if (firstData == "")
  171. {
  172. firstData = project.ProjectName;
  173. }
  174. else
  175. {
  176. firstData = project.ProjectName + " " + firstData;
  177. }
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. }
  185. }