2024-10-29 10:23:27 +08:00
using EPLAN.Harness.Common ;
using EPLAN.Harness.Common.Extensions ;
using EPLAN.Harness.Core.Common ;
2024-10-24 18:01:26 +08:00
using EPLAN.Harness.Core.Controls ;
2024-10-29 10:23:27 +08:00
using EPLAN.Harness.Core.Events ;
using EPLAN.Harness.Core.Lampy ;
2024-10-24 18:01:26 +08:00
using EPLAN.Harness.Core.Settings ;
using EPLAN.Harness.IO ;
2024-10-29 10:23:27 +08:00
using EPLAN.Harness.ProjectCore ;
using EPLAN.Harness.ProjectCore.Occurrences ;
using EPLAN.Harness.ProjectCore.Occurrences.Designer ;
2024-10-24 18:01:26 +08:00
using EPLAN.Harness.ProjectCore.Report ;
2024-11-15 15:04:08 +08:00
using HandyControl.Controls ;
2024-10-24 18:01:26 +08:00
using Microsoft.Win32 ;
2024-12-05 14:37:31 +08:00
using Sinvo.EplanHpD.Plugin.WPFUI.Enum ;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension ;
2024-10-24 18:01:26 +08:00
using Sinvo.EplanHpD.Plugin.WPFUI.Models ;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils ;
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Diagnostics ;
using System.IO ;
using System.Linq ;
using System.Threading.Tasks ;
using System.Windows ;
using System.Windows.Controls ;
namespace Sinvo.EplanHpD.Plugin.WPFUI ;
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
2024-11-15 15:04:08 +08:00
public partial class MainWindow : System . Windows . Window
2024-10-24 18:01:26 +08:00
{
2024-11-15 15:04:08 +08:00
private MainViewModel ViewModel ;
2024-10-24 18:01:26 +08:00
public delegate void UpdateDataGridColumns ( List < DataGridColumn > columns , DataGridType type ) ;
private IEnumerable < BaseReportEntry > datas ;
private List < ReportColumn > reportColumns ;
2024-10-29 10:23:27 +08:00
private FlexReport _report ;
public MainWindow ( FlexReport report )
2024-10-24 18:01:26 +08:00
{
InitializeComponent ( ) ;
2024-10-29 10:23:27 +08:00
_report = report ;
2024-11-15 15:04:08 +08:00
Init ( ) ;
Application . Current . SetMainWindow ( this ) ;
}
private void Init ( )
{
2024-10-24 18:01:26 +08:00
this . DataContext = ViewModel = new MainViewModel ( ) ;
ViewModel . UpdateDataGridColumns = UpdateDataGridColumnsByType ;
2024-11-15 15:04:08 +08:00
var columns = _report . Reporter . Formater . RepColumns ;
var datas = _report . GetAllReportEntries ( ) ;
2024-10-24 18:01:26 +08:00
this . datas = datas ;
this . reportColumns = columns ;
ViewModel . DataColumns = [ ] ;
ViewModel . Data = [ ] ;
ViewModel . StuffedData = [ ] ;
ViewModel . ExportData = [ ] ;
2024-11-08 10:16:58 +08:00
ViewModel . SearchedData = [ ] ;
2024-10-24 18:01:26 +08:00
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 更新列
/// </summary>
/// <param name="columns"></param>
/// <param name="type"></param>
2024-10-24 18:01:26 +08:00
public void UpdateDataGridColumnsByType ( List < DataGridColumn > columns , DataGridType type )
{
try
{
//this.Dispatcher.BeginInvoke(delegate ()
//{
switch ( type )
{
case DataGridType . Originial :
UpdateOriginialDataGridColumns ( columns ) ;
break ;
case DataGridType . Import :
UpdateImportDataGridColumns ( columns ) ;
break ;
default :
break ;
}
//});
}
catch ( System . Exception ex )
{
FlexMessageBox . Error ( $"{ex}" ) ;
}
}
public void UpdateOriginialDataGridColumns ( List < DataGridColumn > columns )
{
OriginialDataGrid . Columns . Clear ( ) ;
//var columns = ViewModel.DataColumns;
foreach ( var column in columns )
{
OriginialDataGrid . Columns . Add ( column ) ;
}
}
public void UpdateImportDataGridColumns ( List < DataGridColumn > columns )
{
ImportDataGrid . Columns . Clear ( ) ;
//var columns = ViewModel.DataColumns;
foreach ( var column in columns )
{
ImportDataGrid . Columns . Add ( column ) ;
}
}
private void Button_Click ( object sender , RoutedEventArgs e )
{
DataTabControl . SelectedIndex = 1 ;
LoadingMask . Visibility = Visibility . Visible ;
try
{
2024-10-26 14:01:56 +08:00
ViewModel . CheckAll ( ViewModel . StuffedData ) ;
2024-10-24 18:01:26 +08:00
}
catch ( System . Exception ex )
{
Trace . WriteLine ( ex . ToString ( ) ) ;
}
LoadingMask . Visibility = Visibility . Collapsed ;
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 生成模板数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-10-24 18:01:26 +08:00
private void GenTemplateBtn_Click ( object sender , RoutedEventArgs e )
{
try
{
DataTabControl . SelectedIndex = 2 ;
ViewModel . GenExportData ( ) ;
}
catch ( System . Exception ex )
{
FlexMessageBox . Error ( $"{ex}" ) ;
}
}
private async void Window_Loaded ( object sender , RoutedEventArgs e )
{
try
{
2024-11-15 15:04:08 +08:00
Growl . Register ( "Message" , GrowlParent ) ;
2024-10-24 18:01:26 +08:00
LoadingMask . Visibility = Visibility . Visible ;
2024-11-19 12:11:29 +08:00
await this . Dispatcher . BeginInvoke ( async delegate ( )
{
ExcelHelper . CheckAndGetCache ( true ) ;
await LoadDataAsync ( datas , reportColumns ) ;
} ) ;
2024-10-24 18:01:26 +08:00
}
catch ( System . Exception ex )
{
FlexMessageBox . Error ( $"{ex}" ) ;
}
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 异步加载数据
/// </summary>
/// <param name="reportData"></param>
/// <param name="columns"></param>
/// <returns></returns>
2024-10-24 18:01:26 +08:00
public async Task LoadDataAsync ( IEnumerable < BaseReportEntry > reportData , List < ReportColumn > columns )
{
var dataColumns = ViewModel . GetColumns ( columns ) ;
var data = ViewModel . LoadReportDataAsync ( reportData , columns ) ;
Task . WaitAll ( dataColumns , data ) ;
var stuffedData = ViewModel . StuffData ( data . Result ) ;
2024-10-25 15:16:39 +08:00
_ = stuffedData . ContinueWith ( x = >
2024-10-24 18:01:26 +08:00
{
_ = this . Dispatcher . BeginInvoke ( delegate ( )
{
try
{
ViewModel . DataColumns ? . Clear ( ) ;
dataColumns . Result . Where ( it = > it ! = null ) . ForEach ( ViewModel . DataColumns . Add ) ;
ViewModel . Data ? . Clear ( ) ;
data . Result . Where ( it = > it ! = null ) . ForEach ( ViewModel . Data . Add ) ;
ViewModel . StuffedData ? . Clear ( ) ;
stuffedData . Result . Where ( it = > it ! = null ) . ForEach ( ViewModel . StuffedData . Add ) ;
UpdateDataGridColumnsByType ( [ . . ViewModel . DataColumns ] , DataGridType . Originial ) ;
2024-11-08 10:16:58 +08:00
ViewModel . SearchByWireName ( null ) ;
2024-10-24 18:01:26 +08:00
}
catch ( Exception ex )
{
Trace . WriteLine ( $"{ex}" ) ;
}
LoadingMask . Visibility = Visibility . Collapsed ;
} ) ;
} ) ;
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 导出报表数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-10-24 18:01:26 +08:00
private void ExportDataBtn_Click ( object sender , RoutedEventArgs e )
{
try
{
if ( ViewModel . ExportData = = null | | ViewModel . ExportData . Count < = 0 )
{
2024-11-08 17:11:07 +08:00
FlexMessageBox . Info ( $"无数据可导出,请先点击上方生成导入模板数据!" ) ;
2024-10-24 18:01:26 +08:00
}
else
{
2024-11-15 15:04:08 +08:00
if ( ViewModel . NameType = = ExportFileNameType . ProjectNo & & string . IsNullOrEmpty ( ViewModel . ProjectNo ) )
2024-10-24 18:01:26 +08:00
{
2024-11-15 15:04:08 +08:00
FlexMessageBox . Warning ( $"请输入项目号!" ) ;
}
else
2024-10-24 18:01:26 +08:00
{
2024-11-15 15:04:08 +08:00
SaveFileDialog saveFileDialog = new ( )
{
Filter = "MS Excel (*.xlsx)|*.xlsx" , //Singleton<LRS>.Instance["Report_ExpFilter", "Report_ExpFilter"],
FilterIndex = 1 ,
//FileName = $"{单芯线下单}{DateTime.Now:yyyy_MM_dd}.xlsx",
FileName = $"{GetFileName()}.xlsx" ,
AddExtension = true ,
InitialDirectory = StudioSettings . Instance . ReportExport_Path ,
CheckPathExists = true
} ;
if ( saveFileDialog . ShowDialog ( ) = = true )
{
ExcelHelper . SaveByTemplate ( ViewModel . ExportData , Path . Combine ( FlexIOBase . GetParentPath ( saveFileDialog . FileName ) , saveFileDialog . FileName ) ) ;
FlexMessageBox . Info ( $"导出完成!" ) ;
}
2024-10-24 18:01:26 +08:00
}
}
}
catch ( System . Exception ex )
{
FlexMessageBox . Error ( $"{ex}" ) ;
}
}
2024-11-15 15:04:08 +08:00
private string GetFileName ( )
{
if ( ViewModel . NameType = = ExportFileNameType . ProjectNo )
{
return $"{ViewModel.ProjectNo}" ;
}
if ( ViewModel . NameType = = ExportFileNameType . Mechanism )
{
return $"{ViewModel.MechanismNo}&{ViewModel.MechanismName}" ;
}
return $"{ViewModel.CustomFileName}" ;
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 忽略异常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
2024-10-24 18:01:26 +08:00
private void IgnoreSelectedError_Click ( object sender , RoutedEventArgs e )
{
2024-11-08 15:27:46 +08:00
bool isContinue = false ;
if ( FlexMessageBox . Warning ( FlexMessageBox . Buttons . OK_CANCEL ,
"Report" ,
"忽略异常后在导出下单报表时,将不会再进行管控,是否继续?" , false ) = = System . Windows . Forms . DialogResult . OK )
{
isContinue = true ;
}
if ( isContinue )
2024-11-08 15:28:38 +08:00
if ( ModelGenDataGrid . SelectedItems ! = null )
2024-10-24 18:01:26 +08:00
{
2024-11-08 15:28:38 +08:00
var selectedRows = ModelGenDataGrid . SelectedItems ;
foreach ( var item in selectedRows )
2024-10-24 18:01:26 +08:00
{
2024-11-08 15:28:38 +08:00
if ( item is StuffedDataModel model )
2024-11-07 12:14:44 +08:00
{
2024-11-08 15:28:38 +08:00
//var stuffedItem = ViewModel.StuffedData.Where(it => it.WireName == model.WireName).First();
if ( model . IsError )
{
2024-11-07 12:14:44 +08:00
2024-11-08 15:28:38 +08:00
//stuffedItem.IsIgnore = true;
model . IsIgnore = true ;
}
2024-11-07 12:14:44 +08:00
}
2024-10-24 18:01:26 +08:00
}
}
}
private void Copy_Click ( object sender , RoutedEventArgs e )
{
2024-11-07 12:14:44 +08:00
try
2024-10-24 18:01:26 +08:00
{
2024-11-07 12:14:44 +08:00
if ( sender is MenuItem item )
2024-10-24 18:01:26 +08:00
{
2024-11-07 12:14:44 +08:00
var selectItems = ModelGenDataGrid . SelectedItems ;
if ( item . Tag ? . ToString ( ) = = "MNo" )
{
var str = string . Join ( "\n" , selectItems . Cast < StuffedDataModel > ( ) . Select ( item = > item . WireCode ) ) ;
Clipboard . SetText ( str ) ;
}
if ( item . Tag ? . ToString ( ) = = "ErrMsg" )
{
var str = string . Join ( "\n" , selectItems . Cast < StuffedDataModel > ( ) . Select ( item = > item . CheckedMsg ) ) ;
Clipboard . SetText ( str ) ;
}
if ( item . Tag ? . ToString ( ) = = "MNoAndErrMsg" )
{
var str = string . Join ( "\n" , selectItems . Cast < StuffedDataModel > ( ) . Select ( item = > $"{item.WireCode}\t{item.CheckedMsg}" ) ) ;
Clipboard . SetText ( str ) ;
}
if ( item . Tag ? . ToString ( ) = = "WireName" )
{
var str = string . Join ( "\n" , selectItems . Cast < StuffedDataModel > ( ) . Select ( item = > $"{item.WireName}" ) ) ;
Clipboard . SetText ( str ) ;
}
2024-10-24 18:01:26 +08:00
}
2024-11-07 12:14:44 +08:00
e . Handled = true ;
}
catch ( Exception ex )
{
FlexMessageBox . Error ( ex . Message ) ;
2024-10-24 18:01:26 +08:00
}
}
2024-10-26 14:40:46 +08:00
/// <summary>
/// 取消忽略异常
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void UnIgnoreSelectedError_Click ( object sender , RoutedEventArgs e )
{
if ( ModelGenDataGrid . SelectedItems ! = null )
{
var selectedRows = ModelGenDataGrid . SelectedItems ;
foreach ( var item in selectedRows )
{
if ( item is StuffedDataModel model )
{
model . IsIgnore = false ;
}
}
}
}
2024-10-29 10:23:27 +08:00
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 )
{
2025-02-20 10:54:07 +08:00
var repoetEntry = datas . FirstOrDefault ( it = > it . ID = = item . OccPartId ) ;
2024-10-29 10:23:27 +08:00
_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 ;
2024-11-07 12:14:44 +08:00
if ( text ! = string . Empty & & ( flexDesigner = ( SelfControler < FlexBaseOrganizer > . FindInstance ( text ) as FlexDesigner ) ) ! = null & & ( flexDesigner is not FlexWorkdesk | | Lamparna . Instance . IsWorkdeskAvailable ( ) ) & & ( flexDesigner is not FlexWorkspace | | Lamparna . Instance . IsWorkspaceAvailable ( ) ) )
2024-10-29 10:23:27 +08:00
{
2024-11-07 12:14:44 +08:00
Singleton < EventProvider > . Instance . Invoke ( NamedEvents . Open_Studio_Document , this . _report ,
[
2024-10-29 10:23:27 +08:00
flexDesigner
2024-11-07 12:14:44 +08:00
] ) ;
2024-10-29 10:23:27 +08:00
if ( flexDesigner . ReaderStatus ! = DataReaderStatus . Full )
{
break ;
}
flexDesigner . SelectSet . Clear ( ) ;
string origID = repoetEntry . OrigID ;
2024-11-07 12:14:44 +08:00
List < BaseOccurrence > list = [ ] ;
2024-10-29 10:23:27 +08:00
BaseOccurrence baseOccurrence = SelfControler < BaseOccurrence > . FindInstance ( origID ) ;
if ( baseOccurrence ! = null & & flexDesigner . IsOccRegistered ( baseOccurrence ) )
{
2024-11-07 12:14:44 +08:00
Singleton < EventProvider > . Instance . Invoke ( NamedEvents . TreeView_BeginUpdate , this , [ ] ) ;
2024-10-29 10:23:27 +08:00
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 ) ;
2024-11-07 12:14:44 +08:00
Singleton < EventProvider > . Instance . Invoke ( NamedEvents . TreeView_EndUpdate , this , [ ] ) ;
2024-10-29 10:23:27 +08:00
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 ) ;
2024-11-07 12:14:44 +08:00
Singleton < EventProvider > . Instance . Invoke ( NamedEvents . TreeView_EndUpdate , this , [ ] ) ;
2024-10-29 10:23:27 +08:00
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 ) ;
2024-11-07 12:14:44 +08:00
Singleton < EventProvider > . Instance . Invoke ( NamedEvents . TreeView_EndUpdate , this , [ ] ) ;
2024-10-29 10:23:27 +08:00
flexDesigner . FitToSelectSet ( ) ;
2024-11-26 10:31:58 +08:00
2024-10-29 10:23:27 +08:00
//flexDesigner.
flexDesigner . SelectSet . OnSelectionChanged ( ) ;
}
}
}
}
}
}
private void AddToDesignerSelectSet ( FlexDesigner designerDoc , List < BaseOccurrence > occurrences )
{
2024-11-08 08:34:20 +08:00
try
2024-10-29 10:23:27 +08:00
{
2024-11-08 08:34:20 +08:00
List < BaseOccurrence > list = new List < BaseOccurrence > ( ) ;
foreach ( BaseOccurrence baseOccurrence in occurrences )
2024-10-29 10:23:27 +08:00
{
2024-11-08 08:34:20 +08:00
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 ) ;
}
2024-10-29 10:23:27 +08:00
}
2024-11-08 08:34:20 +08:00
designerDoc . SelectSet . Add ( list ) ;
}
catch ( Exception ex )
{
FlexMessageBox . Error ( ex . Message ) ;
2024-10-29 10:23:27 +08:00
}
//designerDoc.
}
private void GoToSource_Click ( object sender , RoutedEventArgs e )
{
2024-11-07 12:14:44 +08:00
try
{
2024-11-26 10:31:58 +08:00
//HideOthers();
2024-11-07 12:14:44 +08:00
GoToSource ( ) ;
2024-11-13 13:39:06 +08:00
if ( ViewModel . ToSourceAndMinSelf )
{
this . WindowState = WindowState . Minimized ;
}
2024-11-07 12:14:44 +08:00
}
catch ( Exception ex )
{
FlexMessageBox . Error ( ex . Message ) ;
}
2024-10-29 10:23:27 +08:00
}
2024-11-08 10:16:58 +08:00
2024-11-26 10:31:58 +08:00
private void OthersWireShow ( bool show = false )
{
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 reportEntry = datas . FirstOrDefault ( it = > it . Properties [ "WireName" ] . ValueString ( ) = = item . WireName ) ;
_report . DataSources . GetSources ( ) ;
if ( reportEntry . OrigDocIDs = = null | | reportEntry . OrigDocIDs . Count = = 0 )
{
reportEntry . 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 ( reportEntry . OrigID ! = null & & SelfControler < BaseOccurrence > . FindInstance ( reportEntry . OrigID ) ! = null )
{
reportEntry . OrigDocIDs . Add ( documentByID . ID ) ;
}
FlexProject . CurrentProject . CloseAllUsedDocuments ( ) ;
}
}
if ( reportEntry . OrigDocIDs ! = null & & reportEntry . OrigDocIDs . Any ( ) )
{
var docId = reportEntry . OrigDocIDs . First ( ) ;
var flexDesigner = SelfControler < FlexBaseOrganizer > . FindInstance ( docId ) as FlexDesigner ;
if ( flexDesigner ! = null )
{
var cables = flexDesigner . GetAllOccurrencesByLibID ( true ) ;
foreach ( var cable in cables )
{
Debug . WriteLine ( "" ) ;
Debug . Write ( cable . Key ) ;
Debug . Write ( "-->" ) ;
//Debug.Write(string.Join(",", cable.Value));
Debug . WriteLine ( "" ) ;
cable . Value . ForEach ( it = >
{
var occ = SelfControler < BaseOccurrence > . FindInstance ( it ) ;
if ( occ is OccWire wire )
{
wire . SetVisibility ( show , null ) ;
Debug . WriteLine ( $"{wire.Name} SetVisibility {show}" ) ;
}
} ) ;
//Debug.Write("-->");
}
}
}
}
}
}
2024-11-08 10:16:58 +08:00
private void SearchBar_SearchStarted ( object sender , HandyControl . Data . FunctionEventArgs < string > e )
{
Trace . WriteLine ( e . Info . ToString ( ) ) ;
ViewModel . SearchByWireName ( e . Info ) ;
}
2024-11-15 15:04:08 +08:00
private void RefreshReportDataBtn_Click ( object sender , RoutedEventArgs e )
{
if ( _report ! = null )
{
var isNeedUpdate = FlexReport . IsUpToDate ( _report ) ;
if ( ! isNeedUpdate )
{
if ( FlexMessageBox . Warning ( FlexMessageBox . Buttons . OK_CANCEL ,
"Report" ,
"是否更新报表数据?" , false ) = = System . Windows . Forms . DialogResult . OK )
{
_report . UpdateReport ( ) ;
Init ( ) ;
try
{
LoadingMask . Visibility = Visibility . Visible ;
this . Dispatcher . BeginInvoke ( async delegate ( )
{
ExcelHelper . CheckAndGetCache ( true ) ;
await LoadDataAsync ( datas , reportColumns ) ;
} ) ;
}
catch ( System . Exception ex )
{
FlexMessageBox . Error ( $"{ex}" ) ;
}
}
}
else
{
try
{
Growl . Success ( "报表数据已是最新!" , "Message" ) ;
}
catch ( Exception )
{
}
}
}
}
2024-11-26 10:31:58 +08:00
private void ToSourceAndHideOthers_Click ( object sender , RoutedEventArgs e )
{
try
{
OthersWireShow ( ) ;
GoToSource ( ) ;
if ( ViewModel . ToSourceAndMinSelf )
{
this . WindowState = WindowState . Minimized ;
}
}
catch ( Exception ex )
{
FlexMessageBox . Error ( ex . Message ) ;
}
}
private void ShowAllWire_Click ( object sender , RoutedEventArgs e )
{
OthersWireShow ( true ) ;
GoToSource ( ) ;
}
2024-10-24 18:01:26 +08:00
}