105040 合并冲突
This commit is contained in:
commit
0b21021566
|
@ -91,5 +91,46 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,58 +6,90 @@
|
|||
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"
|
||||
Title="布线常规属性"
|
||||
Width="1100"
|
||||
Height="120"
|
||||
MinHeight="120"
|
||||
MaxHeight="120"
|
||||
d:DataContext="{d:DesignInstance Type=viewmodel:ScannerViewModel}"
|
||||
AllowsTransparency="True"
|
||||
AllowsTransparency="False"
|
||||
Left="300"
|
||||
ResizeMode="NoResize"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="Manual"
|
||||
WindowStyle="None"
|
||||
WindowStyle="SingleBorderWindow"
|
||||
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">
|
||||
|
||||
<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.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition Width="2.5*" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Grid.ColumnSpan="3"
|
||||
Margin="10,5,10,0"
|
||||
FlowDirection="LeftToRight"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock Text="名字:" />
|
||||
<TextBlock Text="{Binding Code}" />
|
||||
<TextBlock Text=" 型号:" />
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<TextBlock Text=" 长度:" />
|
||||
<TextBlock Text="{Binding Length}" />
|
||||
<TextBlock Text=" 印记:" />
|
||||
<TextBlock Text="{Binding Imprint}" />
|
||||
|
||||
</StackPanel>
|
||||
<TextBlock Grid.Row="1" Text="部件1:" />
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Margin="50,0,0,0"
|
||||
Text="{Binding S_part}" />
|
||||
<TextBlock Grid.Row="2" Text="管脚1:" />
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Margin="50,0,0,0"
|
||||
Text="{Binding S_pin}" />
|
||||
<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>
|
||||
|
||||
|
||||
</Window>
|
||||
|
|
|
@ -44,26 +44,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
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(); // 或者你可以根据需要选择是否关闭当前窗口
|
||||
|
|
|
@ -4,11 +4,15 @@ using EPLAN.Harness.AppCore.StudioCommon.TreeView;
|
|||
using EPLAN.Harness.Common;
|
||||
using EPLAN.Harness.Core.Controls;
|
||||
using EPLAN.Harness.Core.Extensions;
|
||||
using EPLAN.Harness.Core.LibEntities;
|
||||
using EPLAN.Harness.Primitives.Treeviews;
|
||||
using EPLAN.Harness.ProjectCore;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using HandyControl.Tools.Extension;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Common;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -82,10 +86,108 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
if (ScanCableModels != value)
|
||||
{
|
||||
ScanCableModels = value;
|
||||
|
||||
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;
|
||||
|
||||
public ScannerViewModel()
|
||||
|
@ -94,23 +196,39 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
|
||||
|
||||
|
||||
public void GetAllCables()
|
||||
{
|
||||
ScanCableModels.Clear();
|
||||
string s_pinid = "";
|
||||
string e_pinid = "";
|
||||
_currentFlexDesigner.GetOrganizerOccurrences().ToList().ForEach(occ =>
|
||||
{
|
||||
if (occ is OccWire wire)
|
||||
{
|
||||
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()
|
||||
{
|
||||
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),
|
||||
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),
|
||||
S_pinID = s_pinid,
|
||||
E_pinID = e_pinid,
|
||||
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,
|
||||
Imprint = wire.Imprint
|
||||
});
|
||||
|
@ -119,6 +237,55 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
});
|
||||
}
|
||||
/// <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>
|
||||
public void GetCurrentDoc()
|
||||
|
@ -159,6 +326,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
// 清除错误信息
|
||||
ClearErrors(nameof(InputCode));
|
||||
var cable = ScanCableModels.FirstOrDefault(c => c.Code.Equals(searchText, StringComparison.OrdinalIgnoreCase) || c.Imprint.StartsWith(searchText, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
|
||||
if (cable != null)
|
||||
{
|
||||
// 处理其他线是否隐藏
|
||||
|
@ -176,14 +345,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
//cable.IsChecked = true;
|
||||
ScanCableModel scanCableModel = new ScanCableModel();
|
||||
scanCableModel = cable;
|
||||
scanCableModel.IsChecked = true;
|
||||
ScanCableModels.Remove(cable);
|
||||
ScanCableModels.Insert(0,scanCableModel);
|
||||
|
||||
_ScanCableModels.Remove(cable);
|
||||
_ScanCableModels.Insert(0, scanCableModel);
|
||||
_ScanCableModels.FirstOrDefault().IsChecked = true;
|
||||
ToMotorSource(scanCableModel);
|
||||
|
||||
}
|
||||
// 扫描的线位置,选中扫描线的上一条线,避免无法判断是否已扫描
|
||||
// index不能小于0
|
||||
ScanedIndex = Math.Max(cable.Index - 1, 0);
|
||||
ScanedIndex = 0;//Math.Max(cable.Index - 1, 0);
|
||||
ToSourceById(cable.Id);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue