105040 Update 添加多芯线选型界面
This commit is contained in:
parent
d8405f4cf6
commit
d1c511cece
|
@ -285,6 +285,8 @@
|
|||
<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="ViewModel\MultiCoreWireViewModel\MultiCoreWireViewModel.cs" />
|
||||
<Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" />
|
||||
<Compile Include="ViewModel\WireCheck\MainViewModel.cs" />
|
||||
|
|
|
@ -3,28 +3,168 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:multicorewireviewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel"
|
||||
Title="多芯线数据抓取"
|
||||
Width="800"
|
||||
Width="850"
|
||||
Height="450"
|
||||
d:DataContext="{d:DesignInstance Type=multicorewireviewmodel:MultiCoreWireViewModel}"
|
||||
FontSize="14"
|
||||
Loaded="Window_Loaded"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0">
|
||||
<StackPanel />
|
||||
</StackPanel>
|
||||
<TabControl Grid.Row="1">
|
||||
<TabItem Header="多芯线选型">
|
||||
<StackPanel />
|
||||
</TabItem>
|
||||
<TabItem Header="数据抓取">
|
||||
<StackPanel />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Grid>
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<TabControl>
|
||||
<TabItem Header="多芯线选型">
|
||||
<StackPanel Margin="0" Orientation="Vertical">
|
||||
<Border
|
||||
Grid.Row="0"
|
||||
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>
|
||||
<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>
|
||||
<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>
|
||||
</Border>
|
||||
<ListBox>
|
||||
<ListBoxItem>
|
||||
<TextBlock Text="TEST" />
|
||||
</ListBoxItem>
|
||||
</ListBox>
|
||||
</StackPanel>
|
||||
</TabItem>
|
||||
<TabItem Header="数据抓取">
|
||||
<ListBox
|
||||
Padding="0"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
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>
|
||||
<Expander.Resources>
|
||||
<Style BasedOn="{StaticResource ExpanderBaseStyle}" TargetType="Expander">
|
||||
<Setter Property="Background" Value="#CC002255" />
|
||||
</Style>
|
||||
</Expander.Resources>
|
||||
<Expander.Header>
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Foreground="White"
|
||||
Text="{Binding WireModelSpecification}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</Expander.Header>
|
||||
<ItemsControl ItemsSource="{Binding Children}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Margin="5" IsItemsHost="True" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border
|
||||
Margin="10,0"
|
||||
BorderBrush="{Binding WireColorHex}"
|
||||
BorderThickness="0,0,0,2">
|
||||
|
||||
<hc:SimpleStackPanel>
|
||||
<TextBlock Margin="2">
|
||||
<Run Text="线芯名称:" />
|
||||
<Run Text="{Binding WireModelSpecification}" />
|
||||
</TextBlock>
|
||||
<TextBlock Margin="2">
|
||||
<Run Text="线芯颜色:" />
|
||||
<Run Text="{Binding WireColorName}" />
|
||||
</TextBlock>
|
||||
<TextBlock Margin="2">
|
||||
<Run Text="前端子:" />
|
||||
<Run Text="{Binding FrontTerminalModel}" />
|
||||
</TextBlock>
|
||||
<TextBlock Margin="2">
|
||||
<Run Text="后端子:" />
|
||||
<Run Text="{Binding BackTerminalModel}" />
|
||||
</TextBlock>
|
||||
</hc:SimpleStackPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Expander>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
</Window>
|
||||
|
|
|
@ -32,5 +32,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
{
|
||||
viewModel.LoadData();
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.AddWire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model
|
||||
{
|
||||
public class MultiCoreWireDataModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 线材型号规格
|
||||
/// </summary>
|
||||
public string WireModelSpecification { get; set; }
|
||||
/// <summary>
|
||||
/// 线材颜色名
|
||||
/// </summary>
|
||||
public string WireColorName { get; set; }
|
||||
/// <summary>
|
||||
/// 线材颜色十六进制
|
||||
/// </summary>
|
||||
public string WireColorHex { get; set; }
|
||||
/// <summary>
|
||||
/// 线材颜色十六进制 次颜色
|
||||
/// </summary>
|
||||
public string WireColorHexSec { get; set; }
|
||||
|
||||
public bool IsMultiColor { get; set; }
|
||||
|
||||
public string WireType { get; set; }
|
||||
|
||||
public string WireLength { get; set; }
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public bool IsHighFlexibility { get; set; }
|
||||
/// <summary>
|
||||
/// 插头型号
|
||||
/// </summary>
|
||||
public string ConnectorModel { get; set; }
|
||||
/// <summary>
|
||||
/// 前端子型号
|
||||
/// </summary>
|
||||
public string FrontTerminalModel { get; set; }
|
||||
/// <summary>
|
||||
/// 后端子型号
|
||||
/// </summary>
|
||||
public string BackTerminalModel { get; set; }
|
||||
|
||||
private List<MultiCoreWireDataModel> _children = [];
|
||||
public List<MultiCoreWireDataModel> Children
|
||||
{
|
||||
get { return _children; }
|
||||
set { _children = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model
|
||||
{
|
||||
public class MultiCoreWireLecModel
|
||||
{
|
||||
/*
|
||||
* 应用场景 类型 线径规格(mm2) 是否高柔 线芯数 线材型号规格 插头型号 前端子型号 后端子型号
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// 应用场景
|
||||
/// </summary>
|
||||
public string ApplicationScenario { get; set; }
|
||||
/// <summary>
|
||||
/// 线材类型
|
||||
/// </summary>
|
||||
public string WireType { get; set; }
|
||||
/// <summary>
|
||||
/// 线径规格(mm2)
|
||||
/// </summary>
|
||||
public string WireDiameterSpecification { get; set; }
|
||||
/// <summary>
|
||||
/// 是否高柔
|
||||
/// </summary>
|
||||
public bool IsHighFlexibility { get; set; }
|
||||
/// <summary>
|
||||
/// 线芯数
|
||||
/// </summary>
|
||||
public int WireCoreCount { get; set; }
|
||||
/// <summary>
|
||||
/// 线材型号规格
|
||||
/// </summary>
|
||||
public string WireModelSpecification { get; set; }
|
||||
/// <summary>
|
||||
/// 插头型号
|
||||
/// </summary>
|
||||
public string ConnectorModel { get; set; }
|
||||
/// <summary>
|
||||
/// 前端子型号
|
||||
/// </summary>
|
||||
public string FrontTerminalModel { get; set; }
|
||||
/// <summary>
|
||||
/// 后端子型号
|
||||
/// </summary>
|
||||
public string BackTerminalModel { get; set; }
|
||||
|
||||
}
|
||||
}
|
|
@ -1,9 +1,14 @@
|
|||
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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
@ -16,34 +21,60 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
{
|
||||
public string _docId = docId;
|
||||
|
||||
|
||||
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
||||
|
||||
public ObservableCollection<MultiCoreWireDataModel> Wires
|
||||
{
|
||||
get { return _wires; }
|
||||
set
|
||||
{
|
||||
_wires = value;
|
||||
OnPropertyChanged(nameof(Wires));
|
||||
}
|
||||
}
|
||||
public Task LoadData()
|
||||
{
|
||||
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId);
|
||||
if (des == null)
|
||||
{
|
||||
throw new Exception("设计器不存在");
|
||||
}
|
||||
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId) ?? throw new Exception("设计器不存在");
|
||||
var materials = Material.GetPredefinedMaterials().Select(it => it.Diffuse);
|
||||
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
|
||||
Wires?.Clear();
|
||||
cables.Where(it => it.Name?.StartsWith("信号线") ?? false).ForEach(it =>
|
||||
{
|
||||
Debug.WriteLine($"{it.Name} - {it.LibraryName}");
|
||||
var wireData = new MultiCoreWireDataModel
|
||||
{
|
||||
WireModelSpecification = it.LibraryName
|
||||
};
|
||||
//Debug.WriteLine($"{it.Name} - {it.LibraryName}");
|
||||
if (it.Children?.Any() ?? false)
|
||||
{
|
||||
it.Children.ForEach(c =>
|
||||
{
|
||||
Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
|
||||
//Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
|
||||
if (c.Children?.Any() ?? false)
|
||||
{
|
||||
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
|
||||
{
|
||||
if(cc is OccWire wire)
|
||||
{
|
||||
Debug.WriteLine($"\t\t{wire.Name} - {wire.LibraryName} - {wire.Color.Major.Color.Name} - {wire.Color.GetType()}");
|
||||
//var color = materials.Where(col => col == wire.Color)
|
||||
//Debug.WriteLine($"\t\t{wire.Name} - {wire.LibraryName} - {FlexColors.GetName(wire.Color.Major)}");
|
||||
wireData.Children.Add(new MultiCoreWireDataModel
|
||||
{
|
||||
WireModelSpecification = wire.Name,
|
||||
WireColorName = FlexColors.GetName(wire.Color.Major) + (FlexColors.GetName(wire.Color.Minor) == "未设置" ? "" : " " + FlexColors.GetName(wire.Color.Minor)),
|
||||
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
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Wires?.Add(wireData);
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
@ -55,5 +86,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
public void AddWire()
|
||||
{
|
||||
//Wires?.Add(new MultiCoreWireLecModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue