网站开发有哪些服务器,怎么把视频做成网页链接,杭州网站建设设计制作,网站建设简介是什么意思第一步#xff1a;添加wpf窗口#xff1b;第二步#xff1a;在主窗体image的MouseLeftButtonUp事件中调用调试窗口#xff1b;StatusViewWindow svWindow new StatusViewWindow();svWindow.Show();第三步#xff1a;在主窗体中开个线程通过udp接收光电广开的数据#xf… 第一步添加wpf窗口第二步在主窗体image的MouseLeftButtonUp事件中调用调试窗口StatusViewWindow svWindow new StatusViewWindow();svWindow.Show();第三步在主窗体中开个线程通过udp接收光电广开的数据Thread t3 new Thread(StartSwitchDataRevThread);//四个广电开关数据接受线程t3.Name StartSwitchDataRevThread;t3.Start();t3.IsBackground true;private void StartSwitchDataRevThread(){try{Stopwatch elapsetime new Stopwatch();UdpClient client new UdpClient(8012);IPEndPoint endpoint new IPEndPoint(IPAddress.Parse(192.168.1.202), 8008);client.Client.ReceiveBufferSize 1024 * 1024;//默认值是8192while (true){Byte[] recv;recv client.Receive(ref endpoint);for (int i 0; i 4; i){switchSignal[i] recv[i 2];}switchList.Add(switchSignal);elapsetime.Restart();//计时开始if (switchDataWrite true){String switchDataPath Path.Combine(AppDomain.CurrentDomain.BaseDirectory, switchData);string stringData 0x BitConverter.ToString(recv).Replace(-, 0x).ToLower();stringData DateTime.Now.ToString(yyyy-MM-dd_HH:mm:ss:fff) stringData;StrWrite.strWrite(stringData, switchDataPath, switchDataFile.txt);}elapsetime.Stop();//计时结束Console.WriteLine(接收数据耗时 elapsetime.ElapsedMilliseconds.ToString(0000));}}catch (Exception ex){LogWrite.logWrite(ex.Message, ex.StackTrace);}}第四部在StatusViewWindow窗口定义一个10毫秒的定时器每隔十毫秒从主窗体获取一次光电开关的数据并显示到listBox1中Window x:ClassthzSoftware.StatusViewWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:thzSoftwaremc:IgnorabledTitleStatusViewWindow Height450 Width800 LoadedWindow_LoadedGrid ShowGridLinesFalse BackgroundLightCyan Grid.RowDefinitionsRowDefinition Height*/RowDefinitionRowDefinition Height*/RowDefinition/Grid.RowDefinitionsGrid.ColumnDefinitionsColumnDefinition Width*/ColumnDefinition Width*//Grid.ColumnDefinitionsListBox NamelistBox1 Grid.Row0 Grid.Column1 Grid.RowSpan2 BackgroundLightGray/Button NamebtnCtrl1 Content开始采集 FontSize30 Grid.Row0 Grid.Column0 BackgroundLightGray ClickBtnCtrl1_Click/Button NamebtnCtrl2 Content停止采集 FontSize30 Grid.Row1 Grid.Column0 BackgroundLightGray ClickBtnCtrl2_Click//Grid
/Windowusing System;
using System.Windows;
using System.Windows.Threading;namespace thzSoftware
{/// summary/// StatusViewWindow.xaml 的交互逻辑/// /summarypublic partial class StatusViewWindow : Window{public StatusViewWindow(){InitializeComponent();}Byte[] switchSignal new byte[4];DispatcherTimer StatusViewTimer;private void Window_Loaded(object sender, RoutedEventArgs e){StatusViewTimer new DispatcherTimer();StatusViewTimer.Interval TimeSpan.FromMilliseconds(10);StatusViewTimer.Tick StatusViewTimer_Tick;//加载事件敲tab键事件框架可以自己出来 }private void StatusViewTimer_Tick(object sender, EventArgs e){switchSignal thzModel.DataProcess.switchSignal;string stringData 0x BitConverter.ToString(switchSignal).Replace(-, 0x).ToLower();stringData DateTime.Now.ToString(yyyy-MM-dd_HH:mm:ss:fff) stringData;listBox1.Items.Add(stringData);}private void BtnCtrl1_Click(object sender, RoutedEventArgs e){listBox1.Items.Clear();StatusViewTimer.Start();}private void BtnCtrl2_Click(object sender, RoutedEventArgs e){StatusViewTimer.Stop();}}
}运行结果如下