105040
添加 MultiWireCoreDataModel 支持及自定义滚动功能 在 `DBHelper.cs` 中初始化 `MultiWireCoreDataModel` 表,并在 `MultiWireCoreDataModel.cs` 中定义其属性。更新项目文件以包含新模型和自定义的 `MyScrollViewer`,重写鼠标滚动事件以改善用户体验。修改 `MultiCoreWireDataModel` 属性,添加新的绝缘相关字段,并在视图模型中实现数据加载和保存逻辑。更新 XAML 文件以使用新的滚动控件。
This commit is contained in:
parent
e40d2ce185
commit
c6d5b7883a
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
/// <summary>
|
||||
/// 线芯引脚号
|
||||
/// </summary>
|
||||
public int PinIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 线芯号码管标示
|
||||
/// </summary>
|
||||
public string CoreNumberTube { get; set; }
|
||||
}
|
||||
}
|
|
@ -74,6 +74,7 @@
|
|||
<Compile Include="Model\MotorDataModel.cs" />
|
||||
<Compile Include="Model\MotorModel.cs" />
|
||||
<Compile Include="Model\MultiCoreWireLecDBModel.cs" />
|
||||
<Compile Include="Model\MultiWireCoreDataModel.cs" />
|
||||
<Compile Include="Model\UserInfo.cs" />
|
||||
<Compile Include="PluginServices.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
|||
/// <summary>
|
||||
/// 引脚编号
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 线芯号码管标示
|
||||
/// </summary>
|
||||
public string CoreNumberTube
|
||||
{
|
||||
get { return _coreNumberTube; }
|
||||
set
|
||||
{
|
||||
_coreNumberTube = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
绝缘软套型号
|
||||
绝缘软套型号物料编码
|
||||
绝缘软套数量
|
||||
*/
|
||||
private string _insulationModel;
|
||||
/// <summary>
|
||||
/// E绝缘软套型号
|
||||
/// </summary>
|
||||
public string InsulationModel
|
||||
{
|
||||
get { return _insulationModel; }
|
||||
set
|
||||
{
|
||||
|
||||
_insulationModel = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// E绝缘软套型号物料编码
|
||||
/// </summary>
|
||||
private string _insulationMaterialNo;
|
||||
public string InsulationMaterialNo
|
||||
{
|
||||
get { return _insulationMaterialNo; }
|
||||
set
|
||||
{
|
||||
|
||||
_insulationMaterialNo = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绝缘软套型号数量
|
||||
/// </summary>
|
||||
public int InsulationQuantity { get; set; } = 1;
|
||||
|
||||
private List<MultiCoreWireDataModel> _children = [];
|
||||
public List<MultiCoreWireDataModel> 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)
|
||||
{
|
||||
|
|
|
@ -239,6 +239,7 @@
|
|||
<Compile Include="Common\CommonMessage.cs" />
|
||||
<Compile Include="Common\LectotypeMessage.cs" />
|
||||
<Compile Include="Common\OpenDrawMessage.cs" />
|
||||
<Compile Include="Controls\MyScrollViewer.cs" />
|
||||
<Compile Include="Converter\ConnectionTypeConverter.cs" />
|
||||
<Compile Include="Converter\FlagEnumConverter.cs" />
|
||||
<Compile Include="Converter\NameTypeConverter.cs" />
|
||||
|
@ -289,6 +290,7 @@
|
|||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||
<Compile Include="Utils\MultiCoreWireExcelHelper.cs" />
|
||||
<Compile Include="Utils\ScrollSynchronizer.cs" />
|
||||
<Compile Include="Utils\ScrollViewerBehavior.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\CableLectotypeViewModel.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\LayoutHelperViewModel.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\LectotypeViewModel.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);
|
||||
}
|
||||
}
|
|
@ -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 @@
|
|||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="数据抓取">
|
||||
<ListBox
|
||||
x:Name="DataList"
|
||||
Padding="0"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
utils:ScrollSynchronizer.AutoSynchronizeChildren="True"
|
||||
Focusable="True"
|
||||
ItemsSource="{Binding Wires}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
VirtualizingPanel.ScrollUnit="Pixel">
|
||||
<ListBox.Resources>
|
||||
<Style BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="{x:Type ListBox}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListBoxItemBaseStyle}" TargetType="{x:Type ListBoxItem}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#E0E0E0" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border>
|
||||
<Expander IsExpanded="False">
|
||||
<Expander.Resources>
|
||||
<Style BasedOn="{StaticResource ExpanderBaseStyle}" TargetType="Expander">
|
||||
<Setter Property="Background" Value="#CC002255" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
<localCtr:MyScrollViewer>
|
||||
<ListBox
|
||||
x:Name="DataList"
|
||||
Padding="0"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Focusable="True"
|
||||
ItemsSource="{Binding Wires}"
|
||||
PreviewMouseWheel="ListView_PreviewMouseWheel"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<ListBox.Resources>
|
||||
<Style BasedOn="{StaticResource ListBoxBaseStyle}" TargetType="{x:Type ListBox}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
</Style>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListBoxItemBaseStyle}" TargetType="{x:Type ListBoxItem}">
|
||||
<Style.Setters>
|
||||
<Setter Property="Padding" Value="0" />
|
||||
</Style.Setters>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#E0E0E0" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border>
|
||||
<Expander IsExpanded="False">
|
||||
<Expander.Resources>
|
||||
<Style BasedOn="{StaticResource ExpanderBaseStyle}" TargetType="Expander">
|
||||
<Setter Property="Background" Value="#CC002255" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsError}" Value="True">
|
||||
<Setter Property="Background" Value="#dc4d41" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Expander.Resources>
|
||||
<Expander.Header>
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
MinWidth="700"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{Binding WireModelSpecification}" />
|
||||
<TextBlock
|
||||
Margin="10,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{Binding CheckedMsg}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</Expander.Header>
|
||||
<TabControl>
|
||||
<TabItem Header="线芯数据">
|
||||
<hc:SimpleStackPanel Orientation="Vertical">
|
||||
<Button
|
||||
Margin="5"
|
||||
Click="SaveWireCoreData_Click"
|
||||
Content="保存线芯信息"
|
||||
Style="{StaticResource ButtonSuccess}"
|
||||
Tag="{Binding}" />
|
||||
<DataGrid
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Children}"
|
||||
PreviewMouseWheel="ListView_PreviewMouseWheel">
|
||||
<DataGrid.Resources>
|
||||
<localconverter:WireColorConverter x:Key="WireColorConverter" />
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding WireModelSpecification}" Header="线芯名称" />
|
||||
<DataGridTemplateColumn Header="线芯颜色">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Border>
|
||||
<Border.Resources>
|
||||
<Style BasedOn="{StaticResource BorderClip}" TargetType="Border">
|
||||
<Setter Property="BorderBrush">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{StaticResource WireColorConverter}">
|
||||
<Binding Path="WireColorHex" />
|
||||
<Binding Path="WireColorHexSec" />
|
||||
<Binding Path="IsMultiColor" />
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,4" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<TextBlock Text="{Binding WireColorName}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding FrontConnectorModel}" Header="前连接" />
|
||||
<DataGridTextColumn Binding="{Binding FrontConnectorMCode}" Header="前连接料号" />
|
||||
<DataGridTextColumn Binding="{Binding RearConnectorModel}" Header="后连接" />
|
||||
<DataGridTextColumn Binding="{Binding RearConnectorMCode}" Header="后连接料号" />
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.Header>
|
||||
<TextBlock Text="线芯引脚号" />
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<hc:SimpleStackPanel>
|
||||
<hc:TextBox Text="{Binding PinIndex, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.Header>
|
||||
<TextBlock Text="线芯号码管标示" />
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<hc:SimpleStackPanel>
|
||||
<hc:TextBox Text="{Binding CoreNumberTube, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding InsulationModel}" Header="绝缘软套型号" />
|
||||
<DataGridTextColumn Binding="{Binding InsulationMaterialNo}" Header="绝缘软套型号物料编码" />
|
||||
<DataGridTextColumn Binding="{Binding InsulationQuantity}" Header="绝缘软套数量" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</hc:SimpleStackPanel>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
</Style>
|
||||
</Expander.Resources>
|
||||
<Expander.Header>
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
MinWidth="700"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{Binding WireModelSpecification}" />
|
||||
<TextBlock
|
||||
Margin="10,0"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{Binding CheckedMsg}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</Expander.Header>
|
||||
<DataGrid
|
||||
utils:ScrollSynchronizer.SynchronizeWithParent="True"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Children}">
|
||||
<DataGrid.Resources>
|
||||
<localconverter:WireColorConverter x:Key="WireColorConverter" />
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding WireModelSpecification}" Header="线芯名称" />
|
||||
<DataGridTemplateColumn Header="线芯颜色">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Border>
|
||||
<Border.Resources>
|
||||
<Style BasedOn="{StaticResource BorderClip}" TargetType="Border">
|
||||
<Setter Property="BorderBrush">
|
||||
<Setter.Value>
|
||||
<MultiBinding Converter="{StaticResource WireColorConverter}">
|
||||
<Binding Path="WireColorHex" />
|
||||
<Binding Path="WireColorHexSec" />
|
||||
<Binding Path="IsMultiColor" />
|
||||
</MultiBinding>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,4" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<Setter Property="Margin" Value="0" />
|
||||
</Style>
|
||||
</Border.Resources>
|
||||
<TextBlock Text="{Binding WireColorName}" />
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding FrontConnectorModel}" Header="前连接" />
|
||||
<DataGridTextColumn Binding="{Binding FrontConnectorMCode}" Header="前连接料号" />
|
||||
<DataGridTextColumn Binding="{Binding RearConnectorModel}" Header="后连接" />
|
||||
<DataGridTextColumn Binding="{Binding RearConnectorMCode}" Header="后连接料号" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Expander>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Expander>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</localCtr:MyScrollViewer>
|
||||
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<MultiCoreWireExcelModel> _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<MultiCoreWireLecDBModel, MultiCoreWireDataModel>(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<MultiWireCoreDataModel, MultiCoreWireDataModel>(tag);
|
||||
var coreWireDatas = new List<MultiWireCoreDataModel>();
|
||||
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
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue