using EPLAN.Harness.API; using EPLAN.Harness.Core.Controls; using EPLAN.Harness.ProjectCore; using EPLAN.Harness.ProjectCore.Occurrences.Designer; using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; 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 { /// /// LayoutHelperWindow.xaml 的交互逻辑 /// public partial class LayoutHelperWindow { private FlexDesigner _currentFlexDesigner; private LayoutHelperViewModel viewModel; public LayoutHelperWindow(List motorIds) { InitializeComponent(); viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorIds); this.DataContext = viewModel; } private void OnInit() { GetCurrentDoc(); _currentFlexDesigner.SelectSet.SelectionChanged += SelectSet_SelectionChanged; GetMotorCables(); } private void GetMotorCables() { viewModel.GetMotorCables(); } private void SelectSet_SelectionChanged(object sender, EventArgs e) { viewModel.OnSelectChange(sender); } public void GetCurrentDoc() { try { HpdApi api = HpdApi.GetInstance(); var currentDocId = api.CurrentProject.GetActiveDocument()?.ID; var designer = SelfControler.FindInstance(currentDocId) as FlexDesigner; if (designer != null) { _currentFlexDesigner = designer; viewModel._currentFlexDesigner = designer; } else { FlexMessageBox.Warning("未找到当前打开的工作区,请先打开工作区"); } } catch (Exception ex) { FlexMessageBox.Error(ex.Message); } } 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(); } } }