vnc功能实现
This commit is contained in:
commit
2cf6b0ab6a
11 files changed
+176
-49
No files matched your search
@@ -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;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
+1
-1
@@ -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" />
|
||||||
|
|||||||
+15
-33
@@ -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
|
||||||
@@ -30,28 +32,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)
|
||||||
{
|
{
|
||||||
@@ -67,26 +49,33 @@ namespace SunlightCentralizedControlManagement_SCCM_.EX
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
private async void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (await PingTest(host))
|
if (await PingTest(host))
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+27
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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>
|
||||||
@@ -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,9 +4,10 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.UserControls"
|
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.UserControls"
|
||||||
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" >
|
||||||
@@ -22,13 +23,13 @@
|
|||||||
<TextBlock x:Name="mac" TextWrapping="Wrap" Text="------" FontSize="16" />
|
<TextBlock x:Name="mac" TextWrapping="Wrap" Text="------" FontSize="16" />
|
||||||
</Border>
|
</Border>
|
||||||
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,0,0,0" HorizontalAlignment="Right" Width="80">
|
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,0,0,0" HorizontalAlignment="Right" Width="80">
|
||||||
<TextBlock x:Name="macg" TextWrapping="Wrap" Text="------" FontSize="16" />
|
<TextBlock x:Name="macg" TextWrapping="Wrap" Text="------" FontSize="16" />
|
||||||
</Border>
|
</Border>
|
||||||
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,30,80,0">
|
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" Height="30" VerticalAlignment="Top" Margin="150,30,80,0">
|
||||||
<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>
|
||||||
+84
-10
@@ -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
|
||||||
{
|
{
|
||||||
@@ -36,13 +40,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
public DispenseView()
|
public DispenseView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
||||||
DataTable DispenseMac = new DataTable();
|
DataTable DispenseMac = new DataTable();
|
||||||
UserControls.DispenseMacInfo[] dispenseMacInfo = new UserControls.DispenseMacInfo[99]; //定义总览信息卡
|
UserControls.DispenseMacInfo[] dispenseMacInfo = new UserControls.DispenseMacInfo[99]; //定义总览信息卡
|
||||||
//private string SYS_machines = null;
|
//private string SYS_machines = null;
|
||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
@@ -67,7 +71,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dispenseMacInfo[i].USER.Text = DispenseMac.AsEnumerable().Select(row => row.Field<string>("User")).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].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);
|
||||||
@@ -89,21 +94,90 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
dispenseMacInfo[i].mlock.Visibility = Visibility.Collapsed;
|
dispenseMacInfo[i].mlock.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
//dispenseMacInfo[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name", i).ToString();
|
//dispenseMacInfo[i].name.Text = Selet_Machines(MainWindowViewModel.Machines, "name", i).ToString();
|
||||||
// dispenseMacInfo[i].IMAGE = ;
|
// dispenseMacInfo[i].IMAGE = ;
|
||||||
|
|
||||||
MemoryStream memoryStream = new MemoryStream(DispenseMac.AsEnumerable().Select(row => row.Field<byte[]>("DATA")).ElementAt(i));
|
MemoryStream memoryStream = new MemoryStream(DispenseMac.AsEnumerable().Select(row => row.Field<byte[]>("DATA")).ElementAt(i));
|
||||||
//数据流生成图片显示
|
//数据流生成图片显示
|
||||||
BitmapImage bitmapImage = new BitmapImage();
|
BitmapImage bitmapImage = new BitmapImage();
|
||||||
bitmapImage.BeginInit();
|
bitmapImage.BeginInit();
|
||||||
bitmapImage.StreamSource = memoryStream;
|
bitmapImage.StreamSource = memoryStream;
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user