| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- 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;
- using DrawData;
- using SAGA.DotNetUtils.Logger;
- using SAGA.GplotRelationComputerManage.Draw;
- using SAGA.Models;
- using SAGA.Models.GplotElement;
- using SAGA.RevitUtils.Windows;
- namespace SAGA.GplotDrawData
- {
- /// <summary>
- /// WinMachineRoomView.xaml 的交互逻辑
- /// </summary>
- public partial class WinMachineRoomView : WinBase
- {
- public WinMachineRoomView()
- {
- InitializeComponent();
- Vertex.SetRadius(6, 6);
- }
- public Func<List<DocumentNode>> LoadData;
- private ObservableCollection<DocumentNode> DocumentNodes { get; set; }
- protected override void OnLoaded(object sender, RoutedEventArgs e)
- {
- base.OnLoaded(sender, e);
- DocumentNodes = new ObservableCollection<DocumentNode>(this.LoadData?.Invoke()??new List<DocumentNode>());
- this.TreeRootNode.ItemsSource = DocumentNodes;
- if (DocumentNodes.Any())
- {
- SetSelectedItem(DocumentNodes[0].GetLeaves().FirstOrDefault() as DocumentNode);
- }
- }
- private void SetSelectedItem(DocumentNode node)
- {
- node.IsSelected = true;
- node.IsExpanded = true;
- var parent = node.Parent;
- while (parent != null)
- {
- parent.IsExpanded = true;
- parent = parent.Parent;
- }
- RootNode_OnSelectedItemChanged(null, null);
- }
- #region 事件相关
- private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
- {
- if (TreeRootNode.SelectedItem is DocumentNode ln)
- {
- Draw(ln);
- }
- }
- #endregion
- private void Draw(DocumentNode docNode)
- {
- if (docNode?.LinkDocument == null)
- return;
- GplotDocument document = docNode.LinkDocument;
- RoomGraphView view = new RoomGraphView();
- var db = view.CreateDb(document);
- var strJson=db.CreateJsonStrGroup();
- File.WriteAllText(@"c:\roomCl.json", strJson);
- var panel = ucShowElement.Canvas;
- panel.Children.Clear();
- //DrawDocumentUtil.CoordiateMatrix = DrawDocumentUtil.CreateMatrix(ucShowElement, document.GetRect());
- var transformGroup = new TransformGroup();
- transformGroup.Children.Add(new MatrixTransform(DrawDocumentUtil.CreateMatrix(ucShowElement.viewer, document.GetRect())));
- panel.RenderTransform = transformGroup;
- DrawDocumentUtil.Draw(document, panel);
- }
- }
- }
|