WPF 实时绘图的逻辑
实时绘图实际上是两个线程。外部线程直接用thread,只有到绘图那个逻辑才用绘图控件的mycanvas2.Dispatcher.Invoke。
或者说,INVOKE并不是开线程,只是一个绘图的委托而已。
主线程:
private void Read_UDP_Click(object sender, RoutedEventArgs e)
{
TCPRx mytcp = new TCPRx(" ", );
---------------------------------
error
---------------------------------
//Action<Canvas> updateAction = new Action<Canvas>(mytcp.readdata);
//updateAction.Invoke(this.FigureShow);
//this.FigureShow.Dispatcher.Invoke(updateAction,this.FigureShow);
//Action<Canvas, String> updateAction = new Action<Canvas, string>(mytcp.readdata);
//this.Dispatcher.BeginInvoke(updateAction, this.FigureShow, "");
new Thread(() =>
{
//this.FigureShow.Dispatcher.Invoke(new Action(() =>
{
while (true)
{
mytcp.readdata(this.FigureShow);
Thread.Sleep(10);
}
}
//)
//);
}).Start();
}
--------------------------------------------------------------------------------------------------------
绘图
--------------------------------------------------------------------------------------------------------
public void readdata(Canvas mycanvas2)
{
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint senderRemote = (EndPoint)sender;
state = new State(myconnect);
buffer = new byte[length];
//myconnect.BeginReceiveFrom(buffer, 0, length, SocketFlags.None, ref senderRemote, drawfigure, state);
//---- myconnect.Receive(buffer);//buffer, 0, length, SocketFlags.None, ref senderRemote, drawfigure, state);
string message = System.Text.Encoding.Default.GetString(buffer, 0, length);
string line = System.Text.Encoding.Default.GetString(buffer, 0, length);
if (string.IsNullOrEmpty(line.Trim()))
{
return;
}
//this.userName.Text = " 测试UI";
mycanvas2.Dispatcher.Invoke(
new Action(
delegate()
{
}
)
);
}
WPF 实时绘图的逻辑的更多相关文章
- arduino 串口实时绘图(以mpu9250为例)
兴趣之余,利用晚上的时间,做一些个人兴趣方面的开发. 之前没接触过 arduino, 无意之中买了个开发板做一些小开发, 这里利用python 读取 mpu9250 数据实时绘图. 下位机代码 C++ ...
- WPF 在绘图控件(Shape)中添加文字 [2018.7.15]
原文:WPF 在绘图控件(Shape)中添加文字 [2018.7.15] Q:使用Shape的子类Ellipse画一个圆,如何在圆中添加文字? A:Shape类中不包含Text属性.可使用Shape类 ...
- WPF特效-绘图
原文:WPF特效-绘图 WPF玩起来还是挺炫酷的.我实现的效果:不同色块交叉,交叉部分颜色叠加显示.(叠加部分暂时用随机颜色代替).单独色块点击弹出以色块颜色为主的附 ...
- SurfaceView实时绘图,视频流
- WPF中绘图(含调用GDI+)
private void DrawStuff() { // //if (buffer == null) //{ // buffer = new RenderTargetBitmap((int)Back ...
- WPF——OXY绘图_old
plotModel = new PlotModel() { Title = "数据统计", LegendTitle = "Max:红色,Min:黄色", Leg ...
- WPF——OXY绘图
private PlotModel _plotModel; public PlotModel plotModel { get { return _plotModel; } set { _plotMod ...
- iOS---实现在屏幕上实时绘图的简单效果---CAShaperLayer和UIBezierPath的简单运用
首先,声明几个属性 @property(nonatomic,strong)UIBezierPath * beizer; @property(nonatomic,assign)CGPoint start ...
- WPF特效-绘制实时2D激光雷达图
原文:WPF特效-绘制实时2D激光雷达图 接前两篇: https://blog.csdn.net/u013224722/article/details/80738619 https://blog.cs ...
随机推荐
- flask的CBV,flash,Flask-Session,及WTForms-MoudelForm
1,CBV: from flask import vews class LoginView(views.MethodView): def get(self): return "雪雪其实也很好 ...
- C项目实践--图书管理系统(4)
前面已经把图书管理系统的所有功能模块都已实现完毕了,下面通过运行来分析该系统的操作流程并检验是否符合逻辑设计要求. 3.系统操作过程 F5 运行 1.登录系统 系统运行之后,提示输入用户名和密码,系统 ...
- Android4.4.2系统添加自定义按键【转】
本文转载自:http://developer.t-firefly.com/thread-251-1-1.html 网上存在一些关于Android系统添加自定义按键的文章,但大多针对Android2.3 ...
- HDU1176 免费馅饼 —— DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1176 免费馅饼 Time Limit: 2000/1000 MS (Java/Others ...
- c语言struct和c++的class的暧昧
c语言风格的封装 数据放在一起,以引用和指针的方式传给行为c++ 认为封装不彻底 1数据和行为分开 对外提供接口 2没有权限设置 看看struct的一个例子 //data.h //c语言风格的封装 数 ...
- NDK相关收藏【转】
http://blog.csdn.net/column/details/anidea-ndk.html [转] 作者:conowen@大钟
- 将Mozilla ThunderBird最小化到系统托盘(转载)
转自:http://be-evil.org/mozilla-thunderbird-minize-to-tray.html Mozilla ThunderBird是一款非常不错的邮件客户端,但是其在默 ...
- bzoj 3555: [Ctsc2014]企鹅QQ【hash+瞎搞】
首先注意 先hash一下,双hash,然后枚举删去位置,把hash值排个序,把些相等的加起来统计一下对数即可 #include<iostream> #include<cstdio&g ...
- bzoj 1072: [SCOI2007]排列perm【状压dp】
先写了个next_permutation结果T了,于是开始写状压 设f[s][i]为选取状态为s,选的数模d为i的方案数,去重的话直接除以每个数字的出现次数的阶乘即可 #include<iost ...
- hibernate简单实现连接数据库,并实现数据的操作
1:创建实体类 package com.yinfu.entity; public class User { private int id; private String username; priva ...