using CollaborativePlatformMain.DFEntity.MessageSubUtil; using CollaborativePlatformMain.Form.MessageSubPage.Project; 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 { /// /// SeconProjectPage.xaml 的交互逻辑 /// public partial class SeconProjectPage : Page { /// /// 父级窗体 /// public HomepageForm HomepageForm; /// /// 项目信息 /// public List ProjectEntities = new List(); public SeconProjectPage(HomepageForm homepageForm) { InitializeComponent(); HomepageForm = homepageForm; } /// /// 窗体初始化 /// /// /// private void Window_Loaded(object sender, RoutedEventArgs e) { } /// /// 新增项目 /// /// /// private void bt_addPro(object sender, RoutedEventArgs e) { sp_newProject.Visibility = Visibility.Visible; sp_ProjectInfo.Visibility = Visibility.Collapsed; sp_temp.Visibility = Visibility.Collapsed; sp_staging.Visibility = Visibility.Collapsed; sp_custom.Visibility = Visibility.Collapsed; threeNewProject.Navigate(new NewProjrctPage(this)); } /// /// 刷新数据 /// public void FlushData() { tr_vw.ItemsSource = null; tr_vw.ItemsSource = ProjectEntities; } public Dictionary id_Pages = new Dictionary(); public static Dictionary floor_quanPages = new Dictionary(); /// /// treeview点击事件 /// /// /// private void tv_projectLeftButtonUp(object sender, MouseButtonEventArgs e) { ProjectEntity selData = tr_vw.SelectedItem as ProjectEntity; if (selData == null) return; string node = selData.ProjectName; if (node == "项目信息") { sp_newProject.Visibility = Visibility.Collapsed; sp_ProjectInfo.Visibility = Visibility.Visible; sp_temp.Visibility = Visibility.Collapsed; sp_staging.Visibility = Visibility.Collapsed; sp_custom.Visibility = Visibility.Collapsed; if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0) { ProjectInfoPage projectInfoPage = new ProjectInfoPage(selData.SubData); threeProInfoPage.Navigate(projectInfoPage); id_Pages.Add(selData.Id, projectInfoPage); } else { threeProInfoPage.Navigate(id_Pages[selData.Id]); } } else if (node == "团队成员") { sp_newProject.Visibility = Visibility.Collapsed; sp_ProjectInfo.Visibility = Visibility.Collapsed; sp_temp.Visibility = Visibility.Visible; sp_staging.Visibility = Visibility.Collapsed; sp_custom.Visibility = Visibility.Collapsed; if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0) { TempPage tempPage = new TempPage(); threeTempPage.Navigate(tempPage); id_Pages.Add(selData.Id, tempPage); } else { threeTempPage.Navigate(id_Pages[selData.Id]); } } else if (node == "工作台") { sp_newProject.Visibility = Visibility.Collapsed; sp_ProjectInfo.Visibility = Visibility.Collapsed; sp_temp.Visibility = Visibility.Collapsed; sp_staging.Visibility = Visibility.Visible; sp_custom.Visibility = Visibility.Collapsed; if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0) { string firstData = ""; GetFirstName(ProjectEntities, selData, ref firstData); OperatingFloorPage operatingFloorPage = new OperatingFloorPage(HomepageForm, firstData, true); threeStagingPage.Navigate(operatingFloorPage); id_Pages.Add(selData.Id, operatingFloorPage); } else { threeStagingPage.Navigate(id_Pages[selData.Id]); } } else if (node == "自定义") { sp_newProject.Visibility = Visibility.Collapsed; sp_ProjectInfo.Visibility = Visibility.Collapsed; sp_temp.Visibility = Visibility.Collapsed; sp_staging.Visibility = Visibility.Collapsed; sp_custom.Visibility = Visibility.Visible; if (id_Pages.Where(x => x.Key == selData.Id).Count() == 0) { //OperatingFloorPage operatingFloorPage = new OperatingFloorPage(Node); //threeCustomPage.Navigate(operatingFloorPage); //id_Pages.Add(selData.Id, operatingFloorPage); } else { threeCustomPage.Navigate(id_Pages[selData.Id]); } } } /// /// 获取当前选中的项目名称及楼栋名称 /// /// public bool GetFirstName(List projectEntities, ProjectEntity selData, ref string firstData) { foreach (var project in projectEntities) { if (project.Id == selData.Id) { return true; } else { bool isSel = GetFirstName(project.SubBuildNodes, selData, ref firstData); if (isSel) { if (firstData == "") { firstData = project.ProjectName; } else { firstData = project.ProjectName + " " + firstData; } return true; } } } return false; } } }