105040 Update 完善多芯线选型功能
This commit is contained in:
parent
26e0c305be
commit
4df7a23796
|
|
@ -11,11 +11,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
public class PluginServices
|
public class PluginServices
|
||||||
{
|
{
|
||||||
public static UserInfo user;
|
public static UserInfo user;
|
||||||
#if DEBUG
|
|
||||||
public static bool IsLogin => user != null && !string.IsNullOrEmpty(user.GUID) && DynaServerClient.GetClient().IsLoginExpired();
|
public static bool IsLogin => user != null && !string.IsNullOrEmpty(user.GUID) && DynaServerClient.GetClient().IsLoginExpired();
|
||||||
#else
|
|
||||||
|
|
||||||
public static bool IsLogin => true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using MiniExcelLibs.Attributes;
|
using Microsoft.WindowsAPICodePack.ApplicationServices;
|
||||||
|
using MiniExcelLibs.Attributes;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models.MultiCoreWire;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models.MultiCoreWire;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -422,7 +423,23 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool _layouted;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否已布线
|
||||||
|
/// </summary>
|
||||||
|
[ExcelColumn(Ignore = true)]
|
||||||
|
public bool Layouted
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _layouted;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_layouted = value;
|
||||||
|
OnPropertyChanged(nameof(Layouted));
|
||||||
|
}
|
||||||
|
}
|
||||||
[ExcelColumn(Ignore = true)]
|
[ExcelColumn(Ignore = true)]
|
||||||
public List<MultiCoreWireTerminalModel> TerminalModels
|
public List<MultiCoreWireTerminalModel> TerminalModels
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -96,5 +96,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Service
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internal void UpdateWireIsLayout(string id)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(id))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var db = DBHelper.DB;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
db.Updateable<MultiCoreWireLecDBModel>()
|
||||||
|
.Where(it => it.Id == id)
|
||||||
|
.SetColumns(it => it.Layouted == true)
|
||||||
|
.ExecuteCommand();
|
||||||
|
db.CommitTran();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@
|
||||||
<Compile Include="Utils\LambdaComparer.cs" />
|
<Compile Include="Utils\LambdaComparer.cs" />
|
||||||
<Compile Include="Utils\LectotypeLineModelExt.cs" />
|
<Compile Include="Utils\LectotypeLineModelExt.cs" />
|
||||||
<Compile Include="Utils\LectotypeManager.cs" />
|
<Compile Include="Utils\LectotypeManager.cs" />
|
||||||
|
<Compile Include="Utils\MapperUtil.cs" />
|
||||||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||||
<Compile Include="Utils\MultiCoreWireExcelHelper.cs" />
|
<Compile Include="Utils\MultiCoreWireExcelHelper.cs" />
|
||||||
<Compile Include="ViewModel\CableLectotype\CableLectotypeViewModel.cs" />
|
<Compile Include="ViewModel\CableLectotype\CableLectotypeViewModel.cs" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
|
{
|
||||||
|
public class MapperUtil
|
||||||
|
{
|
||||||
|
public static T MapFor<T,S>(S sourceObj)
|
||||||
|
{
|
||||||
|
if (sourceObj == null)
|
||||||
|
return default(T);
|
||||||
|
var destObj = Activator.CreateInstance<T>();
|
||||||
|
var sourceType = sourceObj.GetType();
|
||||||
|
var destType = typeof(T);
|
||||||
|
foreach (var prop in destType.GetProperties())
|
||||||
|
{
|
||||||
|
var sourceProp = sourceType.GetProperty(prop.Name);
|
||||||
|
if (sourceProp != null && prop.CanWrite)
|
||||||
|
{
|
||||||
|
var value = sourceProp.GetValue(sourceObj);
|
||||||
|
prop.SetValue(destObj, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,14 +12,14 @@
|
||||||
Width="450"
|
Width="450"
|
||||||
Height="260"
|
Height="260"
|
||||||
MinWidth="450"
|
MinWidth="450"
|
||||||
MinHeight="260"
|
MinHeight="360"
|
||||||
d:DataContext="{d:DesignInstance Type=multicorewireviewmodel:MultiCoreWireLayoutHelperViewModel}"
|
d:DataContext="{d:DesignInstance Type=multicorewireviewmodel:MultiCoreWireLayoutHelperViewModel}"
|
||||||
ActiveGlowColor="{DynamicResource PrimaryColor}"
|
ActiveGlowColor="{DynamicResource PrimaryColor}"
|
||||||
Background="White"
|
Background="White"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
Left="1460"
|
Left="1460"
|
||||||
Loaded="GlowWindow_Loaded"
|
Loaded="GlowWindow_Loaded"
|
||||||
Top="770"
|
Top="700"
|
||||||
WindowStartupLocation="Manual"
|
WindowStartupLocation="Manual"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
|
@ -46,22 +46,46 @@
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Foreground="#c92d28"
|
Foreground="#c92d28"
|
||||||
Text="触摸屏" />
|
Text="{Binding ApplicationScenario}" />
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<DataGrid
|
|
||||||
|
<ListView
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
AutoGenerateColumns="False"
|
hc:GridViewAttach.ColumnHeaderHeight="10"
|
||||||
ItemsSource="{Binding LecWires}">
|
ItemsSource="{Binding LecWires}"
|
||||||
<DataGrid.Columns>
|
Style="{StaticResource ListView.Small}">
|
||||||
<DataGridTextColumn Header="序号" />
|
<ListView.ItemContainerStyle>
|
||||||
<DataGridTextColumn
|
<Style BasedOn="{StaticResource ListViewItemBaseStyle.Small}" TargetType="ListViewItem">
|
||||||
MinWidth="240"
|
<Style.Triggers>
|
||||||
Binding="{Binding WireModelSpecification}"
|
<DataTrigger Binding="{Binding Layouted}" Value="True">
|
||||||
Header="线型号" />
|
<Setter Property="Background" Value="#18a05d" />
|
||||||
<DataGridCheckBoxColumn Binding="{Binding Layouted}" Header="是否已布线" />
|
<Setter Property="Foreground" Value="White" />
|
||||||
</DataGrid.Columns>
|
</DataTrigger>
|
||||||
</DataGrid>
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ListView.ItemContainerStyle>
|
||||||
|
<ListView.View>
|
||||||
|
<GridView>
|
||||||
|
<GridViewColumn
|
||||||
|
Width="80"
|
||||||
|
DisplayMemberBinding="{Binding SeqNo}"
|
||||||
|
Header="序号" />
|
||||||
|
<GridViewColumn Width="330" Header="线型号">
|
||||||
|
<GridViewColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBox
|
||||||
|
Width="300"
|
||||||
|
MaxWidth="300"
|
||||||
|
GotFocus="TextBox_GotFocus"
|
||||||
|
IsReadOnly="True"
|
||||||
|
Text="{Binding WireModelSpecification}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</GridViewColumn.CellTemplate>
|
||||||
|
</GridViewColumn>
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
<hc:SimpleStackPanel
|
<hc:SimpleStackPanel
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
Margin="10"
|
Margin="10"
|
||||||
|
|
@ -69,14 +93,14 @@
|
||||||
<DockPanel HorizontalAlignment="Stretch">
|
<DockPanel HorizontalAlignment="Stretch">
|
||||||
<Button
|
<Button
|
||||||
Click="PrevBtn_Click"
|
Click="PrevBtn_Click"
|
||||||
Content="上一根线"
|
Content="上一个场景"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
IsEnabled="{Binding HasPrev}"
|
IsEnabled="{Binding HasPrev}"
|
||||||
Style="{StaticResource ButtonDanger}" />
|
Style="{StaticResource ButtonDanger}" />
|
||||||
<Button
|
<Button
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Click="NextBtn_Click"
|
Click="NextBtn_Click"
|
||||||
Content="下一根线"
|
Content="下一个场景"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
IsEnabled="{Binding HasNext}"
|
IsEnabled="{Binding HasNext}"
|
||||||
Style="{StaticResource ButtonPrimary}" />
|
Style="{StaticResource ButtonPrimary}" />
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using HandyControl.Controls;
|
using EPLAN.Harness.Core.Controls;
|
||||||
|
using HandyControl.Controls;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -32,17 +33,40 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWire.LayoutHelper
|
||||||
|
|
||||||
private void GlowWindow_Loaded(object sender, RoutedEventArgs e)
|
private void GlowWindow_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
ViewModel.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextBtn_Click(object sender, RoutedEventArgs e)
|
private void NextBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
ViewModel.Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PrevBtn_Click(object sender, RoutedEventArgs e)
|
private void PrevBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
ViewModel.Prev();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if(sender is System.Windows.Controls.TextBox box)
|
||||||
|
{
|
||||||
|
box.SelectAll();
|
||||||
|
CopyToClipboard(box.Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CopyToClipboard(string content)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Clipboard.SetDataObject(content);
|
||||||
|
Growl.SuccessGlobal("复制成功!");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FlexMessageBox.Error(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<Geometry x:Key="ThumbsUpGeometry">M68.191078 915.462005l161.384597 0L229.575676 431.30719 68.191078 431.30719 68.191078 915.462005zM955.808922 471.653083c0-44.582381-36.109406-80.69281-80.69281-80.69281L620.329241 390.960273 658.859789 206.578915c0.807389-4.034896 1.412163-8.271384 1.412163-12.709463 0-16.743336-6.859221-31.873941-17.752316-42.767036l-42.968627-42.565445L333.871043 374.216937c-14.524808 14.7264-23.602557 34.899858-23.602557 57.090253l0 403.462005c0 44.582381 36.109406 80.69281 80.69281 80.69281l363.116111 0c33.487695 0 62.133106-20.37505 74.236771-49.222051l121.643478-284.441261c3.63069-9.279341 5.850242-19.164478 5.850242-29.452799L955.807898 475.083206l-0.403183-0.403183L955.808922 471.653083z</Geometry>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
@ -43,6 +44,7 @@
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<Button
|
<Button
|
||||||
Margin="10,0"
|
Margin="10,0"
|
||||||
|
Click="Layout_Click"
|
||||||
Content="布线助手"
|
Content="布线助手"
|
||||||
Style="{StaticResource ButtonSuccess}" />
|
Style="{StaticResource ButtonSuccess}" />
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -120,12 +122,8 @@
|
||||||
MinWidth="100"
|
MinWidth="100"
|
||||||
Margin="10,0"
|
Margin="10,0"
|
||||||
IsEnabled="{Binding ApplicationScenarioSelected}"
|
IsEnabled="{Binding ApplicationScenarioSelected}"
|
||||||
SelectedValue="{Binding HighFlexibility, Mode=TwoWay}"
|
ItemsSource="{Binding HighFlexibilitys}"
|
||||||
SelectedValuePath="Content">
|
SelectedValue="{Binding HighFlexibility}" />
|
||||||
<ComboBoxItem Content="是" />
|
|
||||||
<ComboBoxItem Content="否" />
|
|
||||||
<ComboBoxItem Content="" />
|
|
||||||
</hc:ComboBox>
|
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<hc:SimpleStackPanel
|
<hc:SimpleStackPanel
|
||||||
|
|
@ -358,7 +356,10 @@
|
||||||
Text="{Binding WireModelSpecification}" />
|
Text="{Binding WireModelSpecification}" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
</Expander.Header>
|
</Expander.Header>
|
||||||
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Children}">
|
<DataGrid
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
ItemsSource="{Binding Children}">
|
||||||
<DataGrid.Resources>
|
<DataGrid.Resources>
|
||||||
<localconverter:WireColorConverter x:Key="WireColorConverter" />
|
<localconverter:WireColorConverter x:Key="WireColorConverter" />
|
||||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWire.LayoutHelper;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
||||||
using SqlSugar.Extensions;
|
using SqlSugar.Extensions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
@ -51,5 +52,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Layout_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MultiCoreWireLayoutHelperWindow layoutWindow = new(viewModel.CurrUniqueKey)
|
||||||
|
{
|
||||||
|
Topmost = true
|
||||||
|
};
|
||||||
|
layoutWindow.Show();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
using EPLAN.Harness.API;
|
||||||
|
using EPLAN.Harness.Common.Extensions;
|
||||||
|
using EPLAN.Harness.Core.Controls;
|
||||||
|
using EPLAN.Harness.Core;
|
||||||
|
using EPLAN.Harness.ProjectCore;
|
||||||
|
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Service;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
|
@ -7,28 +14,213 @@ using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using EPLAN.Harness.Primitives.Treeviews.NodeMaps;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
|
|
||||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
{
|
{
|
||||||
public class MultiCoreWireLayoutHelperViewModel : INotifyPropertyChanged
|
public class MultiCoreWireLayoutHelperViewModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private MultiCoreWireService _service = new();
|
||||||
private string _uniqueKey;
|
private string _uniqueKey;
|
||||||
|
private FlexDesigner _currentFlexDesigner;
|
||||||
|
|
||||||
|
private List<string> ApplicationScenarios = [];
|
||||||
|
|
||||||
|
public int ApplicationScenarioIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private List<MultiCoreWireLecModel> _wireData = [];
|
||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
public void OnPropertyChanged(string propertyName)
|
public void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void LoadData()
|
||||||
|
{
|
||||||
|
|
||||||
|
var wireDatas = _service.GetByUniqueKey(_uniqueKey);
|
||||||
|
var applicationScenarios = wireDatas.Select(it => it.ApplicationScenario).Distinct().ToList();
|
||||||
|
|
||||||
|
ApplicationScenarios = applicationScenarios;
|
||||||
|
UpdatePropNotify();
|
||||||
|
wireDatas.ForEach(wire =>
|
||||||
|
{
|
||||||
|
_wireData.Add(MapperUtil.MapFor<MultiCoreWireLecModel, MultiCoreWireLecDBModel>(wire));
|
||||||
|
});
|
||||||
|
|
||||||
|
_wireData.Where(wire => wire.ApplicationScenario == ApplicationScenario).ForEach(LecWires.Add);
|
||||||
|
|
||||||
|
UpdatePropNotify();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
GetCurrentDoc();
|
||||||
|
|
||||||
|
if(_currentFlexDesigner != null)
|
||||||
|
{
|
||||||
|
_currentFlexDesigner.SelectSet.SelectionChanged += SelectSet_SelectionChanged;
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SelectSet_SelectionChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (sender is OccSelectSet selectSet)
|
||||||
|
{
|
||||||
|
var item = selectSet.SelectedItem;
|
||||||
|
if (item is OccSubPart part)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Select part -> {part.Name} / {part.ID}");
|
||||||
|
if (part.Parents != null)
|
||||||
|
{
|
||||||
|
var SelectMotorModel = part.Parents?.First()?.Name ?? "";
|
||||||
|
Debug.WriteLine($"Select part parent -> {part.Parents?.First()?.Name} / {part.Parents?.First()?.ID}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item != null)
|
||||||
|
{
|
||||||
|
CheckSelLine(slient: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查选中的线
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slient"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool CheckSelLine(bool slient = false)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var parts = _currentFlexDesigner.SelectSet;
|
||||||
|
foreach (var part in parts)
|
||||||
|
{
|
||||||
|
if (part != null)
|
||||||
|
{
|
||||||
|
// 如果选中的是导线,则直接使用,如果选中的是绝缘层,则使用绝缘层,其他情况使用父级
|
||||||
|
var linePart = part is OccCableForked ?
|
||||||
|
part as OccCableForked
|
||||||
|
: part is OccCablesInsulatorGraph ?
|
||||||
|
part
|
||||||
|
: part.Parents?.FirstOrDefault() as OccCableForked;
|
||||||
|
if (linePart != null)
|
||||||
|
{
|
||||||
|
var libName = linePart?.LibraryName;
|
||||||
|
// 绝缘层选择上一层的导线来获取信息
|
||||||
|
if (part is OccCablesInsulatorGraph)
|
||||||
|
{
|
||||||
|
libName = (part.Parents?.First() as OccCableForked).LibraryName;
|
||||||
|
//partLineModel = (part.Parents?.First() as OccCableForked).LibraryName.Split('&')[1];
|
||||||
|
}
|
||||||
|
if(LecWires.Any(it =>it.WireModelSpecification == libName))
|
||||||
|
{
|
||||||
|
var wire = LecWires.FirstOrDefault(it => it.WireModelSpecification == libName && !it.Layouted);
|
||||||
|
if(wire != null)
|
||||||
|
{
|
||||||
|
wire.Layouted = true;
|
||||||
|
_service.UpdateWireIsLayout(wire.Id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if DEBUG
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
if(!slient)
|
||||||
|
FlexMessageBox.Warning($"当前选中的线不是推荐中的线型号");
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
if (!slient)
|
||||||
|
FlexMessageBox.Warning("抓取线信息异常");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!slient)
|
||||||
|
FlexMessageBox.Warning("请选择正确的线");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public void GetCurrentDoc()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HpdApi api = HpdApi.GetInstance();
|
||||||
|
var currentDocId = api.CurrentProject.GetActiveDocument()?.ID;
|
||||||
|
var designer = SelfControler<FlexBaseOrganizer>.FindInstance(currentDocId) as FlexDesigner;
|
||||||
|
if (designer != null)
|
||||||
|
{
|
||||||
|
_currentFlexDesigner = designer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FlexMessageBox.Warning("未找到当前打开的工作区,请先打开工作区");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FlexMessageBox.Error(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal void Next()
|
||||||
|
{
|
||||||
|
if (ApplicationScenarioIndex < ApplicationScenarios.Count - 1)
|
||||||
|
{
|
||||||
|
ApplicationScenarioIndex++;
|
||||||
|
OnPropertyChanged(nameof(ApplicationScenario));
|
||||||
|
LecWires.Clear();
|
||||||
|
_wireData.Where(wire => wire.ApplicationScenario == ApplicationScenario).ForEach(LecWires.Add);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdatePropNotify();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Prev()
|
||||||
|
{
|
||||||
|
if (ApplicationScenarioIndex > 0)
|
||||||
|
{
|
||||||
|
ApplicationScenarioIndex--;
|
||||||
|
OnPropertyChanged(nameof(ApplicationScenario));
|
||||||
|
LecWires.Clear();
|
||||||
|
_wireData.Where(wire => wire.ApplicationScenario == ApplicationScenario).ForEach(LecWires.Add);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdatePropNotify();
|
||||||
|
}
|
||||||
|
|
||||||
public MultiCoreWireLayoutHelperViewModel(string uniqueKey)
|
public MultiCoreWireLayoutHelperViewModel(string uniqueKey)
|
||||||
{
|
{
|
||||||
_uniqueKey = uniqueKey;
|
_uniqueKey = uniqueKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdatePropNotify()
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(ApplicationScenario));
|
||||||
|
OnPropertyChanged(nameof(HasPrev));
|
||||||
|
OnPropertyChanged(nameof(HasNext));
|
||||||
|
}
|
||||||
#region Props
|
#region Props
|
||||||
|
public string ApplicationScenario
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ApplicationScenarios[ApplicationScenarioIndex];
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(ApplicationScenario));
|
||||||
|
}
|
||||||
|
}
|
||||||
private ObservableCollection<MultiCoreWireLecModel> _lecWires = [];
|
private ObservableCollection<MultiCoreWireLecModel> _lecWires = [];
|
||||||
|
|
||||||
public ObservableCollection<MultiCoreWireLecModel> LecWires
|
public ObservableCollection<MultiCoreWireLecModel> LecWires
|
||||||
|
|
@ -40,6 +232,29 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
OnPropertyChanged(nameof(LecWires));
|
OnPropertyChanged(nameof(LecWires));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool HasPrev
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ApplicationScenarioIndex > 0;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(HasPrev));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool HasNext
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ApplicationScenarioIndex < ApplicationScenarios.Count - 1;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(HasNext));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
public string _docId = docId;
|
public string _docId = docId;
|
||||||
private readonly MultiCoreWireExcelHelper _dataHelper = MultiCoreWireExcelHelper.Instance;
|
private readonly MultiCoreWireExcelHelper _dataHelper = MultiCoreWireExcelHelper.Instance;
|
||||||
private readonly MultiCoreWireService _service = new();
|
private readonly MultiCoreWireService _service = new();
|
||||||
private string CurrUniqueKey = "";
|
public string CurrUniqueKey = "";
|
||||||
#region Props
|
#region Props
|
||||||
|
|
||||||
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
||||||
|
|
@ -269,7 +269,19 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
OnPropertyChanged(nameof(WireModelSpecifications));
|
OnPropertyChanged(nameof(WireModelSpecifications));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private List<string> _highFlexibilitys;
|
||||||
|
/// <summary>
|
||||||
|
/// 线径规格
|
||||||
|
/// </summary>
|
||||||
|
public List<string> HighFlexibilitys
|
||||||
|
{
|
||||||
|
get => _highFlexibilitys;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_highFlexibilitys = value;
|
||||||
|
OnPropertyChanged(nameof(HighFlexibilitys));
|
||||||
|
}
|
||||||
|
}
|
||||||
//private List<string> _connectorModels;
|
//private List<string> _connectorModels;
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 连接器型号
|
///// 连接器型号
|
||||||
|
|
@ -459,8 +471,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
var canUsedDatas = _datas
|
var canUsedDatas = _datas
|
||||||
// 使用场景
|
// 使用场景
|
||||||
.WhereIF(!string.IsNullOrEmpty(ApplicationScenario), it => it.ApplicationScenario == ApplicationScenario)
|
.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(WireDiameterSpecification), it => it.WireDiameterSpecification == WireDiameterSpecification)
|
||||||
// 是否高柔
|
// 是否高柔
|
||||||
|
|
@ -470,41 +480,42 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
// 线芯数
|
// 线芯数
|
||||||
.WhereIF(!string.IsNullOrEmpty(WireCoreCount), it => it.WireCoreCount == WireCoreCount)
|
.WhereIF(!string.IsNullOrEmpty(WireCoreCount), it => it.WireCoreCount == WireCoreCount)
|
||||||
;
|
;
|
||||||
SetDatas(canUsedDatas, propName);
|
SetDatas(canUsedDatas, propName,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDatas(IEnumerable<MultiCoreWireLecModel> datas, string propName = "")
|
private void SetDatas(IEnumerable<MultiCoreWireLecModel> datas, string propName = "",bool isLecChange = false)
|
||||||
{
|
{
|
||||||
if (datas != null)
|
if (datas != null)
|
||||||
{
|
{
|
||||||
LecChanging = true;
|
LecChanging = true;
|
||||||
|
if (!isLecChange)
|
||||||
|
{
|
||||||
ApplicationScenarios = [.. datas.Where(it => !string.IsNullOrEmpty(it.ApplicationScenario)).Select(it => it.ApplicationScenario).Distinct(), ""];
|
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))
|
//if (ApplicationScenarios.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(ApplicationScenario))
|
||||||
//{
|
//{
|
||||||
// ApplicationScenario = ApplicationScenarios.FirstOrDefault();
|
// 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(), ""];
|
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))
|
//if (WireDiameterSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireDiameterSpecification))
|
||||||
//{
|
//{
|
||||||
// WireDiameterSpecification = WireDiameterSpecifications.FirstOrDefault();
|
// WireDiameterSpecification = WireDiameterSpecifications.FirstOrDefault();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
HighFlexibilitys = [.. datas.Where(it => !string.IsNullOrEmpty(it.IsHighFlexibilityStr)).Select(it => it.IsHighFlexibilityStr).Distinct(), ""];
|
||||||
|
|
||||||
WireCores = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireCoreCount)).Select(it => it.WireCoreCount).Distinct(), ""];
|
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))
|
//if (WireCores.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireCoreCount))
|
||||||
//{
|
//{
|
||||||
// WireCoreCount = WireCores.FirstOrDefault();
|
// WireCoreCount = WireCores.FirstOrDefault();
|
||||||
//}
|
//}
|
||||||
|
//FrontConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.FrontTerminalModel)).Select(it => it.FrontTerminalModel).Distinct(), ""];
|
||||||
|
//BackConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.BackTerminalModel)).Select(it => it.BackTerminalModel).Distinct(), ""];
|
||||||
WireModelSpecifications = [.. datas.Where(it => !string.IsNullOrEmpty(it.WireModelSpecification)).Select(it => it.WireModelSpecification).Distinct(), ""];
|
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))
|
if (WireModelSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireModelSpecification))
|
||||||
{
|
{
|
||||||
WireModelSpecification = WireModelSpecifications.FirstOrDefault();
|
WireModelSpecification = WireModelSpecifications.FirstOrDefault();
|
||||||
}
|
}
|
||||||
//FrontConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.FrontTerminalModel)).Select(it => it.FrontTerminalModel).Distinct(), ""];
|
|
||||||
//BackConnectorModels = [.. datas.Where(it => !string.IsNullOrEmpty(it.BackTerminalModel)).Select(it => it.BackTerminalModel).Distinct(), ""];
|
|
||||||
LecChanging = false;
|
LecChanging = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -593,11 +604,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
||||||
HandyControl.Controls.MessageBox.Show("有信息未选择!",caption: "提示",icon: MessageBoxImage.Warning);
|
HandyControl.Controls.MessageBox.Show("有信息未选择!",caption: "提示",icon: MessageBoxImage.Warning);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//if(LecWires.Any(it=> it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification))
|
if (LecWires.Any(it => it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification
|
||||||
//{
|
&& it.FrontConnectorModel == FrontConnectorModel && it.BackConnectorModel == BackConnectorModel))
|
||||||
// MessageBox.Show("已选择相同的线!");
|
{
|
||||||
// return;
|
var result = HandyControl.Controls.MessageBox.Show("存在信息相同的线,是否继续添加?", "提示", button: MessageBoxButton.YesNo);
|
||||||
//}
|
if(!(result == MessageBoxResult.Yes))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,17 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
LectotypeWindow window;
|
LectotypeWindow window;
|
||||||
|
|
||||||
public void Execute(HpdApi api)
|
public void Execute(HpdApi api)
|
||||||
|
{
|
||||||
|
bool isLogin = PluginServices.IsLogin;
|
||||||
|
if (!isLogin)
|
||||||
|
{
|
||||||
|
var LoginWindow = new LoginWindow();
|
||||||
|
if (LoginWindow.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
isLogin = PluginServices.IsLogin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isLogin)
|
||||||
{
|
{
|
||||||
new DBHelper().CodeFirst();
|
new DBHelper().CodeFirst();
|
||||||
var doc = api.CurrentProject.GetActiveDocument();
|
var doc = api.CurrentProject.GetActiveDocument();
|
||||||
|
|
@ -82,6 +93,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
window.Activate();
|
window.Activate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (!AppDomainDllLoader.isLoaded)
|
if (!AppDomainDllLoader.isLoaded)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ using System.Windows.Forms.Integration;
|
||||||
|
|
||||||
namespace Sinvo.EplanHpD.Plugin
|
namespace Sinvo.EplanHpD.Plugin
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if Release_WireAndCable || DEBUG
|
||||||
public class MultiCoreWirePluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
|
public class MultiCoreWirePluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
|
||||||
#else
|
#else
|
||||||
public class MultiCoreWirePluginEntry
|
public class MultiCoreWirePluginEntry
|
||||||
|
|
@ -59,7 +59,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
|
|
||||||
public void Execute(HpdApi api)
|
public void Execute(HpdApi api)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
bool isLogin = PluginServices.IsLogin;
|
bool isLogin = PluginServices.IsLogin;
|
||||||
if (!isLogin)
|
if (!isLogin)
|
||||||
{
|
{
|
||||||
|
|
@ -71,7 +70,6 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
}
|
}
|
||||||
if (isLogin)
|
if (isLogin)
|
||||||
{
|
{
|
||||||
#endif
|
|
||||||
new DBHelper().CodeFirst();
|
new DBHelper().CodeFirst();
|
||||||
var doc = api.CurrentProject.GetActiveDocument();
|
var doc = api.CurrentProject.GetActiveDocument();
|
||||||
if (window == null)
|
if (window == null)
|
||||||
|
|
@ -94,9 +92,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
window.WindowState = System.Windows.WindowState.Normal;
|
window.WindowState = System.Windows.WindowState.Normal;
|
||||||
window.Activate();
|
window.Activate();
|
||||||
}
|
}
|
||||||
#if DEBUG
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,17 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
|
|
||||||
private MainWindow window;
|
private MainWindow window;
|
||||||
public void Execute(HpdApi api)
|
public void Execute(HpdApi api)
|
||||||
|
{
|
||||||
|
bool isLogin = PluginServices.IsLogin;
|
||||||
|
if (!isLogin)
|
||||||
|
{
|
||||||
|
var LoginWindow = new LoginWindow();
|
||||||
|
if (LoginWindow.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
isLogin = PluginServices.IsLogin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isLogin)
|
||||||
{
|
{
|
||||||
bool isUpdated = false;
|
bool isUpdated = false;
|
||||||
try
|
try
|
||||||
|
|
@ -139,6 +150,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
FlexMessageBox.Error(ex.ToString());
|
FlexMessageBox.Error(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue