using LiveChartsCore.Geo;
using SkiaSharp;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
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.Net.NetworkInformation;
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 System.Xml.Linq;
using TouchSocket.Core;
using TouchSocket.Sockets;
using VncSharpWpf;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Net.WebRequestMethods;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
///
/// MonitorView.xaml 的交互逻辑
///
public partial class MonitorView : 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 MonitorView()
{
DataContext = this;
InitializeComponent();
CountDown();
machine= MainWindowViewModel.machine;
workOrder= MainWindowViewModel.workOrder;
dyelot= MainWindowViewModel.dyelot;
machin_LOG.Text = MainWindowViewModel.machin_LOG;
IsInteractive = false;
DATA_view();
}
private string machine;
private string workOrder;
private string dyelot;
private int machines_info=0;
public static string Sys_log;
public static DataTable Product_DAT = new DataTable();
public static bool Product_bool = false;
private void Griddata_SelectionChanged(object sender, SelectionChangedEventArgs e)//设备列表
{
int rownum = Griddata.SelectedIndex;//获取鼠标选中行并定义变量
string mac_s = "800";
if (rownum != -1)//判断鼠标定位是否有效
{
mac_s = (Griddata.Columns[0].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
}
else { return; }
if ((mac_s != "800") && (mac_s != "801") && (mac_s != "802"))
{
Stop.IsHitTestVisible = true;
Paused.IsHitTestVisible = true;
Insert.IsHitTestVisible = false;
edit.IsHitTestVisible = false;
Resume.IsHitTestVisible = false;
Delete.IsHitTestVisible = false;
Jump.IsHitTestVisible = false;
DyeingMachine.IsHitTestVisible = true;
Curve.IsHitTestVisible = true;
Screen.IsHitTestVisible = true;
Receipt.IsHitTestVisible = true;
TechnologicalProcess_bool = true;
IsInteractive = false;
if (rownum != -1)//判断鼠标定位是否有效
{
machine = (Griddata.Columns[2].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第1列,
workOrder = (Griddata.Columns[3].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
dyelot = (Griddata.Columns[4].GetCellContent(Griddata.Items[rownum]) as TextBlock).Text;//定位第列,
MainWindowViewModel.machine = machine;
MainWindowViewModel.workOrder = workOrder;
MainWindowViewModel.dyelot = dyelot;
MainWindowViewModel.machin_LOG = Properties.Resources.Machine + ":" + machine + " " + Properties.Resources.WorkOrder + ":" + workOrder;
machin_LOG.Text = MainWindowViewModel.machin_LOG;
}
}
else
{
MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); //
}
}
private void Gridstep_SelectionChanged(object sender, SelectionChangedEventArgs e)//步骤定位
{
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;
rdp.Visibility = Visibility.Collapsed;
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)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
string host = drEmployee.Field("IP");
int port = 5900;
string password = "123456";//drEmployee.Field("SYSKEY");
// bool Desktop = drEmployee.Field("Desktop");
if (!drEmployee.Field("Desktop"))
{
MessageBox.Show(Properties.Resources.Not_a, "Desktop", MessageBoxButton.OK);
return;
}
machines_info = 1;
log.Visibility = Visibility.Collapsed;
Picture.Visibility = Visibility.Collapsed;
rdp.Visibility = Visibility.Visible;
// RemoteDesktopWpf remoteDesktopWpf = new RemoteDesktopWpf();
// Picture.Content = remoteDesktopWpf;
if (await PingTest(host))
{
if (!rdp.IsConnected)
{
try
{
rdp.VncPort = port;
rdp.Passwd = password;
rdp.Connect(host, true, false);
}
catch (Exception ex)
{
LogGing.ERRDATA(ex);
}
}
}
}//远程
private void ListViewItem_Receipt(object sender, MouseButtonEventArgs e)
{
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
if (!drEmployee.Field("Dispense"))
{
MessageBox.Show(Properties.Resources.Not_a, "Dispense", MessageBoxButton.OK);
return;
}
int index = Convert.ToInt16(drEmployee.Field