| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using HMI.Core.Util; |
| | | using HMI.UI.Util; |
| | | using Panuon.WPF.UI; |
| | | using System; |
| | | using System.ComponentModel; |
| | | using System.IO.Ports; |
| | | using System.Linq; |
| | | using System.Runtime.CompilerServices; |
| | | 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; |
| | | |
| | | namespace Plugin.TestResult_WPF |
| | | { |
| | |
| | | /// <summary> |
| | | /// Scanner.xaml 的交互逻辑 |
| | | /// </summary> |
| | | public partial class Scanner : Window, INotifyPropertyChanged |
| | | public partial class Scanner : WindowX |
| | | { |
| | | #region ... |
| | | public event PropertyChangedEventHandler PropertyChanged; |
| | | |
| | | public virtual void RaisePropertyChanged(string name) |
| | | { |
| | | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); |
| | | } |
| | | |
| | | public void RaiseAndSetIfchanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null) |
| | | { |
| | | old = @new; |
| | | if (propertyName != null) RaisePropertyChanged(propertyName); |
| | | } |
| | | #endregion |
| | | |
| | | private string _title; |
| | | |
| | | public string title |
| | | { |
| | | get { return _title; } |
| | | set => RaiseAndSetIfchanged(ref _title, value); |
| | | set => Set(ref _title, value); |
| | | } |
| | | |
| | | public event EventHandler<BarcodeEventArg> FinishBarcode; |
| | |
| | | this.title = title; |
| | | this.DataContext = this; |
| | | InitializeComponent(); |
| | | Loaded += Scanner_Loaded; |
| | | } |
| | | |
| | | private void Scanner_Loaded(object sender, RoutedEventArgs e) |
| | | { |
| | | InitScanner(); |
| | | Loaded -= Scanner_Loaded; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | string comStr = ""; |
| | | if (serialPort != null) return; |
| | | if (this.title == "一区扫码") |
| | | if (this.Tag == "Zone1") |
| | | { |
| | | comStr = "COM1"; |
| | | } |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"初始化扫码枪失败!{ex.StackTrace}"); |
| | | ViewControl.Logger.Error("Init Scan Gun Failed.", ex); |
| | | MsgBoxHelper.Error(this, $"{this.lang("Tr.InitGunFailed")}: {ex.StackTrace}"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show($"获取扫码枪数据失败!{ex.StackTrace}"); |
| | | ViewControl.Logger.Error("Get Scan Gun Data Failed.", ex); |
| | | MessageBox.Show($"{this.lang("Tr.GetGunData")}: {ex.StackTrace}"); |
| | | } |
| | | } |
| | | |
| | |
| | | string position = positionText.Text, snr = snrText.Text; |
| | | if (string.IsNullOrEmpty(position) || string.IsNullOrEmpty(snr)) |
| | | { |
| | | MessageBox.Show("请输入储位条码和产品条码"); |
| | | ToastHelper.Warning(this, this.lang("Tr.PleaseInputSnrs")); |
| | | return; |
| | | } |
| | | try |
| | | { |
| | | FinishBarcode.Invoke(this, new BarcodeEventArg(title, position, snr)); |
| | | FinishBarcode.Invoke(this, new BarcodeEventArg(Tag.ToString(), position, snr)); |
| | | //positionText.Text = ""; |
| | | //snrText.Text = ""; |
| | | positionText.Focus(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | ViewControl.Logger.Error("Con_Click Failed.", ex); |
| | | ToastHelper.Warning(this, ex.Message); |
| | | } |
| | | }); |
| | | } |
| | |
| | | string position = positionText.Text, snr = snrText.Text; |
| | | if (string.IsNullOrEmpty(position) || string.IsNullOrEmpty(snr)) |
| | | { |
| | | MessageBox.Show("请输入储位条码和产品条码"); |
| | | ToastHelper.Warning(this, this.lang("Tr.PleaseInputSnrs")); |
| | | return; |
| | | } |
| | | try |
| | | { |
| | | FinishBarcode.Invoke(this, new BarcodeEventArg(title, position, snr)); |
| | | FinishBarcode.Invoke(this, new BarcodeEventArg(Tag.ToString(), position, snr)); |
| | | this.Close(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | ViewControl.Logger.Error("Con_Click Failed.", ex); |
| | | ToastHelper.Warning(this, ex.Message); |
| | | } |
| | | } |
| | | |