EPLAN_PROD_Plugin/Sinvo.EplanHpD.Plugin.WPFUI/View/Scanner/ScannerWindow.xaml.cs

113 lines
3.6 KiB
C#
Raw Normal View History

2024-12-02 09:28:54 +08:00
using CommunityToolkit.Mvvm.Messaging;
using EPLAN.Harness.API;
using EPLAN.Harness.Common.Extensions;
using EPLAN.Harness.Core;
using EPLAN.Harness.Core.Controls;
using EPLAN.Harness.Core.Settings;
using EPLAN.Harness.IO;
using EPLAN.Harness.PlatformCore.P8Objects;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using EPLAN.Harness.ProjectCore.Occurrences.Nailboard;
using HandyControl.Controls;
using Microsoft.Win32;
using Sinvo.EplanHpD.Plugin.WPFUI.Common;
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.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
/// <summary>
/// ScannerWindow.xaml 的交互逻辑
/// </summary>
public partial class ScannerWindow : System.Windows.Window
{
private ScannerViewModel _viewModel;
public ScannerWindow()
{
InitializeComponent();
_viewModel = new ScannerViewModel();
this.DataContext = _viewModel;
}
private void TopMostWindow_Checked(object sender, RoutedEventArgs e)
{
this.Topmost = true;
}
private void TopMostWindow_Unchecked(object sender, RoutedEventArgs e)
{
this.Topmost = false;
}
private void ShowAllWire_Click(object sender, RoutedEventArgs e)
{
_viewModel.OthersOccShow(true);
}
private void GetDoc_Click(object sender, RoutedEventArgs e)
{
_viewModel.GetCurrentDoc();
_viewModel.GetAllCables();
}
private void ExportScanedListBtn_Click(object sender, RoutedEventArgs e)
{
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 = $"线材扫描记录_{DateTime.Now:yyyy-MM-dd_hF}.xlsx",
AddExtension = true,
InitialDirectory = StudioSettings.Instance.ReportExport_Path,
CheckPathExists = true
};
if (saveFileDialog.ShowDialog() == true)
{
_viewModel.ExportWires(System.IO.Path.Combine(FlexIOBase.GetParentPath(saveFileDialog.FileName), saveFileDialog.FileName));
//ExcelHelper.SaveByTemplate(ViewModel.ExportData, Path.Combine(FlexIOBase.GetParentPath(saveFileDialog.FileName), saveFileDialog.FileName));
FlexMessageBox.Info($"导出完成!");
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
2024-12-02 09:28:54 +08:00
_viewModel.GetCurrentDoc();
_viewModel.GetAllCables();
ScannerInfo scannerInfo = new(_viewModel);
this.Closing += scannerInfo.ScannerInfoClosed;
scannerInfo.Show();
2024-12-02 09:28:54 +08:00
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ScanCodeTextBox.Focus();
}
2024-12-02 09:28:54 +08:00
}
}