SeconMessagePage.xaml.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. using CollaborativePlatformMain.DFEntity.MessageSubUtil;
  2. using CollaborativePlatformMain.Form.MessageSubPage.Project;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace CollaborativePlatformMain.Form.MessageSubPage
  18. {
  19. /// <summary>
  20. /// SeconMessagePage.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class SeconMessagePage : Page
  23. {
  24. /// <summary>
  25. /// 父级窗体
  26. /// </summary>
  27. public HomepageForm Homepage;
  28. /// <summary>
  29. /// 有参构造
  30. /// </summary>
  31. /// <param name="homepageForm">父级窗体</param>
  32. public SeconMessagePage(HomepageForm homepageForm)
  33. {
  34. InitializeComponent();
  35. Homepage = homepageForm;
  36. }
  37. public ObservableCollection<MessageData> tongzhis1 = new ObservableCollection<MessageData>();
  38. public ObservableCollection<MessageData> tongzhis2 = new ObservableCollection<MessageData>();
  39. public ObservableCollection<MessageData> xiangmu1 = new ObservableCollection<MessageData>();
  40. public ObservableCollection<MessageData> xiangmu2 = new ObservableCollection<MessageData>();
  41. public List<MessageData> xitong1 = new List<MessageData>();
  42. public List<MessageData> xitong2 = new List<MessageData>();
  43. /// <summary>
  44. /// 消息更新
  45. /// </summary>
  46. public static List<MessageData> MessageDatas = new List<MessageData>();
  47. /// <summary>
  48. /// 窗体初始化
  49. /// </summary>
  50. /// <param name="sender"></param>
  51. /// <param name="e"></param>
  52. private void Window_Loaded(object sender, RoutedEventArgs e)
  53. {
  54. List<string> secondaryNodes = new List<string>() { "通知公告", "项目", "系统" };
  55. for (int i = 0; i < secondaryNodes.Count; i++)
  56. {
  57. if (i == 0)
  58. {
  59. List<string> projects = new List<string>() { "国博城项目总消息", "北京大兴项目总消息", "绿地项目总消息" };
  60. MessageData messageData = new MessageData();
  61. messageData.SeconNode = secondaryNodes[i];
  62. messageData.ThreeNodes = projects;
  63. tongzhis1.Add(messageData);
  64. for (int j = 0; j < projects.Count; j++)
  65. {
  66. MessageData threeData = new MessageData();
  67. threeData.SeconNode = projects[j];
  68. if (j == 0)
  69. {
  70. List<string> nodes = new List<string>() { "按甲方要求,国博城项目务必在4月15号之前完成报审版。" };
  71. threeData.ThreeNodes = nodes;
  72. }
  73. else if (j == 1)
  74. {
  75. List<string> nodes = new List<string>() { "按甲方要求,北京大兴项目务必在4月22号之前完成报审版。" };
  76. threeData.ThreeNodes = nodes;
  77. }
  78. else if (j == 2)
  79. {
  80. List<string> nodes = new List<string>() { "按甲方要求,绿地项目务必在4月30号之前完成报审版。" };
  81. threeData.ThreeNodes = nodes;
  82. }
  83. tongzhis2.Add(threeData);
  84. }
  85. }
  86. else if (i == 1)
  87. {
  88. List<string> projects = new List<string>() { };
  89. //添加新增数据
  90. projects.AddRange(MessageDatas.Select(x => x.SeconNode).ToList());
  91. MessageData messageData = new MessageData();
  92. messageData.SeconNode = secondaryNodes[i];
  93. messageData.ThreeNodes = projects;
  94. xiangmu1.Add(messageData);
  95. for (int j = 0; j < projects.Count; j++)
  96. {
  97. MessageData threeData = new MessageData();
  98. threeData.SeconNode = projects[j];
  99. //if (j == 0)
  100. //{
  101. // List<string> nodes = new List<string>() { "国博城项目建筑1#楼3层更新。", "国博城项目建筑1#楼5层更新", "国博城项目建筑2#楼3层更新。" };
  102. // threeData.ThreeNodes = nodes;
  103. //}
  104. //else if (j == 1)
  105. //{
  106. // List<string> nodes = new List<string>() { "北京大兴项目结构2#楼1层墙柱平法图更新。", "北京大兴项目结构1#楼3层墙柱平法图更新。" };
  107. // threeData.ThreeNodes = nodes;
  108. //}
  109. //else if (j == 2)
  110. //{
  111. // List<string> nodes = new List<string>() { "绿地项目地下人防图更新。", "绿地项目暖通3#楼3层更新" };
  112. // threeData.ThreeNodes = nodes;
  113. //}
  114. //else
  115. //{
  116. foreach (var item in MessageDatas)
  117. {
  118. if (item.SeconNode.Equals(threeData.SeconNode))
  119. {
  120. threeData.ThreeNodes = item.ThreeNodes;
  121. break;
  122. }
  123. }
  124. //}
  125. xiangmu2.Add(threeData);
  126. }
  127. }
  128. else if (i == 2)
  129. {
  130. List<string> projects = new List<string>() { "系统更新", "停服升级" };
  131. MessageData messageData = new MessageData();
  132. messageData.SeconNode = secondaryNodes[i];
  133. messageData.ThreeNodes = projects;
  134. xitong1.Add(messageData);
  135. for (int j = 0; j < projects.Count; j++)
  136. {
  137. MessageData threeData = new MessageData();
  138. threeData.SeconNode = projects[j];
  139. if (j == 0)
  140. {
  141. List<string> nodes = new List<string>() { "交互平台版本更新至2.0版本",
  142. " 本次更新了:",
  143. " 1.主界面消息分组。",
  144. " 2.修改了登陆界面。",
  145. " 请及时更新!!",};
  146. threeData.ThreeNodes = nodes;
  147. }
  148. else if (j == 1)
  149. {
  150. List<string> nodes = new List<string>() { "交互平台版本将在4月13日8点20分至4月13日8点50分进行停服更新",
  151. "本次停服更新不会导致您的数据丢失。"};
  152. threeData.ThreeNodes = nodes;
  153. }
  154. xitong2.Add(threeData);
  155. }
  156. }
  157. }
  158. me_message.Children.Clear();
  159. foreach (var item in tongzhis2)
  160. {
  161. Button button = new Button();
  162. button.Content = item.SeconNode;
  163. button.BorderThickness = new Thickness(0);
  164. button.Width = 180;
  165. button.Height = 30;
  166. button.Tag = item;
  167. button.Click += new RoutedEventHandler(messageBtnClick);
  168. button.HorizontalContentAlignment = HorizontalAlignment.Left;
  169. me_message.Children.Add(button);
  170. }
  171. }
  172. /// <summary>
  173. /// 二级菜单选中的元素
  174. /// </summary>
  175. public static string SelectNode = "";
  176. /// <summary>
  177. /// 通知公告
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void me_announcementClick(object sender, RoutedEventArgs e)
  182. {
  183. MenuItem menu = sender as MenuItem;
  184. if (menu == null) return;
  185. me_message.Children.Clear();
  186. foreach (var item in tongzhis2)
  187. {
  188. Button button = new Button();
  189. button.Content = item.SeconNode;
  190. button.BorderThickness = new Thickness(0);
  191. button.Width = 180;
  192. button.Height = 30;
  193. button.Background = Brushes.WhiteSmoke;
  194. button.Visibility = Visibility.Visible;
  195. button.Click += new RoutedEventHandler(messageBtnClick);
  196. button.Tag = item;
  197. button.HorizontalContentAlignment = HorizontalAlignment.Left;
  198. me_message.Children.Add(button);
  199. }
  200. SelectNode = menu.Header.ToString();
  201. }
  202. /// <summary>
  203. /// 项目
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. private void me_projectClick(object sender, RoutedEventArgs e)
  208. {
  209. MenuItem menu = sender as MenuItem;
  210. if (menu == null) return;
  211. me_message.Children.Clear();
  212. foreach (var item in xiangmu2)
  213. {
  214. Button button = new Button();
  215. button.Content = item.SeconNode;
  216. button.BorderThickness = new Thickness(0);
  217. button.Width = 180;
  218. button.Height = 30;
  219. button.Tag = item;
  220. button.Click += new RoutedEventHandler(messageBtnClick);
  221. button.HorizontalContentAlignment = HorizontalAlignment.Left;
  222. me_message.Children.Add(button);
  223. }
  224. SelectNode = menu.Header.ToString();
  225. }
  226. /// <summary>
  227. /// 系统
  228. /// </summary>
  229. /// <param name="sender"></param>
  230. /// <param name="e"></param>
  231. private void me_systemClick(object sender, RoutedEventArgs e)
  232. {
  233. MenuItem menu = sender as MenuItem;
  234. if (menu == null) return;
  235. me_message.Children.Clear();
  236. foreach (var item in xitong2)
  237. {
  238. Button button = new Button();
  239. button.Content = item.SeconNode;
  240. button.BorderThickness = new Thickness(0);
  241. button.Width = 180;
  242. button.Height = 30;
  243. button.Tag = item;
  244. button.Click += new RoutedEventHandler(messageBtnClick);
  245. button.HorizontalContentAlignment = HorizontalAlignment.Left;
  246. me_message.Children.Add(button);
  247. }
  248. SelectNode = menu.Header.ToString();
  249. }
  250. /// <summary>
  251. /// 具体消息按钮
  252. /// </summary>
  253. /// <param name="sender"></param>
  254. /// <param name="e"></param>
  255. private void messageBtnClick(object sender, RoutedEventArgs e)
  256. {
  257. Button button = sender as Button;
  258. MessageData announcement = button.Tag as MessageData;
  259. if (announcement == null) return;
  260. List<string> specificContent = announcement.ThreeNodes;
  261. me_right.Children.Clear();
  262. foreach (var specificConten in specificContent)
  263. {
  264. //ScrollViewer scrollViewer = new ScrollViewer();
  265. //scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
  266. //me_right.Children.Add(scrollViewer);
  267. if (SelectNode.Equals("项目"))
  268. {
  269. DockPanel dockPanel = new DockPanel();
  270. dockPanel.Margin = new Thickness(0, 10, 30, 0);
  271. dockPanel.HorizontalAlignment = HorizontalAlignment.Right;
  272. TextBlock textBlock1 = new TextBlock();
  273. textBlock1.Text = "查看";
  274. textBlock1.FontSize = 13;
  275. textBlock1.Foreground = new SolidColorBrush(Colors.Green);
  276. textBlock1.TextDecorations = TextDecorations.Underline;
  277. textBlock1.Margin = new Thickness(0, 0, 10, 0);
  278. textBlock1.FontFamily = new FontFamily("黑体");
  279. textBlock1.DataContext = specificConten;
  280. textBlock1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(Message_Look);
  281. textBlock1.HorizontalAlignment = HorizontalAlignment.Right;
  282. dockPanel.Children.Add(textBlock1);
  283. TextBlock textBlock2 = new TextBlock();
  284. textBlock2.Text = "忽略";
  285. textBlock2.FontSize = 13;
  286. textBlock2.FontFamily = new FontFamily("黑体");
  287. textBlock2.Foreground = new SolidColorBrush(Colors.Green);
  288. textBlock2.TextDecorations = TextDecorations.Underline;
  289. textBlock2.DataContext = specificConten;
  290. textBlock2.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(Message_Ignore);
  291. dockPanel.Children.Add(textBlock2);
  292. dockPanel.HorizontalAlignment = HorizontalAlignment.Right;
  293. StackPanel stackPanel1 = new StackPanel();
  294. TextBlock textBlock3 = new TextBlock();
  295. textBlock3.Text = specificConten;
  296. textBlock3.FontSize = 15;
  297. textBlock3.FontFamily = new FontFamily("黑体");
  298. textBlock3.DataContext = specificConten;
  299. textBlock3.HorizontalAlignment = HorizontalAlignment.Left;
  300. stackPanel1.DataContext = specificConten;
  301. stackPanel1.Children.Add(textBlock3);
  302. stackPanel1.Children.Add(dockPanel);
  303. stackPanel1.Width = 480;
  304. me_right.Children.Add(stackPanel1);
  305. }
  306. else
  307. {
  308. TextBlock textBlock = new TextBlock();
  309. textBlock.Text = specificConten;
  310. textBlock.FontSize = 15;
  311. textBlock.FontFamily = new FontFamily("黑体");
  312. textBlock.DataContext = announcement;
  313. me_right.Children.Add(textBlock);
  314. }
  315. }
  316. }
  317. /// <summary>
  318. /// 忽略事件
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. private void Message_Ignore(object sender, RoutedEventArgs e)
  323. {
  324. int count = xiangmu2.Count;
  325. TextBlock textBlock = sender as TextBlock;
  326. string messageData = textBlock.DataContext as string;
  327. bool isEqual = false;
  328. //删除单独一条消息
  329. foreach (var item in xiangmu2)
  330. {
  331. for (int i = 0; i < item.ThreeNodes.Count; i++)
  332. {
  333. string iThreeNode = item.ThreeNodes[i];
  334. if (iThreeNode.Equals(messageData))
  335. {
  336. item.ThreeNodes.RemoveAt(i);
  337. isEqual = true;
  338. break;
  339. }
  340. }
  341. if (isEqual) break;
  342. }
  343. for (int i = 0; i < me_right.Children.Count; i++)
  344. {
  345. if (me_right.Children[i] is StackPanel stackPanel)
  346. {
  347. for (int j = 0; j < stackPanel.Children.Count; j++)
  348. {
  349. string stackMessageData = stackPanel.DataContext as string;
  350. if (stackMessageData.Equals(messageData))
  351. {
  352. me_right.Children.RemoveAt(i);
  353. i--;
  354. break;
  355. }
  356. }
  357. }
  358. }
  359. xiangmu2 = new ObservableCollection<MessageData>(xiangmu2.Where(x => x.ThreeNodes.Count > 0));
  360. //一条信息没有父级删除
  361. if (count != xiangmu2.Count)
  362. {
  363. me_message.Children.Clear();
  364. foreach (var item in xiangmu2)
  365. {
  366. Button button = new Button();
  367. button.Content = item.SeconNode;
  368. button.BorderThickness = new Thickness(0);
  369. button.Width = 180;
  370. button.Height = 30;
  371. button.Tag = item;
  372. button.Click += new RoutedEventHandler(messageBtnClick);
  373. button.HorizontalContentAlignment = HorizontalAlignment.Left;
  374. me_message.Children.Add(button);
  375. }
  376. }
  377. }
  378. /// <summary>
  379. /// 查看
  380. /// </summary>
  381. /// <param name="sender"></param>
  382. /// <param name="e"></param>
  383. private void Message_Look(object sender, RoutedEventArgs e)
  384. {
  385. TextBlock textBlock = sender as TextBlock;
  386. string messageData = textBlock.DataContext as string;
  387. Dictionary<string, FullProfessionPage> keyValuePairs = SeconProjectPage.floor_quanPages;
  388. FullProfessionPage fullProfessionPage = null;
  389. foreach (var item in keyValuePairs)
  390. {
  391. string probBuliName = item.Key.Replace(" ", "");
  392. messageData = messageData.Replace("项目", "");
  393. messageData = messageData.Replace(" ", "");
  394. messageData = messageData.Replace("更新", "");
  395. messageData = messageData.Replace("建筑", "");
  396. if (messageData.Contains(probBuliName))
  397. {
  398. fullProfessionPage = item.Value;
  399. break;
  400. }
  401. }
  402. if (fullProfessionPage != null)
  403. {
  404. BigFullProfessiongForm bigFullProfessiongForm = new BigFullProfessiongForm(Homepage, OperatingFloorPage.FullProfessionPage, messageData);
  405. bigFullProfessiongForm.ShowDialog();
  406. }
  407. }
  408. }
  409. }