using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Net;
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 VncSharpWpf;
using System.Xml.Linq;
using TouchSocket.Core;
using TouchSocket.Sockets;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using System.Net.NetworkInformation;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
///
/// MonitorView.xaml 的交互逻辑
///
public partial class MonitorView : UserControl
{
public MonitorView()
{
InitializeComponent();
CountDown();
}
private string machine;
private string workOrder;
private string dyelot;
private int machines_info=0;
public static string Sys_log;
private void Griddata_SelectionChanged(object sender, SelectionChangedEventArgs e)//设备列表
{
Stop.IsEnabled = true;
Insert.IsEnabled = false;
edit.IsEnabled = false;
Paused.IsEnabled = false;
Resume.IsEnabled = false;
Delete.IsEnabled = false;
Jump.IsEnabled = false;
MainWindowViewModel.TechnologicalProcess_bool = true;
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
machine = (Griddata.Columns[1].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
workOrder = (Griddata.Columns[2].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
dyelot = (Griddata.Columns[3].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
machin_LOG.Text = Properties.Resources.Machine + ":" + machine + " " + Properties.Resources.WorkOrder + ":" + workOrder;
}
}
private void Gridstep_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Paused.IsEnabled = true;
MainWindowViewModel.TechnologicalProcess_bool = false;
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
ID = (Gridstep.Columns[2].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第0列,
Numder = (Gridstep.Columns[3].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第1列,
P1 = (Gridstep.Columns[6].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第6列,
P2 = (Gridstep.Columns[7].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (Gridstep.Columns[8].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (Gridstep.Columns[9].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Gridstep.Columns[10].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第10列,
}
}
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
{
machines_info = 0;
log.Visibility = Visibility.Visible;
Picture.Visibility = Visibility.Collapsed;
}//信息
private async Task PingTest(string ip)
{
bool result = false;
Ping pingSender = new Ping();
try
{
PingReply reply = await pingSender.SendPingAsync(ip, 3000);
if (reply.Status == IPStatus.Success)
{
result = true;
}
}
catch (PingException)
{
result = false;
}
return result;
}
private async void ListViewItem_Screen(object sender, MouseButtonEventArgs e)
{
machines_info = 1;
log.Visibility = Visibility.Visible;
Picture.Visibility = Visibility.Collapsed;
RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf();
Picture.Content = remoteDesktopWpf;
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
string host = drEmployee.Field("IP");
int port = Convert.ToInt16(drEmployee.Field("PORT"));
string password = drEmployee.Field("SYSKEY");
if (await PingTest(host))
{
if (!remoteDesktopWpf.IsConnected)
{
try
{
remoteDesktopWpf.VncPort = port;
remoteDesktopWpf.Passwd = password;
remoteDesktopWpf.Connect(host, true, false);
}
catch (Exception ex)
{
LogGing.ERRDATA(ex);
}
}
}
}//远程
private void ListViewItem_Receipt(object sender, MouseButtonEventArgs e)
{
machines_info = 2;
log.Visibility = Visibility.Visible;
Picture.Visibility = Visibility.Collapsed;
DyelotView dyelotView = new DyelotView();
dyelotView.Dyelot(workOrder);
Picture.Content = dyelotView;
}//单据
private void ListViewItem_Curve(object sender, MouseButtonEventArgs e)
{
log.Visibility = Visibility.Collapsed;
Picture.Visibility = Visibility.Visible;
Picture.Content = new View.CurveDiagram(true, "", "", "", workOrder);
machines_info = 3;
}//曲线
private void ListViewItem_Resume(object sender, MouseButtonEventArgs e)
{
if (!string.IsNullOrEmpty(machine))
{
Dictionary dat_821 = new Dictionary();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "CONTINUE");
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
int index = Convert.ToInt16(drEmployee.Field