diff --git a/EX/VNC.xaml.cs b/EX/VNC.xaml.cs index 30168df..a1448c1 100644 --- a/EX/VNC.xaml.cs +++ b/EX/VNC.xaml.cs @@ -63,17 +63,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX //rdp.SetScalingMode(false);//自动缩放全屏 // rdp.SetInputMode(false);//可交互 - - } catch (Exception ex) { LogGing.ERRDATA(ex); } - } } - } private async Task PingTest(string ip) diff --git a/View/MonitorView.xaml b/View/MonitorView.xaml index d62036c..0a1008f 100644 --- a/View/MonitorView.xaml +++ b/View/MonitorView.xaml @@ -169,10 +169,10 @@ - + - - + + diff --git a/View/MonitorView.xaml.cs b/View/MonitorView.xaml.cs index 0e277a8..b979149 100644 --- a/View/MonitorView.xaml.cs +++ b/View/MonitorView.xaml.cs @@ -21,12 +21,15 @@ 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 { @@ -91,12 +94,59 @@ namespace SunlightCentralizedControlManagement_SCCM_.View log.Visibility = Visibility.Visible; Picture.Visibility = Visibility.Collapsed; }//信息 - private void ListViewItem_Conveyor(object sender, MouseButtonEventArgs e) + + 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;