WPF中的方波或脉冲序列 [英] Square wave or pulse train in WPF
本文介绍了WPF中的方波或脉冲序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何在WPF中绘制方波或脉冲序列?我已经在互联网上阅读..但找不到任何解决方案..我发现接近的唯一解决方案是使用正弦函数..这是使用频率...但我没有任何频率...我有一个整数数组..我想从那些整数中绘制方波。因为那些整数代表波浪的过渡状态...
什么我试过了:
ImageShack - gr1.PNG [ ^ ]
how can we draw square wave or pulse train in WPF? I have read on the internet .. but could not find any solution.. the only solution I found that was close was using sine function.. that was using frequency... But i do not have any frequency... i have an array of integers.. and i want to draw square wave from those integers.. As those integers represent the transitional state of the wave...
What I have tried:
ImageShack - gr1.PNG[^]
Line redLine = new Line();
redLine.X1 = 100;
redLine.Y1 = 0;
redLine.X2 = 200;
redLine.Y2 = 0;
SolidColorBrush redBrush = new SolidColorBrush();
redBrush.Color = Colors.Red;
redLine.StrokeThickness = 4;
redLine.Stroke = redBrush;
myCanvas.Children.Add(redLine);
Line Line = new Line();
Line.X1 = 200;
Line.Y1 = 0;
Line.X2 = 200;
Line.Y2 = 150;
SolidColorBrush Brush = new SolidColorBrush();
Brush.Color = Colors.Black;
Line.StrokeThickness = 4;
Line.Stroke = Brush;
myCanvas.Children.Add(Line);
Line line = new Line();
line.X1 = 200;
line.Y1 = 150;
line.X2 = 400;
line.Y2 = 150;
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Colors.Orange;
line.StrokeThickness = 4;
line.Stroke = Brush;
myCanvas.Children.Add(line);
Line line4 = new Line();
line4.X1 = 400;
line4.Y1 = 150;
line4.X2 = 400;
line4.Y2 = 500;
SolidColorBrush brush4 = new SolidColorBrush();
brush4.Color = Colors.Blue;
line4.StrokeThickness = 4;
line4.Stroke = Brush;
myCanvas.Children.Add(line4);
推荐答案
唯一的解决方案是使用画布。您可以创建一个自定义画布,其中包括创建此类图形的方法。网上有很多例子,显然你看过了。这是一个:
tp://csharphelper.com/blog / 2014/09 / draw-graph-wpf-c / [ ^ ]。如果我这样做,我可能会创建一个自定义控件继承自Canvas,并具有Max,Min,increment和函数的依赖属性。
The only solution is to use a canvas. You could possibly create a custom canvas that would include a way to create such a graph. Lots of examples on the web, and obviously you have looked. Here is one:
tp://csharphelper.com/blog/2014/09/draw-graph-wpf-c/[^]. If I was to do it I would probably create a custom control the inherits from the Canvas, and have dependency properties for Max, Min, increment, and for the function.
这篇关于WPF中的方波或脉冲序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文