105040 Update 完善多芯线选型界面
This commit is contained in:
parent
0698cb2ccd
commit
89a5aa21a2
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class MultiCoreWireDataModel
|
||||
{
|
|
@ -1,11 +1,13 @@
|
|||
using System;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model
|
||||
{
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class MultiCoreWireLecModel
|
||||
{
|
||||
/*
|
||||
|
@ -15,39 +17,56 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model
|
|||
/// <summary>
|
||||
/// 应用场景
|
||||
/// </summary>
|
||||
public string ApplicationScenario { get; set; }
|
||||
[ExcelColumn(Name = "应用场合")]
|
||||
public string ApplicationScenario { get; set; }
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public string WireType { get; set; }
|
||||
[ExcelColumn(Ignore = true)]
|
||||
public string WireType { get; set; }
|
||||
/// <summary>
|
||||
/// 线径规格(mm2)
|
||||
/// </summary>
|
||||
[ExcelColumn(IndexName = "F")]
|
||||
public string WireDiameterSpecification { get; set; }
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public bool IsHighFlexibility { get; set; }
|
||||
[ExcelColumn(Ignore = true)]
|
||||
public bool IsHighFlexibility { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
[ExcelColumn(Name = "是否高柔")]
|
||||
public string IsHighFlexibilityStr { get; set; }
|
||||
/// <summary>
|
||||
/// 线芯数
|
||||
/// </summary>
|
||||
public int WireCoreCount { get; set; }
|
||||
[ExcelColumn(Name = "线芯数")]
|
||||
public string WireCoreCount { get; set; }
|
||||
/// <summary>
|
||||
/// 线材型号规格
|
||||
/// </summary>
|
||||
public string WireModelSpecification { get; set; }
|
||||
[ExcelColumn(Name = "线材型号规格")]
|
||||
public string WireModelSpecification { get; set; }
|
||||
/// <summary>
|
||||
/// 插头型号
|
||||
/// </summary>
|
||||
public string ConnectorModel { get; set; }
|
||||
[ExcelColumn(Name = "插头型号")]
|
||||
public string ConnectorModel { get; set; }
|
||||
/// <summary>
|
||||
/// 前端子型号
|
||||
/// </summary>
|
||||
public string FrontTerminalModel { get; set; }
|
||||
[ExcelColumn(Ignore = true)]
|
||||
public string FrontTerminalModel { get; set; }
|
||||
/// <summary>
|
||||
/// 后端子型号
|
||||
/// </summary>
|
||||
[ExcelColumn(Ignore = true)]
|
||||
public string BackTerminalModel { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -253,22 +253,22 @@
|
|||
<Compile Include="Extension\CheckedModelExt.cs" />
|
||||
<Compile Include="Extension\MotorModelUniqueFlagExt.cs" />
|
||||
<Compile Include="Extension\PropertyListExt.cs" />
|
||||
<Compile Include="Models\CheckedModel.cs" />
|
||||
<Compile Include="Models\WireCheck\CheckedModel.cs" />
|
||||
<Compile Include="Models\ConfigItemModel.cs" />
|
||||
<Compile Include="Models\ExcelModel.cs" />
|
||||
<Compile Include="Models\ExportModel.cs" />
|
||||
<Compile Include="Models\InsulationModel.cs" />
|
||||
<Compile Include="Models\LectotypeLineModel.cs" />
|
||||
<Compile Include="Models\LectotypeModel.cs" />
|
||||
<Compile Include="Models\LineBomItemModel.cs" />
|
||||
<Compile Include="Models\LineBomModel.cs" />
|
||||
<Compile Include="Models\MotorModel.cs" />
|
||||
<Compile Include="Models\MotorPassthroughCable.cs" />
|
||||
<Compile Include="Models\MotorPowerModel.cs" />
|
||||
<Compile Include="Models\ReportModel.cs" />
|
||||
<Compile Include="Models\WireCheck\ExcelModel.cs" />
|
||||
<Compile Include="Models\WireCheck\ExportModel.cs" />
|
||||
<Compile Include="Models\WireCheck\InsulationModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\LectotypeLineModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\LectotypeModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\LineBomItemModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\LineBomModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\MotorModel.cs" />
|
||||
<Compile Include="Models\CableLectotype\MotorPassthroughCable.cs" />
|
||||
<Compile Include="Models\CableLectotype\MotorPowerModel.cs" />
|
||||
<Compile Include="Models\WireCheck\ReportModel.cs" />
|
||||
<Compile Include="Models\ScanCableModel.cs" />
|
||||
<Compile Include="Models\StuffedDataModel.cs" />
|
||||
<Compile Include="Models\TerminalModel.cs" />
|
||||
<Compile Include="Models\WireCheck\StuffedDataModel.cs" />
|
||||
<Compile Include="Models\WireCheck\TerminalModel.cs" />
|
||||
<Compile Include="Models\UserLoginModel.cs" />
|
||||
<Compile Include="Selector\LectotypeLengthDataTemplateSelector.cs" />
|
||||
<Compile Include="Service\MotorLectotypeService.cs" />
|
||||
|
@ -281,12 +281,13 @@
|
|||
<Compile Include="Utils\LectotypeLineModelExt.cs" />
|
||||
<Compile Include="Utils\LectotypeManager.cs" />
|
||||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||
<Compile Include="Utils\MultiCoreWireExcelHelper.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\CableLectotypeViewModel.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\LayoutHelperViewModel.cs" />
|
||||
<Compile Include="ViewModel\CableLectotype\LectotypeViewModel.cs" />
|
||||
<Compile Include="ViewModel\LoginViewModel.cs" />
|
||||
<Compile Include="ViewModel\MultiCoreWireViewModel\Model\MultiCoreWireDataModel.cs" />
|
||||
<Compile Include="ViewModel\MultiCoreWireViewModel\Model\MultiCoreWireLecModel.cs" />
|
||||
<Compile Include="Models\MultiCoreWire\MultiCoreWireDataModel.cs" />
|
||||
<Compile Include="Models\MultiCoreWire\MultiCoreWireLecModel.cs" />
|
||||
<Compile Include="ViewModel\MultiCoreWireViewModel\MultiCoreWireViewModel.cs" />
|
||||
<Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" />
|
||||
<Compile Include="ViewModel\WireCheck\MainViewModel.cs" />
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
public static string PLUGIN_DATA_FILE_NAME = "线材选型数据表.xlsx";
|
||||
public static string PLUGIN_DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
||||
public static string PLUGIN_TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
||||
|
||||
public static string PLUGIN_MULTI_CORE_WIRE_FILE_NAME = "多芯线材选型数据.xlsx";
|
||||
/// <summary>
|
||||
/// 线径平方规格匹配
|
||||
/// </summary>
|
||||
|
@ -94,6 +94,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
Debug.WriteLine(PLUGIN_TEMPLATE_FILE_NAME);
|
||||
}
|
||||
|
||||
if (jsonObj.ContainsKey("PLUGIN_MULTI_CORE_WIRE_FILE_NAME"))
|
||||
{
|
||||
PLUGIN_MULTI_CORE_WIRE_FILE_NAME = jsonObj["PLUGIN_MULTI_CORE_WIRE_FILE_NAME"];
|
||||
Debug.WriteLine(PLUGIN_MULTI_CORE_WIRE_FILE_NAME);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
using MiniExcelLibs;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public class MultiCoreWireExcelHelper
|
||||
{
|
||||
public static MultiCoreWireExcelHelper Instance = new();
|
||||
|
||||
private Stream dataFileStream;
|
||||
public void ReadDataToStream()
|
||||
{
|
||||
var file = Path.Combine(Consts.PLUGIN_DATA_FILE_PATH, Consts.PLUGIN_MULTI_CORE_WIRE_FILE_NAME);
|
||||
if (File.Exists(file))
|
||||
{
|
||||
var bytes = File.ReadAllBytes(file);
|
||||
dataFileStream = new MemoryStream(bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new FileNotFoundException(file);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MultiCoreWireLecModel> GetMultiCoreWireLecDatas()
|
||||
{
|
||||
if (dataFileStream == null || !dataFileStream.CanRead)
|
||||
{
|
||||
// 未初始化或是无法读取时,重试一次
|
||||
ReadDataToStream();
|
||||
}
|
||||
//var filePath = "D:\\旧电脑文件\\Desktop\\Data\\三菱伺服HK-KT线材选型BOM表_按程序格式整理后.xlsx";
|
||||
var data = MiniExcel.Query<MultiCoreWireLecModel>(dataFileStream,sheetName: "多芯线WPS数据配对");
|
||||
//MiniExcel.Query()
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,55 +29,128 @@
|
|||
Margin="0"
|
||||
VerticalAlignment="Top"
|
||||
Style="{StaticResource BorderRegion}">
|
||||
<WrapPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
<hc:SimpleStackPanel Orientation="Vertical">
|
||||
<hc:SimpleStackPanel.Resources>
|
||||
<Style BasedOn="{StaticResource TextBlockBaseStyle}" TargetType="TextBlock">
|
||||
<Setter Property="MinWidth" Value="80" />
|
||||
</Style>
|
||||
</hc:SimpleStackPanel.Resources>
|
||||
<hc:SimpleStackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<hc:SimpleStackPanel
|
||||
MinWidth="200"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="100"
|
||||
Margin="10,0"
|
||||
ItemsSource="{Binding ApplicationScenarios}"
|
||||
SelectedValue="{Binding ApplicationScenario}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="类型:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="100"
|
||||
Margin="10,0"
|
||||
SelectedValue="{Binding WireType, Mode=TwoWay}"
|
||||
SelectedValuePath="Content">
|
||||
<ComboBoxItem Content="插头+端子" />
|
||||
<ComboBoxItem Content="端子+端子" />
|
||||
</hc:ComboBox>
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||
<hc:SimpleStackPanel
|
||||
MinWidth="200"
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="线径规格:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="60"
|
||||
Margin="10,0"
|
||||
ItemsSource="{Binding WireDiameterSpecifications}"
|
||||
SelectedValue="{Binding WireDiameterSpecification}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="是否高柔:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="50"
|
||||
Margin="10,0"
|
||||
SelectedValue="{Binding HighFlexibility, Mode=TwoWay}"
|
||||
SelectedValuePath="Content">
|
||||
<ComboBoxItem Content="是" />
|
||||
<ComboBoxItem Content="否" />
|
||||
<ComboBoxItem Content="" />
|
||||
</hc:ComboBox>
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
<TextBlock VerticalAlignment="Center" Text="线芯数量:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="30"
|
||||
Margin="10,0"
|
||||
ItemsSource="{Binding WireCores}"
|
||||
SelectedValue="{Binding WireCoreCount}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
<TextBlock VerticalAlignment="Center" Text="线材型号:" />
|
||||
<hc:ComboBox
|
||||
MinWidth="100"
|
||||
Margin="10,0"
|
||||
AutoComplete="True"
|
||||
IsEditable="True"
|
||||
ItemsSource="{Binding WireModelSpecifications}"
|
||||
SelectedValue="{Binding WireModelSpecification}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock VerticalAlignment="Center" Text="应用场景:" />
|
||||
<hc:ComboBox MinWidth="100" Margin="10,0" />
|
||||
</hc:SimpleStackPanel>
|
||||
</WrapPanel>
|
||||
<DockPanel>
|
||||
<hc:SimpleStackPanel
|
||||
Margin="2"
|
||||
VerticalAlignment="Center"
|
||||
DockPanel.Dock="Left"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Click="SaveLecToLine_Click"
|
||||
Content="保存选择的线"
|
||||
Style="{StaticResource ButtonSuccess}" />
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Click="ClearLecData_Click"
|
||||
Content="清除选择"
|
||||
Style="{StaticResource ButtonWarning}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel DockPanel.Dock="Right">
|
||||
<Button
|
||||
Margin="10,0"
|
||||
HorizontalAlignment="Right"
|
||||
Click="ClearLecLine_Click"
|
||||
Content="清空选中的线"
|
||||
Style="{StaticResource ButtonDanger}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</DockPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
</Border>
|
||||
<ListBox>
|
||||
<ListBoxItem>
|
||||
<TextBlock Text="TEST" />
|
||||
</ListBoxItem>
|
||||
<ListBox ItemsSource="{Binding LecWires}">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding WireModelSpecification}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
|
|
|
@ -1,18 +1,5 @@
|
|||
using EPLAN.Harness.Common.Extensions;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||
{
|
||||
|
@ -21,7 +8,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
/// </summary>
|
||||
public partial class MultiCoreWireWindow : Window
|
||||
{
|
||||
private MultiCoreWireViewModel viewModel;
|
||||
private readonly MultiCoreWireViewModel viewModel;
|
||||
public MultiCoreWireWindow(string docId)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -30,12 +17,23 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.LoadData();
|
||||
viewModel.LoadWiresData();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
|
||||
private void SaveLecToLine_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.AddWire();
|
||||
viewModel.SaveLecToLine();
|
||||
}
|
||||
|
||||
private void ClearLecData_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.ClearLecData();
|
||||
}
|
||||
|
||||
private void ClearLecLine_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.ClearLecLines();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,28 @@
|
|||
using EPLAN.Harness.Common.Extensions;
|
||||
using EPLAN.Harness.Core;
|
||||
using EPLAN.Harness.Core.Appearance;
|
||||
using EPLAN.Harness.Core.Utils;
|
||||
using EPLAN.Harness.MathLib.Styling;
|
||||
using EPLAN.Harness.ProjectCore;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model;
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||
{
|
||||
public class MultiCoreWireViewModel(string docId) : INotifyPropertyChanged
|
||||
{
|
||||
public string _docId = docId;
|
||||
|
||||
private readonly MultiCoreWireExcelHelper _dataHelper = MultiCoreWireExcelHelper.Instance;
|
||||
#region Props
|
||||
|
||||
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
||||
|
||||
|
@ -33,10 +35,339 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
OnPropertyChanged(nameof(Wires));
|
||||
}
|
||||
}
|
||||
public Task LoadData()
|
||||
|
||||
private ObservableCollection<MultiCoreWireLecModel> _lecWires = [];
|
||||
|
||||
public ObservableCollection<MultiCoreWireLecModel> LecWires
|
||||
{
|
||||
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId) ?? throw new Exception("设计器不存在");
|
||||
get { return _lecWires; }
|
||||
set
|
||||
{
|
||||
_lecWires = value;
|
||||
OnPropertyChanged(nameof(LecWires));
|
||||
}
|
||||
}
|
||||
|
||||
private string _applicationScenario;
|
||||
/// <summary>
|
||||
/// 应用场景
|
||||
/// </summary>
|
||||
public string ApplicationScenario
|
||||
{
|
||||
get => _applicationScenario;
|
||||
set
|
||||
{
|
||||
_applicationScenario = value;
|
||||
OnPropertyChanged(nameof(ApplicationScenario));
|
||||
OnLecChanged(nameof(ApplicationScenario));
|
||||
}
|
||||
}
|
||||
|
||||
private string _wireType;
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public string WireType
|
||||
{
|
||||
get => _wireType;
|
||||
set
|
||||
{
|
||||
_wireType = value;
|
||||
OnPropertyChanged(nameof(WireType));
|
||||
OnLecChanged(nameof(WireType));
|
||||
}
|
||||
}
|
||||
private string _wireDiameterSpecification;
|
||||
/// <summary>
|
||||
/// 线径规格(mm2)
|
||||
/// </summary>
|
||||
public string WireDiameterSpecification
|
||||
{
|
||||
get => _wireDiameterSpecification;
|
||||
set
|
||||
{
|
||||
_wireDiameterSpecification = value;
|
||||
OnPropertyChanged(nameof(WireDiameterSpecification));
|
||||
OnLecChanged(nameof(WireDiameterSpecification));
|
||||
}
|
||||
|
||||
}
|
||||
private string _highFlexibility;
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public string HighFlexibility
|
||||
{
|
||||
get => _highFlexibility;
|
||||
set
|
||||
{
|
||||
_highFlexibility = value;
|
||||
OnPropertyChanged(nameof(HighFlexibility));
|
||||
OnLecChanged(nameof(HighFlexibility));
|
||||
}
|
||||
}
|
||||
private string _wireCoreCount;
|
||||
/// <summary>
|
||||
/// 线芯数
|
||||
/// </summary>
|
||||
public string WireCoreCount
|
||||
{
|
||||
get => _wireCoreCount;
|
||||
set
|
||||
{
|
||||
_wireCoreCount = value;
|
||||
OnPropertyChanged(nameof(WireCoreCount));
|
||||
OnLecChanged(nameof(WireCoreCount));
|
||||
}
|
||||
}
|
||||
private string _wireModelSpecification;
|
||||
/// <summary>
|
||||
/// 线材型号规格
|
||||
/// </summary>
|
||||
public string WireModelSpecification
|
||||
{
|
||||
get => _wireModelSpecification;
|
||||
set
|
||||
{
|
||||
_wireModelSpecification = value;
|
||||
OnPropertyChanged(nameof(WireModelSpecification));
|
||||
OnLecChanged(nameof(WireModelSpecification));
|
||||
}
|
||||
}
|
||||
private string _connectorModel;
|
||||
/// <summary>
|
||||
/// 插头型号
|
||||
/// </summary>
|
||||
public string ConnectorModel
|
||||
{
|
||||
get => _connectorModel;
|
||||
set
|
||||
{
|
||||
_connectorModel = value;
|
||||
OnPropertyChanged(nameof(ConnectorModel));
|
||||
}
|
||||
}
|
||||
private string _frontTerminalModel;
|
||||
/// <summary>
|
||||
/// 前端子型号
|
||||
/// </summary>
|
||||
public string FrontTerminalModel
|
||||
{
|
||||
get => _frontTerminalModel;
|
||||
set
|
||||
{
|
||||
_frontTerminalModel = value;
|
||||
OnPropertyChanged(nameof(FrontTerminalModel));
|
||||
}
|
||||
}
|
||||
|
||||
private string _backTerminalModel;
|
||||
/// <summary>
|
||||
/// 后端子型号
|
||||
/// </summary>
|
||||
public string BackTerminalModel
|
||||
{
|
||||
get => _backTerminalModel;
|
||||
set
|
||||
{
|
||||
_backTerminalModel = value;
|
||||
OnPropertyChanged(nameof(BackTerminalModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<string> _applicationScenarios;
|
||||
/// <summary>
|
||||
/// 使用场景
|
||||
/// </summary>
|
||||
public List<string> ApplicationScenarios
|
||||
{
|
||||
get => _applicationScenarios;
|
||||
set
|
||||
{
|
||||
_applicationScenarios = value;
|
||||
OnPropertyChanged(nameof(ApplicationScenarios));
|
||||
}
|
||||
}
|
||||
private List<string> _wireTypes;
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public List<string> WireTypes
|
||||
{
|
||||
get => _wireTypes;
|
||||
set
|
||||
{
|
||||
_wireTypes = value;
|
||||
OnPropertyChanged(nameof(WireTypes));
|
||||
}
|
||||
}
|
||||
private List<string> _wireDiameterSpecifications;
|
||||
/// <summary>
|
||||
/// 线径规格
|
||||
/// </summary>
|
||||
public List<string> WireDiameterSpecifications
|
||||
{
|
||||
get => _wireDiameterSpecifications;
|
||||
set
|
||||
{
|
||||
_wireDiameterSpecifications = value;
|
||||
OnPropertyChanged(nameof(WireDiameterSpecifications));
|
||||
}
|
||||
}
|
||||
private List<string> _wireCores;
|
||||
|
||||
/// <summary>
|
||||
/// 线芯数量
|
||||
/// </summary>
|
||||
public List<string> WireCores
|
||||
{
|
||||
get => _wireCores;
|
||||
set
|
||||
{
|
||||
_wireCores = value;
|
||||
OnPropertyChanged(nameof(WireCores));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<string> _wireModelSpecifications;
|
||||
/// <summary>
|
||||
/// 线径规格
|
||||
/// </summary>
|
||||
public List<string> WireModelSpecifications
|
||||
{
|
||||
get => _wireModelSpecifications;
|
||||
set
|
||||
{
|
||||
_wireModelSpecifications = value;
|
||||
OnPropertyChanged(nameof(WireModelSpecifications));
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> _connectorModels;
|
||||
/// <summary>
|
||||
/// 连接器型号
|
||||
/// </summary>
|
||||
public List<string> ConnectorModels
|
||||
{
|
||||
get => _connectorModels;
|
||||
set
|
||||
{
|
||||
_connectorModels = value;
|
||||
OnPropertyChanged(nameof(ConnectorModels));
|
||||
}
|
||||
}
|
||||
private List<string> _frontTerminalModels;
|
||||
/// <summary>
|
||||
/// 前端子型号
|
||||
/// </summary>
|
||||
public List<string> FrontTerminalModels
|
||||
{
|
||||
get => _frontTerminalModels;
|
||||
set
|
||||
{
|
||||
_frontTerminalModels = value;
|
||||
OnPropertyChanged(nameof(FrontTerminalModels));
|
||||
}
|
||||
}
|
||||
private List<string> _backTerminalModels;
|
||||
/// <summary>
|
||||
/// 后端子型号
|
||||
/// </summary>
|
||||
public List<string> BackTerminalModels
|
||||
{
|
||||
get => _backTerminalModels;
|
||||
set
|
||||
{
|
||||
_backTerminalModels = value;
|
||||
OnPropertyChanged(nameof(BackTerminalModels));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private IEnumerable<MultiCoreWireLecModel> _datas;
|
||||
public void LoadLecData()
|
||||
{
|
||||
_datas = _dataHelper.GetMultiCoreWireLecDatas();
|
||||
|
||||
SetDatas(_datas);
|
||||
}
|
||||
private bool LecChanging = false;
|
||||
public void OnLecChanged(string propName)
|
||||
{
|
||||
if (LecChanging) return;
|
||||
//var datas = _dataHelper.GetMultiCoreWireLecDatas();
|
||||
var canUsedDatas = _datas
|
||||
// 使用场景
|
||||
.WhereIF(!string.IsNullOrEmpty(ApplicationScenario), it => it.ApplicationScenario == ApplicationScenario)
|
||||
//线材类型
|
||||
//.WhereIF(!string.IsNullOrEmpty(WireType), it => it.WireType == LecData.WireType)
|
||||
// 线径规格
|
||||
.WhereIF(!string.IsNullOrEmpty(WireDiameterSpecification), it => it.WireDiameterSpecification == WireDiameterSpecification)
|
||||
// 是否高柔
|
||||
.WhereIF(!string.IsNullOrEmpty(HighFlexibility),it => it.IsHighFlexibilityStr == HighFlexibility)
|
||||
// 型号
|
||||
.WhereIF(!string.IsNullOrEmpty(WireModelSpecification), it => it.WireModelSpecification == WireModelSpecification)
|
||||
// 线芯数
|
||||
.WhereIF(!string.IsNullOrEmpty(WireCoreCount), it => it.WireCoreCount == WireCoreCount)
|
||||
// 连接器
|
||||
.WhereIF(!string.IsNullOrEmpty(ConnectorModel), it => it.ConnectorModel == ConnectorModel)
|
||||
.WhereIF(!string.IsNullOrEmpty(FrontTerminalModel), it => it.FrontTerminalModel == FrontTerminalModel)
|
||||
.WhereIF(!string.IsNullOrEmpty(BackTerminalModel), it => it.BackTerminalModel == BackTerminalModel)
|
||||
;
|
||||
SetDatas(canUsedDatas, propName);
|
||||
}
|
||||
|
||||
private void SetDatas(IEnumerable<MultiCoreWireLecModel> datas,string propName = "")
|
||||
{
|
||||
if (datas != null)
|
||||
{
|
||||
LecChanging = true;
|
||||
ApplicationScenarios = [.. datas.Where(it => !string.IsNullOrEmpty(it.ApplicationScenario)).Select(it => it.ApplicationScenario).Distinct(), ""];
|
||||
//if (ApplicationScenarios.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(ApplicationScenario))
|
||||
//{
|
||||
// ApplicationScenario = ApplicationScenarios.FirstOrDefault();
|
||||
//}
|
||||
WireTypes = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireType)).Select(it => it.WireType).Distinct(), ""];
|
||||
//if (WireTypes.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireType))
|
||||
//{
|
||||
// WireType = WireTypes.FirstOrDefault();
|
||||
//}
|
||||
WireDiameterSpecifications = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireDiameterSpecification)).Select(it => it.WireDiameterSpecification).Distinct(), ""];
|
||||
//if (WireDiameterSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireDiameterSpecification))
|
||||
//{
|
||||
// WireDiameterSpecification = WireDiameterSpecifications.FirstOrDefault();
|
||||
//}
|
||||
WireCores = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireCoreCount)).Select(it => it.WireCoreCount).Distinct(), ""];
|
||||
//if (WireCores.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireCoreCount))
|
||||
//{
|
||||
// WireCoreCount = WireCores.FirstOrDefault();
|
||||
//}
|
||||
WireModelSpecifications = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireModelSpecification)).Select(it => it.WireModelSpecification).Distinct(), ""];
|
||||
if (WireModelSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireModelSpecification))
|
||||
{
|
||||
WireModelSpecification = WireModelSpecifications.FirstOrDefault();
|
||||
}
|
||||
ConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.ConnectorModel)).Select(it => it.ConnectorModel).Distinct(), ""];
|
||||
FrontTerminalModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.FrontTerminalModel)).Select(it => it.FrontTerminalModel).Distinct(), ""];
|
||||
BackTerminalModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.BackTerminalModel)).Select(it => it.BackTerminalModel).Distinct(), ""];
|
||||
LecChanging = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Task LoadWiresData()
|
||||
{
|
||||
//LecData = new();
|
||||
LoadLecData();
|
||||
// 颜色信息
|
||||
var materials = Material.GetPredefinedMaterials().Select(it => it.Diffuse);
|
||||
// 抓取所有线材数据
|
||||
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId) ?? throw new Exception("设计器不存在");
|
||||
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
|
||||
Wires?.Clear();
|
||||
cables.Where(it => it.Name?.StartsWith("信号线") ?? false).ForEach(it =>
|
||||
|
@ -68,7 +399,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
IsMultiColor = wire.Color.Major.IsValid() && wire.Color.Minor.IsValid(),
|
||||
FrontTerminalModel = wire.GetEndingPins()?.FirstOrDefault()?.Parents?.FirstOrDefault()?.LibraryName,
|
||||
BackTerminalModel = wire.GetEndingPins()?.LastOrDefault()?.Parents?.FirstOrDefault()?.LibraryName
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -77,19 +408,49 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
Wires?.Add(wireData);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void AddWire()
|
||||
public void ClearLecData()
|
||||
{
|
||||
//Wires?.Add(new MultiCoreWireLecModel());
|
||||
LecChanging = true;
|
||||
ApplicationScenario = "";
|
||||
WireType = "";
|
||||
WireDiameterSpecification = "";
|
||||
HighFlexibility = "";
|
||||
WireCoreCount = "";
|
||||
WireModelSpecification = "";
|
||||
ConnectorModel = "";
|
||||
FrontTerminalModel = "";
|
||||
BackTerminalModel = "";
|
||||
|
||||
LecChanging = false;
|
||||
OnLecChanged("");
|
||||
}
|
||||
|
||||
public void SaveLecToLine()
|
||||
{
|
||||
LecWires.Add(new MultiCoreWireLecModel
|
||||
{
|
||||
ApplicationScenario = ApplicationScenario,
|
||||
WireType = WireType,
|
||||
WireDiameterSpecification = WireDiameterSpecification,
|
||||
IsHighFlexibility = HighFlexibility == "是",
|
||||
WireCoreCount = WireCoreCount,
|
||||
WireModelSpecification = WireModelSpecification,
|
||||
ConnectorModel = ConnectorModel,
|
||||
FrontTerminalModel = FrontTerminalModel,
|
||||
BackTerminalModel = BackTerminalModel
|
||||
});
|
||||
}
|
||||
|
||||
public void ClearLecLines()
|
||||
{
|
||||
LecWires.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue