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 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + +