From 6bed559bfef9e5c79efb001128ac43e71f51e84b Mon Sep 17 00:00:00 2001 From: "SINVO\\yangshunli" Date: Wed, 15 Jan 2025 09:40:04 +0800 Subject: [PATCH] =?UTF-8?q?105067=20=20add=E7=BA=BF=E6=9D=90=E4=B8=A4?= =?UTF-8?q?=E7=AB=AF=E7=AE=A1=E8=84=9A=E4=BF=A1=E6=81=AF=E7=AA=97=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sinvo.EplanHpD.Plugin.WPFUI.csproj | 9 ++- .../View/ScannerInfo.xaml | 63 +++++++++++++++++ .../View/ScannerInfo.xaml.cs | 68 +++++++++++++++++++ .../View/ScannerWindow.xaml | 9 +-- .../View/ScannerWindow.xaml.cs | 12 ++++ .../ViewModel/ScannerViewModel.cs | 3 +- 6 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml.cs diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj index f3743c7..ba40b69 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj @@ -207,6 +207,9 @@ MainWindow.xaml + + ScannerInfo.xaml + ScannerWindow.xaml @@ -234,6 +237,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -266,7 +273,7 @@ - + {60d3c75c-e71d-4116-bd7e-cac68c4dd96b} PdfiumViewer diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml new file mode 100644 index 0000000..28c0302 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml.cs new file mode 100644 index 0000000..0fce9ae --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerInfo.xaml.cs @@ -0,0 +1,68 @@ +using EPLAN.Harness.Core; +using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; +using System; +using System.Collections.Generic; +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.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using DataGrid = System.Windows.Controls.DataGrid; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.View +{ + /// ScannerInfo.xaml 的交互逻辑 + /// + public partial class ScannerInfo : Window + { + public ScannerViewModel _scannerViewModel; + public static readonly bool o = false; + public ScannerInfo(ScannerViewModel scannerViewModel) + { + InitializeComponent(); + _scannerViewModel = scannerViewModel; + this.DataContext = _scannerViewModel; + this.Topmost = true; + } + + private void DataGrid_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) + { + for (int i = 1; i < this.scannerinfo.Items.Count; i++) + { + DataGridRow row = (DataGridRow)scannerinfo.ItemContainerGenerator.ContainerFromIndex(i); + // 如果行还没有生成,则调用此方法以强制生成 + if (row == null) + { + scannerinfo.ScrollIntoView(scannerinfo.Items[i]); + scannerinfo.ScrollIntoView(scannerinfo.Items[i]); + row = (DataGridRow)scannerinfo.ItemContainerGenerator.ContainerFromIndex(i); + if (row != null) + { + row.Visibility = Visibility.Collapsed; + } + } + + + } + } + public void ScannerInfoClosed(object sender, EventArgs e) + { + this.Close(); // 或者你可以根据需要选择是否关闭当前窗口 + // 如果你想要关闭的是另一个特定的窗口实例,而不是当前窗口, + // 那么你应该在这里关闭那个特定的窗口实例,比如: + // someOtherWindowInstance.Close(); + } + + private void DataGrid_DataContextChanged(object sender, DataGridRowDetailsEventArgs e) + { + + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml index f0657a7..f34b2f7 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml @@ -8,11 +8,11 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel" Title="扫描" - Width="540" + Width="340" Height="750" MinWidth="340" d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}" - Left="1300" + Left="1500" Loaded="Window_Loaded" Top="450" WindowStartupLocation="Manual" @@ -49,6 +49,7 @@ ValidatesOnNotifyDataErrors="True" /> + - + Header="结束管脚" />--> diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml.cs index d56d15d..a880ca2 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/ScannerWindow.xaml.cs @@ -49,6 +49,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View InitializeComponent(); _viewModel = new ScannerViewModel(); this.DataContext = _viewModel; + + } private void TopMostWindow_Checked(object sender, RoutedEventArgs e) @@ -95,8 +97,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View private void Window_Loaded(object sender, RoutedEventArgs e) { + _viewModel.GetCurrentDoc(); _viewModel.GetAllCables(); + ScannerInfo scannerInfo = new ScannerInfo(_viewModel); + this.Closing += scannerInfo.ScannerInfoClosed; + scannerInfo.Show(); WeakReferenceMessenger.Default.Register(sender, "ScanedIndexChanged", (r, m) => { Dispatcher.BeginInvoke(new Action(() => @@ -106,5 +112,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View } ); } + + private void Button_Click(object sender, RoutedEventArgs e) + { + ScanCodeTextBox.Focus(); + } + } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs index 62ccb61..d6bdc02 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/ScannerViewModel.cs @@ -1,6 +1,7 @@ using CommunityToolkit.Mvvm.Messaging; using EPLAN.Harness.API; using EPLAN.Harness.AppCore.StudioCommon.TreeView; +using EPLAN.Harness.Common; using EPLAN.Harness.Core.Controls; using EPLAN.Harness.Core.Extensions; using EPLAN.Harness.Primitives.Treeviews; @@ -107,7 +108,7 @@ private DispatcherTimer _debounceTimer; 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(), + Length= Math.Ceiling(wire.Length_VH.GetValueInUnit(UNIT_CLASS.LENGTH)).ToString(), Code = wire.Name, Imprint = wire.Imprint });