| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- using CEFSharpWPF;
- using SAGA.MBI.Common;
- using SAGA.Models;
- using SAGA.RevitUtils.Windows;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media;
- using System.Windows.Threading;
- namespace SAGA.GplotDrawData
- {
- /// <summary>
- /// WinEquipmentRelation_Web.xaml 的交互逻辑
- /// </summary>
- public partial class WinEquipmentRelation_Web : WinBase
- {
- public WinEquipmentRelation_Web()
- {
- InitializeComponent();
- this.Loaded += MainWindow_Loaded;
- }
- public ObservableCollection<DataNode> InDataNodes;
- private bool m_isReadData = true;
- private List<DataNode> dataNodes;
- private List<DataNode> orphanNodes;
- public WinEquipmentRelation_Web(List<DataNode> dataNodes, List<DataNode> orphanNodes) : this()
- {
- this.dataNodes = dataNodes;
- this.orphanNodes = orphanNodes;
- m_isReadData = false;
- }
- public UcGplotShow UcShow => ucShowElement;
- public void ReLoad(List<DataNode> dataNodes, List<DataNode> orphanNodes)
- {
- this.dataNodes = dataNodes;
- this.orphanNodes = orphanNodes;
- MainWindow_Loaded(null, null);
- }
- private void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- if (m_isReadData)
- {
- #region 自定义读取
- var dataNodes = DbHelper.FindOneByFile<DataNode>();
- DataNode root = new DataNode("低压配电图") { Sno = "root", FloorName = "1" };
- dataNodes.Childrens.ForEach(d =>
- {
- //if (d.Type != "母联柜")
- {
- root.Childrens.Add(new DataNode(d.EName)
- {
- EId = d.EId,
- Sno = d.Sno,
- Type = d.Type,
- InLineNo = d.InLineNo,
- FloorName = d.FloorName
- });
- }
- });
- this.InDataNodes = new ObservableCollection<DataNode>(dataNodes.Childrens);
- this.rootNode.ItemsSource = new ObservableCollection<DataNode> { root };
- #endregion
- }
- else
- {
- #region 整理显示数据
- DataNode root = new DataNode("低压配电图") { Sno = "root", FloorName = "1" };
- var orphan = new DataNode("孤立节点") { Sno = "orphan", FloorName = "2" };
- //配电箱
- var orphanTdls = new DataNode("配电箱") { Sno = "TDLS", FloorName = "1" };
- //设备
- var orphanEq = new DataNode("设备") { Sno = "EQ", FloorName = "2" };
- orphan.Childrens.Add(orphanTdls);
- orphan.Childrens.Add(orphanEq);
- this.InDataNodes = new ObservableCollection<DataNode>(dataNodes);
- dataNodes.ForEach(d =>
- {
- root.Childrens.Add(new DataNode(d.EName)
- {
- EId = d.EId,
- Sno = d.Sno,
- Type = d.Type,
- InLineNo = d.InLineNo,
- FloorName = d.FloorName
- });
- });
- orphanNodes.ForEach(d =>
- {
- InDataNodes.Add(d);
- if (d.Type == "TDLS")
- {
- orphan.Childrens[0].Childrens.Add(new DataNode(d.EName)
- {
- EId = d.EId,
- Sno = d.Sno,
- Type = d.Type,
- InLineNo = d.InLineNo,
- FloorName = d.FloorName
- });
- }
- else
- {
- orphan.Childrens[1].Childrens.Add(new DataNode(d.EName)
- {
- EId = d.EId,
- Sno = d.Sno,
- Type = d.Type,
- InLineNo = d.InLineNo,
- FloorName = d.FloorName
- });
- }
- });
- root.Childrens = root.Childrens.OrderBy(t => t.FloorName).ToList();
- orphan.Childrens = orphan.Childrens.OrderBy(t => t.FloorName).ToList();
- orphan.Childrens[0].Childrens = orphan.Childrens[0].Childrens.OrderBy(t => t.FloorName).ToList();
- orphan.Childrens[1].Childrens = orphan.Childrens[1].Childrens.OrderBy(t => t.FloorName).ToList();
- this.rootNode.ItemsSource = new ObservableCollection<DataNode> { root, orphan };
- #endregion
- }
- }
- private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
- {
- Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
- {
- if (this.rootNode.SelectedItem is DataNode currNode)
- {
- if (currNode.Sno == "root")
- {
- // this.m_rootElements.ForEach(t => this.Canvas.Children.Add(t));
- }
- else
- {
- var data = InDataNodes.FirstOrDefault(d => d.EId == currNode.EId);
- if (data != null)
- {
- EquipmentGraphView view = new EquipmentGraphView();
- var db = view.CreateDb(data);
- ConstData.ResponseData = db.CreateJObjectGroup();
- ucShowElement.Show(WebGplotSettings.MindMapUrl);
- //显示属性窗体
- RevitModelFileUpload.ShowSpaceProperty(data.EId);
- }
- }
- }
- });
- }
- }
- }
|