2024-12-05 14:37:31 +08:00
|
|
|
|
using EPLAN.Harness.API;
|
|
|
|
|
using EPLAN.Harness.Core.Controls;
|
|
|
|
|
using EPLAN.Harness.ProjectCore;
|
|
|
|
|
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
2024-12-10 17:02:58 +08:00
|
|
|
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
2024-12-05 14:37:31 +08:00
|
|
|
|
using System;
|
2024-12-04 14:21:35 +08:00
|
|
|
|
using System.Collections.Generic;
|
2024-12-05 14:37:31 +08:00
|
|
|
|
using System.Diagnostics;
|
2024-12-04 14:21:35 +08:00
|
|
|
|
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>
|
2024-12-05 14:37:31 +08:00
|
|
|
|
public partial class LayoutHelperWindow
|
2024-12-04 14:21:35 +08:00
|
|
|
|
{
|
2024-12-05 14:37:31 +08:00
|
|
|
|
private FlexDesigner _currentFlexDesigner;
|
2024-12-10 17:02:58 +08:00
|
|
|
|
private LayoutHelperViewModel viewModel;
|
|
|
|
|
public LayoutHelperWindow(List<string> motorIds)
|
2024-12-04 14:21:35 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-12-10 17:02:58 +08:00
|
|
|
|
viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorIds);
|
|
|
|
|
|
|
|
|
|
this.DataContext = viewModel;
|
|
|
|
|
|
2024-12-05 14:37:31 +08:00
|
|
|
|
}
|
|
|
|
|
private void OnInit()
|
|
|
|
|
{
|
|
|
|
|
GetCurrentDoc();
|
|
|
|
|
_currentFlexDesigner.SelectSet.SelectionChanged += SelectSet_SelectionChanged;
|
2024-12-10 17:02:58 +08:00
|
|
|
|
GetMotorCables();
|
|
|
|
|
}
|
2024-12-05 14:37:31 +08:00
|
|
|
|
|
2024-12-10 17:02:58 +08:00
|
|
|
|
private void GetMotorCables()
|
|
|
|
|
{
|
|
|
|
|
viewModel.GetMotorCables();
|
2024-12-05 14:37:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectSet_SelectionChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2024-12-10 17:02:58 +08:00
|
|
|
|
viewModel.OnSelectChange(sender);
|
2024-12-05 14:37:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2024-12-10 17:02:58 +08:00
|
|
|
|
viewModel._currentFlexDesigner = designer;
|
2024-12-05 14:37:31 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FlexMessageBox.Warning("未找到当前打开的工作区,请先打开工作区");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
FlexMessageBox.Error(ex.Message);
|
|
|
|
|
}
|
2024-12-04 14:21:35 +08:00
|
|
|
|
}
|
2024-12-10 17:02:58 +08:00
|
|
|
|
|
|
|
|
|
private void GlowWindow_Loaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
OnInit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void PrevBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
viewModel.ToPrevLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void NextBtn_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
viewModel.ToNextLine();
|
|
|
|
|
}
|
2024-12-04 14:21:35 +08:00
|
|
|
|
}
|
2024-12-05 14:37:31 +08:00
|
|
|
|
|
2024-12-04 14:21:35 +08:00
|
|
|
|
}
|