//private void ClonePoints(Point[] private void NewDrawLines(Graphics GS, Pen GPen, OpenMedIC.Samples GPoints, long FirstAbsIndex, int StartPoint, int EndPoint) { //Clear the X columns that we'll be drawing over GS.FillRectangle(wfBGBrush, PixelFromAbsIndex(FirstAbsIndex + StartPoint), 0, PixelFromAbsIndex(FirstAbsIndex + EndPoint) - PixelFromAbsIndex(FirstAbsIndex + StartPoint), pnlGraphingDisplay.Height); for (int i = StartPoint; i != EndPoint; i++) { GS.DrawLine(GPen, PixelFromAbsIndex(FirstAbsIndex + i), PixelFromYVal(GPoints[i].sampleValue), PixelFromAbsIndex(FirstAbsIndex + i + 1), PixelFromYVal(GPoints[i + 1].sampleValue)); } if (EndPoint < (GPoints.size - 1)) { //Clear the X columns that we'll be drawing over GS.FillRectangle(wfBGBrush, PixelFromAbsIndex(FirstAbsIndex + EndPoint), 0, PixelFromAbsIndex(FirstAbsIndex + EndPoint + 1) + pnlGraphingDisplay.Width, pnlGraphingDisplay.Height); //we're going to wrap to beginning of GS //so draw another line segment to the next offscreen point GS.DrawLine(GPen, PixelFromAbsIndex(FirstAbsIndex + EndPoint), PixelFromYVal(GPoints[EndPoint].sampleValue), PixelFromAbsIndex(FirstAbsIndex + EndPoint + 1) + pnlGraphingDisplay.Width, PixelFromYVal(GPoints[EndPoint + 1].sampleValue)); } }
private void NewGraphPoints(long StartIndex, OpenMedIC.Samples InSamples) { Point PixelToDraw = new Point(); //Graphics GS = pnlGraphingDisplay.CreateGraphics(); for (int i = 0; i != InSamples.size; i++) { PixelToDraw.X = PixelFromAbsIndex(StartIndex + i); PixelToDraw.Y = PixelFromYVal(InSamples[i].sampleValue); if ((PixelToDraw.X != LatestPixelDisplayed.X) || (PixelToDraw.Y != LatestPixelDisplayed.Y)) { //if we're moving to a new x column, we need to clear waveform if (PixelToDraw.X > LatestPixelDisplayed.X) { OffscreenDC.FillRectangle(wfBGBrush, LatestPixelDisplayed.X + 1, 0, PixelToDraw.X - LatestPixelDisplayed.X, pnlGraphingDisplay.Height); } if (PixelToDraw.X >= LatestPixelDisplayed.X) { //test for the first time we're plotting the point //if it is the first time, then the LatestPixelDisplayed.Y //is a dummy, so simply skip it if (LatestPixelDisplayed.Y > -1) { //draw the segment OffscreenDC.DrawLine(wfPen, LatestPixelDisplayed.X, LatestPixelDisplayed.Y, PixelToDraw.X, PixelToDraw.Y); } } else { //we should wrap back to the beginning of the graph //clear the space to the end OffscreenDC.FillRectangle(wfBGBrush, LatestPixelDisplayed.X, 0, (pnlGraphingDisplay.Width - LatestPixelDisplayed.X), pnlGraphingDisplay.Height); //draw the line segment that goes off of the screen OffscreenDC.DrawLine(wfPen, LatestPixelDisplayed.X, LatestPixelDisplayed.Y, PixelToDraw.X + pnlGraphingDisplay.Width, PixelToDraw.Y); //clear the space at the start OffscreenDC.FillRectangle(wfBGBrush, 0, 0, PixelToDraw.X + 1, pnlGraphingDisplay.Height); //draw the line segment that starts off of the screen OffscreenDC.DrawLine(wfPen, LatestPixelDisplayed.X - pnlGraphingDisplay.Width, LatestPixelDisplayed.Y, PixelToDraw.X, PixelToDraw.Y); } //lastAbsIndexDisplayed = PixelFromAbsIndex(StartIndex + InSamples.size); LatestPixelDisplayed.X = PixelToDraw.X; LatestPixelDisplayed.Y = PixelToDraw.Y; } lastAbsIndexDisplayed = StartIndex + InSamples.size; } //finally, draw the cursor OffscreenDC.DrawLine(cursPen, LatestPixelDisplayed.X + 1, 0, LatestPixelDisplayed.X + 1, pnlGraphingDisplay.Height); OffscreenDC.FillRectangle(wfBGBrush, LatestPixelDisplayed.X + 2, 0, cursForeWidth, pnlGraphingDisplay.Height); //now bitblt to the Display Graphics GS = pnlGraphingDisplay.CreateGraphics(); GS.DrawImage(OffscreenBitmap, 0, 0); }