博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF(5)---很据数据绘制趋势表
阅读量:6092 次
发布时间:2019-06-20

本文共 2883 字,大约阅读时间需要 9 分钟。

1---XAML布局的设计 3层嵌套

2---绘制显示的表格 11x21

for (int i = 0; i <=10; i++)            {                Polyline line = new Polyline();                line.Stroke = new SolidColorBrush(Colors.Red);                Point startPoint = new Point(0,i*30);//起点                Point endPoint = new Point(600,i*30);//终点                line.Points.Add(startPoint);                line.Points.Add(endPoint);                MyCanvas.Children.Add(line);            }            for (int i = 0; i <= 20;i++ )            {                Polyline line = new Polyline();                line.Stroke = new SolidColorBrush(Colors.Red);                Point startPoint = new Point(i*30,0);                Point endPoint = new Point(i*30,600);                line.Points.Add(startPoint);                line.Points.Add(endPoint);                MyCanvas.Children.Add(line);            }

3---根据数据绘制变化曲线

ComSettingModel MyComSettingModel = new ComSettingModel();        private DispatcherTimer tm = new DispatcherTimer();        private PointCollection MyPointCollection = new PointCollection();        private Polyline MyPolyline = new Polyline();        ZigBee MyZigBee;        private void Window_Loaded_1(object sender, RoutedEventArgs e)        {            MyComSettingModel.ZigbeeCom = "COM3";            MyZigBee = new ZigBee(MyComSettingModel);            MyZigBee.Open();            MyPolyline.Stroke = new SolidColorBrush(Color.FromRgb(191, 71, 22));            MainCanvs.Children.Add(MyPolyline);            MyPolyline.Points = MyPointCollection;            //定时器设定            tm.Tick += new EventHandler(tm_Tick);            tm.Interval = TimeSpan.FromSeconds(1.0);            tm.Start();        } int count=0;        void tm_Tick(object sender, EventArgs e)        {               MyZigBee.GetSet();               float temperature =float.Parse( MyZigBee.temperatureValue);               Point pt = new Point(count * 6, 300 - temperature * 6);               MyPointCollection.Add(pt);               if (count <=100)               {                   for (int i = 0; i < MyPointCollection.Count; i++)                   {                       Point npt = new Point(MyPointCollection[i].X, MyPointCollection[i].Y);                       MyPointCollection[i] = npt;                   }                   count++;               }               else               {                   for (int i = 0; i < MyPointCollection.Count; i++)                   {                       Point Line = new Point(MyPointCollection[i].X -6, MyPointCollection[i].Y);                       MyPointCollection[i] = Line;                   }                   count = 100;               }               txtTest.Text = string.Format("变化值:{0}", temperature);            }

 

转载于:https://www.cnblogs.com/Probably/p/4605348.html

你可能感兴趣的文章
文本挖掘之文本推荐(子集合生成)
查看>>
JavaScript+Html 调用Wcf Rest Api接口
查看>>
推荐:python科学计算pandas/python画图库matplotlib【转】
查看>>
我理解的优秀软件工程师
查看>>
信息安全管理(3):网络安全
查看>>
Unity3D初识---窗口和菜单基础介绍
查看>>
[改善Java代码]集合中的元素必须做到compareTo和equals同步
查看>>
ASM文件系统
查看>>
poj1164 The Castle
查看>>
Combinations Of Coins - Medium
查看>>
vue swiper中的大坑
查看>>
Template Metaprogramming with Modern C++: Introduction
查看>>
二进制、八进制、十进制、十六进制之间的转换
查看>>
洛谷——P1596 [USACO10OCT]湖计数Lake Counting
查看>>
智力大冲浪
查看>>
算法思想(一)理解复杂度
查看>>
JSONP实现跨域
查看>>
Python基础班---第一部分(基础)---Python基础知识---计算机组成原理
查看>>
虚拟机VMware 9安装苹果MAC OSX 10.8图文教程
查看>>
POJ3694 Network
查看>>