105040 Update 完善多芯线选型功能
This commit is contained in:
parent
26e0c305be
commit
4df7a23796
|
@ -11,11 +11,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
|||
public class PluginServices
|
||||
{
|
||||
public static UserInfo user;
|
||||
#if DEBUG
|
||||
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 System;
|
||||
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)]
|
||||
public List<MultiCoreWireTerminalModel> TerminalModels
|
||||
{
|
||||
|
|
|
@ -96,5 +96,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Service
|
|||
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\LectotypeLineModelExt.cs" />
|
||||
<Compile Include="Utils\LectotypeManager.cs" />
|
||||
<Compile Include="Utils\MapperUtil.cs" />
|
||||
<Compile Include="Utils\MotorExcelHelper.cs" />
|
||||
<Compile Include="Utils\MultiCoreWireExcelHelper.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"
|
||||
Height="260"
|
||||
MinWidth="450"
|
||||
MinHeight="260"
|
||||
MinHeight="360"
|
||||
d:DataContext="{d:DesignInstance Type=multicorewireviewmodel:MultiCoreWireLayoutHelperViewModel}"
|
||||
ActiveGlowColor="{DynamicResource PrimaryColor}"
|
||||
Background="White"
|
||||
FontSize="14"
|
||||
Left="1460"
|
||||
Loaded="GlowWindow_Loaded"
|
||||
Top="770"
|
||||
Top="700"
|
||||
WindowStartupLocation="Manual"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
|
@ -46,22 +46,46 @@
|
|||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="#c92d28"
|
||||
Text="触摸屏" />
|
||||
Text="{Binding ApplicationScenario}" />
|
||||
</TextBlock>
|
||||
</hc:SimpleStackPanel>
|
||||
<DataGrid
|
||||
|
||||
<ListView
|
||||
Grid.Row="1"
|
||||
AutoGenerateColumns="False"
|
||||
ItemsSource="{Binding LecWires}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="序号" />
|
||||
<DataGridTextColumn
|
||||
MinWidth="240"
|
||||
Binding="{Binding WireModelSpecification}"
|
||||
Header="线型号" />
|
||||
<DataGridCheckBoxColumn Binding="{Binding Layouted}" Header="是否已布线" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
hc:GridViewAttach.ColumnHeaderHeight="10"
|
||||
ItemsSource="{Binding LecWires}"
|
||||
Style="{StaticResource ListView.Small}">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListViewItemBaseStyle.Small}" TargetType="ListViewItem">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Layouted}" Value="True">
|
||||
<Setter Property="Background" Value="#18a05d" />
|
||||
<Setter Property="Foreground" Value="White" />
|
||||
</DataTrigger>
|
||||
</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
|
||||
Grid.Row="4"
|
||||
Margin="10"
|
||||
|
@ -69,14 +93,14 @@
|
|||
<DockPanel HorizontalAlignment="Stretch">
|
||||
<Button
|
||||
Click="PrevBtn_Click"
|
||||
Content="上一根线"
|
||||
Content="上一个场景"
|
||||
DockPanel.Dock="Left"
|
||||
IsEnabled="{Binding HasPrev}"
|
||||
Style="{StaticResource ButtonDanger}" />
|
||||
<Button
|
||||
HorizontalAlignment="Right"
|
||||
Click="NextBtn_Click"
|
||||
Content="下一根线"
|
||||
Content="下一个场景"
|
||||
DockPanel.Dock="Right"
|
||||
IsEnabled="{Binding HasNext}"
|
||||
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 System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -32,17 +33,40 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWire.LayoutHelper
|
|||
|
||||
private void GlowWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
ViewModel.Init();
|
||||
}
|
||||
|
||||
private void NextBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
ViewModel.Next();
|
||||
}
|
||||
|
||||
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 Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||
</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>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
|
@ -43,6 +44,7 @@
|
|||
</hc:SimpleStackPanel>
|
||||
<Button
|
||||
Margin="10,0"
|
||||
Click="Layout_Click"
|
||||
Content="布线助手"
|
||||
Style="{StaticResource ButtonSuccess}" />
|
||||
<Button
|
||||
|
@ -120,12 +122,8 @@
|
|||
MinWidth="100"
|
||||
Margin="10,0"
|
||||
IsEnabled="{Binding ApplicationScenarioSelected}"
|
||||
SelectedValue="{Binding HighFlexibility, Mode=TwoWay}"
|
||||
SelectedValuePath="Content">
|
||||
<ComboBoxItem Content="是" />
|
||||
<ComboBoxItem Content="否" />
|
||||
<ComboBoxItem Content="" />
|
||||
</hc:ComboBox>
|
||||
ItemsSource="{Binding HighFlexibilitys}"
|
||||
SelectedValue="{Binding HighFlexibility}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel
|
||||
|
@ -358,7 +356,10 @@
|
|||
Text="{Binding WireModelSpecification}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</Expander.Header>
|
||||
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding Children}">
|
||||
<DataGrid
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Children}">
|
||||
<DataGrid.Resources>
|
||||
<localconverter:WireColorConverter x:Key="WireColorConverter" />
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.View.MultiCoreWire.LayoutHelper;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel;
|
||||
using SqlSugar.Extensions;
|
||||
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.Service;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
|
@ -7,28 +14,213 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
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
|
||||
{
|
||||
public class MultiCoreWireLayoutHelperViewModel : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private MultiCoreWireService _service = new();
|
||||
private string _uniqueKey;
|
||||
private FlexDesigner _currentFlexDesigner;
|
||||
|
||||
private List<string> ApplicationScenarios = [];
|
||||
|
||||
public int ApplicationScenarioIndex = 0;
|
||||
|
||||
|
||||
private List<MultiCoreWireLecModel> _wireData = [];
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged(string 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)
|
||||
{
|
||||
_uniqueKey = uniqueKey;
|
||||
}
|
||||
|
||||
|
||||
private void UpdatePropNotify()
|
||||
{
|
||||
OnPropertyChanged(nameof(ApplicationScenario));
|
||||
OnPropertyChanged(nameof(HasPrev));
|
||||
OnPropertyChanged(nameof(HasNext));
|
||||
}
|
||||
#region Props
|
||||
|
||||
public string ApplicationScenario
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApplicationScenarios[ApplicationScenarioIndex];
|
||||
}
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(nameof(ApplicationScenario));
|
||||
}
|
||||
}
|
||||
private ObservableCollection<MultiCoreWireLecModel> _lecWires = [];
|
||||
|
||||
public ObservableCollection<MultiCoreWireLecModel> LecWires
|
||||
|
@ -40,6 +232,29 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
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
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
public string _docId = docId;
|
||||
private readonly MultiCoreWireExcelHelper _dataHelper = MultiCoreWireExcelHelper.Instance;
|
||||
private readonly MultiCoreWireService _service = new();
|
||||
private string CurrUniqueKey = "";
|
||||
public string CurrUniqueKey = "";
|
||||
#region Props
|
||||
|
||||
private ObservableCollection<MultiCoreWireDataModel> _wires = [];
|
||||
|
@ -269,7 +269,19 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
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;
|
||||
///// <summary>
|
||||
///// 连接器型号
|
||||
|
@ -459,8 +471,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
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)
|
||||
// 是否高柔
|
||||
|
@ -470,41 +480,42 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
// 线芯数
|
||||
.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)
|
||||
{
|
||||
LecChanging = true;
|
||||
ApplicationScenarios = [.. datas.Where(it => !string.IsNullOrEmpty(it.ApplicationScenario)).Select(it => it.ApplicationScenario).Distinct(), ""];
|
||||
if (!isLecChange)
|
||||
{
|
||||
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();
|
||||
//}
|
||||
|
||||
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(), ""];
|
||||
//if (WireCores.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireCoreCount))
|
||||
//{
|
||||
// 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(), ""];
|
||||
if (WireModelSpecifications.Where(it => !string.IsNullOrEmpty(it)).Count() == 1 && propName != nameof(WireModelSpecification))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -593,11 +604,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel.MultiCoreWireViewModel
|
|||
HandyControl.Controls.MessageBox.Show("有信息未选择!",caption: "提示",icon: MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
//if(LecWires.Any(it=> it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification))
|
||||
//{
|
||||
// MessageBox.Show("已选择相同的线!");
|
||||
// return;
|
||||
//}
|
||||
if (LecWires.Any(it => it.ApplicationScenario == ApplicationScenario && it.WireModelSpecification == WireModelSpecification
|
||||
&& it.FrontConnectorModel == FrontConnectorModel && it.BackConnectorModel == BackConnectorModel))
|
||||
{
|
||||
var result = HandyControl.Controls.MessageBox.Show("存在信息相同的线,是否继续添加?", "提示", button: MessageBoxButton.YesNo);
|
||||
if(!(result == MessageBoxResult.Yes))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -59,27 +59,39 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
|
||||
public void Execute(HpdApi api)
|
||||
{
|
||||
new DBHelper().CodeFirst();
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
if (window == null)
|
||||
bool isLogin = PluginServices.IsLogin;
|
||||
if (!isLogin)
|
||||
{
|
||||
window = new LectotypeWindow(doc.ID);
|
||||
// 获取版本号并显示到窗口标题
|
||||
window.Title += $" V{Version} - {doc.Name}";
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
var mainApp = BaseApp.ActiveApplication;
|
||||
var helper = new System.Windows.Interop.WindowInteropHelper(window);
|
||||
helper.Owner = mainApp.Handle;
|
||||
window.Closed += delegate
|
||||
var LoginWindow = new LoginWindow();
|
||||
if (LoginWindow.ShowDialog() == true)
|
||||
{
|
||||
window = null;
|
||||
};
|
||||
window.Show();
|
||||
isLogin = PluginServices.IsLogin;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (isLogin)
|
||||
{
|
||||
window.WindowState = System.Windows.WindowState.Normal;
|
||||
window.Activate();
|
||||
new DBHelper().CodeFirst();
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
if (window == null)
|
||||
{
|
||||
window = new LectotypeWindow(doc.ID);
|
||||
// 获取版本号并显示到窗口标题
|
||||
window.Title += $" V{Version} - {doc.Name}";
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
var mainApp = BaseApp.ActiveApplication;
|
||||
var helper = new System.Windows.Interop.WindowInteropHelper(window);
|
||||
helper.Owner = mainApp.Handle;
|
||||
window.Closed += delegate
|
||||
{
|
||||
window = null;
|
||||
};
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.WindowState = System.Windows.WindowState.Normal;
|
||||
window.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Initialize()
|
||||
|
|
|
@ -16,7 +16,7 @@ using System.Windows.Forms.Integration;
|
|||
|
||||
namespace Sinvo.EplanHpD.Plugin
|
||||
{
|
||||
#if DEBUG
|
||||
#if Release_WireAndCable || DEBUG
|
||||
public class MultiCoreWirePluginEntry : EPLAN.Harness.API.Plugins.IHpDPlugin
|
||||
#else
|
||||
public class MultiCoreWirePluginEntry
|
||||
|
@ -59,7 +59,6 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
|
||||
public void Execute(HpdApi api)
|
||||
{
|
||||
#if DEBUG
|
||||
bool isLogin = PluginServices.IsLogin;
|
||||
if (!isLogin)
|
||||
{
|
||||
|
@ -71,7 +70,6 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
}
|
||||
if (isLogin)
|
||||
{
|
||||
#endif
|
||||
new DBHelper().CodeFirst();
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
if (window == null)
|
||||
|
@ -94,9 +92,7 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
window.WindowState = System.Windows.WindowState.Normal;
|
||||
window.Activate();
|
||||
}
|
||||
#if DEBUG
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public void Initialize()
|
||||
{
|
||||
|
|
|
@ -61,83 +61,95 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
private MainWindow window;
|
||||
public void Execute(HpdApi api)
|
||||
{
|
||||
bool isUpdated = false;
|
||||
try
|
||||
bool isLogin = PluginServices.IsLogin;
|
||||
if (!isLogin)
|
||||
{
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
//doc.ID
|
||||
//if(doc is FlexReport)
|
||||
if (doc is EPLAN.Harness.API.Projects.Documents.Report report)
|
||||
var LoginWindow = new LoginWindow();
|
||||
if (LoginWindow.ShowDialog() == true)
|
||||
{
|
||||
var reportId = report.ID;
|
||||
var allReports = FlexProject.CurrentProject.GetReports();
|
||||
if (allReports.Any(item => item.ID == reportId))
|
||||
isLogin = PluginServices.IsLogin;
|
||||
}
|
||||
}
|
||||
if (isLogin)
|
||||
{
|
||||
bool isUpdated = false;
|
||||
try
|
||||
{
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
//doc.ID
|
||||
//if(doc is FlexReport)
|
||||
if (doc is EPLAN.Harness.API.Projects.Documents.Report report)
|
||||
{
|
||||
var flexReport = allReports.Where(item => item.ID == reportId).First();
|
||||
if (flexReport != null)
|
||||
var reportId = report.ID;
|
||||
var allReports = FlexProject.CurrentProject.GetReports();
|
||||
if (allReports.Any(item => item.ID == reportId))
|
||||
{
|
||||
var isNeedUpdate = FlexReport.IsUpToDate(flexReport);
|
||||
if (!isNeedUpdate)
|
||||
var flexReport = allReports.Where(item => item.ID == reportId).First();
|
||||
if (flexReport != null)
|
||||
{
|
||||
if (FlexMessageBox.Warning(FlexMessageBox.Buttons.OK_CANCEL,
|
||||
"Report",
|
||||
"报表数据不是最新的,是否更新?", false) == DialogResult.OK)
|
||||
var isNeedUpdate = FlexReport.IsUpToDate(flexReport);
|
||||
if (!isNeedUpdate)
|
||||
{
|
||||
flexReport.UpdateReport();
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
if (window == null)
|
||||
{
|
||||
|
||||
window = new MainWindow(flexReport);
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isUpdated)
|
||||
if (FlexMessageBox.Warning(FlexMessageBox.Buttons.OK_CANCEL,
|
||||
"Report",
|
||||
"报表数据不是最新的,是否更新?", false) == DialogResult.OK)
|
||||
{
|
||||
window.Close();
|
||||
flexReport.UpdateReport();
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
if (window == null)
|
||||
{
|
||||
|
||||
window = new MainWindow(flexReport);
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
}
|
||||
window.ShowActivated = true;
|
||||
if (window.WindowState == System.Windows.WindowState.Minimized)
|
||||
else
|
||||
{
|
||||
window.WindowState = System.Windows.WindowState.Normal;
|
||||
if (isUpdated)
|
||||
{
|
||||
window.Close();
|
||||
window = new MainWindow(flexReport);
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
}
|
||||
window.ShowActivated = true;
|
||||
if (window.WindowState == System.Windows.WindowState.Minimized)
|
||||
{
|
||||
window.WindowState = System.Windows.WindowState.Normal;
|
||||
}
|
||||
window.Show();
|
||||
window.Activate();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
window = new MainWindow(flexReport);
|
||||
// 解决WPF窗体在WinForm中无法输入的问题
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
window.Activate();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
window = new MainWindow(flexReport);
|
||||
// 解决WPF窗体在WinForm中无法输入的问题
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FlexMessageBox.Error("未找到项目中匹配的报表,请检查是否生成成功或是未保存到项目中!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FlexMessageBox.Error("未找到项目中匹配的报表,请检查是否生成成功或是未保存到项目中!");
|
||||
FlexMessageBox.Error("请打开一个报表后再使用!");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error("请打开一个报表后再使用!");
|
||||
FlexMessageBox.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
|
Loading…
Reference in New Issue