change-修改识别结果展示

master
liuwf 5 months ago
parent 0bdfe55b39
commit be7255bdd4

@ -20,7 +20,7 @@ namespace SlnMesnac.Common
try
{
// 获取目录中的所有文件
string[] files = Directory.GetFiles(directoryPath, "*.bmp");
string[] files = Directory.GetFiles(directoryPath);
// 检查是否有文件
if (files.Length == 0)

@ -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;
}
/// <summary>
@ -72,7 +75,8 @@ namespace SlnMesnac.WPF.ViewModel
/// <exception cref="NotImplementedException"></exception>
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

@ -151,19 +151,32 @@
<Border Grid.Row="0" BorderBrush="#0288d1" BorderThickness="0,0,0,1" CornerRadius="0" Background="Transparent" Margin="1,1,1,5" >
<Grid>
<TextBlock Text="识别信息" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="识别结果:" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" />
<TextBlock Text="{Binding ResultTxt,Mode=TwoWay}" FontSize="20" FontWeight="Bold" Foreground="{Binding ResultColor}" VerticalAlignment="Center" Margin="0 0 40 0" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 80 0">
<TextBlock Text="识别结果" FontSize="20" FontWeight="Bold" Foreground="White" VerticalAlignment="Center" />
<!--<TextBlock Text="{Binding ResultTxt,Mode=TwoWay}" FontSize="20" FontWeight="Bold" Foreground="{Binding ResultColor}" VerticalAlignment="Center" Margin="0 0 40 0" />-->
</StackPanel>
</Grid>
</Border>
<Border HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="HeightHelperPanel" Grid.Row="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="10" Background="Transparent" Margin="5,1,5,5">
<StackPanel>
<Image Source="{Binding ImageData, Converter={StaticResource ByteArrayToImageConverter}}" Height="{Binding ElementName=HeightHelperPanel, Path=ActualHeight}" Width="{Binding ElementName=HeightHelperPanel, Path=ActualWidth}"/>
</StackPanel >
<Border Grid.Row="1" BorderBrush="#0288d1" BorderThickness="1" CornerRadius="10" Background="Transparent" Margin="5,1,5,5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Image Source="{Binding ImageData, Converter={StaticResource ByteArrayToImageConverter}}" Height="{Binding ElementName=HeightHelperPanel, Path=ActualHeight}" Width="{Binding ElementName=HeightHelperPanel, Path=ActualWidth}"/>
</StackPanel >
<Grid Grid.Column="1" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Visibility="{Binding OKIsVis}" Grid.Row="0" Text="OK" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="LightGreen"></TextBlock>
<TextBlock Visibility="{Binding NGIsVis}" Grid.Row="1" Text="NG" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="OrangeRed"></TextBlock>
</Grid >
</Grid>
</Border>
</Grid>
</Border>

Loading…
Cancel
Save