123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439 |
- using CollaborativePlatformMain.DFEntity.MessageSubUtil;
- using CollaborativePlatformMain.Form.MessageSubPage;
- using CollaborativePlatformMain.Form.MessageSubPage.Project;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- 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
- {
- /// <summary>
- /// BigFullProfessiongForm.xaml 的交互逻辑
- /// </summary>
- public partial class BigFullProfessiongForm : Window
- {
- /// <summary>
- /// 父级窗体
- /// </summary>
- public HomepageForm HomepageForm;
- ///// <summary>
- ///// 父级窗体
- ///// </summary>
- //public OperatingFloorPage OperatingFloorPage;
- /// <summary>
- /// 子级窗体
- /// </summary>
- public FullProfessionPage SmallPage;
- /// <summary>
- /// 子级窗体
- /// </summary>
- public FullProfessionPage BigPage;
- ///// <summary>
- ///// 暖通数据
- ///// </summary>
- //public ObservableCollection<OperatEntity> WarmDatas = new ObservableCollection<OperatEntity>();
- public BigFullProfessiongForm(HomepageForm homepageForm, FullProfessionPage fullProfessionPage, string bulingName = "")
- {
- InitializeComponent();
- HomepageForm = homepageForm;
- SmallPage = fullProfessionPage;
- }
- /// <summary>
- /// 窗体初始化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- BigPage = new FullProfessionPage(HomepageForm);
- //长款
- BigPage.Width = 1000;
- BigPage.Height = 420;
- //tree赋值
- BigPage.tr_threemodel.ItemsSource = OperatingFloorPage.ArchOperaDatas;
- BigPage.tr_threemode2.ItemsSource = OperatingFloorPage.StruOperaDatas;
- BigPage.tr_threemode3.ItemsSource = OperatingFloorPage.WaterOperaDatas;
- BigPage.tr_threemode4.ItemsSource = OperatingFloorPage.WarmOperaDatas;
- BigPage.tr_threemode5.ItemsSource = OperatingFloorPage.EleOperaDatas;
- //屏蔽点击事件
- BigPage.tb_arch.IsHitTestVisible = false;
- BigPage.tb_stru.IsHitTestVisible = false;
- BigPage.tb_water.IsHitTestVisible = false;
- BigPage.tb_warm.IsHitTestVisible = false;
- BigPage.tb_ele.IsHitTestVisible = false;
- // 创建新的列定义
- ColumnDefinition colDef1 = new ColumnDefinition();
- colDef1.Width = new GridLength(1, GridUnitType.Star);
- ColumnDefinition colDef2 = new ColumnDefinition();
- colDef2.Width = new GridLength(1, GridUnitType.Star);
- ColumnDefinition colDef3 = new ColumnDefinition();
- colDef3.Width = new GridLength(1, GridUnitType.Star);
- ColumnDefinition colDef4 = new ColumnDefinition();
- colDef4.Width = new GridLength(1, GridUnitType.Star);
- ColumnDefinition colDef5 = new ColumnDefinition();
- colDef5.Width = new GridLength(1, GridUnitType.Star);
- // 清除旧的列定义
- BigPage.gridName.ColumnDefinitions.Clear();
- // 添加到Grid中
- BigPage.gridName.ColumnDefinitions.Add(colDef1);
- BigPage.gridName.ColumnDefinitions.Add(colDef2);
- BigPage.gridName.ColumnDefinitions.Add(colDef3);
- BigPage.gridName.ColumnDefinitions.Add(colDef4);
- BigPage.gridName.ColumnDefinitions.Add(colDef5);
- frame.Navigate(BigPage);
- }
- /// <summary>
- /// 窗体关闭事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_Closed(object sender, EventArgs e)
- {
- HomepageForm.Visibility = Visibility.Visible;
- }
- /// <summary>
- /// 一键底图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- string value = bt_ditu.Content.ToString();
- if (value.Contains("底图"))
- {
- SelectItemByClick(BigPage.tr_threemodel, false, "Visible");
- bt_ditu.Content = "确定";
- }
- else
- {
- //选中的标高
- Dictionary<string, List<OperatEntity>> archDatas = new Dictionary<string, List<OperatEntity>>();
- foreach (OperatEntity operatEntity in BigPage.tr_threemodel.ItemsSource)
- {
- //版本号
- foreach (var twoData in operatEntity.SubDatas)
- {
- //原图、对比图、治理图
- foreach (var threeData in twoData.SubDatas)
- {
- if (threeData.Node.Contains("治理"))
- {
- //整栋图、分层图
- foreach (var fourData in threeData.SubDatas)
- {
- if (fourData.Node.Contains("分层"))
- {
- foreach (var fiveData in fourData.SubDatas)
- {
- if (archDatas.ContainsKey(fiveData.Node))
- {
- archDatas[fiveData.Node].AddRange(fiveData.SubDatas.Where(x => x.IsCheck).ToList());
- }
- else
- {
- archDatas.Add(fiveData.Node, fiveData.SubDatas.Where(x => x.IsCheck).ToList());
- }
- }
- }
- }
- }
- }
- }
- }
- SelectItemByClick(BigPage.tr_threemodel, false, "Collapsed");
- //项目
- foreach (OperatEntity firstData in BigPage.tr_threemode4.ItemsSource)
- {
- //版本号
- foreach (var twoData in firstData.SubDatas)
- {
- //原图、对比图、治理图
- foreach (var threeData in twoData.SubDatas)
- {
- if (threeData.Node.Contains("治理"))
- {
- //整栋图、分层图
- foreach (var fourData in threeData.SubDatas)
- {
- if (fourData.Node.Contains("分层"))
- {
- foreach (var fiveData in fourData.SubDatas)
- {
- List<OperatEntity> sameDatas = archDatas[fiveData.Node];
- sameDatas.ForEach(x =>
- {
- OperatEntity operatEntity = new OperatEntity(x.Node, x.DrawPath, new ObservableCollection<OperatEntity>(), true);
- operatEntity.isShow = "Collapsed";
- operatEntity.isCheck = false;
- fiveData.SubDatas.Add(operatEntity);
- });
- }
- }
- }
- }
- }
- }
- }
- bt_ditu.Content = "一键底图";
- }
- }
- /// <summary>
- /// 修改checkbox选中
- /// </summary>
- /// <param name="itemsControl"></param>
- /// <param name="selData"></param>
- /// <param name="isSelect"></param>
- /// <param name="isSub"></param>
- /// <returns></returns>
- public TreeViewItem SelectItemByClick(ItemsControl itemsControl, bool isSelect, string isvisible, bool isSub = false)
- {
- foreach (object item in itemsControl.Items)
- {
- TreeViewItem currentItem = itemsControl.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
- if (currentItem == null) continue;
- OperatEntity testData = currentItem.DataContext as OperatEntity;
- //if (testData.IsLayer)
- //{
- if (currentItem.IsExpanded)
- {
- CheckBox checkBox = FindVisualChild(currentItem, "cb_Check");
- if (checkBox != null)
- {
- OperatEntity operatEntity = checkBox.DataContext as OperatEntity;
- if (operatEntity.IsLayer)
- {
- checkBox.IsChecked = isSelect;
- if (isvisible == "Visible")
- {
- checkBox.Visibility = Visibility.Visible;
- }
- else
- {
- checkBox.Visibility = Visibility.Collapsed;
- }
- checkBox.UpdateLayout();
- }
- }
- SelectItemByClick(currentItem, isSelect, isvisible, true);
- }
- else
- {
- currentItem.IsExpanded = true;
- currentItem.UpdateLayout();
- CheckBox checkBox = FindVisualChild(currentItem, "cb_Check");
- if (checkBox != null)
- {
- OperatEntity operatEntity = checkBox.DataContext as OperatEntity;
- if (operatEntity.IsLayer)
- {
- checkBox.IsChecked = isSelect;
- if (isvisible == "Visible")
- {
- checkBox.Visibility = Visibility.Visible;
- }
- else
- {
- checkBox.Visibility = Visibility.Collapsed;
- }
- checkBox.UpdateLayout();
- }
- }
- SelectItemByClick(currentItem, isSelect, isvisible, true);
- currentItem.IsExpanded = false;
- currentItem.UpdateLayout();
- }
- //}
- //else
- //{
- // SelectItemByClick(currentItem, isSelect, isvisible);
- //}
- }
- return null;
- }
- /// <summary>
- /// 获取listview某一列子控件
- /// </summary>
- /// <param name="obj">控件</param>
- /// <param name="name">指定名称</param>
- /// <returns></returns>
- private CheckBox FindVisualChild(DependencyObject obj, string name)
- {
- //无限寻找下一级
- for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
- {
- DependencyObject child = VisualTreeHelper.GetChild(obj, i);
- if (child != null && child is CheckBox text && text.Name == name) return text;
- else
- {
- CheckBox childOfChildren = FindVisualChild(child, name);
- if (childOfChildren != null) return childOfChildren;
- }
- }
- return null;
- }
- /// <summary>
- /// 修改选择框可见性
- /// </summary>
- public void SetShow(ObservableCollection<OperatEntity> operatEntities, string value)
- {
- foreach (var operatEntity in operatEntities)
- {
- if (operatEntity.IsLayer)
- {
- operatEntity.IsShow = value;
- }
- SetShow(operatEntity.SubDatas, value);
- }
- }
- /// <summary>
- /// 一键落图
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- string value = bt_luotu.Content.ToString();
- if (value.Contains("落图"))
- {
- SelectItemByClick(BigPage.tr_threemode4, false, "Visible");
- bt_luotu.Content = "确定";
- }
- else
- {
- //选中的标高
- Dictionary<string, List<OperatEntity>> archDatas = new Dictionary<string, List<OperatEntity>>();
- foreach (OperatEntity operatEntity in BigPage.tr_threemode4.ItemsSource)
- {
- //版本号
- foreach (var twoData in operatEntity.SubDatas)
- {
- //原图、对比图、治理图
- foreach (var threeData in twoData.SubDatas)
- {
- if (threeData.Node.Contains("治理"))
- {
- //整栋图、分层图
- foreach (var fourData in threeData.SubDatas)
- {
- if (fourData.Node.Contains("分层"))
- {
- foreach (var fiveData in fourData.SubDatas)
- {
- if (archDatas.ContainsKey(fiveData.Node))
- {
- archDatas[fiveData.Node].AddRange(fiveData.SubDatas.Where(x => x.IsCheck).ToList());
- }
- else
- {
- archDatas.Add(fiveData.Node, fiveData.SubDatas.Where(x => x.IsCheck).ToList());
- }
- }
- }
- }
- }
- }
- }
- }
- SelectItemByClick(BigPage.tr_threemode4, false, "Collapsed");
- //项目
- foreach (OperatEntity firstData in BigPage.tr_threemodel.ItemsSource)
- {
- //版本号
- foreach (var twoData in firstData.SubDatas)
- {
- //原图、对比图、治理图
- foreach (var threeData in twoData.SubDatas)
- {
- if (threeData.Node.Contains("治理"))
- {
- //整栋图、分层图
- foreach (var fourData in threeData.SubDatas)
- {
- if (fourData.Node.Contains("分层"))
- {
- foreach (var fiveData in fourData.SubDatas)
- {
- List<OperatEntity> sameDatas = archDatas[fiveData.Node];
- sameDatas.ForEach(x =>
- {
- OperatEntity operatEntity = new OperatEntity(x.Node, x.DrawPath, new ObservableCollection<OperatEntity>(), true);
- operatEntity.isShow = "Collapsed";
- operatEntity.isCheck = false;
- fiveData.SubDatas.Add(operatEntity);
- });
- }
- }
- }
- }
- }
- }
- }
- bt_luotu.Content = "一键落图";
- }
- }
- private void Butto_Click_1(object sender, RoutedEventArgs e)
- {
- }
- }
- }
|