diff --git a/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs b/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs
index 57d0d3b..b940fde 100644
--- a/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs
+++ b/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs
@@ -45,6 +45,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
DB.CodeFirst.InitTables(typeof(Model.CableLectotype));
DB.CodeFirst.InitTables(typeof(Model.LectotypeLine));
DB.CodeFirst.InitTables(typeof(Model.MultiCoreWireLecDBModel));
+ DB.CodeFirst.InitTables(typeof(Model.MultiWireCoreDataModel));
}
}
}
diff --git a/Sinvo.EplanHpD.Plugin.Service/Model/MultiWireCoreDataModel.cs b/Sinvo.EplanHpD.Plugin.Service/Model/MultiWireCoreDataModel.cs
new file mode 100644
index 0000000..0facc9d
--- /dev/null
+++ b/Sinvo.EplanHpD.Plugin.Service/Model/MultiWireCoreDataModel.cs
@@ -0,0 +1,30 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Sinvo.EplanHpD.Plugin.Service.Model
+{
+ [SugarTable("T_MCWIRE_LEC_CORE")]
+ public class MultiWireCoreDataModel
+ {
+
+ [SugarColumn(IsPrimaryKey = true)]
+ public string Id { get; set; }
+ public string PId { get; set; }
+ public int SeqNo { get; set; }
+ public string CoreWireName { get; set; }
+ ///
+ /// 线芯引脚号
+ ///
+ public int PinIndex { get; set; }
+
+ ///
+ /// 线芯号码管标示
+ ///
+ public string CoreNumberTube { get; set; }
+ }
+}
diff --git a/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj b/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj
index de6c2c4..a2b2528 100644
--- a/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj
+++ b/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj
@@ -74,6 +74,7 @@
+
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Controls/MyScrollViewer.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Controls/MyScrollViewer.cs
new file mode 100644
index 0000000..6eb7658
--- /dev/null
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Controls/MyScrollViewer.cs
@@ -0,0 +1,53 @@
+using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media.Animation;
+
+namespace Sinvo.EplanHpD.Plugin.WPFUI.Controls
+{
+ //继承ScrollViewer 通过截获MouseWheel事件控制滚动
+ public class MyScrollViewer : ScrollViewer
+ {
+ //记录上一次的滚动位置
+ private double LastLocation = 0;
+ //重写鼠标滚动事件
+ protected override void OnMouseWheel(MouseWheelEventArgs e)
+ {
+ double WheelChange = e.Delta;
+ //可以更改一次滚动的距离倍数 (WheelChange可能为正负数!)
+ double newOffset = LastLocation - (WheelChange * 2);
+ //Animation并不会改变真正的VerticalOffset(只是它的依赖属性) 所以将VOffset设置到上一次的滚动位置 (相当于衔接上一个动画)
+ ScrollToVerticalOffset(LastLocation);
+ //碰到底部和顶部时的处理
+ if (newOffset < 0)
+ newOffset = 0;
+ if (newOffset > ScrollableHeight)
+ newOffset = ScrollableHeight;
+
+ AnimateScroll(newOffset);
+ LastLocation = newOffset;
+ //告诉ScrollViewer我们已经完成了滚动
+ e.Handled = true;
+ }
+ private void AnimateScroll(double ToValue)
+ {
+ //为了避免重复,先结束掉上一个动画
+ BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, null);
+ DoubleAnimation Animation = new DoubleAnimation();
+ Animation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
+ Animation.From = VerticalOffset;
+ Animation.To = ToValue;
+ //动画速度
+ Animation.Duration = TimeSpan.FromMilliseconds(800);
+ //考虑到性能,可以降低动画帧数
+ //Timeline.SetDesiredFrameRate(Animation, 40);
+ BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, Animation);
+ }
+ }
+
+}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
index dd5b2ef..d6b2130 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs
@@ -1,4 +1,5 @@
-using MiniExcelLibs.Attributes;
+using EPLAN.Harness.API.Occurrences.Nailboard;
+using MiniExcelLibs.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -154,8 +155,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
///
/// 引脚编号
///
- private string _pinIndex;
- public string PinIndex
+ private int _pinIndex;
+ public int PinIndex
{
get => _pinIndex;
set
@@ -708,6 +709,63 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
}
}
}
+
+
+
+ private string _coreNumberTube;
+ ///
+ /// 线芯号码管标示
+ ///
+ public string CoreNumberTube
+ {
+ get { return _coreNumberTube; }
+ set
+ {
+ _coreNumberTube = value;
+ OnPropertyChanged();
+ }
+ }
+
+ /*
+ 绝缘软套型号
+ 绝缘软套型号物料编码
+ 绝缘软套数量
+ */
+ private string _insulationModel;
+ ///
+ /// E绝缘软套型号
+ ///
+ public string InsulationModel
+ {
+ get { return _insulationModel; }
+ set
+ {
+
+ _insulationModel = value;
+ OnPropertyChanged();
+ }
+ }
+
+ ///
+ /// E绝缘软套型号物料编码
+ ///
+ private string _insulationMaterialNo;
+ public string InsulationMaterialNo
+ {
+ get { return _insulationMaterialNo; }
+ set
+ {
+
+ _insulationMaterialNo = value;
+ OnPropertyChanged();
+ }
+ }
+
+ ///
+ /// 绝缘软套型号数量
+ ///
+ public int InsulationQuantity { get; set; } = 1;
+
private List _children = [];
public List Children
{
@@ -722,7 +780,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
}
}
- public event PropertyChangedEventHandler PropertyChanged;
+ public new event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
index 1e10a78..83f78c5 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj
@@ -239,6 +239,7 @@
+
@@ -289,6 +290,7 @@
+
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollViewerBehavior.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollViewerBehavior.cs
new file mode 100644
index 0000000..bdf2ecb
--- /dev/null
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ScrollViewerBehavior.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
+{
+ public static class ScrollViewerBehavior
+ {
+ public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.RegisterAttached("VerticalOffset", typeof(double), typeof(ScrollViewerBehavior), new UIPropertyMetadata(0.0, OnVerticalOffsetChanged));
+ public static void SetVerticalOffset(FrameworkElement target, double value) => target.SetValue(VerticalOffsetProperty, value);
+ public static double GetVerticalOffset(FrameworkElement target) => (double)target.GetValue(VerticalOffsetProperty);
+ private static void OnVerticalOffsetChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) => (target as ScrollViewer)?.ScrollToVerticalOffset((double)e.NewValue);
+ }
+}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
index e5d2563..6049d2b 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml
@@ -5,6 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.View"
+ xmlns:localCtr="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Controls"
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"
@@ -378,110 +379,151 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
index d70c078..4851d6e 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/MultiCoreWire/MultiCoreWireWindow.xaml.cs
@@ -68,5 +68,34 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
viewModel.ExportLines();
}
+
+ private void SaveWireCoreData_Click(object sender, RoutedEventArgs e)
+ {
+ if(sender is Button btn)
+ {
+ var tag = btn.Tag as MultiCoreWireDataModel;
+ if (tag != null)
+ {
+ viewModel.SaveWireCoreData(tag);
+ }
+ }
+ }
+
+
+ private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
+ {
+ if (!e.Handled)
+ {
+ // ListView拦截鼠标滚轮事件
+ e.Handled = true;
+
+ // 激发一个鼠标滚轮事件,冒泡给外层ListView接收到
+ var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
+ eventArg.RoutedEvent = UIElement.MouseWheelEvent;
+ eventArg.Source = sender;
+ var parent = ((Control)sender).Parent as UIElement;
+ parent.RaiseEvent(eventArg);
+ }
+ }
}
}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
index 991fdc9..89b324e 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MultiCoreWireViewModel/MultiCoreWireViewModel.cs
@@ -3,6 +3,7 @@ using EPLAN.Harness.Core.Appearance;
using EPLAN.Harness.Core.Utils;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
+using EPLAN.Harness.ProjectCore.Occurrences.Nailboard;
using HandyControl.Controls;
using MiniExcelLibs;
using MiniExcelLibs.Attributes;
@@ -504,17 +505,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
#endregion
-
private IEnumerable _datas;
public void LoadLecData()
{
try
{
-
_datas = _dataHelper.GetMultiCoreWireLecDatas();
-
-
}
catch (Exception ex)
{
@@ -524,7 +521,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
SetDatas(_datas);
try
{
-
var wiresData = _service.GetByUniqueKey(CurrUniqueKey);
if (wiresData != null)
{
@@ -615,17 +611,23 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
var wireData = new MultiCoreWireDataModel
{
WireModelSpecification = $"{it.Name} / {it.LibraryName}"
- };
- if(LecWires != null && !LecWires.Any(i => $"{i.ApplicationScenario}-{i.WireKey}" == it.Name && i.WireModelSpecification == it.LibraryName))
+ };
+ var lecData = LecWires?.FirstOrDefault(i => $"{i.ApplicationScenario}-{i.WireKey}" == it.Name && i.WireModelSpecification == it.LibraryName);
+ if (lecData == null)
{
wireData.IsError = true;
wireData.CheckedMsg = "无法匹配选型数据!";
wireData.IsChecked = true;
}
+ else
+ {
+ wireData.IsChecked = true;
+ wireData.Id = lecData.Id;
+ }
if (it.Children?.Any() ?? false)
{
it.Children.ForEach(c =>
- {
+ {
if (c.Children?.Any() ?? false)
{
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
@@ -722,14 +724,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
return;
}
}
-
try
{
var frontConnectorMCode = GetConnectorMCode(FrontConnectorModel, FrontConnectorType);
var rearConnectorMCode = GetConnectorMCode(RearConnectorModel, RearConnectorType);
-
-
-
var wire = new MultiCoreWireDataModel
{
Id = Guid.NewGuid().ToString(),
@@ -768,7 +766,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
{
wire.BlackHeatShrinkTubeMCode = connectorInfo.HeatShrinkTubeSpecification;
wire.BlackHeatShrinkTubeMCode = connectorInfo.HeatShrinkTubeMaterialCode;
- //wire.bla
}
}
@@ -806,7 +803,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
wire.RearStrippingLength = wireData.TerminalModels.FirstOrDefault(it => it.TerminalModel == wire.RearConnectorModel)?.TerminalStripLength ?? 0;
}
}
-
}
catch (Exception ex)
{
@@ -814,27 +810,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
}
}).ContinueWith(x =>
{
- // TODO Save line data
- //_service.SaveData(new MultiCoreWireLecDBModel
- //{
- // Id = wire.Id,
- // UniqueKey = wire.UniqueKey,
- // ProjectName = wire.ProjectName,
- // UserId = wire.UserId,
- // SeqNo = wire.SeqNo,
- // ApplicationScenario = wire.ApplicationScenario,
-
- // WireDiameterSpecification = wire.WireDiameterSpecification,
- // IsHighFlexibilityStr = wire.IsHighFlexibilityStr,
- // WireCoreCount = wire.WireCoreCount,
- // WireModelSpecification = wire.WireModelSpecification,
-
- // FrontConnectorModel = wire.FrontConnectorModel,
- // FrontConnectorQuantity = wire.FrontConnectorQuantity,
- // RearConnectorModel = wire.RearConnectorModel,
- // RearConnectorQuantity = wire.RearConnectorQuantity
-
- //});
var wireData = MapperUtil.MapFor(wire);
Application.Current.Dispatcher.BeginInvoke(() =>
{
@@ -934,11 +909,31 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
new { MechanismNo, MechanismName, WireModelStr= '2' },
new { MechanismNo, MechanismName, WireModelStr= '3' }
}
- },new OpenXmlConfiguration
- {
- FillMergedCells = true
});
}
+
+ public void SaveWireCoreData(MultiCoreWireDataModel tag)
+ {
+ //var coreWireData = MapperUtil.MapFor(tag);
+ var coreWireDatas = new List();
+ if(tag.Children != null && tag.Children.Any())
+ {
+ var seq = 0;
+ tag.Children.ForEach(it =>
+ {
+ seq++;
+ coreWireDatas.Add(new MultiWireCoreDataModel
+ {
+ Id = Guid.NewGuid().ToString(),
+ PId = tag.Id,
+ CoreWireName = it.WireModelSpecification,
+ PinIndex = it.PinIndex,
+ CoreNumberTube = it.CoreNumberTube,
+ SeqNo = seq
+ });
+ });
+ }
+ }
}
}