using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
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.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
///
/// MachinesSet.xaml 的交互逻辑
///
public partial class MachinesView : UserControl, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
if (propertyName != null)
{
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public MachinesView()
{
DataContext = this;
InitializeComponent();
CountDown();
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
string machine;
int LOG_ = 0;
public static DataTable LOG_dataTable = new DataTable();
private void Griddata_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
machine = (Griddata.Columns[1].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
MAC_name.Text= machine;
MainWindowViewModel.dt_d.Clear();
MainWindowViewModel.dt_a.Clear();
MainWindowViewModel.dt_m.Clear();
MainWindowViewModel.dt_ParameterSet.Clear();
MainWindowViewModel.dt_SysSet.Clear();
}
}
private void ListViewItem_ArrowLeftRight(object sender, MouseButtonEventArgs e)
{
LOG_GRID.Visibility = Visibility.Collapsed;
IO_GRID.Visibility = Visibility.Visible;
SYS_GRID.Visibility = Visibility.Collapsed;
SET_GRID.Visibility = Visibility.Collapsed;
view = 0;
}
private void ListViewItem_VideoHomeSystem(object sender, MouseButtonEventArgs e)
{
LOG_GRID.Visibility = Visibility.Collapsed;
IO_GRID.Visibility = Visibility.Collapsed;
SYS_GRID.Visibility = Visibility.Visible;
SET_GRID.Visibility = Visibility.Collapsed;
view = 2;
}
private void ListViewItem_LOG(object sender, MouseButtonEventArgs e)
{
if (LOG_ >= 3) { LOG_ = 0; }
else
{ LOG_++; }
LOG_GRID.Visibility = Visibility.Visible;
IO_GRID.Visibility = Visibility.Collapsed;
SYS_GRID.Visibility = Visibility.Collapsed;
SET_GRID.Visibility = Visibility.Collapsed;
view = 3;
LOG_dataTable.Clear();
Dictionary dat_859 =new Dictionary();
if (LOG_ == 0)
{
MAC_name.Text = machine+ "(SERVER)";
dat_859.Add("INSTRUCTION", "SERVER");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
}
else if (LOG_ == 1)
{
MAC_name.Text = machine + "(OperationLog)";
dat_859.Add("INSTRUCTION", "OperationLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
}
else if (LOG_ == 2)
{
MAC_name.Text = machine + "(IOLog)";
dat_859.Add("INSTRUCTION", "IOLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
}
else
{
MAC_name.Text = machine + "(ERRLog)";
dat_859.Add("INSTRUCTION", "ERRLog");
dat_859.Add("TIME_S", DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss"));
dat_859.Add("TIME_E", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
}
if (!string.IsNullOrEmpty(machine))
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int State_ = Convert.ToInt16(drEmployee.Field