BigFullProfessiongForm.xaml.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using CollaborativePlatformMain.Form.MessageSubPage;
  3. using CollaborativePlatformMain.Form.MessageSubPage.Project;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  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
  19. {
  20. /// <summary>
  21. /// BigFullProfessiongForm.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class BigFullProfessiongForm : Window
  24. {
  25. /// <summary>
  26. /// 父级窗体
  27. /// </summary>
  28. public HomepageForm HomepageForm;
  29. /// <summary>
  30. /// 父级窗体
  31. /// </summary>
  32. public OperatingFloorPage OperatingFloorPage;
  33. /// <summary>
  34. /// 子级窗体
  35. /// </summary>
  36. public FullProfessionPage SmallPage;
  37. /// <summary>
  38. /// 子级窗体
  39. /// </summary>
  40. public FullProfessionPage BigPage;
  41. ///// <summary>
  42. ///// 暖通数据
  43. ///// </summary>
  44. //public ObservableCollection<OperatEntity> WarmDatas = new ObservableCollection<OperatEntity>();
  45. public BigFullProfessiongForm(HomepageForm homepageForm, FullProfessionPage fullProfessionPage, OperatingFloorPage operatingFloorPage)
  46. {
  47. InitializeComponent();
  48. HomepageForm = homepageForm;
  49. SmallPage = fullProfessionPage;
  50. OperatingFloorPage = operatingFloorPage;
  51. }
  52. /// <summary>
  53. /// 窗体初始化
  54. /// </summary>
  55. /// <param name="sender"></param>
  56. /// <param name="e"></param>
  57. private void Window_Loaded(object sender, RoutedEventArgs e)
  58. {
  59. BigPage = new FullProfessionPage(HomepageForm);
  60. //长款
  61. BigPage.Width = 1000;
  62. BigPage.Height = 420;
  63. //tree赋值
  64. BigPage.tr_threemodel.ItemsSource = OperatingFloorPage.ArchOperaDatas;
  65. BigPage.tr_threemode2.ItemsSource = OperatingFloorPage.StruOperaDatas;
  66. BigPage.tr_threemode3.ItemsSource = OperatingFloorPage.WaterOperaDatas;
  67. BigPage.tr_threemode4.ItemsSource = OperatingFloorPage.WarmOperaDatas;
  68. BigPage.tr_threemode5.ItemsSource = OperatingFloorPage.EleOperaDatas;
  69. //屏蔽点击事件
  70. BigPage.tb_arch.IsHitTestVisible = false;
  71. BigPage.tb_stru.IsHitTestVisible = false;
  72. BigPage.tb_water.IsHitTestVisible = false;
  73. BigPage.tb_warm.IsHitTestVisible = false;
  74. BigPage.tb_ele.IsHitTestVisible = false;
  75. // 创建新的列定义
  76. ColumnDefinition colDef1 = new ColumnDefinition();
  77. colDef1.Width = new GridLength(1, GridUnitType.Star);
  78. ColumnDefinition colDef2 = new ColumnDefinition();
  79. colDef2.Width = new GridLength(1, GridUnitType.Star);
  80. ColumnDefinition colDef3 = new ColumnDefinition();
  81. colDef3.Width = new GridLength(1, GridUnitType.Star);
  82. ColumnDefinition colDef4 = new ColumnDefinition();
  83. colDef4.Width = new GridLength(1, GridUnitType.Star);
  84. ColumnDefinition colDef5 = new ColumnDefinition();
  85. colDef5.Width = new GridLength(1, GridUnitType.Star);
  86. // 清除旧的列定义
  87. BigPage.gridName.ColumnDefinitions.Clear();
  88. // 添加到Grid中
  89. BigPage.gridName.ColumnDefinitions.Add(colDef1);
  90. BigPage.gridName.ColumnDefinitions.Add(colDef2);
  91. BigPage.gridName.ColumnDefinitions.Add(colDef3);
  92. BigPage.gridName.ColumnDefinitions.Add(colDef4);
  93. BigPage.gridName.ColumnDefinitions.Add(colDef5);
  94. frame.Navigate(BigPage);
  95. }
  96. /// <summary>
  97. /// 窗体关闭事件
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void Window_Closed(object sender, EventArgs e)
  102. {
  103. HomepageForm.Visibility = Visibility.Visible;
  104. }
  105. /// <summary>
  106. /// 一键底图
  107. /// </summary>
  108. /// <param name="sender"></param>
  109. /// <param name="e"></param>
  110. private void Button_Click(object sender, RoutedEventArgs e)
  111. {
  112. string value = bt_ditu.Content.ToString();
  113. if (value.Contains("底图"))
  114. {
  115. SelectItemByClick(BigPage.tr_threemodel, false, "Visible");
  116. bt_ditu.Content = "确定";
  117. }
  118. else
  119. {
  120. //选中的标高
  121. Dictionary<string, List<OperatEntity>> archDatas = new Dictionary<string, List<OperatEntity>>();
  122. foreach (OperatEntity operatEntity in BigPage.tr_threemodel.ItemsSource)
  123. {
  124. //版本号
  125. foreach (var twoData in operatEntity.SubDatas)
  126. {
  127. //原图、对比图、治理图
  128. foreach (var threeData in twoData.SubDatas)
  129. {
  130. if (threeData.Node.Contains("治理"))
  131. {
  132. //整栋图、分层图
  133. foreach (var fourData in threeData.SubDatas)
  134. {
  135. if (fourData.Node.Contains("分层"))
  136. {
  137. foreach (var fiveData in fourData.SubDatas)
  138. {
  139. if (archDatas.ContainsKey(fiveData.Node))
  140. {
  141. archDatas[fiveData.Node].AddRange(fiveData.SubDatas.Where(x => x.IsCheck).ToList());
  142. }
  143. else
  144. {
  145. archDatas.Add(fiveData.Node, fiveData.SubDatas.Where(x => x.IsCheck).ToList());
  146. }
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. SelectItemByClick(BigPage.tr_threemodel, false, "Collapsed");
  155. //项目
  156. foreach (OperatEntity firstData in BigPage.tr_threemode4.ItemsSource)
  157. {
  158. //版本号
  159. foreach (var twoData in firstData.SubDatas)
  160. {
  161. //原图、对比图、治理图
  162. foreach (var threeData in twoData.SubDatas)
  163. {
  164. if (threeData.Node.Contains("治理"))
  165. {
  166. //整栋图、分层图
  167. foreach (var fourData in threeData.SubDatas)
  168. {
  169. if (fourData.Node.Contains("分层"))
  170. {
  171. foreach (var fiveData in fourData.SubDatas)
  172. {
  173. List<OperatEntity> sameDatas = archDatas[fiveData.Node];
  174. sameDatas.ForEach(x =>
  175. {
  176. OperatEntity operatEntity = new OperatEntity(x.Node, x.DrawPath, new ObservableCollection<OperatEntity>(), true);
  177. operatEntity.isShow = "Collapsed";
  178. operatEntity.isCheck = false;
  179. fiveData.SubDatas.Add(operatEntity);
  180. });
  181. }
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. bt_ditu.Content = "一键底图";
  189. }
  190. }
  191. /// <summary>
  192. /// 修改checkbox选中
  193. /// </summary>
  194. /// <param name="itemsControl"></param>
  195. /// <param name="selData"></param>
  196. /// <param name="isSelect"></param>
  197. /// <param name="isSub"></param>
  198. /// <returns></returns>
  199. public TreeViewItem SelectItemByClick(ItemsControl itemsControl, bool isSelect, string isvisible, bool isSub = false)
  200. {
  201. foreach (object item in itemsControl.Items)
  202. {
  203. TreeViewItem currentItem = itemsControl.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
  204. if (currentItem == null) continue;
  205. OperatEntity testData = currentItem.DataContext as OperatEntity;
  206. //if (testData.IsLayer)
  207. //{
  208. if (currentItem.IsExpanded)
  209. {
  210. CheckBox checkBox = FindVisualChild(currentItem, "cb_Check");
  211. if (checkBox != null)
  212. {
  213. OperatEntity operatEntity = checkBox.DataContext as OperatEntity;
  214. if (operatEntity.IsLayer)
  215. {
  216. checkBox.IsChecked = isSelect;
  217. if (isvisible == "Visible")
  218. {
  219. checkBox.Visibility = Visibility.Visible;
  220. }
  221. else
  222. {
  223. checkBox.Visibility = Visibility.Collapsed;
  224. }
  225. checkBox.UpdateLayout();
  226. }
  227. }
  228. SelectItemByClick(currentItem, isSelect, isvisible, true);
  229. }
  230. else
  231. {
  232. currentItem.IsExpanded = true;
  233. currentItem.UpdateLayout();
  234. CheckBox checkBox = FindVisualChild(currentItem, "cb_Check");
  235. if (checkBox != null)
  236. {
  237. OperatEntity operatEntity = checkBox.DataContext as OperatEntity;
  238. if (operatEntity.IsLayer)
  239. {
  240. checkBox.IsChecked = isSelect;
  241. if (isvisible == "Visible")
  242. {
  243. checkBox.Visibility = Visibility.Visible;
  244. }
  245. else
  246. {
  247. checkBox.Visibility = Visibility.Collapsed;
  248. }
  249. checkBox.UpdateLayout();
  250. }
  251. }
  252. SelectItemByClick(currentItem, isSelect, isvisible, true);
  253. currentItem.IsExpanded = false;
  254. currentItem.UpdateLayout();
  255. }
  256. //}
  257. //else
  258. //{
  259. // SelectItemByClick(currentItem, isSelect, isvisible);
  260. //}
  261. }
  262. return null;
  263. }
  264. /// <summary>
  265. /// 获取listview某一列子控件
  266. /// </summary>
  267. /// <param name="obj">控件</param>
  268. /// <param name="name">指定名称</param>
  269. /// <returns></returns>
  270. private CheckBox FindVisualChild(DependencyObject obj, string name)
  271. {
  272. //无限寻找下一级
  273. for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
  274. {
  275. DependencyObject child = VisualTreeHelper.GetChild(obj, i);
  276. if (child != null && child is CheckBox text && text.Name == name) return text;
  277. else
  278. {
  279. CheckBox childOfChildren = FindVisualChild(child, name);
  280. if (childOfChildren != null) return childOfChildren;
  281. }
  282. }
  283. return null;
  284. }
  285. /// <summary>
  286. /// 修改选择框可见性
  287. /// </summary>
  288. public void SetShow(ObservableCollection<OperatEntity> operatEntities, string value)
  289. {
  290. foreach (var operatEntity in operatEntities)
  291. {
  292. if (operatEntity.IsLayer)
  293. {
  294. operatEntity.IsShow = value;
  295. }
  296. SetShow(operatEntity.SubDatas, value);
  297. }
  298. }
  299. /// <summary>
  300. /// 一键落图
  301. /// </summary>
  302. /// <param name="sender"></param>
  303. /// <param name="e"></param>
  304. private void Button_Click_1(object sender, RoutedEventArgs e)
  305. {
  306. string value = bt_luotu.Content.ToString();
  307. if (value.Contains("落图"))
  308. {
  309. SelectItemByClick(BigPage.tr_threemode4, false, "Visible");
  310. bt_luotu.Content = "确定";
  311. }
  312. else
  313. {
  314. //选中的标高
  315. Dictionary<string, List<OperatEntity>> archDatas = new Dictionary<string, List<OperatEntity>>();
  316. foreach (OperatEntity operatEntity in BigPage.tr_threemode4.ItemsSource)
  317. {
  318. //版本号
  319. foreach (var twoData in operatEntity.SubDatas)
  320. {
  321. //原图、对比图、治理图
  322. foreach (var threeData in twoData.SubDatas)
  323. {
  324. if (threeData.Node.Contains("治理"))
  325. {
  326. //整栋图、分层图
  327. foreach (var fourData in threeData.SubDatas)
  328. {
  329. if (fourData.Node.Contains("分层"))
  330. {
  331. foreach (var fiveData in fourData.SubDatas)
  332. {
  333. if (archDatas.ContainsKey(fiveData.Node))
  334. {
  335. archDatas[fiveData.Node].AddRange(fiveData.SubDatas.Where(x => x.IsCheck).ToList());
  336. }
  337. else
  338. {
  339. archDatas.Add(fiveData.Node, fiveData.SubDatas.Where(x => x.IsCheck).ToList());
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. SelectItemByClick(BigPage.tr_threemode4, false, "Collapsed");
  349. //项目
  350. foreach (OperatEntity firstData in BigPage.tr_threemodel.ItemsSource)
  351. {
  352. //版本号
  353. foreach (var twoData in firstData.SubDatas)
  354. {
  355. //原图、对比图、治理图
  356. foreach (var threeData in twoData.SubDatas)
  357. {
  358. if (threeData.Node.Contains("治理"))
  359. {
  360. //整栋图、分层图
  361. foreach (var fourData in threeData.SubDatas)
  362. {
  363. if (fourData.Node.Contains("分层"))
  364. {
  365. foreach (var fiveData in fourData.SubDatas)
  366. {
  367. List<OperatEntity> sameDatas = archDatas[fiveData.Node];
  368. sameDatas.ForEach(x =>
  369. {
  370. OperatEntity operatEntity = new OperatEntity(x.Node, x.DrawPath, new ObservableCollection<OperatEntity>(), true);
  371. operatEntity.isShow = "Collapsed";
  372. operatEntity.isCheck = false;
  373. fiveData.SubDatas.Add(operatEntity);
  374. });
  375. }
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. bt_luotu.Content = "一键落图";
  383. }
  384. }
  385. }
  386. }