105040 右键菜单列表增加 转至源 选项,直接打开3D模型并跳转选中到对应的线

This commit is contained in:
lihanbo 2024-10-29 10:23:27 +08:00
parent 04b57294ce
commit d5e61f5ac2
6 changed files with 202 additions and 10 deletions

View File

@ -200,6 +200,7 @@
<DataGrid.ContextMenu> <DataGrid.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Click="IgnoreSelectedError_Click" Header="忽略选中项的异常" /> <MenuItem Click="IgnoreSelectedError_Click" Header="忽略选中项的异常" />
<MenuItem Click="GoToSource_Click" Header="转至源" />
<MenuItem Click="UnIgnoreSelectedError_Click" Header="取消忽略选中项的异常" /> <MenuItem Click="UnIgnoreSelectedError_Click" Header="取消忽略选中项的异常" />
<MenuItem <MenuItem
Click="Copy_Click" Click="Copy_Click"
@ -439,8 +440,12 @@
Fill="#18a05d" /> Fill="#18a05d" />
<TextBlock VerticalAlignment="Center" Text="绿色表示该项正常,检查通过" /> <TextBlock VerticalAlignment="Center" Text="绿色表示该项正常,检查通过" />
</StackPanel> </StackPanel>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal"> <StackPanel VerticalAlignment="Center" Orientation="Vertical">
<TextBlock VerticalAlignment="Center" Text="检查线时,会根据型号配对表中的数据进行检查,当未与配对表中的信息匹配时,将会提示错误,具体错误请查看每一项的异常信息。" /> <TextBlock VerticalAlignment="Center" Text="检查线时,会根据型号配对表中的数据进行检查,当端子使用未与配对表中的信息匹配时,将会提示错误,具体错误请查看每一项的异常信息。" />
<TextBlock VerticalAlignment="Center" Text="当线径为1.5或是1.5以下时变色套管绝缘软套应使用1.5平方,如未按此规则使用,将提示异常。" />
<TextBlock VerticalAlignment="Center" Text="当勾选全部CE认证时未使用CE认证的线或是端子将提示异常。" />
<TextBlock VerticalAlignment="Center" Text="当型号出现重复时将会自动增加5mm长度如果依旧出现重复将会再增加一次第二次增加长度后依旧重复则根据原有长度提示异常。增加长度如果未出现异常则会以增加后的长度进行生成(不会修改已有的数据,只会影响检查时的显示与导出报表)。" />
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</GroupBox> </GroupBox>

View File

@ -1,7 +1,14 @@
using EPLAN.Harness.Common.Extensions; using EPLAN.Harness.Common;
using EPLAN.Harness.Common.Extensions;
using EPLAN.Harness.Core.Common;
using EPLAN.Harness.Core.Controls; using EPLAN.Harness.Core.Controls;
using EPLAN.Harness.Core.Events;
using EPLAN.Harness.Core.Lampy;
using EPLAN.Harness.Core.Settings; using EPLAN.Harness.Core.Settings;
using EPLAN.Harness.IO; using EPLAN.Harness.IO;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using EPLAN.Harness.ProjectCore.Report; using EPLAN.Harness.ProjectCore.Report;
using Microsoft.Win32; using Microsoft.Win32;
using Sinvo.EplanHpD.Plugin.WPFUI.Models; using Sinvo.EplanHpD.Plugin.WPFUI.Models;
@ -28,11 +35,15 @@ public partial class MainWindow : Window
public delegate void UpdateDataGridColumns(List<DataGridColumn> columns, DataGridType type); public delegate void UpdateDataGridColumns(List<DataGridColumn> columns, DataGridType type);
private IEnumerable<BaseReportEntry> datas; private IEnumerable<BaseReportEntry> datas;
private List<ReportColumn> reportColumns; private List<ReportColumn> reportColumns;
public MainWindow(IEnumerable<BaseReportEntry> datas, List<ReportColumn> columns) private FlexReport _report;
public MainWindow(FlexReport report)
{ {
InitializeComponent(); InitializeComponent();
_report = report;
this.DataContext = ViewModel = new MainViewModel(); this.DataContext = ViewModel = new MainViewModel();
ViewModel.UpdateDataGridColumns = UpdateDataGridColumnsByType; ViewModel.UpdateDataGridColumns = UpdateDataGridColumnsByType;
var columns = report.Reporter.Formater.RepColumns;
var datas = report.GetAllReportEntries();
this.datas = datas; this.datas = datas;
this.reportColumns = columns; this.reportColumns = columns;
ViewModel.DataColumns = []; ViewModel.DataColumns = [];
@ -281,4 +292,138 @@ public partial class MainWindow : Window
} }
} }
} }
private void GoToSource()
{
var selectItems = ModelGenDataGrid.SelectedItems;
if (selectItems != null && selectItems.Count > 0)
//if (selectItems is List<StuffedDataModel> reportItems)
{
//foreach (ReportModel item in selectItems)
StuffedDataModel item = (StuffedDataModel)selectItems[0];
if (item != null)
{
var repoetEntry = datas.FirstOrDefault(it => it.Properties["WireName"].ValueString() == item.WireName);
_report.DataSources.GetSources();
if (repoetEntry.OrigDocIDs == null || repoetEntry.OrigDocIDs.Count == 0)
{
repoetEntry.OrigDocIDs = new List<string>();
foreach (IDataSource dataSource in _report.DataSources.GetSources())
{
IFlexStudioDocument documentByID = FlexProject.CurrentProject.GetDocumentByID(dataSource.ParentID);
FlexDesigner designer;
if ((designer = (documentByID as FlexDesigner)) != null)
{
FlexProject.CurrentProject.LoadDesignerMetadata(designer);
}
if (repoetEntry.OrigID != null && SelfControler<BaseOccurrence>.FindInstance(repoetEntry.OrigID) != null)
{
repoetEntry.OrigDocIDs.Add(documentByID.ID);
}
FlexProject.CurrentProject.CloseAllUsedDocuments();
}
}
foreach (string text in repoetEntry.OrigDocIDs.Distinct<string>())
{
FlexDesigner flexDesigner;
if (text != string.Empty && (flexDesigner = (SelfControler<FlexBaseOrganizer>.FindInstance(text) as FlexDesigner)) != null && (!(flexDesigner is FlexWorkdesk) || Lamparna.Instance.IsWorkdeskAvailable()) && (!(flexDesigner is FlexWorkspace) || Lamparna.Instance.IsWorkspaceAvailable()))
{
Singleton<EventProvider>.Instance.Invoke(NamedEvents.Open_Studio_Document, this._report, new object[]
{
flexDesigner
});
if (flexDesigner.ReaderStatus != DataReaderStatus.Full)
{
break;
}
flexDesigner.SelectSet.Clear();
string origID = repoetEntry.OrigID;
List<BaseOccurrence> list = new List<BaseOccurrence>();
BaseOccurrence baseOccurrence = SelfControler<BaseOccurrence>.FindInstance(origID);
if (baseOccurrence != null && flexDesigner.IsOccRegistered(baseOccurrence))
{
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_BeginUpdate, this, Array.Empty<object>());
if (_report.Reporter is AggregatedBOMReporter)
{
using (List<string>.Enumerator enumerator3 = flexDesigner.GetOccurrencesWithSameLibID(new GUIDVerClass(baseOccurrence.LibID, baseOccurrence.LibVersion), false).GetEnumerator())
{
while (enumerator3.MoveNext())
{
string objID = enumerator3.Current;
list.Add(SelfControler<BaseOccurrence>.FindInstance(objID));
}
}
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
flexDesigner.FitToSelectSet();
continue;
}
if (baseOccurrence is OccSurfaceProtectionBase)
{
using (IEnumerator<IOccBundle> enumerator4 = (baseOccurrence as OccSurfaceProtectionBase).GetParentBundles().GetEnumerator())
{
while (enumerator4.MoveNext())
{
IOccBundle occBundle = enumerator4.Current;
list.Add(occBundle as BaseOccurrence);
}
}
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
flexDesigner.FitToSelectSet();
continue;
}
//if (_report.Reporter is AccessoryReporter && (baseOccurrence is OccAttachedPart || baseOccurrence is OccAttachedPartEC || baseOccurrence is BaseEncapsulatedOcc))
//{
// this.GoToSourceAttachedPart(baseOccurrence);
// Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
// break;
//}
list.Add(baseOccurrence);
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
flexDesigner.FitToSelectSet();
//flexDesigner.
flexDesigner.SelectSet.OnSelectionChanged();
}
}
}
}
}
}
private void AddToDesignerSelectSet(FlexDesigner designerDoc, List<BaseOccurrence> occurrences)
{
List<BaseOccurrence> list = new List<BaseOccurrence>();
foreach (BaseOccurrence baseOccurrence in occurrences)
{
bool? flag;
if (baseOccurrence == null)
{
flag = null;
}
else
{
FlexBaseOrganizer parentOrganizer = baseOccurrence.GetParentOrganizer();
flag = ((parentOrganizer != null) ? new bool?(parentOrganizer.IsOccRegistered(baseOccurrence)) : null);
}
if (flag ?? false)
{
baseOccurrence.SetVisibility(true, null);
list.Add(baseOccurrence);
}
}
designerDoc.SelectSet.Add(list);
//designerDoc.
}
private void GoToSource_Click(object sender, RoutedEventArgs e)
{
GoToSource();
}
} }

View File

@ -74,9 +74,15 @@
<Reference Include="EPLAN.Harness.Core"> <Reference Include="EPLAN.Harness.Core">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.Core.dll</HintPath> <HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.Graphics">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.Graphics.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.IO"> <Reference Include="EPLAN.Harness.IO">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.IO.dll</HintPath> <HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.IO.dll</HintPath>
</Reference> </Reference>
<Reference Include="EPLAN.Harness.PlatformCore">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.PlatformCore.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.Primitives"> <Reference Include="EPLAN.Harness.Primitives">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.Primitives.dll</HintPath> <HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.Primitives.dll</HintPath>
</Reference> </Reference>

View File

@ -49,9 +49,10 @@ namespace Sinvo.EplanHpD.Plugin
public HpDModule Module => HpDModule.Report; public HpDModule Module => HpDModule.Report;
private MainWindow window;
public void Execute(HpdApi api) public void Execute(HpdApi api)
{ {
bool isUpdated = false;
try try
{ {
var doc = api.CurrentProject.GetActiveDocument(); var doc = api.CurrentProject.GetActiveDocument();
@ -73,15 +74,50 @@ namespace Sinvo.EplanHpD.Plugin
"报表数据不是最新的,是否更新?", false) == DialogResult.OK) "报表数据不是最新的,是否更新?", false) == DialogResult.OK)
{ {
flexReport.UpdateReport(); flexReport.UpdateReport();
isUpdated = true;
} }
} }
// 取可见的列 // 取可见的列
var columns = flexReport.Reporter.Formater.RepColumns; //var columns = flexReport.Reporter.Formater.RepColumns;
var datas = flexReport.GetAllReportEntries(); //var datas = flexReport.GetAllReportEntries();
var window = new MainWindow(datas, columns); //var window = new MainWindow(datas, columns);
try
{
if (window == null)
{
window = new MainWindow(flexReport);
ElementHost.EnableModelessKeyboardInterop(window);
window.Show();
}
else
{
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);
ElementHost.EnableModelessKeyboardInterop(window);
window.Show();
}
// 解决WPF窗体在WinForm中无法输入的问题 // 解决WPF窗体在WinForm中无法输入的问题
ElementHost.EnableModelessKeyboardInterop(window);
window.Show();
} }
} }
else else