当前位置: 首页>>代码示例>>C#>>正文


C# DoubleRange.Scale方法代码示例

本文整理汇总了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;
                        }
                    }
                }
            }
        }
开发者ID:CanerPatir,项目名称:framework,代码行数:66,代码来源:Wavechart.cs


注:本文中的AForge.DoubleRange.Scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。