예제 #1
0
        private void DrawScope()
        {
            if (this.ScopeData == null)
            {
                return;
            }

            int maxX = this.devicePanel.Width;
            int maxY = this.devicePanel.Height;

            if (this.scopeVerts == null || this.scopeVerts.Length != this.NumberOfChannels)
            {
                this.scopeVertsLen         = this.ScopeLength;
                this.scrollBar.LargeChange = (int)(this.scopeVertsLen / this.SamplesPerSecond);
                this.scrollBar.SmallChange = (this.scrollBar.LargeChange > 10) ? this.scrollBar.LargeChange / 10 : 1;

                this.scopeVerts = new VectorColored[this.NumberOfChannels][];
                for (int i = 0; i < this.NumberOfChannels; i++)
                {
                    this.scopeVerts[i] = new VectorColored[this.scopeVertsLen];
                }
            }

            int len = this.CalculatePulseVerts();

            if (len > 0)
            {
                this.device.BeginScene();
                for (int i = this.NumberOfChannels - 1; i >= 0; i--)
                {
                    this.device.DrawUserPrimitives(PrimitiveType.LineStrip, len - 1, this.scopeVerts[i]);
                }

                this.device.EndScene();
            }

            // Draw cursor line
            int cursorMargin = 25;
            int ylen         = (maxY - cursorMargin - cursorMargin) / 2;

            if (ylen > 0)
            {
                VectorColored[] verts = new VectorColored[ylen];
                for (int i = 0; i < ylen; i++)
                {
                    verts[i] = new VectorColored(this.ScopeX + this.borderMargin, cursorMargin + 4 + (i * 2), this.lineColor);
                }

                this.device.BeginScene();
                this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
                this.device.EndScene();
            }
        }
예제 #2
0
        private void DrawScope()
        {
            if (this.ScopeData == null)
            {
                return;
            }

            int maxX = this.devicePanel.Width;
            int maxY = this.devicePanel.Height;

            if (this.scopeVerts == null || this.scopeVerts.Length != this.NumberOfChannels)
            {
                this.scopeVertsLen = this.ScopeLength;
                this.scrollBar.LargeChange = (int)(this.scopeVertsLen / this.SamplesPerSecond);
                this.scrollBar.SmallChange = (this.scrollBar.LargeChange > 10) ? this.scrollBar.LargeChange / 10 : 1;

                this.scopeVerts = new VectorColored[this.NumberOfChannels][];
                for (int i = 0; i < this.NumberOfChannels; i++)
                {
                    this.scopeVerts[i] = new VectorColored[this.scopeVertsLen];
                }
            }

            int len = this.CalculatePulseVerts();

            if (len > 0)
            {
                this.device.BeginScene();
                for (int i = this.NumberOfChannels - 1; i >= 0; i--)
                {
                    this.device.DrawUserPrimitives(PrimitiveType.LineStrip, len - 1, this.scopeVerts[i]);
                }

                this.device.EndScene();
            }

            // Draw cursor line
            int cursorMargin = 25;
            int ylen = (maxY - cursorMargin - cursorMargin) / 2;
            if (ylen > 0)
            {
                VectorColored[] verts = new VectorColored[ylen];
                for (int i = 0; i < ylen; i++)
                {
                    verts[i] = new VectorColored(this.ScopeX + this.borderMargin, cursorMargin + 4 + (i * 2), this.lineColor);
                }

                this.device.BeginScene();
                this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
                this.device.EndScene();
            }
        }
예제 #3
0
        private void DrawBackground()
        {
            int maxX = this.devicePanel.Width;
            int maxY = this.devicePanel.Height;

            this.device.Clear(ClearFlags.Target, this.backgroundColor, 0f, 0);

            VectorColored[] verts = new VectorColored[5];
            verts[0] = new VectorColored(this.borderMargin, this.borderMargin, Color.Black);
            verts[1] = new VectorColored(maxX - this.borderMargin, this.borderMargin, Color.Black);
            verts[2] = new VectorColored(maxX - this.borderMargin, maxY - this.borderMargin, Color.Black);
            verts[3] = new VectorColored(this.borderMargin, maxY - this.borderMargin, Color.Black);
            verts[4] = new VectorColored(this.borderMargin, this.borderMargin, Color.Black);

            this.device.BeginScene();
            this.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 3, verts);
            this.device.EndScene();

            int borderVertsLen = maxX - this.borderMargin - this.borderMargin + maxY - this.borderMargin - this.borderMargin;

            verts = new VectorColored[borderVertsLen];

            int xlen = (maxX - this.borderMargin - this.borderMargin) / 2;
            int ylen = (maxY - this.borderMargin - this.borderMargin) / 2;
            if (xlen <= 0 || ylen <= 0)
            {
                return;
            }

            for (int i = 0; i < xlen; i++)
            {
                verts[i] = new VectorColored(this.borderMargin + (i * 2), this.borderMargin, this.lineColor);
            }

            for (int i = 0; i < xlen; i++)
            {
                verts[i + xlen] = new VectorColored(this.borderMargin + (i * 2), maxY - this.borderMargin - 1, this.lineColor);
            }

            for (int i = 0; i < ylen; i++)
            {
                verts[i + (2 * xlen)] = new VectorColored(this.borderMargin, this.borderMargin + (i * 2), this.lineColor);
            }

            for (int i = 0; i < ylen; i++)
            {
                verts[i + (2 * xlen) + ylen] = new VectorColored(maxX - this.borderMargin, this.borderMargin + (i * 2), this.lineColor);
            }

            this.device.BeginScene();
            this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
            this.device.EndScene();

            // Horizontal lines
            int horisontalGridLineLendth = (maxX - this.borderMargin - this.borderMargin) / 2;

            int lineSpace = (maxY - this.borderMargin - this.borderMargin) / (this.HorizontalLinesCount + 1);
            for (int j = 1; j <= this.HorizontalLinesCount; j++)
            {
                verts = new VectorColored[horisontalGridLineLendth];
                for (int i = 0; i < xlen; i++)
                {
                    if (this.HorizontalLinesCount > 1 && this.HorizontalLinesCount % 2 == 1 &&
                        j == (this.HorizontalLinesCount + 1) / 2)
                    {
                        verts[i] = new VectorColored(this.borderMargin + (i * 2), (lineSpace * j) + this.borderMargin, Color.White);
                        verts[i].Color = Color.White.ToArgb();
                    }
                    else
                    {
                        verts[i] = new VectorColored(this.borderMargin + (i * 2), (lineSpace * j) + this.borderMargin, this.lineColor);
                    }
                }

                this.device.BeginScene();
                this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
                this.device.EndScene();
            }
        }
예제 #4
0
        private void DrawBackground()
        {
            int maxX = this.devicePanel.Width;
            int maxY = this.devicePanel.Height;

            this.device.Clear(ClearFlags.Target, this.backgroundColor, 0f, 0);

            VectorColored[] verts = new VectorColored[5];
            verts[0] = new VectorColored(this.borderMargin, this.borderMargin, Color.Black);
            verts[1] = new VectorColored(maxX - this.borderMargin, this.borderMargin, Color.Black);
            verts[2] = new VectorColored(maxX - this.borderMargin, maxY - this.borderMargin, Color.Black);
            verts[3] = new VectorColored(this.borderMargin, maxY - this.borderMargin, Color.Black);
            verts[4] = new VectorColored(this.borderMargin, this.borderMargin, Color.Black);

            this.device.BeginScene();
            this.device.DrawUserPrimitives(PrimitiveType.TriangleStrip, 3, verts);
            this.device.EndScene();

            int borderVertsLen = maxX - this.borderMargin - this.borderMargin + maxY - this.borderMargin - this.borderMargin;

            verts = new VectorColored[borderVertsLen];

            int xlen = (maxX - this.borderMargin - this.borderMargin) / 2;
            int ylen = (maxY - this.borderMargin - this.borderMargin) / 2;

            if (xlen <= 0 || ylen <= 0)
            {
                return;
            }

            for (int i = 0; i < xlen; i++)
            {
                verts[i] = new VectorColored(this.borderMargin + (i * 2), this.borderMargin, this.lineColor);
            }

            for (int i = 0; i < xlen; i++)
            {
                verts[i + xlen] = new VectorColored(this.borderMargin + (i * 2), maxY - this.borderMargin - 1, this.lineColor);
            }

            for (int i = 0; i < ylen; i++)
            {
                verts[i + (2 * xlen)] = new VectorColored(this.borderMargin, this.borderMargin + (i * 2), this.lineColor);
            }

            for (int i = 0; i < ylen; i++)
            {
                verts[i + (2 * xlen) + ylen] = new VectorColored(maxX - this.borderMargin, this.borderMargin + (i * 2), this.lineColor);
            }

            this.device.BeginScene();
            this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
            this.device.EndScene();

            // Horizontal lines
            int horisontalGridLineLendth = (maxX - this.borderMargin - this.borderMargin) / 2;

            int lineSpace = (maxY - this.borderMargin - this.borderMargin) / (this.HorizontalLinesCount + 1);

            for (int j = 1; j <= this.HorizontalLinesCount; j++)
            {
                verts = new VectorColored[horisontalGridLineLendth];
                for (int i = 0; i < xlen; i++)
                {
                    if (this.HorizontalLinesCount > 1 && this.HorizontalLinesCount % 2 == 1 &&
                        j == (this.HorizontalLinesCount + 1) / 2)
                    {
                        verts[i]       = new VectorColored(this.borderMargin + (i * 2), (lineSpace * j) + this.borderMargin, Color.White);
                        verts[i].Color = Color.White.ToArgb();
                    }
                    else
                    {
                        verts[i] = new VectorColored(this.borderMargin + (i * 2), (lineSpace * j) + this.borderMargin, this.lineColor);
                    }
                }

                this.device.BeginScene();
                this.device.DrawUserPrimitives(PrimitiveType.PointList, verts.Length, verts);
                this.device.EndScene();
            }
        }