添加vnc功能
This commit is contained in:
commit
18d6aa3e87
8 files changed
+72
-42
No files matched your search
Binary file not shown.
+4
-4
@@ -6,15 +6,15 @@
|
||||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.EX"
|
||||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
|
||||
xmlns:vnc="clr-namespace:VncSharp;assembly=VncSharp"
|
||||
xmlns:rdp="clr-namespace:VncSharpWpf;assembly=VncSharpWpf"
|
||||
mc:Ignorable="d" Loaded="Window_Loaded"
|
||||
Title="VNC" Height="450" Width="800">
|
||||
<Grid Margin="0,0,0,0">
|
||||
<Button x:Name="Save" Content="{x:Static lang:Resources.Cancel}" HorizontalAlignment="Right" Height="35" Margin="450,0,50,10" VerticalAlignment="Bottom" Width="80" Click="Save_Click"/>
|
||||
<WindowsFormsHost Margin="0,0,0,60">
|
||||
<vnc:RemoteDesktop x:Name="vnc" />
|
||||
</WindowsFormsHost>
|
||||
<TextBlock x:Name="log" VerticalAlignment="Bottom" Text="LINK-------" Margin="0,0,0,10" HorizontalAlignment="Left" Width="600" Height="35" FontSize="24" FontWeight="Bold" FontStyle="Italic" />
|
||||
<Grid Margin="0,0,0,60">
|
||||
<rdp:RemoteDesktopWpf x:Name="rdp" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
+48
-30
@@ -14,6 +14,7 @@ using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Net.NetworkInformation;
|
||||
using VncSharpWpf;
|
||||
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
@@ -30,15 +31,60 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
public VNC()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// vnc.Cursor = Cursors;
|
||||
|
||||
// vnc.MouseMove += Vnc_MouseMove;
|
||||
// vnc.MouseDown += Vnc_MouseDown ;
|
||||
// vnc.MouseUp += Vnc_MouseUp;
|
||||
// vnc.MouseLeave += Vnc_MouseLeave;
|
||||
// vnc.MouseWheel += Vnc_MouseWheel;
|
||||
// vnc.PreviewKeyDown += Vnc_PreviewKeyDown;
|
||||
|
||||
|
||||
// rdp.ConnectComplete += new ConnectCompleteHandler(ConnectCompleteEventHandler);
|
||||
// rdp.ConnectionLost += new EventHandler(ConnectionLostEventHandler);
|
||||
// rdp.StoppedListen += new EventHandler(ConnectionLostEventHandler);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (rdp.IsConnected) { rdp.Disconnect(); }//断开连接
|
||||
this.Close();
|
||||
}
|
||||
|
||||
public void Parameter(object IP, object PROT, object USER, object PASSWD)
|
||||
{
|
||||
host = IP.ToString();
|
||||
port = Convert.ToInt16(PROT);
|
||||
password = PASSWD.ToString();
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (await PingTest(host))
|
||||
{
|
||||
if (!rdp.IsConnected)
|
||||
{
|
||||
try
|
||||
{
|
||||
rdp.VncPort = port;
|
||||
rdp.Passwd = password;
|
||||
rdp.Connect(host, true, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private async Task<bool> PingTest(string ip)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -46,7 +92,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
|
||||
try
|
||||
{
|
||||
PingReply reply = await pingSender.SendPingAsync(ip, 3000);
|
||||
PingReply reply = await pingSender.SendPingAsync(ip, 3000);
|
||||
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
@@ -66,33 +112,5 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Parameter(object IP,object PROT,object USER ,object PASSWD)
|
||||
{// host = IP.ToString();
|
||||
//port =Convert.ToInt16( PROT);
|
||||
// password = PASSWD.ToString();
|
||||
}
|
||||
|
||||
/* private Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}*/
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
if (await PingTest(host))
|
||||
{
|
||||
if (!vnc.IsConnected)
|
||||
{
|
||||
vnc.VncPort = port;
|
||||
vnc.GetPassword();
|
||||
vnc.Connect(host, true, true);
|
||||
// vnc.Authenticate(password);
|
||||
|
||||
//System.Windows.MessageBox.Show("VNC 连接成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user