105067 add线材两端管脚信息窗口

This commit is contained in:
SINVO\yangshunli 2025-01-15 09:40:04 +08:00
parent a598f5f352
commit 6bed559bfe
6 changed files with 158 additions and 6 deletions

View File

@ -207,6 +207,9 @@
<Compile Include="View\MainWindow.xaml.cs"> <Compile Include="View\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>MainWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="View\ScannerInfo.xaml.cs">
<DependentUpon>ScannerInfo.xaml</DependentUpon>
</Compile>
<Compile Include="View\ScannerWindow.xaml.cs"> <Compile Include="View\ScannerWindow.xaml.cs">
<DependentUpon>ScannerWindow.xaml</DependentUpon> <DependentUpon>ScannerWindow.xaml</DependentUpon>
</Compile> </Compile>
@ -234,6 +237,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="View\ScannerInfo.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="View\ScannerWindow.xaml"> <Page Include="View\ScannerWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@ -266,7 +273,7 @@
<None Include="App.config" /> <None Include="App.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\PdfiumViewer\PdfiumViewer.csproj"> <ProjectReference Include="..\..\PDFView\PdfiumViewer.csproj">
<Project>{60d3c75c-e71d-4116-bd7e-cac68c4dd96b}</Project> <Project>{60d3c75c-e71d-4116-bd7e-cac68c4dd96b}</Project>
<Name>PdfiumViewer</Name> <Name>PdfiumViewer</Name>
</ProjectReference> </ProjectReference>

View File

@ -0,0 +1,63 @@
<Window
x:Class="Sinvo.EplanHpD.Plugin.WPFUI.View.ScannerInfo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.View"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
Title="ScannerInfo"
Width="1000"
Height="70"
MinHeight="85"
MaxHeight="85"
d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}"
AllowsTransparency="True"
Left="300"
Topmost="True"
WindowStartupLocation="Manual"
WindowStyle="None"
mc:Ignorable="d">
<Grid x:Name="top">
<DataGrid
x:Name="scannerinfo"
Width="auto"
Margin="6"
AutoGenerateColumns="False"
CanUserSortColumns="False"
ColumnHeaderHeight="30"
ColumnWidth="auto"
FontSize="18"
HorizontalScrollBarVisibility="Disabled"
IsReadOnly="True"
ItemsSource="{Binding _ScanCableModels}"
VerticalScrollBarVisibility="Disabled">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
<Setter Property="Foreground" Value="White" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsChecked}" Value="false">
<Setter Property="Background" Value="#dc4d41" />
</DataTrigger>
<DataTrigger Binding="{Binding IsChecked}" Value="true">
<Setter Property="Background" Value="#18a05d" />
</DataTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="#33326cf3" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="线材名" />
<DataGridTextColumn Binding="{Binding Code}" Header="线材号" />
<DataGridTextColumn Binding="{Binding S_Pin}" Header="开始管脚" />
<DataGridTextColumn Binding="{Binding E_Pin}" Header="结束管脚" />
<DataGridTextColumn Binding="{Binding Length}" Header="长度" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

View File

@ -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 的交互逻辑
/// </summary>
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)
{
}
}
}

View File

@ -8,11 +8,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel" xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
Title="扫描" Title="扫描"
Width="540" Width="340"
Height="750" Height="750"
MinWidth="340" MinWidth="340"
d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}" d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}"
Left="1300" Left="1500"
Loaded="Window_Loaded" Loaded="Window_Loaded"
Top="450" Top="450"
WindowStartupLocation="Manual" WindowStartupLocation="Manual"
@ -49,6 +49,7 @@
ValidatesOnNotifyDataErrors="True" /> ValidatesOnNotifyDataErrors="True" />
</hc:TextBox.Text> </hc:TextBox.Text>
</hc:TextBox> </hc:TextBox>
<WrapPanel Margin="10"> <WrapPanel Margin="10">
<CheckBox <CheckBox
x:Name="HideOthersWire" x:Name="HideOthersWire"
@ -161,7 +162,7 @@
hc:Poptip.HitMode="Hover" hc:Poptip.HitMode="Hover"
Binding="{Binding Name}" Binding="{Binding Name}"
Header="线材名称" /> Header="线材名称" />
<DataGridTextColumn <!--<DataGridTextColumn
Width="60" Width="60"
hc:Poptip.Content="{Binding Length}" hc:Poptip.Content="{Binding Length}"
hc:Poptip.HitMode="Hover" hc:Poptip.HitMode="Hover"
@ -178,7 +179,7 @@
hc:Poptip.Content="{Binding Length}" hc:Poptip.Content="{Binding Length}"
hc:Poptip.HitMode="Hover" hc:Poptip.HitMode="Hover"
Binding="{Binding E_Pin}" Binding="{Binding E_Pin}"
Header="结束管脚" /> Header="结束管脚" />-->
<DataGridTextColumn Binding="{Binding Imprint}" Header="印记" /> <DataGridTextColumn Binding="{Binding Imprint}" Header="印记" />
<!--<DataGridTextColumn Binding="{Binding IsChecked}" Header="线材名称" />--> <!--<DataGridTextColumn Binding="{Binding IsChecked}" Header="线材名称" />-->
</DataGrid.Columns> </DataGrid.Columns>

View File

@ -49,6 +49,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
InitializeComponent(); InitializeComponent();
_viewModel = new ScannerViewModel(); _viewModel = new ScannerViewModel();
this.DataContext = _viewModel; this.DataContext = _viewModel;
} }
private void TopMostWindow_Checked(object sender, RoutedEventArgs e) 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) private void Window_Loaded(object sender, RoutedEventArgs e)
{ {
_viewModel.GetCurrentDoc(); _viewModel.GetCurrentDoc();
_viewModel.GetAllCables(); _viewModel.GetAllCables();
ScannerInfo scannerInfo = new ScannerInfo(_viewModel);
this.Closing += scannerInfo.ScannerInfoClosed;
scannerInfo.Show();
WeakReferenceMessenger.Default.Register<CommonMessage, string>(sender, "ScanedIndexChanged", (r, m) => WeakReferenceMessenger.Default.Register<CommonMessage, string>(sender, "ScanedIndexChanged", (r, m) =>
{ {
Dispatcher.BeginInvoke(new Action(() => Dispatcher.BeginInvoke(new Action(() =>
@ -106,5 +112,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
} }
); );
} }
private void Button_Click(object sender, RoutedEventArgs e)
{
ScanCodeTextBox.Focus();
}
} }
} }

View File

@ -1,6 +1,7 @@
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using EPLAN.Harness.API; using EPLAN.Harness.API;
using EPLAN.Harness.AppCore.StudioCommon.TreeView; using EPLAN.Harness.AppCore.StudioCommon.TreeView;
using EPLAN.Harness.Common;
using EPLAN.Harness.Core.Controls; using EPLAN.Harness.Core.Controls;
using EPLAN.Harness.Core.Extensions; using EPLAN.Harness.Core.Extensions;
using EPLAN.Harness.Primitives.Treeviews; using EPLAN.Harness.Primitives.Treeviews;
@ -107,7 +108,7 @@ private DispatcherTimer _debounceTimer;
S_Pin= wire.ConnectedPinsUI.Substring(0,wire.ConnectedPinsUI.IndexOf("<>")), 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), E_Pin= wire.ConnectedPinsUI.Substring( wire.ConnectedPinsUI.IndexOf("<>")+3,wire.ConnectedPinsUI.Length- wire.ConnectedPinsUI.IndexOf("<>")-3),
Name = wire.LibraryName, Name = wire.LibraryName,
Length=wire.Length_VH.ToString(), Length= Math.Ceiling(wire.Length_VH.GetValueInUnit(UNIT_CLASS.LENGTH)).ToString(),
Code = wire.Name, Code = wire.Name,
Imprint = wire.Imprint Imprint = wire.Imprint
}); });