diff --git a/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs b/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs
index a9f4017..7ea4fea 100644
--- a/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs
+++ b/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs
@@ -45,14 +45,25 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
///
public string WireModelSpecification { get; set; }
///
- /// 前连接
- ///
+ /// 前连接物型号
+ ///
public string FrontConnectorModel { get; set; }
+ ///
+ /// 前连接物数量
+ ///
+ public int FrontConnectorQuantity { get; set; }
+
///
- /// 后连接
- ///
- public string BackConnectorModel { get; set; }
+ /// 后连接物型号
+ ///
+ public string RearConnectorModel { get; set; }
+ ///
+ /// 后连接物数量
+ ///
+ public int RearConnectorQuantity { get; set; }
+
+
///
/// 是否已布线
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
index 283db85..f381646 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
@@ -8,6 +8,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
public class MultiCoreWireDataModel
{
+ ///
+ /// 引脚编号
+ ///
+ public string PinIndex { get; set; }
///
/// 线材型号规格
///
@@ -36,13 +40,35 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
public bool IsHighFlexibility { get; set; }
///
- /// 前端子型号
+ /// 前连接物型号
///
- public string FrontTerminalModel { get; set; }
+ public string FrontConnectorModel { get; set; }
+
///
- /// 后端子型号
+ /// 前连接物料号
///
- public string BackTerminalModel { get; set; }
+ public string FrontConnectorMCode { get; set; }
+ ///
+ /// 前连接物数量
+ ///
+ public int FrontConnectorQuantity { get; set; }
+
+
+ ///
+ /// 后连接物型号
+ ///
+ public string RearConnectorModel { get; set; }
+
+ ///
+ /// 后连接物料号
+ ///
+ public string RearConnectorMCode { get; set; }
+ ///
+ /// 后连接物数量
+ ///
+ public int RearConnectorQuantity { get; set; }
+
+
private List _children = [];
public List Children
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs
index 2f769ab..6ffbf1b 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs
@@ -19,7 +19,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
public string UniqueKey { get; set; }
public string ProjectName { get; set; }
public string UserId { get; set; }
-
+ ///
+ /// 线材名称
+ ///
+ public string WireKey { get; set; }
private int _seqNo;
[ExcelColumn(Ignore = true)]
@@ -407,22 +410,43 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
OnPropertyChanged(nameof(FrontConnectorModel));
}
}
+ private string _frontConnectorMCode;
+ [ExcelColumn(Ignore = true)]
+ public string FrontConnectorMCode
+ {
+ get => _frontConnectorMCode;
+ set
+ {
+ _frontConnectorMCode = value;
+ OnPropertyChanged(nameof(FrontConnectorMCode));
+ }
+ }
///
/// 后连接
///
- private string _backConnectorModel;
+ private string _rearConnectorModel;
[ExcelColumn(Ignore = true)]
- public string BackConnectorModel
+ public string RearConnectorModel
{
- get => _backConnectorModel;
+ get => _rearConnectorModel;
set
{
- _backConnectorModel = value;
- OnPropertyChanged(nameof(BackConnectorModel));
+ _rearConnectorModel = value;
+ OnPropertyChanged(nameof(RearConnectorModel));
+ }
+ }
+ private string _rearConnectorMCode;
+ [ExcelColumn(Ignore = true)]
+ public string RearConnectorMCode
+ {
+ get => _rearConnectorMCode;
+ set
+ {
+ _rearConnectorMCode = value;
+ OnPropertyChanged(nameof(RearConnectorMCode));
}
}
-
private bool _layouted;
///
/// 是否已布线
@@ -446,41 +470,77 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
get
{
// 将所有类型的端子模型组合成一个列表
- return [
+ List terminals = [
new MultiCoreWireTerminalModel
- {
- TerminalModel = ForkTerminal,
- TerminalStripLength = ForkTerminalStripLength,
- TerminalMaterialCode = ForkTerminalMaterialCode
- },
- new MultiCoreWireTerminalModel
- {
- TerminalModel = FlatTerminal,
- TerminalStripLength = FlatTerminalStripLength,
- TerminalMaterialCode = FlatTerminalMaterialCode
- },
- new MultiCoreWireTerminalModel
- {
- TerminalModel = OTypeTerminal,
- TerminalStripLength = OTypeTerminalStripLength,
- TerminalMaterialCode = OTypeTerminalMaterialCode
- },
- new MultiCoreWireTerminalModel
- {
- TerminalModel = PinTerminal,
- TerminalStripLength = PinTerminalStripLength,
- TerminalMaterialCode = PinTerminalMaterialCode
- },
- new MultiCoreWireTerminalModel
- {
- TerminalModel = YTypeTerminal,
- TerminalStripLength = YTypeTerminalStripLength,
- TerminalMaterialCode = YTypeTerminalMaterialCode
- }
+ {
+ TerminalModel = ForkTerminal,
+ TerminalStripLength = ForkTerminalStripLength,
+ TerminalMaterialCode = ForkTerminalMaterialCode
+ },
+ new MultiCoreWireTerminalModel
+ {
+ TerminalModel = FlatTerminal,
+ TerminalStripLength = FlatTerminalStripLength,
+ TerminalMaterialCode = FlatTerminalMaterialCode
+ },
+ new MultiCoreWireTerminalModel
+ {
+ TerminalModel = OTypeTerminal,
+ TerminalStripLength = OTypeTerminalStripLength,
+ TerminalMaterialCode = OTypeTerminalMaterialCode
+ },
+ new MultiCoreWireTerminalModel
+ {
+ TerminalModel = PinTerminal,
+ TerminalStripLength = PinTerminalStripLength,
+ TerminalMaterialCode = PinTerminalMaterialCode
+ },
+ new MultiCoreWireTerminalModel
+ {
+ TerminalModel = YTypeTerminal,
+ TerminalStripLength = YTypeTerminalStripLength,
+ TerminalMaterialCode = YTypeTerminalMaterialCode
+ }
];
+ return [.. terminals.Where(it => !string.IsNullOrEmpty(it.TerminalModel))];
}
}
+
+
+ private int _frontConnectorCount;
+ ///
+ ///
+ [ExcelColumn(Ignore = true)]
+ public int FrontConnectorQuantity
+ {
+ get => _frontConnectorCount;
+ set
+ {
+ _frontConnectorCount = value;
+ OnPropertyChanged(nameof(FrontConnectorQuantity));
+ }
+ }
+ private int _rearConnectorQuantity;
+ ///
+ ///
+ [ExcelColumn(Ignore = true)]
+ public int RearConnectorQuantity
+ {
+ get => _rearConnectorQuantity;
+ set
+ {
+ _rearConnectorQuantity = value;
+ OnPropertyChanged(nameof(RearConnectorQuantity));
+ }
+ }
+
+ ///
+ /// 号码管型号
+ ///
+ public string NumberTubeModel { get; set; }
+
+
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
index 0631070..bf5b959 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
@@ -286,6 +286,7 @@
+
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollSynchronizer.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollSynchronizer.cs
new file mode 100644
index 0000000..75c7f3e
--- /dev/null
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollSynchronizer.cs
@@ -0,0 +1,202 @@
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
+{
+ public static class ScrollSynchronizer
+ {
+ // 附加属性定义
+ public static readonly DependencyProperty SynchronizeWithParentProperty =
+ DependencyProperty.RegisterAttached(
+ "SynchronizeWithParent",
+ typeof(bool),
+ typeof(ScrollSynchronizer),
+ new PropertyMetadata(false, OnSynchronizeWithParentChanged));
+ // 为 ListBox 添加自动寻找内部 DataGrid 的附加属性
+ public static readonly DependencyProperty AutoSynchronizeChildrenProperty =
+ DependencyProperty.RegisterAttached(
+ "AutoSynchronizeChildren",
+ typeof(bool),
+ typeof(ScrollSynchronizer),
+ new PropertyMetadata(false, OnAutoSynchronizeChildrenChanged));
+
+ // Getter 和 Setter
+ public static bool GetSynchronizeWithParent(DependencyObject obj)
+ {
+ return (bool)obj.GetValue(SynchronizeWithParentProperty);
+ }
+
+ public static void SetSynchronizeWithParent(DependencyObject obj, bool value)
+ {
+ obj.SetValue(SynchronizeWithParentProperty, value);
+ }
+
+ ///
+ /// 当属性值改变时触发
+ ///
+ ///
+ ///
+ private static void OnSynchronizeWithParentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is UIElement element)
+ {
+ if ((bool)e.NewValue)
+ {
+ // 添加事件处理
+ element.PreviewMouseWheel += Element_PreviewMouseWheel;
+ }
+ else
+ {
+ // 移除事件处理
+ element.PreviewMouseWheel -= Element_PreviewMouseWheel;
+ }
+ }
+ }
+
+ ///
+ /// 处理滚动事件
+ ///
+ ///
+ ///
+ private static void Element_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ if (sender is UIElement element)
+ {
+ // 向上查找父级 ListBox
+ var listBox = FindParentListBox(element);
+ if (listBox != null)
+ {
+ // 直接获取 ListBox 的 ScrollViewer
+ ScrollViewer scrollViewer = GetScrollViewer(listBox);
+ if (scrollViewer != null)
+ {
+ // 直接控制滚动位置
+ if (e.Delta < 0)
+ {
+ scrollViewer.LineDown();
+ }
+ else
+ {
+ scrollViewer.LineUp();
+ }
+
+ // 标记事件已处理
+ e.Handled = true;
+ }
+ else
+ {
+ // 如果找不到 ScrollViewer,回退到事件传递
+ var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
+ eventArg.RoutedEvent = UIElement.MouseWheelEvent;
+ eventArg.Source = sender;
+ listBox.RaiseEvent(eventArg);
+ e.Handled = true;
+ }
+ }
+ }
+ }
+ ///
+ /// 添加获取 ScrollViewer 的辅助方法
+ ///
+ ///
+ ///
+ private static ScrollViewer GetScrollViewer(DependencyObject element)
+ {
+ if (element is ScrollViewer scrollViewer)
+ return scrollViewer;
+
+ // 尝试从控件模板中查找 ScrollViewer
+ ScrollViewer result = null;
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element) && result == null; i++)
+ {
+ var child = VisualTreeHelper.GetChild(element, i);
+ result = GetScrollViewer(child); // 递归查找
+ }
+
+ return result;
+ }
+
+ ///
+ /// 查找父级 ListBox
+ ///
+ ///
+ ///
+ private static ListBox FindParentListBox(DependencyObject child)
+ {
+ var parent = VisualTreeHelper.GetParent(child);
+ while (parent != null && !(parent is ListBox))
+ {
+ parent = VisualTreeHelper.GetParent(parent);
+ }
+ return parent as ListBox;
+ }
+
+ public static bool GetAutoSynchronizeChildren(DependencyObject obj)
+ {
+ return (bool)obj.GetValue(AutoSynchronizeChildrenProperty);
+ }
+
+ public static void SetAutoSynchronizeChildren(DependencyObject obj, bool value)
+ {
+ obj.SetValue(AutoSynchronizeChildrenProperty, value);
+ }
+
+ private static void OnAutoSynchronizeChildrenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (d is ListBox listBox && (bool)e.NewValue)
+ {
+ // 监听 ListBox 的 Loaded 事件
+ listBox.Loaded += ListBox_Loaded;
+ // 监听 ItemContainerGenerator 状态变化,处理动态加载的项
+ listBox.ItemContainerGenerator.StatusChanged += (s, args) =>
+ {
+ if (listBox.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
+ {
+ AttachToAllDataGrids(listBox);
+ }
+ };
+ }
+ }
+
+ private static void ListBox_Loaded(object sender, RoutedEventArgs e)
+ {
+ if (sender is ListBox listBox)
+ {
+ AttachToAllDataGrids(listBox);
+ }
+ }
+
+ private static void AttachToAllDataGrids(ListBox listBox)
+ {
+ var dataGrids = FindVisualChildren(listBox);
+ foreach (var dataGrid in dataGrids)
+ {
+ SetSynchronizeWithParent(dataGrid, true);
+ }
+ }
+
+ /// 查找所有指定类型的可视化子元素
+ private static IEnumerable FindVisualChildren(DependencyObject obj) where T : DependencyObject
+ {
+ if (obj != null)
+ {
+ for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++)
+ {
+ DependencyObject child = VisualTreeHelper.GetChild(obj, i);
+ if (child != null && child is T)
+ {
+ yield return (T)child;
+ }
+
+ foreach (T childOfChild in FindVisualChildren(child))
+ {
+ yield return childOfChild;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
index b18c852..84a98c8 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
@@ -8,6 +8,7 @@
xmlns:localconverter="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Converter"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:multicorewireviewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel"
+ xmlns:utils="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Utils"
Title="多芯线数据抓取"
Width="1200"
Height="600"
@@ -56,7 +57,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
@@ -314,8 +350,10 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
index 77000c0..4b65973 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
@@ -4,6 +4,7 @@ using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
using SqlSugar.Extensions;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Input;
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
@@ -62,5 +63,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
layoutWindow.Show();
this.Close();
}
+
}
}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireLayoutHelperViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireLayoutHelperViewModel.cs
index 8b3c3cc..911143f 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireLayoutHelperViewModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireLayoutHelperViewModel.cs
@@ -24,29 +24,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
public class MultiCoreWireLayoutHelperViewModel : INotifyPropertyChanged
{
- private MultiCoreWireService _service = new();
+ private readonly MultiCoreWireService _service = new();
private string _uniqueKey;
private FlexDesigner _currentFlexDesigner;
-
private List ApplicationScenarios = [];
-
public int ApplicationScenarioIndex = 0;
-
-
private List _wireData = [];
-
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
-
internal void LoadData()
{
-
var wireDatas = _service.GetByUniqueKey(_uniqueKey);
var applicationScenarios = wireDatas.Select(it => it.ApplicationScenario).Distinct().ToList();
-
ApplicationScenarios = applicationScenarios;
UpdatePropNotify();
wireDatas.ForEach(wire =>
@@ -69,7 +61,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
LoadData();
}
-
private void SelectSet_SelectionChanged(object sender, EventArgs e)
{
if (sender is OccSelectSet selectSet)
@@ -81,7 +72,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
if (part.Parents != null)
{
var SelectMotorModel = part.Parents?.First()?.Name ?? "";
- Debug.WriteLine($"Select part parent -> {part.Parents?.First()?.Name} / {part.Parents?.First()?.ID}");
+ Debug.WriteLine($"Select part parent -> {SelectMotorModel} / {part.Parents?.First()?.ID}");
}
}
else if (item != null)
@@ -90,8 +81,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}
}
-
-
///
/// 检查选中的线
///
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
index add2617..0efd87a 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
@@ -76,6 +76,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}
+ private string _wireKey;
+ ///
+ /// 线材标识
+ ///
+ public string Wirekey
+ {
+ get => _wireKey;
+ set
+ {
+ _wireKey = value;
+
+ OnPropertyChanged(nameof(Wirekey));
+
+ }
+ }
private bool _applicationScenarioSelected;
public bool ApplicationScenarioSelected
@@ -157,6 +172,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
_wireModelSpecification = value;
OnPropertyChanged(nameof(WireModelSpecification));
OnLecChanged(nameof(WireModelSpecification));
+ OnWireChange();
}
}
//private string _connectorModel;
@@ -267,8 +283,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
_wireModelSpecifications = value;
OnPropertyChanged(nameof(WireModelSpecifications));
+ OnWireChange();
}
}
+
+
private List _highFlexibilitys;
///
/// 线径规格
@@ -310,17 +329,17 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
- private List _backConnectorModels;
+ private List _rearConnectorModels;
///
/// 后连接器型号
///
- public List BackConnectorModels
+ public List RearConnectorModels
{
- get => _backConnectorModels;
+ get => _rearConnectorModels;
set
{
- _backConnectorModels = value;
- OnPropertyChanged(nameof(BackConnectorModels));
+ _rearConnectorModels = value;
+ OnPropertyChanged(nameof(RearConnectorModels));
}
}
@@ -335,51 +354,51 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
_frontConnectorType = value;
OnPropertyChanged(nameof(FrontConnectorType));
- OnFrontTypeChange(FrontConnectorType);
+ OnFrontConnectorTypeModels(FrontConnectorType);
}
}
- private void OnFrontTypeChange(string type)
+ private void OnFrontConnectorTypeModels(string type)
{
if (type == "端子")
{
- FrontConnectorModels = [.. _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.TerminalModels];
+ FrontConnectorModels = [.. _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.TerminalModels ?? [] ];
}
else
{
FrontConnectorModels = [new MultiCoreWireTerminalModel {
- TerminalModel = _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.ConnectorModel
+ TerminalModel = _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.ConnectorModel ?? null
}];
}
}
- private string _backConnectorType;
+ private string _rearConnectorType;
///
/// 后连接器类型
///
- public string BackConnectorType
+ public string RearConnectorType
{
- get => _backConnectorType;
+ get => _rearConnectorType;
set
{
- _backConnectorType = value;
- OnPropertyChanged(nameof(BackConnectorType));
- OnBackTypeChange(BackConnectorType);
+ _rearConnectorType = value;
+ OnPropertyChanged(nameof(RearConnectorType));
+ OnRearConnectorTypeChange(RearConnectorType);
}
}
- private void OnBackTypeChange(string type)
+ private void OnRearConnectorTypeChange(string type)
{
if (type == "端子")
{
- BackConnectorModels = [.. _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.TerminalModels];
+ RearConnectorModels = [.. _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.TerminalModels ?? []];
}
else
{
- BackConnectorModels = [new MultiCoreWireTerminalModel {
- TerminalModel = _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.ConnectorModel
+ RearConnectorModels = [new MultiCoreWireTerminalModel {
+ TerminalModel = _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.ConnectorModel ?? null
}];
}
@@ -401,17 +420,42 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
- private string _backConnectorModel;
+ private string _rearConnectorModel;
///
/// 后连接器型号
///
- public string BackConnectorModel
+ public string RearConnectorModel
{
- get => _backConnectorModel;
+ get => _rearConnectorModel;
set
{
- _backConnectorModel = value;
- OnPropertyChanged(nameof(BackConnectorModel));
+ _rearConnectorModel = value;
+ OnPropertyChanged(nameof(RearConnectorModel));
+ }
+ }
+
+ private int _frontConnectorCount;
+ ///
+ ///
+ public int FrontConnectorCount
+ {
+ get => _frontConnectorCount;
+ set
+ {
+ _frontConnectorCount = value;
+ OnPropertyChanged(nameof(FrontConnectorCount));
+ }
+ }
+ private int _rearConnectorCount;
+ ///
+ ///
+ public int RearConnectorCount
+ {
+ get => _rearConnectorCount;
+ set
+ {
+ _rearConnectorCount = value;
+ OnPropertyChanged(nameof(RearConnectorCount));
}
}
#endregion
@@ -436,12 +480,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
Id = wire.Id,
SeqNo = wire.SeqNo,
ApplicationScenario = wire.ApplicationScenario,
+ WireKey = Wirekey,
WireDiameterSpecification = wire.WireDiameterSpecification,
IsHighFlexibilityStr = wire.IsHighFlexibilityStr,
WireCoreCount = wire.WireCoreCount,
WireModelSpecification = wire.WireModelSpecification,
FrontConnectorModel = wire.FrontConnectorModel,
- BackConnectorModel = wire.BackConnectorModel,
+ RearConnectorModel = wire.RearConnectorModel,
UserId = wire.UserId,
ProjectName = wire.ProjectName,
UniqueKey = wire.UniqueKey
@@ -557,8 +602,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
WireColorHex = $"#{wire.Color.Major.ToHex()}",
WireColorHexSec = $"#{wire.Color.Minor.ToHex()}",
IsMultiColor = wire.Color.Major.IsValid() && wire.Color.Minor.IsValid(),
- FrontTerminalModel = wire.GetEndingPins()?.FirstOrDefault()?.Parents?.FirstOrDefault()?.LibraryName,
- BackTerminalModel = wire.GetEndingPins()?.LastOrDefault()?.Parents?.FirstOrDefault()?.LibraryName
+ FrontConnectorModel = wire.GetEndingPins()?.FirstOrDefault()?.Parents?.FirstOrDefault()?.LibraryName,
+ RearConnectorModel = wire.GetEndingPins()?.LastOrDefault()?.Parents?.FirstOrDefault()?.LibraryName
});
}
});
@@ -585,7 +630,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
WireCoreCount = "";
WireModelSpecification = "";
FrontConnectorType = "";
- BackConnectorType = "";
+ RearConnectorType = "";
LecChanging = false;
OnLecChanged("");
@@ -599,13 +644,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|| WireCoreCount == null
|| WireModelSpecification == null
|| FrontConnectorModel == null
- || BackConnectorModel == null)
+ || RearConnectorModel == null)
{
HandyControl.Controls.MessageBox.Show("有信息未选择!",caption: "提示",icon: MessageBoxImage.Warning);
return;
}
if (LecWires.Any(it => it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification
- && it.FrontConnectorModel == FrontConnectorModel && it.BackConnectorModel == BackConnectorModel))
+ && it.FrontConnectorModel == FrontConnectorModel && it.RearConnectorModel == RearConnectorModel))
{
var result = HandyControl.Controls.MessageBox.Show("存在信息相同的线,是否继续添加?", "提示", button: MessageBoxButton.YesNo);
if(!(result == MessageBoxResult.Yes))
@@ -616,6 +661,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
try
{
+ var frontConnectorMCode = GetConnectorMCode(FrontConnectorModel, FrontConnectorType);
+ var rearConnectorMCode = GetConnectorMCode(RearConnectorModel, RearConnectorType);
+
+
+
var wire = new MultiCoreWireLecModel
{
Id = Guid.NewGuid().ToString(),
@@ -626,7 +676,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
WireCoreCount = WireCoreCount,
WireModelSpecification = WireModelSpecification,
FrontConnectorModel = FrontConnectorModel,
- BackConnectorModel = BackConnectorModel,
+ FrontConnectorQuantity = FrontConnectorCount,
+ FrontConnectorMCode = frontConnectorMCode,
+
+ RearConnectorModel = RearConnectorModel,
+ RearConnectorQuantity = RearConnectorCount,
+ RearConnectorMCode = rearConnectorMCode,
+
UserId = PluginServices.user.ID,
ProjectName = LectotypeManager.CURRENT_DOC_NAME,
UniqueKey = $"{LectotypeManager.CURRENT_DOC_NAME}_{PluginServices.user.ID}"
@@ -644,8 +700,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
IsHighFlexibilityStr = wire.IsHighFlexibilityStr,
WireCoreCount = wire.WireCoreCount,
WireModelSpecification = wire.WireModelSpecification,
+
FrontConnectorModel = wire.FrontConnectorModel,
- BackConnectorModel = wire.BackConnectorModel
+ FrontConnectorQuantity = wire.FrontConnectorQuantity,
+ RearConnectorModel = wire.RearConnectorModel,
+ RearConnectorQuantity = wire.RearConnectorQuantity
});
LecWires.Add(wire);
@@ -693,6 +752,33 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}
+ private string GetConnectorMCode(string connectorModel,string connectorType)
+ {
+ if(_datas != null)
+ {
+ if (connectorType == "端子")
+ {
+
+ var terminals = _datas.Where(it => it.WireModelSpecification == WireModelSpecification).FirstOrDefault()?.TerminalModels;
+ return terminals.FirstOrDefault(it => it.TerminalModel == connectorModel)?.TerminalMaterialCode ?? "";
+ }
+ else
+ {
+ //TODO 插头型号信息获取
+ return "";
+ }
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ private void OnWireChange()
+ {
+ OnFrontConnectorTypeModels(FrontConnectorType);
+ OnRearConnectorTypeChange(RearConnectorType);
+ }
//private void ReOrderLecWires()
//{
// int seq = 1;
diff --git a/Sinvo.EplanHpD.Plugin/MultiCoreWirePluginEntry.cs b/Sinvo.EplanHpD.Plugin/MultiCoreWirePluginEntry.cs
index 49f9589..7c1203a 100644
--- a/Sinvo.EplanHpD.Plugin/MultiCoreWirePluginEntry.cs
+++ b/Sinvo.EplanHpD.Plugin/MultiCoreWirePluginEntry.cs
@@ -1,6 +1,7 @@
using EPLAN.Harness.API;
using EPLAN.Harness.API.Plugins.Core;
using EPLAN.Harness.AppCore;
+using HandyControl.Controls;
using Sinvo.EplanHpD.Plugin.DynaClient;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.WPFUI;
@@ -70,27 +71,34 @@ namespace Sinvo.EplanHpD.Plugin
}
if (isLogin)
{
- new DBHelper().CodeFirst();
- var doc = api.CurrentProject.GetActiveDocument();
- if (window == null)
+ try
{
- window = new MultiCoreWireWindow(doc.ID);
- // 获取版本号并显示到窗口标题
- window.Title += $" V{Version} - {doc.Name}";
- ElementHost.EnableModelessKeyboardInterop(window);
- var mainApp = BaseApp.ActiveApplication;
- var helper = new System.Windows.Interop.WindowInteropHelper(window);
- helper.Owner = mainApp.Handle;
- window.Closed += delegate
+ new DBHelper().CodeFirst();
+ var doc = api.CurrentProject.GetActiveDocument();
+ if (window == null)
{
- window = null;
- };
- window.Show();
+ window = new MultiCoreWireWindow(doc.ID);
+ // 获取版本号并显示到窗口标题
+ window.Title += $" V{Version} - {doc.Name}";
+ ElementHost.EnableModelessKeyboardInterop(window);
+ var mainApp = BaseApp.ActiveApplication;
+ var helper = new System.Windows.Interop.WindowInteropHelper(window);
+ helper.Owner = mainApp.Handle;
+ window.Closed += delegate
+ {
+ window = null;
+ };
+ window.Show();
+ }
+ else
+ {
+ window.WindowState = System.Windows.WindowState.Normal;
+ window.Activate();
+ }
}
- else
+ catch (Exception ex)
{
- window.WindowState = System.Windows.WindowState.Normal;
- window.Activate();
+ MessageBox.Show(ex.ToString());
}
}
}