From be7255bdd4e7cf33610a6a05e296ec718b5a440f Mon Sep 17 00:00:00 2001 From: liuwf Date: Tue, 25 Jun 2024 22:38:59 +0800 Subject: [PATCH] =?UTF-8?q?change-=E4=BF=AE=E6=94=B9=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Common/FileHelper.cs | 2 +- SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 63 +++++++++++++++++------ SlnMesnac.WPF/Views/IndexPage.xaml | 29 ++++++++--- 3 files changed, 69 insertions(+), 25 deletions(-) diff --git a/SlnMesnac.Common/FileHelper.cs b/SlnMesnac.Common/FileHelper.cs index 86d7d9f..dc7af4f 100644 --- a/SlnMesnac.Common/FileHelper.cs +++ b/SlnMesnac.Common/FileHelper.cs @@ -20,7 +20,7 @@ namespace SlnMesnac.Common try { // 获取目录中的所有文件 - string[] files = Directory.GetFiles(directoryPath, "*.bmp"); + string[] files = Directory.GetFiles(directoryPath); // 检查是否有文件 if (files.Length == 0) diff --git a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs index 2a58476..64e7ede 100644 --- a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs @@ -23,6 +23,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Windows; using System.Windows.Media; namespace SlnMesnac.WPF.ViewModel @@ -63,6 +64,8 @@ namespace SlnMesnac.WPF.ViewModel //程序启动,打开绿色指示灯 gunHelper.SendData("OK"); + OKIsVis = Visibility.Hidden; + NGIsVis = Visibility.Hidden; } /// @@ -72,7 +75,8 @@ namespace SlnMesnac.WPF.ViewModel /// private void Reset() { - //FileHelper.FindPhoto(DebugConfig.Instance.CameraFilePath); + + logoBusiness.Pass(); } @@ -263,39 +267,66 @@ namespace SlnMesnac.WPF.ViewModel #region Logo识别结果 - private string _resultTxt; - public string ResultTxt + //private string _resultTxt; + //public string ResultTxt + //{ + // get { return _resultTxt; } + // set + // { + // _resultTxt = value; + // RaisePropertyChanged(nameof(ResultTxt)); + // } + //} + + //private System.Windows.Media.Brush _resultColor; + //public System.Windows.Media.Brush ResultColor + //{ + // get { return _resultColor; } + // set + // { + // _resultColor = value; + // RaisePropertyChanged(nameof(ResultColor)); + // } + //} + + #region 识别结果ok\ng展示 + private Visibility _OKIsVis; + public Visibility OKIsVis { - get { return _resultTxt; } + get { return _OKIsVis; } set { - _resultTxt = value; - RaisePropertyChanged(nameof(ResultTxt)); + _OKIsVis = value; + RaisePropertyChanged(nameof(OKIsVis)); } } - private System.Windows.Media.Brush _resultColor; - public System.Windows.Media.Brush ResultColor + private Visibility _NGIsVis; + public Visibility NGIsVis { - get { return _resultColor; } + get { return _NGIsVis; } set { - _resultColor = value; - RaisePropertyChanged(nameof(ResultColor)); + _NGIsVis = value; + RaisePropertyChanged(nameof(NGIsVis)); } } - + #endregion public void RefreshResultColor(bool isSuccess) { if (isSuccess) { - ResultTxt = "OK"; - ResultColor = System.Windows.Media.Brushes.LimeGreen; + OKIsVis = Visibility.Visible; + NGIsVis = Visibility.Collapsed; + //ResultTxt = "OK"; + //ResultColor = System.Windows.Media.Brushes.LimeGreen; } else { - ResultTxt = "NG"; - ResultColor = System.Windows.Media.Brushes.Red; + OKIsVis = Visibility.Collapsed; + NGIsVis = Visibility.Visible; + //ResultTxt = "NG"; + //ResultColor = System.Windows.Media.Brushes.Red; } } #endregion diff --git a/SlnMesnac.WPF/Views/IndexPage.xaml b/SlnMesnac.WPF/Views/IndexPage.xaml index 8898c83..701896a 100644 --- a/SlnMesnac.WPF/Views/IndexPage.xaml +++ b/SlnMesnac.WPF/Views/IndexPage.xaml @@ -151,19 +151,32 @@ - - - + + + - - - - - + + + + + + + + + + + + + + + + + +