WinMachineRoom.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Windows;
  5. using CEFSharpWPF;
  6. using SAGA.GplotRelationComputerManage.Draw;
  7. using SAGA.Models;
  8. using SAGA.RevitUtils.Windows;
  9. namespace SAGA.GplotDrawData.View
  10. {
  11. /// <summary>
  12. /// WinMachineRoom.xaml 的交互逻辑
  13. /// </summary>
  14. public partial class WinMachineRoom : WinBase
  15. {
  16. public WinMachineRoom()
  17. {
  18. InitializeComponent();
  19. }
  20. public Func<List<DocumentNode>> LoadData;
  21. private ObservableCollection<DocumentNode> DocumentNodes { get; set; }
  22. protected override void OnLoaded(object sender, RoutedEventArgs e)
  23. {
  24. base.OnLoaded(sender, e);
  25. DocumentNodes = new ObservableCollection<DocumentNode>(this.LoadData?.Invoke() ?? new List<DocumentNode>());
  26. this.TreeRootNode.ItemsSource = DocumentNodes;
  27. }
  28. private void SetSelectedItem(DocumentNode node)
  29. {
  30. node.IsSelected = true;
  31. node.IsExpanded = true;
  32. var parent = node.Parent;
  33. while (parent != null)
  34. {
  35. parent.IsExpanded = true;
  36. parent = parent.Parent;
  37. }
  38. RootNode_OnSelectedItemChanged(null, null);
  39. }
  40. #region 事件相关
  41. private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  42. {
  43. if (TreeRootNode.SelectedItem is DocumentNode ln)
  44. {
  45. Draw(ln);
  46. }
  47. }
  48. #endregion
  49. private void Draw(DocumentNode docNode)
  50. {
  51. if (docNode?.LinkDocument == null)
  52. return;
  53. GplotDocument document = docNode.LinkDocument;
  54. RoomGraphView view = new RoomGraphView();
  55. var db = view.CreateDb(document);
  56. ConstData.ResponseData = db.CreateJObjectGroup();
  57. ucShowElement.Show(WebGplotSettings.GplotUrl);
  58. }
  59. }
  60. }