Browse Source

信息栏增加异常显示红色

master
sc 3 months ago
parent
commit
2148bb0b9d
  1. 2
      MainWindow.xaml
  2. 5
      UserClass/ERRinf.cs
  3. 68
      ViewModel/MainWindowViewModel.cs

2
MainWindow.xaml

@ -117,7 +117,7 @@
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/> IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Status_Str}" HorizontalAlignment="Center" Height="50" Margin="0,0,0,0" <TextBox Text="{Binding Status_Str}" HorizontalAlignment="Center" Height="50" Margin="0,0,0,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="700" FontSize="35" TextWrapping="Wrap" VerticalAlignment="Top" Width="700" FontSize="35"
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" Foreground="{Binding Status_Str_coloer}"
IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/> IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
<TextBox Text="{Binding Sys_Time}" HorizontalAlignment="Right" Height="50" Margin="0,0,5,0" <TextBox Text="{Binding Sys_Time}" HorizontalAlignment="Right" Height="50" Margin="0,0,5,0"
TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20" TextWrapping="Wrap" VerticalAlignment="Top" Width="150" FontSize="20"

5
UserClass/ERRinf.cs

@ -38,8 +38,9 @@ namespace DyeingComputer.UserClass
public static int i=0; public static int i=0;
public static string ERRinf_r(DataTable dataTable)//读取 public static string ERRinf_r(DataTable dataTable)//读取
{ {
if (i >= dataTable.Rows.Count) { i = 0; } else { i++; } if (i < 0) { i = dataTable.Rows.Count - 1; }
string index = dataTable.Rows[i].Field<string>("INF"); string index = dataTable.Rows[i].Field<string>("INF");
i--;
return index; return index;
} }
} }

68
ViewModel/MainWindowViewModel.cs

@ -1,37 +1,38 @@
using System; using CommonServiceLocator;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommonServiceLocator; using CommunityToolkit.Mvvm.Input;
using System.Windows.Threading; using DyeingComputer.Properties;
using static DyeingComputer.UserClass.SqliteHelper;
using System.Data;
using System.Collections.ObjectModel;
using DyeingComputer.View;
using System.Windows;
using DyeingComputer.UserClass; using DyeingComputer.UserClass;
using System.Reflection; using DyeingComputer.View;
using System.Windows.Documents; using Microsoft.Win32;
using System.Runtime.CompilerServices;
using NModbus; using NModbus;
using NModbus.Serial; using NModbus.Serial;
using System.IO.Ports;
using OpenTK.Graphics.ES11; using OpenTK.Graphics.ES11;
using DyeingComputer.Properties; using System;
using Microsoft.Win32; using System.Collections.Generic;
using static DyeingComputer.Windows.ViewStep; using System.Collections.ObjectModel;
using System.Windows.Media; using System.ComponentModel;
using System.Runtime.Remoting.Channels; using System.Data;
using System.Diagnostics.Eventing.Reader; using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.IO; using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using TouchSocket.Sockets; using TouchSocket.Sockets;
using static DyeingComputer.UserClass.SqliteHelper;
using static DyeingComputer.Windows.ViewStep;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
namespace DyeingComputer.ViewModel namespace DyeingComputer.ViewModel
@ -61,6 +62,8 @@ namespace DyeingComputer.ViewModel
public class MainWindowViewModel : ViewModelBase public class MainWindowViewModel : ViewModelBase
{ {
System.Windows.Media.Brush Status_red = new SolidColorBrush() { Color = System.Windows.Media.Color.FromArgb(255, 255, 0, 0) };
System.Windows.Media.Brush Status_Black = new SolidColorBrush() { Color = System.Windows.Media.Color.FromArgb(255, 0, 0, 0) };
private static SQLiteHelper SQLiteHelpers = null; //定义数据库 private static SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径 private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径 private readonly string ChartAdress = Environment.CurrentDirectory + "\\DataBase\\Chart.db"; //数据库路径
@ -116,6 +119,16 @@ namespace DyeingComputer.ViewModel
OnPropertyChanged("Link_bool"); OnPropertyChanged("Link_bool");
} }
} }
System.Windows.Media.Brush Status_str_coloer;
public System.Windows.Media.Brush Status_Str_coloer
{
get => Status_str_coloer;
set
{
Status_str_coloer = value;
OnPropertyChanged("Status_Str_coloer");
}
}
public string work_Temp; //显示温度 public string work_Temp; //显示温度
public string Work_Temp //通知UI控件参数改变 public string Work_Temp //通知UI控件参数改变
{ {
@ -414,15 +427,16 @@ namespace DyeingComputer.ViewModel
IO_view(); IO_view();
TechnologicalProcess_view(); TechnologicalProcess_view();
if (errTabler.Rows.Count!=0) if (errTabler.Rows.Count != 0)
{ {
Status_Str = ERRinf.ERRinf_r(errTabler); Status_Str = ERRinf.ERRinf_r(errTabler);
Alert_red = true; Alert_red = true;
Alert_bell = true; Alert_bell = true;
Status_Str_coloer = Status_red;
} }
else { Status_Str_coloer = Status_Black; }
Updata_dtd("3001", Alert_red); Updata_dtd("3001", Alert_red);
Updata_dtd("3003", Alert_yellow); Updata_dtd("3003", Alert_yellow);
Updata_dtd("3004", Alert_bell); Updata_dtd("3004", Alert_bell);

Loading…
Cancel
Save