BigFullProfessiongForm.xaml.cs 17 KB

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