Browse Source

修改vnc相关部分

master
sc 7 months ago
parent
commit
982b9a8f28
  1. 3
      EX/VNC.xaml
  2. 41
      EX/VNC.xaml.cs
  3. 5
      UserControls/DispenseMacInfo.xaml
  4. 7
      UserControls/DispenseMacInfo.xaml.cs
  5. 2
      View/DispenseMachinesSet.xaml.cs
  6. 4
      View/DispenseView.xaml.cs

3
EX/VNC.xaml

@ -6,12 +6,13 @@
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.EX" xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.EX"
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:vnc="clr-namespace:VncSharp;assembly=VncSharp" xmlns:vnc="clr-namespace:VncSharp;assembly=VncSharp"
mc:Ignorable="d" mc:Ignorable="d" Loaded="Window_Loaded"
Title="VNC" Height="450" Width="800"> Title="VNC" Height="450" Width="800">
<Grid Margin="0,0,0,0"> <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"/> <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"/>
<ContentControl Margin="0,0,0,60"> <ContentControl Margin="0,0,0,60">
<vnc:RemoteDesktop x:Name="vnc" /> <vnc:RemoteDesktop x:Name="vnc" />
</ContentControl> </ContentControl>
<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> </Grid>
</Window> </Window>

41
EX/VNC.xaml.cs

@ -23,24 +23,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
/// </summary> /// </summary>
public partial class VNC : Window public partial class VNC : Window
{ {
string host = "172.0.0.1"; // 替换为你的 VNC 服务器地址 string host = "127.0.0.1"; // 替换为你的 VNC 服务器地址
int port = 5901; // 替换为你的 VNC 服务器端口 int port = 5901; // 替换为你的 VNC 服务器端口
string password = " "; // 替换为你的 VNC 服务器密码 string password = " "; // 替换为你的 VNC 服务器密码
public VNC() public VNC()
{ {
InitializeComponent(); 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; bool result = false;
Ping pingSender = new Ping(); Ping pingSender = new Ping();
try try
{ {
PingReply reply = pingSender.Send(ip, 120); PingReply reply = await pingSender.SendPingAsync(ip, 6);
if (reply.Status == IPStatus.Success) if (reply.Status == IPStatus.Success)
{ {
result = true; result = true;
log.Text = ip + " Connected";
}
else
{
log.Text = ip + " Timeout";
} }
} }
catch (PingException e) catch (PingException e)
{ {
result = false; result = false;
log.Text = ip + " Not Connected";
} }
return result; 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 连接成功!");
}
}
}
} }
} }

5
UserControls/DispenseMacInfo.xaml

@ -38,6 +38,11 @@
<Button x:Name="Screen" Content="{x:Static lang:Resources.Screen}" HorizontalAlignment="Right" Height="35" Margin="0,0,215,10" VerticalAlignment="Bottom" Width="80" Click="Screen_Click" Padding="0,4,0,4"/> <Button x:Name="Screen" Content="{x:Static lang:Resources.Screen}" HorizontalAlignment="Right" Height="35" Margin="0,0,215,10" VerticalAlignment="Bottom" Width="80" Click="Screen_Click" Padding="0,4,0,4"/>
<materialDesign:PackIcon x:Name="mlock" Kind="Lock" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="50" Height="50" Foreground="#FFA98C00" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/> <materialDesign:PackIcon x:Name="mlock" Kind="Lock" VerticalAlignment="Bottom" HorizontalAlignment="Left" Width="50" Height="50" Foreground="#FFA98C00" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
</Grid> </Grid>
<TextBlock x:Name="IP" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="PORT" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="USER" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="PASSWD" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid> </Grid>
</UserControl> </UserControl>

7
UserControls/DispenseMacInfo.xaml.cs

@ -30,8 +30,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
public DispenseMacInfo() public DispenseMacInfo()
{ {
InitializeComponent(); InitializeComponent();
} }
private void State_Click(object sender, RoutedEventArgs e)//状态 private void State_Click(object sender, RoutedEventArgs e)//状态
{ {
if (mlock.Visibility == Visibility.Visible) if (mlock.Visibility == Visibility.Visible)
@ -63,6 +63,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserControls
MessageBox.Show(Properties.Resources.Not_a, "Dispense", MessageBoxButton.OK); MessageBox.Show(Properties.Resources.Not_a, "Dispense", MessageBoxButton.OK);
return; return;
} }
VNC screen = new VNC();
screen.Parameter(IP.Text,PORT.Text,USER.Text,PASSWD.Text);
screen.Show();
} }
} }

2
View/DispenseMachinesSet.xaml.cs

@ -86,7 +86,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dr_new.Add("type", type_); dr_new.Add("type", type_);
dr_new.Add("State", "899"); dr_new.Add("State", "899");
dr_new.Add("User", User.Text); dr_new.Add("User", User.Text);
dr_new.Add("Passsword", Password.Text); dr_new.Add("Password", Password.Text);
dr_new.Add("LOCK", dLICK.IsChecked.ToString()); dr_new.Add("LOCK", dLICK.IsChecked.ToString());
dr_new.Add("DATA",imageData); dr_new.Add("DATA",imageData);

4
View/DispenseView.xaml.cs

@ -63,6 +63,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dispenseMacInfo[i].Margin = new Thickness(5, 5, 0, 5); dispenseMacInfo[i].Margin = new Thickness(5, 5, 0, 5);
dispenseMacInfo[i].Width = 400; dispenseMacInfo[i].Width = 400;
dispenseMacInfo[i].Height = 600; dispenseMacInfo[i].Height = 600;
dispenseMacInfo[i].IP.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("IP")).ElementAt(i);
dispenseMacInfo[i].USER.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("User")).ElementAt(i);
dispenseMacInfo[i].PORT.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("PORT")).ElementAt(i).ToString();
dispenseMacInfo[i].PASSWD.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Password")).ElementAt(i);
dispenseMacInfo[i].type_.Text= DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i).ToString(); dispenseMacInfo[i].type_.Text= DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i).ToString();
dispenseMacInfo[i].mac.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("name")).ElementAt(i); dispenseMacInfo[i].mac.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("name")).ElementAt(i);
dispenseMacInfo[i].macg.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Groups")).ElementAt(i); dispenseMacInfo[i].macg.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("Groups")).ElementAt(i);

Loading…
Cancel
Save