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\LayoutHelperViewModel.cs" />
|
||||||
<Compile Include="ViewModel\CableLectotype\LectotypeViewModel.cs" />
|
<Compile Include="ViewModel\CableLectotype\LectotypeViewModel.cs" />
|
||||||
<Compile Include="ViewModel\LoginViewModel.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\MultiCoreWireViewModel\MultiCoreWireViewModel.cs" />
|
||||||
<Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" />
|
<Compile Include="ViewModel\WireCheck\MainViewModel.Check.cs" />
|
||||||
<Compile Include="ViewModel\WireCheck\MainViewModel.cs" />
|
<Compile Include="ViewModel\WireCheck\MainViewModel.cs" />
|
||||||
|
|
|
@ -3,28 +3,168 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
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:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.View"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:multicorewireviewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel"
|
||||||
Title="多芯线数据抓取"
|
Title="多芯线数据抓取"
|
||||||
Width="800"
|
Width="850"
|
||||||
Height="450"
|
Height="450"
|
||||||
|
d:DataContext="{d:DesignInstance Type=multicorewireviewmodel:MultiCoreWireViewModel}"
|
||||||
|
FontSize="14"
|
||||||
Loaded="Window_Loaded"
|
Loaded="Window_Loaded"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Grid>
|
<Window.Resources>
|
||||||
<Grid.RowDefinitions>
|
<ResourceDictionary>
|
||||||
<RowDefinition Height="80" />
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<RowDefinition Height="*" />
|
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||||
</Grid.RowDefinitions>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<StackPanel Grid.Row="0">
|
</ResourceDictionary>
|
||||||
<StackPanel />
|
</Window.Resources>
|
||||||
</StackPanel>
|
<TabControl>
|
||||||
<TabControl Grid.Row="1">
|
<TabItem Header="多芯线选型">
|
||||||
<TabItem Header="多芯线选型">
|
<StackPanel Margin="0" Orientation="Vertical">
|
||||||
<StackPanel />
|
<Border
|
||||||
</TabItem>
|
Grid.Row="0"
|
||||||
<TabItem Header="数据抓取">
|
Margin="0"
|
||||||
<StackPanel />
|
VerticalAlignment="Top"
|
||||||
</TabItem>
|
Style="{StaticResource BorderRegion}">
|
||||||
</TabControl>
|
<WrapPanel>
|
||||||
</Grid>
|
<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>
|
</Window>
|
||||||
|
|
|
@ -32,5 +32,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
{
|
{
|
||||||
viewModel.LoadData();
|
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.Common.Extensions;
|
||||||
|
using EPLAN.Harness.Core;
|
||||||
|
using EPLAN.Harness.Core.Appearance;
|
||||||
|
using EPLAN.Harness.Core.Utils;
|
||||||
using EPLAN.Harness.MathLib.Styling;
|
using EPLAN.Harness.MathLib.Styling;
|
||||||
using EPLAN.Harness.ProjectCore;
|
using EPLAN.Harness.ProjectCore;
|
||||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -16,34 +21,60 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
{
|
{
|
||||||
public string _docId = docId;
|
public string _docId = docId;
|
||||||
|
|
||||||
|
|
||||||
|
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
||||||
|
|
||||||
|
public ObservableCollection<MultiCoreWireDataModel> Wires
|
||||||
|
{
|
||||||
|
get { return _wires; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_wires = value;
|
||||||
|
OnPropertyChanged(nameof(Wires));
|
||||||
|
}
|
||||||
|
}
|
||||||
public Task LoadData()
|
public Task LoadData()
|
||||||
{
|
{
|
||||||
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId);
|
var des = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(it => it.ID == _docId) ?? throw new Exception("设计器不存在");
|
||||||
if (des == null)
|
var materials = Material.GetPredefinedMaterials().Select(it => it.Diffuse);
|
||||||
{
|
|
||||||
throw new Exception("设计器不存在");
|
|
||||||
}
|
|
||||||
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
|
var cables = des.GetOrganizerOccurrences(_docId, typeof(OccCableForked));
|
||||||
|
Wires?.Clear();
|
||||||
cables.Where(it => it.Name?.StartsWith("信号线") ?? false).ForEach(it =>
|
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)
|
if (it.Children?.Any() ?? false)
|
||||||
{
|
{
|
||||||
it.Children.ForEach(c =>
|
it.Children.ForEach(c =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
|
//Debug.WriteLine($"\t{c.Name} - {c.LibraryName}");
|
||||||
if (c.Children?.Any() ?? false)
|
if (c.Children?.Any() ?? false)
|
||||||
{
|
{
|
||||||
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
|
c.Children.Where(ccc => ccc is OccWire).ForEach(cc =>
|
||||||
{
|
{
|
||||||
if(cc is OccWire wire)
|
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;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
@ -55,5 +86,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddWire()
|
||||||
|
{
|
||||||
|
//Wires?.Add(new MultiCoreWireLecModel());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue