123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Media;
- using CEFSharpWPF;
- using Newtonsoft.Json.Linq;
- using SAGA.GplotRelationComputerManage;
- using SAGA.Models;
- using SAGA.RevitUtils;
- using SAGA.RevitUtils.Windows;
- namespace SAGA.GplotDrawData.View
- {
- /// <summary>
- /// WinMachineRoom.xaml 的交互逻辑
- /// </summary>
- public partial class WinMachineRoom : WinBase
- {
- public WinMachineRoom()
- {
- InitializeComponent();
- ucShowElement.RegisterJsObject("wpfEvent", this);
- }
- protected override void OnLoaded(object sender, RoutedEventArgs e)
- {
- base.OnLoaded(sender, e);
- InitTreeNode();
- }
- #region 事件相关
- private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
- {
- if (TreeRootNode.SelectedItem is DataNode ln)
- {
- Draw(ln.GetData<MachineRoomDrawRecord>());
- }
- }
- #endregion
- #region 数据相关处理
- /// <summary>
- /// 获取平面绘图数据
- /// </summary>
- /// <returns></returns>
- private List<List<MachineRoomDrawRecord>> GetMachineRoomDrawData()
- {
- List<List<MachineRoomDrawRecord>> datas = new List<List<MachineRoomDrawRecord>>();
- List<string> relationTypes = RelationTypeManager.GetSystemRelationTypeNames();
- foreach (string relationType in relationTypes)
- {
- LoadMachineRoomDrawData loadData = new LoadMachineRoomDrawData(relationType);
- loadData.LoadData();
- datas.Add(loadData.MachineRoomDrawRecords);
- }
- return datas;
- }
- /// <summary>
- /// 初始化树形结构显示
- /// </summary>
- private void InitTreeNode()
- {
- try
- {
- List<List<MachineRoomDrawRecord>> drawDatas = GetMachineRoomDrawData();
- List<DataNode> treeDataSource = new List<DataNode>();
- foreach (var drawData in drawDatas)
- {
- foreach (var drawRecord in drawData)
- {
- if (!drawRecord.NodePaths.Any())
- continue;
- var relationNode = treeDataSource.FirstOrDefault(d => d.EName == drawRecord.RelationName);
- if (relationNode == null)
- {
- relationNode = new DataNode(drawRecord.RelationName);
- treeDataSource.Add(relationNode);
- }
- var recordNode = new DataNode(drawRecord.FloorName);
- recordNode.SetData(drawRecord);
- relationNode.Childrens.Add(recordNode);
- }
- }
- this.TreeRootNode.ItemsSource = treeDataSource;
- if (treeDataSource.Count == 0)
- {
- this.Content = CommonControlUtils.CreatMaskElement("未发现计算数据");
- }
- }
- catch (Exception ex)
- {
- MessageShow.Show(ex);
- }
- }
- private void Draw(MachineRoomDrawRecord record)
- {
- if (record == null)
- return;
- MachineRoomGraphView view = new MachineRoomGraphView();
- var db = view.CreateDb(record);
- var jobject = db.CreateJObjectGroup();
- jobject["Id"] = record.FloorName + "-"+ record.BuildingTime;
- ConstData.ResponseData = jobject;
- //ucShowElement.Show(WebGplotSettings.GplotUrl);
- ucShowElement.Show(WebGplotSettings.MachineRoomUrl);
- }
- public void SaveStr(string path)
- {
- //MessageBox.Show(path ?? "没有数据");
- var data = new JObject();//JObject.Parse(path);
- data.Add("id", "sdada");
- DataServerUtil.Current.SaveData("dd",data);
- if (DataServerUtil.Current.GetFile("dd").Exists())
- {
- var cc= DataServerUtil.Current.LoadData<JObject>("dd");
- }
- }
- #endregion
- }
- }
|