Browse Source

vnc功能实现

master
sc 7 months ago
parent
commit
2cf6b0ab6a
  1. 3
      ConvertMoels/StatenClassConvert.cs
  2. 3
      ConvertMoels/StatenConvert.cs
  3. 2
      EX/VNC.xaml
  4. 42
      EX/VNC.xaml.cs
  5. 27
      Properties/Resources.Designer.cs
  6. 9
      Properties/Resources.en-US.resx
  7. 9
      Properties/Resources.resx
  8. 9
      Properties/Resources.zh-CN.resx
  9. 9
      Properties/Resources.zh-TW.resx
  10. 4
      UserControls/DispenseMacInfo.xaml
  11. 74
      View/DispenseView.xaml.cs

3
ConvertMoels/StatenClassConvert.cs

@ -37,6 +37,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels
else if (i == "801") Staten = Properties.Resources.Implementation;//连接成功 else if (i == "801") Staten = Properties.Resources.Implementation;//连接成功
else if (i == "802") Staten = Properties.Resources.Online;//在线 else if (i == "802") Staten = Properties.Resources.Online;//在线
else if (i == "899") Staten = Properties.Resources.CloseTheConnection;//关闭连接 else if (i == "899") Staten = Properties.Resources.CloseTheConnection;//关闭连接
else if (i == "1") Staten = Properties.Resources.dye;//染料
else if (i == "2") Staten = Properties.Resources.chemicals;//助剂
else if (i == "3") Staten = Properties.Resources.powder;//粉体
else Staten = "null"; else Staten = "null";
return Staten; return Staten;

3
ConvertMoels/StatenConvert.cs

@ -38,6 +38,9 @@ namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels
else if (i == "801") Staten = Properties.Resources.Implementation;//连接成功 else if (i == "801") Staten = Properties.Resources.Implementation;//连接成功
else if (i == "801") Staten = Properties.Resources.Online;//在线 else if (i == "801") Staten = Properties.Resources.Online;//在线
else if (i == "899") Staten = Properties.Resources.CloseTheConnection;//关闭连接 else if (i == "899") Staten = Properties.Resources.CloseTheConnection;//关闭连接
else if (i == "1") Staten = Properties.Resources.dye;//染料
else if (i == "2") Staten = Properties.Resources.chemicals;//助剂
else if (i == "3") Staten = Properties.Resources.powder;//粉体
else Staten = ""; else Staten = "";
return Staten; return Staten;

2
EX/VNC.xaml

@ -8,7 +8,7 @@
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:rdp="clr-namespace:VncSharpWpf;assembly=VncSharpWpf" xmlns:rdp="clr-namespace:VncSharpWpf;assembly=VncSharpWpf"
mc:Ignorable="d" Loaded="Window_Loaded" mc:Ignorable="d" Loaded="Window_Loaded"
Title="VNC" Height="450" Width="800"> Title="VNC" Height="1140" Width="1920">
<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"/>
<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" /> <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" />

42
EX/VNC.xaml.cs

@ -15,6 +15,8 @@ using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using VncSharpWpf; using VncSharpWpf;
using System.Net.Sockets;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
namespace SunlightCentralizedControlManagement_SCCM_.EX namespace SunlightCentralizedControlManagement_SCCM_.EX
@ -31,28 +33,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
public VNC() public VNC()
{ {
InitializeComponent(); 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);//自动缩放全屏
} }
private void Save_Click(object sender, RoutedEventArgs e) private void Save_Click(object sender, RoutedEventArgs e)
{ {
if (rdp.IsConnected) { rdp.Disconnect(); }//断开连接 if (rdp.IsConnected) { rdp.Disconnect(); }//断开连接
@ -72,21 +54,28 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
{ {
if (!rdp.IsConnected) if (!rdp.IsConnected)
{ {
log.Text = host + " OK";
try try
{ {
rdp.VncPort = port; rdp.VncPort = port;
rdp.Passwd = password; rdp.Passwd = password;
rdp.Connect(host, true, true); rdp.Connect(host, false, false);
//rdp.SetScalingMode(false);//自动缩放全屏
// rdp.SetInputMode(false);//可交互
} }
catch (Exception ex) catch (Exception ex)
{ {
LogGing.ERRDATA(ex);
} }
} }
} }
} }
private async Task<bool> PingTest(string ip) private async Task<bool> PingTest(string ip)
{ {
bool result = false; bool result = false;
@ -99,18 +88,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
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)
{ {
result = false; result = false;
log.Text = ip + " Not Connected";
} }
return result; return result;
} }

27
Properties/Resources.Designer.cs

@ -276,6 +276,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 chemicals 的本地化字符串。
/// </summary>
public static string chemicals {
get {
return ResourceManager.GetString("chemicals", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Client 的本地化字符串。 /// 查找类似 Client 的本地化字符串。
/// </summary> /// </summary>
@ -744,6 +753,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 dye 的本地化字符串。
/// </summary>
public static string dye {
get {
return ResourceManager.GetString("dye", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 DyeingMachine 的本地化字符串。 /// 查找类似 DyeingMachine 的本地化字符串。
/// </summary> /// </summary>
@ -1779,6 +1797,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties {
} }
} }
/// <summary>
/// 查找类似 powder 的本地化字符串。
/// </summary>
public static string powder {
get {
return ResourceManager.GetString("powder", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 PrepareMedications 的本地化字符串。 /// 查找类似 PrepareMedications 的本地化字符串。
/// </summary> /// </summary>

9
Properties/Resources.en-US.resx

@ -1038,4 +1038,13 @@
<data name="Not_M" xml:space="preserve"> <data name="Not_M" xml:space="preserve">
<value>Machine does not exist</value> <value>Machine does not exist</value>
</data> </data>
<data name="dye" xml:space="preserve">
<value>Dye</value>
</data>
<data name="chemicals" xml:space="preserve">
<value>Chemicals</value>
</data>
<data name="powder" xml:space="preserve">
<value>Powder</value>
</data>
</root> </root>

9
Properties/Resources.resx

@ -1038,4 +1038,13 @@
<data name="Not_M" xml:space="preserve"> <data name="Not_M" xml:space="preserve">
<value>NOT Machine</value> <value>NOT Machine</value>
</data> </data>
<data name="dye" xml:space="preserve">
<value>dye</value>
</data>
<data name="chemicals" xml:space="preserve">
<value>chemicals</value>
</data>
<data name="powder" xml:space="preserve">
<value>powder</value>
</data>
</root> </root>

9
Properties/Resources.zh-CN.resx

@ -1038,4 +1038,13 @@
<data name="Not_M" xml:space="preserve"> <data name="Not_M" xml:space="preserve">
<value>机台不存在</value> <value>机台不存在</value>
</data> </data>
<data name="dye" xml:space="preserve">
<value>染料</value>
</data>
<data name="chemicals" xml:space="preserve">
<value>助剂</value>
</data>
<data name="powder" xml:space="preserve">
<value>粉体</value>
</data>
</root> </root>

9
Properties/Resources.zh-TW.resx

@ -1038,4 +1038,13 @@
<data name="Not_M" xml:space="preserve"> <data name="Not_M" xml:space="preserve">
<value>機台不存在</value> <value>機台不存在</value>
</data> </data>
<data name="dye" xml:space="preserve">
<value />
</data>
<data name="chemicals" xml:space="preserve">
<value />
</data>
<data name="powder" xml:space="preserve">
<value />
</data>
</root> </root>

4
UserControls/DispenseMacInfo.xaml

@ -7,6 +7,7 @@
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel" xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:ConvertMoels="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ConvertMoels"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="400" Background="#FF828282"> d:DesignHeight="600" d:DesignWidth="400" Background="#FF828282">
<Grid Margin="5,5,5,5" Background="White" > <Grid Margin="5,5,5,5" Background="White" >
@ -28,7 +29,7 @@
<TextBlock x:Name="state" TextWrapping="Wrap" Text="------" FontSize="16" /> <TextBlock x:Name="state" TextWrapping="Wrap" Text="------" FontSize="16" />
</Border> </Border>
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,30,0,0" HorizontalAlignment="Right" Width="80"> <Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,30,0,0" HorizontalAlignment="Right" Width="80">
<TextBlock x:Name="type_" TextWrapping="Wrap" Text="------" FontSize="16" /> <TextBlock x:Name="type_N" TextWrapping="Wrap" Text="-------" FontSize="16" />
</Border> </Border>
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,60,0,0"> <Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,60,0,0">
<TextBlock x:Name="WorkingStatus" TextWrapping="Wrap" Text="------" FontSize="16" /> <TextBlock x:Name="WorkingStatus" TextWrapping="Wrap" Text="------" FontSize="16" />
@ -44,5 +45,6 @@
<TextBlock x:Name="PORT" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" /> <TextBlock x:Name="PORT" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" />
<TextBlock x:Name="USER" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" /> <TextBlock x:Name="USER" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" />
<TextBlock x:Name="PASSWD" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" /> <TextBlock x:Name="PASSWD" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" />
<TextBlock x:Name="type_" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="{x:Null}" />
</Grid> </Grid>
</UserControl> </UserControl>

74
View/DispenseView.xaml.cs

@ -26,6 +26,10 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper; using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using System.Windows.Threading;
using Newtonsoft.Json.Linq;
using System.Xml.Linq;
using static System.Windows.Forms.AxHost;
namespace SunlightCentralizedControlManagement_SCCM_.View namespace SunlightCentralizedControlManagement_SCCM_.View
{ {
@ -68,6 +72,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
dispenseMacInfo[i].PORT.Text = DispenseMac.AsEnumerable().Select(row => row.Field<int>("PORT")).ElementAt(i).ToString(); 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].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].type_N.Text = StatenClassConvert.Convert(DispenseMac.AsEnumerable().Select(row => row.Field<int>("type")).ElementAt(i));
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);
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x); dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x);
@ -100,10 +105,79 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
bitmapImage.EndInit(); bitmapImage.EndInit();
dispenseMacInfo[i].IMAGE.Source = bitmapImage; dispenseMacInfo[i].IMAGE.Source = bitmapImage;
DispenseMacView.Children.Add(dispenseMacInfo[i]); DispenseMacView.Children.Add(dispenseMacInfo[i]);
CountDown();
} }
} }
private void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每10秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(10)//秒
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
}//时间周期初始化
async void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
for (int i = 0; i < DispenseMac.Rows.Count; i++)
{
if (await PingTest(dispenseMacInfo[i].IP.Text))
{
DataRow drEmployee = DispenseMac.Select("IP='" + dispenseMacInfo[i].IP.Text + "'").First();
drEmployee.BeginEdit();
drEmployee["State"] = "802";
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
}
string x = DispenseMac.AsEnumerable().Select(row => row.Field<string>("State")).ElementAt(i);
bool y = DispenseMac.AsEnumerable().Select(row => row.Field<bool>("LOCK")).ElementAt(i);
dispenseMacInfo[i].state.Text = StatenClassConvert.Convert(x);
dispenseMacInfo[i].WorkingStatus.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("WorkingStatus")).ElementAt(i);
if (x == "899")
{
dispenseMacInfo[i].state.Background = new SolidColorBrush(Color.FromRgb(255, 0, 0));
}
else
{
dispenseMacInfo[i].state.Background = new SolidColorBrush(Color.FromRgb(255, 255, 255));
}
if (y)
{
dispenseMacInfo[i].mlock.Visibility = Visibility.Visible;
}
else
{
dispenseMacInfo[i].mlock.Visibility = Visibility.Collapsed;
}
}
}
private async Task<bool> 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;
}
} }
} }

Loading…
Cancel
Save