博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF绘制折线
阅读量:4710 次
发布时间:2019-06-10

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

WPF后台绘制折线,填充到一个GRID下

private void btnPreview_Click(object sender, RoutedEventArgs e)        {            GridImg.Children.Clear();            System.Drawing.Point p0 = new System.Drawing.Point(0, 0);            System.Drawing.Point p1 = new System.Drawing.Point(0, 0);            System.Drawing.Point p2 = new System.Drawing.Point(0, 0);            System.Drawing.Point p3 = new System.Drawing.Point(0, 0);            int x1 = Convert.ToInt32(txta1.Text);            int y1 = Convert.ToInt32(txtb1.Text);            int x2 = Convert.ToInt32(txta2.Text);            int y2 = Convert.ToInt32(txtb2.Text);            p0.X = 0; p0.Y = 255;            p1.X = x1; p1.Y = 255 - y1;            p2.X = x2; p2.Y = 255 - y2;            p3.X = 255; p3.Y = 0;            Line LX = new Line();//X轴            LX.X1 = 0; LX.X2 = 255; LX.Y1 = 255; LX.Y2 = 255;            LX.StrokeThickness = 1;            LX.Stroke = System.Windows.Media.Brushes.Black;            Line LY = new Line();//Y轴            LY.X1 = 0; LY.X2 = 0; LY.Y1 = 0; LY.Y2 = 255;            LY.StrokeThickness = 1;            LY.Stroke = System.Windows.Media.Brushes.Black;            Polyline PL = new Polyline();//绘制折线            PointCollection collection = new PointCollection();            collection.Add(new System.Windows.Point(p0.X, p0.Y));            collection.Add(new System.Windows.Point(p1.X, p1.Y));            collection.Add(new System.Windows.Point(p2.X, p2.Y));            collection.Add(new System.Windows.Point(p3.X, p3.Y));            PL.Points = collection;            PL.Stroke = new SolidColorBrush(Colors.Red);            PL.StrokeThickness = 1;            GridImg.Children.Add(LX);            GridImg.Children.Add(LY);            GridImg.Children.Add(PL);        }

 

转载于:https://www.cnblogs.com/ZXdeveloper/p/3781688.html

你可能感兴趣的文章
父类 子类 构造方法
查看>>
vs2015下编译duilib的几个问题
查看>>
获取周的日期范围
查看>>
css案例学习之盒子模型
查看>>
postMan模拟get和post请求,支持局域网和外网
查看>>
day16T3改错记
查看>>
Linux 安装 JDK 8
查看>>
ASP.NET Core根据环境切换NLog配置
查看>>
高质量程序设计指南c++/c语言(20)--符号常量
查看>>
strncpy实现
查看>>
华为机试——字符倒叙输出
查看>>
SQLite3中dos命令下退出"...>"状态的方法
查看>>
通过Html5 Canvas画柱状图
查看>>
青蛙跳台阶(Fibonacci数列)
查看>>
洛谷P3834 [模板]可持久化线段树1(主席树) [主席树]
查看>>
Codeforces Round #316 (Div. 2)C. Replacement(模拟)
查看>>
Python入门学习笔记17(sqlalchemyd的使用)
查看>>
.NET CORE TOKEN 权限验证
查看>>
.Net Core 中间件之主机地址过滤(HostFiltering)源码解析
查看>>
Lucene.Net 2.3.1开发介绍 —— 一、接触Lucene.Net
查看>>