vnc功能实现
This commit is contained in:
commit
2cf6b0ab6a
11 files changed
+176
-49
No files matched your search
+1
-1
@@ -8,7 +8,7 @@
|
||||
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
|
||||
xmlns:rdp="clr-namespace:VncSharpWpf;assembly=VncSharpWpf"
|
||||
mc:Ignorable="d" Loaded="Window_Loaded"
|
||||
Title="VNC" Height="450" Width="800">
|
||||
Title="VNC" Height="1140" Width="1920">
|
||||
<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"/>
|
||||
<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" />
|
||||
|
||||
+15
-33
@@ -15,6 +15,8 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Net.NetworkInformation;
|
||||
using VncSharpWpf;
|
||||
using System.Net.Sockets;
|
||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||
|
||||
|
||||
namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
@@ -30,28 +32,8 @@ 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);
|
||||
|
||||
rdp.SetScalingMode(false);//自动缩放全屏
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Save_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -67,26 +49,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
}
|
||||
|
||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
{
|
||||
if (await PingTest(host))
|
||||
{
|
||||
if (!rdp.IsConnected)
|
||||
{
|
||||
log.Text = host + " OK";
|
||||
try
|
||||
{
|
||||
rdp.VncPort = port;
|
||||
rdp.Passwd = password;
|
||||
rdp.Connect(host, true, true);
|
||||
rdp.Connect(host, false, false);
|
||||
|
||||
//rdp.SetScalingMode(false);//自动缩放全屏
|
||||
// rdp.SetInputMode(false);//可交互
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
LogGing.ERRDATA(ex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task<bool> PingTest(string ip)
|
||||
{
|
||||
bool result = false;
|
||||
@@ -99,18 +88,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
result = true;
|
||||
log.Text = ip + " Connected";
|
||||
}
|
||||
else
|
||||
{
|
||||
log.Text = ip + " Timeout";
|
||||
}
|
||||
|
||||
}
|
||||
catch (PingException e)
|
||||
catch (PingException)
|
||||
{
|
||||
result = false;
|
||||
log.Text = ip + " Not Connected";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user