void BitmapUpdate(Size CurrentSize) { // release graphics if (HUDGraphics != null) { HUDGraphics.Dispose(); } if (GraphicAndCurvesGraphics != null) { GraphicAndCurvesGraphics.Dispose(); } if (PictureBoxGraphics != null) { PictureBoxGraphics.Dispose(); } // release bitmaps if (HUDBitmap != null) { HUDBitmap.Dispose(); } if (GraphicAndCurvesBitmap != null) { GraphicAndCurvesBitmap.Dispose(); } if (Image != null) { Image.Dispose(); } // allocate new bitmap if (CurrentSize.Width > 0 && CurrentSize.Height > 0) { HUDBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); GraphicAndCurvesBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); Image = new Bitmap(CurrentSize.Width, CurrentSize.Height); } else { HUDBitmap = new Bitmap(1, 1); GraphicAndCurvesBitmap = new Bitmap(1, 1); Image = new Bitmap(1, 1); } // create new graphics HUDGraphics = Graphics.FromImage(HUDBitmap); GraphicAndCurvesGraphics = Graphics.FromImage(GraphicAndCurvesBitmap); PictureBoxGraphics = Graphics.FromImage(Image); }
void DisplayZoomBox(int nX) { Int64 Low = -1; Int64 High = -1; int SampleCount = -1; DetermineNewFrequencyRange(nX, ref Low, ref High, ref SampleCount); int X1 = GraphConfig.GetXFromFrequency(Low); int X2 = GraphConfig.GetXFromFrequency(High); if (X1 < GraphConfig.LeftBorder) { X1 = GraphConfig.LeftBorder; } if (X2 > Size.Width - GraphConfig.RightBorder) { X2 = Size.Width - GraphConfig.RightBorder; } int nWidh = X2 - X1; HUDGraphics.Clear(Color.Transparent); Brush brush = new SolidBrush(Color.FromArgb(10, 255, 0, 0)); //Brush brushText = new SolidBrush(Color.FromArgb(10, 255, 0, 0)); HUDGraphics.FillRectangle(brush, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); Pen RecPen = new Pen(Color.FromArgb(100, 255, 0, 0), 2); HUDGraphics.DrawRectangle(RecPen, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); //HUDGraphics.DrawString("F1 & F2 to ajust size", new Font(FontFamily.GenericMonospace, 10), brushText, new PointF(X1, Size.Height - GraphConfig.LowBorder-20)); //ForeGroundImageGraphics. this.Invalidate(); //ImageUpdate(); }
public void SpectrumPictureBox_MouseLeave(object sender, EventArgs e) { GraphConfig.DrawTopBox(CurvesList); // to redraw only curve names HUDGraphics.Clear(Color.Transparent); ImageUpdate(); }