EPLAN_PROD_Plugin/Sinvo.EplanHpD.Plugin.WPFUI/View/LayoutHelperWindow.xaml.cs

80 lines
2.3 KiB
C#

using EPLAN.Harness.API;
using EPLAN.Harness.Core.Controls;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 Sinvo.EplanHpD.Plugin.WPFUI.View
{
/// <summary>
/// LayoutHelperWindow.xaml 的交互逻辑
/// </summary>
public partial class LayoutHelperWindow
{
private FlexDesigner _currentFlexDesigner;
public LayoutHelperWindow()
{
InitializeComponent();
OnInit();
}
private void OnInit()
{
GetCurrentDoc();
_currentFlexDesigner.SelectSet.SelectionChanged += SelectSet_SelectionChanged;
}
private void SelectSet_SelectionChanged(object sender, EventArgs e)
{
if (sender is OccSelectSet selectSet)
{
var item = selectSet.SelectedItem;
if (item is OccSubPart part)
{
Debug.WriteLine($"Select part -> {part.Name} / {part.ID}");
if (part.Parents != null)
{
Debug.WriteLine($"Select part parent -> {part.Parents.First()?.Name} / {part.Parents.First()?.ID}");
}
}
}
}
public void GetCurrentDoc()
{
try
{
HpdApi api = HpdApi.GetInstance();
var currentDocId = api.CurrentProject.GetActiveDocument()?.ID;
var designer = SelfControler<FlexBaseOrganizer>.FindInstance(currentDocId) as FlexDesigner;
if (designer != null)
{
_currentFlexDesigner = designer;
}
else
{
FlexMessageBox.Warning("未找到当前打开的工作区,请先打开工作区");
}
}
catch (Exception ex)
{
FlexMessageBox.Error(ex.Message);
}
}
}
}