本文整理汇总了C#中AForge.DoubleRange.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleRange.Scale方法的具体用法?C# DoubleRange.Scale怎么用?C# DoubleRange.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AForge.DoubleRange
的用法示例。
在下文中一共展示了DoubleRange.Scale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaint
/// <summary>
/// Paints the control.
/// </summary>
///
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int clientWidth = ClientRectangle.Width;
int clientHeight = ClientRectangle.Height;
// fill with background
g.FillRectangle(backgroundBrush, 0, 0, clientWidth - 1, clientHeight - 1);
// draw borders
g.DrawRectangle(bordersPen, 0, 0, clientWidth - 1, clientHeight - 1);
if (DesignMode)
return;
DoubleRange rangeClientX = new DoubleRange(0, clientWidth);
DoubleRange rangeClientY = new DoubleRange(clientHeight, 0);
// walk through all data series
foreach (Waveform waveform in waveTable.Values)
{
// get data of the waveform
float[] data = waveform.data;
// check for available data
if (data == null) continue;
using (Pen pen = new Pen(waveform.color, waveform.width))
{
if (SimpleMode)
{
int blockSize = waveform.samples / clientWidth;
for (int x = 0; x < clientWidth; x++)
{
double max = data.RootMeanSquare(x * blockSize, blockSize);
int y = clientHeight / 2 + (int)(max * clientHeight);
g.DrawLine(pen, x, clientHeight - y, x, y);
}
}
else
{
int xPrev = 0;
int yPrev = (int)rangeY.Scale(rangeClientY, data[0]);
for (int x = 0; x < clientWidth; x++)
{
int index = (int)rangeClientX.Scale(rangeX, x);
if (index < 0 || index >= data.Length)
index = data.Length - 1;
int y = (int)rangeY.Scale(rangeClientY, data[index]);
g.DrawLine(pen, xPrev, yPrev, x, y);
xPrev = x;
yPrev = y;
}
}
}
}
}