From d7dbc3c8723089a5055b2ea365755731baad64a6 Mon Sep 17 00:00:00 2001 From: "SINVO\\yangshunli" Date: Mon, 13 Jan 2025 09:36:58 +0800 Subject: [PATCH] =?UTF-8?q?105067=20=E6=89=AB=E6=8F=8F=E5=99=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=95=BF=E5=BA=A6=20.=E7=BA=BF=E4=B8=A4=E5=A4=B4?= =?UTF-8?q?=E7=AE=A1=E8=84=9A=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/ScanCableModel.cs | 31 +++++++++++++++++++ .../View/ScannerWindow.xaml | 28 ++++++++++++++--- .../ViewModel/ScannerViewModel.cs | 27 ++++++++++++++-- 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ScanCableModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ScanCableModel.cs index 2ce20b9..c00ee4d 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ScanCableModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ScanCableModel.cs @@ -60,5 +60,36 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models OnPropertyChanged(nameof(Imprint)); } } + private string _length; + public string Length + { + get => _length; + set + { + _length = value; + OnPropertyChanged(nameof(Length)); + } + } + + private string _s_pin; + public string S_Pin + { + get => _s_pin; + set + { + _s_pin = value; + OnPropertyChanged(nameof(S_Pin)); + } + } + private string _e_pin; + public string E_Pin + { + get => _e_pin; + set + { + _e_pin = value; + OnPropertyChanged(nameof(E_Pin)); + } + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml index 2197be0..f0657a7 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml @@ -8,13 +8,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel" Title="扫描" - Width="340" - Height="450" + Width="540" + Height="750" MinWidth="340" d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}" - Left="1580" + Left="1300" Loaded="Window_Loaded" - Top="590" + Top="450" WindowStartupLocation="Manual" mc:Ignorable="d"> @@ -113,7 +113,7 @@ EnableRowVirtualization="False" HeadersVisibility="Column" IsReadOnly="True" - ItemsSource="{Binding ScanCableModels}" + ItemsSource="{Binding _ScanCableModels}" SelectedIndex="{Binding ScanedIndex}" VirtualizingPanel.IsVirtualizing="False"> @@ -161,6 +161,24 @@ hc:Poptip.HitMode="Hover" Binding="{Binding Name}" Header="线材名称" /> + + + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs index 4a08ee9..62ccb61 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs @@ -2,6 +2,7 @@ using EPLAN.Harness.API; using EPLAN.Harness.AppCore.StudioCommon.TreeView; using EPLAN.Harness.Core.Controls; +using EPLAN.Harness.Core.Extensions; using EPLAN.Harness.Primitives.Treeviews; using EPLAN.Harness.ProjectCore; using EPLAN.Harness.ProjectCore.Occurrences.Designer; @@ -69,7 +70,20 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel public ObservableCollection ScanCableModels { get; set; } = []; - private DispatcherTimer _debounceTimer; + + public ObservableCollection _ScanCableModels + { + get => ScanCableModels; + set + { + if (ScanCableModels != value) + { + ScanCableModels = value; + OnPropertyChanged(nameof(_ScanCableModels)); + } + } + } +private DispatcherTimer _debounceTimer; public ScannerViewModel() { @@ -90,7 +104,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { Index = ScanCableModels.Count + 1, Id = wire.ID, + S_Pin= wire.ConnectedPinsUI.Substring(0,wire.ConnectedPinsUI.IndexOf("<>")), + E_Pin= wire.ConnectedPinsUI.Substring( wire.ConnectedPinsUI.IndexOf("<>")+3,wire.ConnectedPinsUI.Length- wire.ConnectedPinsUI.IndexOf("<>")-3), Name = wire.LibraryName, + Length=wire.Length_VH.ToString(), Code = wire.Name, Imprint = wire.Imprint }); @@ -146,7 +163,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel } if (ScanAndAssembled) { - cable.IsChecked = true; + //cable.IsChecked = true; + ScanCableModel scanCableModel = new ScanCableModel(); + scanCableModel = cable; + scanCableModel.IsChecked = true; + ScanCableModels.Remove(cable); + ScanCableModels.Insert(0,scanCableModel); + } ScanedIndex = Math.Max(cable.Index - 1, 0); ToSourceById(cable.Id);