123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- using CollaborativePlatformMain.DFEntity.MessageSubUtil;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace CollaborativePlatformMain.Form.MessageSubPage.Project
- {
- /// <summary>
- /// NewProjrctPage.xaml 的交互逻辑
- /// </summary>
- public partial class NewProjrctPage : Page
- {
- /// <summary>
- /// 父级窗体
- /// </summary>
- public SeconProjectPage SeconProjectPage;
- public NewProjrctPage(SeconProjectPage seconProjectPage)
- {
- InitializeComponent();
- SeconProjectPage = seconProjectPage;
- }
- /// <summary>
- /// 窗体初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Page_Loaded(object sender, RoutedEventArgs e)
- {
- //初始化业态数据
- List<string> business = new List<string>() { "住宅", "公寓", "宿舍", "医疗", "商业", "学校", "其他" };
- cb_staus.ItemsSource = business;
- cb_staus.SelectedItem = business.FirstOrDefault();
- //初始化项目地址
- List<string> paths = new List<string>() { "山东","山西", "河北","河南", "江苏","浙江",
- "辽宁","吉林", "黑龙江","安徽", "福建","江西",
- "湖北","湖南", "广东","海南", "四川","贵州",
- "云南","陕西", "甘肃","青海", "台湾","内蒙古", "广西",
- "西藏", "宁夏","新疆","北京","天津","上海","重庆",
- "香港","澳门"};
- cb_Path.ItemsSource = paths;
- cb_Path.SelectedItem = paths.FirstOrDefault();
- }
- /// <summary>
- /// 青蓝小助手提示关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void close_Click(object sender, RoutedEventArgs e)
- {
- gd_top.Visibility = Visibility.Collapsed;
- }
- /// <summary>
- /// 新增楼栋
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bt_build_Click(object sender, RoutedEventArgs e)
- {
- string buildName = tb_buildName.Text.ToString();
- if (buildName == null || buildName == "")
- {
- MessageBox.Show("请输入新增楼栋名称");
- return;
- }
- TextBox textBox = new TextBox();
- textBox.Width = 100;
- textBox.Text = buildName;
- DockPanel dockPanel = new DockPanel();
- dockPanel.Margin = new Thickness(30, 10, 0, 0);
- dockPanel.HorizontalAlignment = HorizontalAlignment.Left;
- dockPanel.Children.Add(textBox);
- sp_buildNames.Children.Add(dockPanel);
- tb_buildName.Text = "";
- }
- /// <summary>
- /// 提交项目
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void bt_addPorject_Click(object sender, RoutedEventArgs e)
- {
- //项目名称
- string projectName = tb_projectName.Text.ToString();
- if (projectName == null || projectName == "")
- {
- MessageBox.Show("请输入项目名称");
- return;
- }
- //项目业态
- string businessName = cb_staus.SelectedItem.ToString();
- if (businessName == null || businessName == "")
- {
- MessageBox.Show("请输入项目业态");
- return;
- }
- //项目地址
- string pathName = cb_Path.SelectedItem.ToString();
- if (pathName == null || pathName == "")
- {
- MessageBox.Show("请输入项目地址");
- return;
- }
- //楼栋名称
- BuildNames = new List<string>();
- GetBuildNames(sp_buildNames);
- //项目信息
- ProjectEntity projectEntity = new ProjectEntity(projectName, businessName, pathName);
- List<ProjectEntity> buildDatas = new List<ProjectEntity>();
- foreach (var buildName in BuildNames)
- {
- //项目信息
- ProjectEntity subData1 = new ProjectEntity("项目信息", projectEntity);
- //团队成员
- Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
- keyValuePairs.Add("主管", "");
- keyValuePairs.Add("建筑", "");
- keyValuePairs.Add("结构", "");
- keyValuePairs.Add("给排水", "");
- keyValuePairs.Add("暖通", "");
- keyValuePairs.Add("电气", "");
- ProjectEntity subData2 = new ProjectEntity("团队成员", keyValuePairs);
- //工作台
- OperatingFloorData operatingFloorData = new OperatingFloorData(projectName);
- ProjectEntity subData3 = new ProjectEntity("工作台", operatingFloorData);
- //自定义
- ProjectEntity subData4 = new ProjectEntity("自定义", new List<ProjectEntity>());
- //添加数据
- buildDatas.Add(new ProjectEntity(buildName, new List<ProjectEntity>() { subData1, subData2, subData3, subData4 }));
- }
- ProjectEntity projectInfo = new ProjectEntity(projectName, buildDatas);
- //存储消息数据
- if (!projectName.Contains("项目")) projectName = projectName + " 项目";
- //二级菜单
- string seconNode = projectName + "建筑" + "图纸更新";
- bool isExisteSecon = false;
- for (int i = 0; i < SeconMessagePage.MessageDatas.Count; i++)
- {
- MessageData existMessageData = SeconMessagePage.MessageDatas[i];
- if (existMessageData.SeconNode.Equals(seconNode))
- {
- foreach (var item in BuildNames)
- {
- string addStringName = projectName + item + "更新";
- bool isExisteThree = false;
- foreach (var threeNode in SeconMessagePage.MessageDatas[i].ThreeNodes)
- {
- if (addStringName.Equals(threeNode))
- {
- isExisteThree = true;
- }
- }
- if (!isExisteThree)
- {
- SeconMessagePage.MessageDatas[i].ThreeNodes.Add(addStringName);
- }
- }
- isExisteSecon = true;
- break;
- }
- }
- if (!isExisteSecon)
- {
- MessageData newMessageData = new MessageData();
- newMessageData.SeconNode = seconNode;
- foreach (var item in BuildNames)
- {
- newMessageData.ThreeNodes.Add(projectName + "建筑" + item + "更新");
- }
- SeconMessagePage.MessageDatas.Add(newMessageData);
- }
- //messageData
- SeconProjectPage.ProjectEntities.Add(projectInfo);
- SeconProjectPage.FlushData();
- }
- /// <summary>
- /// 所有的楼栋名称
- /// </summary>
- public List<string> BuildNames = new List<string>();
- /// <summary>
- /// 获取所有的楼栋名称
- /// </summary>
- /// <param name="obj"></param>
- public void GetBuildNames(DependencyObject obj)
- {
- for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
- {
- DependencyObject child = VisualTreeHelper.GetChild(obj, i);
- if (child is TextBox textBox)
- {
- BuildNames.Add(textBox.Text.ToString());
- }
- GetBuildNames(child);
- }
- }
- }
- }
|