105040 合并冲突

This commit is contained in:
lihanbo 2025-01-20 17:03:35 +08:00
commit 0b21021566
4 changed files with 300 additions and 77 deletions

View File

@ -91,5 +91,46 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
OnPropertyChanged(nameof(E_Pin)); OnPropertyChanged(nameof(E_Pin));
} }
} }
private string _s_pinID;
public string S_pinID
{
get => _s_pinID;
set
{
_s_pinID = value;
OnPropertyChanged(nameof(S_pinID));
}
}
private string _e_pinID;
public string E_pinID
{
get => _e_pinID;
set
{
_e_pinID = value;
OnPropertyChanged(nameof(E_pinID));
}
}
private string _s_part;
public string S_part
{
get => _s_part;
set
{
_s_part = value;
OnPropertyChanged(nameof(S_part));
}
}
private string _e_part;
public string E_part
{
get => _e_part;
set
{
_e_part = value;
OnPropertyChanged(nameof(E_part));
}
}
} }
} }

View File

@ -6,58 +6,90 @@
xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.View" xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.View"
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="ScannerInfo" Title="布线常规属性"
Width="1000" Width="1100"
Height="70" Height="120"
MinHeight="85" MinHeight="120"
MaxHeight="85" MaxHeight="120"
d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}" d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}"
AllowsTransparency="True" AllowsTransparency="False"
Left="300" Left="300"
ResizeMode="NoResize"
Topmost="True" Topmost="True"
WindowStartupLocation="Manual" WindowStartupLocation="Manual"
WindowStyle="None" WindowStyle="SingleBorderWindow"
mc:Ignorable="d"> mc:Ignorable="d">
<Window.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="15" />
<Setter Property="FontWeight" Value="ExtraBold" />
</Style>
</Window.Resources>
<Grid x:Name="top"> <Grid x:Name="top">
<DataGrid
x:Name="scannerinfo" <Grid.RowDefinitions>
Width="auto" <RowDefinition />
Margin="6" <RowDefinition />
AutoGenerateColumns="False" <RowDefinition />
CanUserSortColumns="False" </Grid.RowDefinitions>
ColumnHeaderHeight="30" <Grid.ColumnDefinitions>
ColumnWidth="auto" <ColumnDefinition />
FontSize="18" <ColumnDefinition Width="2.5*" />
HorizontalScrollBarVisibility="Disabled" <ColumnDefinition />
IsReadOnly="True" </Grid.ColumnDefinitions>
ItemsSource="{Binding _ScanCableModels}" <StackPanel
VerticalScrollBarVisibility="Disabled"> Grid.Column="1"
<DataGrid.RowStyle> Grid.ColumnSpan="3"
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow"> Margin="10,5,10,0"
<Setter Property="Foreground" Value="White" /> FlowDirection="LeftToRight"
<Style.Triggers> Orientation="Horizontal">
<DataTrigger Binding="{Binding IsChecked}" Value="false"> <TextBlock Text="名字:" />
<Setter Property="Background" Value="#dc4d41" /> <TextBlock Text="{Binding Code}" />
</DataTrigger> <TextBlock Text=" 型号:" />
<DataTrigger Binding="{Binding IsChecked}" Value="true"> <TextBlock Text="{Binding Name}" />
<Setter Property="Background" Value="#18a05d" /> <TextBlock Text=" 长度:" />
</DataTrigger> <TextBlock Text="{Binding Length}" />
<Trigger Property="IsSelected" Value="True"> <TextBlock Text=" 印记:" />
<Setter Property="Foreground" Value="White" /> <TextBlock Text="{Binding Imprint}" />
<Setter Property="Background" Value="#33326cf3" />
</Trigger> </StackPanel>
</Style.Triggers> <TextBlock Grid.Row="1" Text="部件1:" />
</Style> <TextBlock
</DataGrid.RowStyle> Grid.Row="1"
<DataGrid.Columns> Margin="50,0,0,0"
<DataGridTextColumn Binding="{Binding Name}" Header="线材名" /> Text="{Binding S_part}" />
<DataGridTextColumn Binding="{Binding Code}" Header="线材号" /> <TextBlock Grid.Row="2" Text="管脚1:" />
<DataGridTextColumn Binding="{Binding S_Pin}" Header="开始管脚" /> <TextBlock
<DataGridTextColumn Binding="{Binding E_Pin}" Header="结束管脚" /> Grid.Row="2"
<DataGridTextColumn Binding="{Binding Length}" Header="长度" /> Margin="50,0,0,0"
</DataGrid.Columns> Text="{Binding S_pin}" />
</DataGrid> <TextBlock
Grid.Row="1"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,15,0,0"
Text="《-------------------------------------------------------------------------------------》" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Text="部件2:" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="50,0,0,0"
Text="{Binding E_part}" />
<TextBlock
Grid.Row="2"
Grid.Column="2"
Text="管脚2:" />
<TextBlock
Grid.Row="2"
Grid.Column="2"
Margin="50,0,0,0"
Text="{Binding E_pin}" />
</Grid> </Grid>
</Window> </Window>

View File

@ -44,26 +44,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
this.Topmost = true; 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) public void ScannerInfoClosed(object sender, EventArgs e)
{ {
this.Close(); // 或者你可以根据需要选择是否关闭当前窗口 this.Close(); // 或者你可以根据需要选择是否关闭当前窗口

View File

@ -4,11 +4,15 @@ using EPLAN.Harness.AppCore.StudioCommon.TreeView;
using EPLAN.Harness.Common; 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.Core.LibEntities;
using EPLAN.Harness.Primitives.Treeviews; using EPLAN.Harness.Primitives.Treeviews;
using EPLAN.Harness.ProjectCore; using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences;
using EPLAN.Harness.ProjectCore.Occurrences.Designer; using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using HandyControl.Tools.Extension;
using Sinvo.EplanHpD.Plugin.WPFUI.Common; using Sinvo.EplanHpD.Plugin.WPFUI.Common;
using Sinvo.EplanHpD.Plugin.WPFUI.Models; using Sinvo.EplanHpD.Plugin.WPFUI.Models;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -82,10 +86,108 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
if (ScanCableModels != value) if (ScanCableModels != value)
{ {
ScanCableModels = value; ScanCableModels = value;
OnPropertyChanged(nameof(_ScanCableModels)); OnPropertyChanged(nameof(_ScanCableModels));
} }
} }
} }
#region
private string _S_part;
public string S_part
{
get => _S_part;
set
{
_S_part = value;
OnPropertyChanged(nameof(S_part));
}
}
private string _E_part;
public string E_part
{
get => _E_part;
set
{
_E_part = value;
OnPropertyChanged(nameof(E_part));
}
}
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));
}
}
private string _Name;
public string Name
{
get => _Name;
set
{
_Name = value;
OnPropertyChanged(nameof(Name));
}
}
private string _Code;
public string Code
{
get => _Code;
set
{
_Code = value;
OnPropertyChanged(nameof(Code));
}
}
private string _Length;
public string Length
{
get => _Length;
set
{
_Length = value;
OnPropertyChanged(nameof(Length));
}
}
private string _Imprint;
public string Imprint
{
get => _Imprint;
set
{
_Imprint = value;
OnPropertyChanged(nameof(Imprint));
}
}
#endregion
private DispatcherTimer _debounceTimer; private DispatcherTimer _debounceTimer;
public ScannerViewModel() public ScannerViewModel()
@ -94,23 +196,39 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
} }
public void GetAllCables() public void GetAllCables()
{ {
ScanCableModels.Clear(); ScanCableModels.Clear();
string s_pinid = "";
string e_pinid = "";
_currentFlexDesigner.GetOrganizerOccurrences().ToList().ForEach(occ => _currentFlexDesigner.GetOrganizerOccurrences().ToList().ForEach(occ =>
{ {
if (occ is OccWire wire) if (occ is OccWire wire)
{ {
if (wire.Name.StartsWith("w_", StringComparison.OrdinalIgnoreCase)) if (wire.Name.StartsWith("w_", StringComparison.OrdinalIgnoreCase))
{ {
//获取线两端管脚id,id唯一
var wire_pin = wire.DBG_GetPins.Split(';');
if (wire_pin.Length != 0)
{
s_pinid = wire_pin[0].Substring(1, 32);
e_pinid = wire_pin[1].Trim().Substring(1, 32);
}
//保存线材基础属性
ScanCableModels.Add(new ScanCableModel() ScanCableModels.Add(new ScanCableModel()
{ {
Index = ScanCableModels.Count + 1, Index = ScanCableModels.Count + 1,
Id = wire.ID, Id = wire.ID,
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),
S_pinID = s_pinid,
E_pinID = e_pinid,
Name = wire.LibraryName, Name = wire.LibraryName,
Length= Math.Ceiling(wire.Length_VH.GetValueInUnit(UNIT_CLASS.LENGTH)).ToString(), Length = Math.Ceiling(wire.Length_VH.GetValueInUnit(UNIT_CLASS.LENGTH)).ToString(),
Code = wire.Name, Code = wire.Name,
Imprint = wire.Imprint Imprint = wire.Imprint
}); });
@ -119,6 +237,55 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
}); });
} }
/// <summary> /// <summary>
/// scaninfo界面数据 和找到管脚上级部件
/// </summary>
/// <param name="scanCableModel"></param>
public void ToMotorSource(ScanCableModel scanCableModel)
{
try
{
S_pin = scanCableModel.E_Pin;
E_pin = scanCableModel.E_Pin;
S_part = scanCableModel.S_part;
Length = scanCableModel.Length;
Name = scanCableModel.Name;
Code = scanCableModel.Code;
Imprint = scanCableModel.Imprint;
_currentFlexDesigner.GetOrganizerOccurrences().ToList().ForEach(occ =>
{
//if (occ is OccConnector Assembly)
//{
//var Assembly = occ;
//根据管脚id获取上级部件信息
if (occ.ID.Equals(scanCableModel.S_pinID))
{
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(occ.ID);
var parent = oriOcc.Parents?.FirstOrDefault();
var grandparent = parent.Parents?.FirstOrDefault();
scanCableModel.S_part = grandparent.Name;
S_part = scanCableModel.S_part;
}
if (occ.ID.Equals(scanCableModel.E_pinID))
{
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(occ.ID);
var parent = oriOcc.Parents?.FirstOrDefault();
var grandparent = parent.Parents?.FirstOrDefault();
scanCableModel.E_part = grandparent.Name;
E_part = scanCableModel.E_part;
}
//}
}
);
}
catch (Exception ex)
{
FlexMessageBox.Error(ex.Message);
}
}
/// <summary>
/// 获取当前设计器 /// 获取当前设计器
/// </summary> /// </summary>
public void GetCurrentDoc() public void GetCurrentDoc()
@ -142,7 +309,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
FlexMessageBox.Error(ex.Message); FlexMessageBox.Error(ex.Message);
} }
} }
private void DebounceTimer_Tick(object sender, EventArgs e) private void DebounceTimer_Tick(object sender, EventArgs e)
{ {
@ -159,6 +326,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
// 清除错误信息 // 清除错误信息
ClearErrors(nameof(InputCode)); ClearErrors(nameof(InputCode));
var cable = ScanCableModels.FirstOrDefault(c => c.Code.Equals(searchText, StringComparison.OrdinalIgnoreCase) || c.Imprint.StartsWith(searchText, StringComparison.OrdinalIgnoreCase)); var cable = ScanCableModels.FirstOrDefault(c => c.Code.Equals(searchText, StringComparison.OrdinalIgnoreCase) || c.Imprint.StartsWith(searchText, StringComparison.OrdinalIgnoreCase));
if (cable != null) if (cable != null)
{ {
// 处理其他线是否隐藏 // 处理其他线是否隐藏
@ -176,14 +345,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
//cable.IsChecked = true; //cable.IsChecked = true;
ScanCableModel scanCableModel = new ScanCableModel(); ScanCableModel scanCableModel = new ScanCableModel();
scanCableModel = cable; scanCableModel = cable;
scanCableModel.IsChecked = true;
ScanCableModels.Remove(cable); _ScanCableModels.Remove(cable);
ScanCableModels.Insert(0,scanCableModel); _ScanCableModels.Insert(0, scanCableModel);
_ScanCableModels.FirstOrDefault().IsChecked = true;
ToMotorSource(scanCableModel);
} }
// 扫描的线位置,选中扫描线的上一条线,避免无法判断是否已扫描 ScanedIndex = 0;//Math.Max(cable.Index - 1, 0);
// index不能小于0
ScanedIndex = Math.Max(cable.Index - 1, 0);
ToSourceById(cable.Id); ToSourceById(cable.Id);
} }
@ -240,7 +409,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
// 缩放设计器且触发选中事件 // 缩放设计器且触发选中事件
_currentFlexDesigner.FitToSelectSet(); _currentFlexDesigner.FitToSelectSet();
_currentFlexDesigner.SelectSet.OnSelectionChanged(); _currentFlexDesigner.SelectSet.OnSelectionChanged();
//_currentFlexDesigner.Camera.GraphicControl._HighlightNode() //_currentFlexDesigner.Camera.GraphicControl._HighlightNode()
/* /*
List<DatTreeNodeEx<BaseOccurrence>> nodeByEntity = this._occTreeView.GetNodeByEntity(baseOccurrence); List<DatTreeNodeEx<BaseOccurrence>> nodeByEntity = this._occTreeView.GetNodeByEntity(baseOccurrence);
@ -258,7 +427,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
} }
} }
public void OthersOccShow(bool show = false) public void OthersOccShow(bool show = false)
{ {