|
|
@ -23,24 +23,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX |
|
|
|
/// </summary>
|
|
|
|
public partial class VNC : Window |
|
|
|
{ |
|
|
|
string host = "172.0.0.1"; // 替换为你的 VNC 服务器地址
|
|
|
|
string host = "127.0.0.1"; // 替换为你的 VNC 服务器地址
|
|
|
|
int port = 5901; // 替换为你的 VNC 服务器端口
|
|
|
|
string password = " "; // 替换为你的 VNC 服务器密码
|
|
|
|
|
|
|
|
public VNC() |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!vnc.IsConnected) |
|
|
|
{ |
|
|
|
vnc.Connect(host, false, true); |
|
|
|
//System.Windows.MessageBox.Show("VNC 连接成功!");
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -50,30 +39,48 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private bool PingTest(string ip) |
|
|
|
private async Task<bool> PingTest(string ip) |
|
|
|
{ |
|
|
|
bool result = false; |
|
|
|
Ping pingSender = new Ping(); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
PingReply reply = pingSender.Send(ip, 120); |
|
|
|
PingReply reply = await pingSender.SendPingAsync(ip, 6); |
|
|
|
|
|
|
|
if (reply.Status == IPStatus.Success) |
|
|
|
{ |
|
|
|
result = true; |
|
|
|
log.Text = ip + " Connected"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
log.Text = ip + " Timeout"; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
catch (PingException e) |
|
|
|
{ |
|
|
|
result = false; |
|
|
|
log.Text = ip + " Not Connected"; |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public void Parameter(object IP,object PROT,object USER ,object PASSWD) |
|
|
|
{ host = IP.ToString();port =Convert.ToInt16( PROT); password = PASSWD.ToString(); } |
|
|
|
|
|
|
|
|
|
|
|
private async Task Window_Loaded(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
if (await PingTest(host)) |
|
|
|
{ |
|
|
|
if (!vnc.IsConnected) |
|
|
|
{ |
|
|
|
vnc.Connect(host, false, true); |
|
|
|
//System.Windows.MessageBox.Show("VNC 连接成功!");
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|