void BitmapUpdate(Size CurrentSize) { // release graphics if (ForeGroundImageGraphics != null) { ForeGroundImageGraphics.Dispose(); } if (BackGroundImageGraphics != null) { BackGroundImageGraphics.Dispose(); } // release bitmaps if (ForeGroundImageBitmap != null) { ForeGroundImageBitmap.Dispose(); } if (BackGroundImageBitmap != null) { BackGroundImageBitmap.Dispose(); } // allocate new bitmap if (CurrentSize.Width > 0 && CurrentSize.Height > 0) { ForeGroundImageBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); BackGroundImageBitmap = new Bitmap(CurrentSize.Width, CurrentSize.Height); } else { ForeGroundImageBitmap = new Bitmap(1, 1); BackGroundImageBitmap = new Bitmap(1, 1); } // create new graphics ForeGroundImageGraphics = Graphics.FromImage(ForeGroundImageBitmap); BackGroundImageGraphics = Graphics.FromImage(BackGroundImageBitmap); }
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; ForeGroundImageGraphics.Clear(Color.Transparent); Brush brush = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); //Brush brushText = new SolidBrush(Color.FromArgb(50, 255, 0, 0)); ForeGroundImageGraphics.FillRectangle(brush, X1, GraphConfig.UpBorder, nWidh, Size.Height - GraphConfig.LowBorder - GraphConfig.UpBorder); //ForeGroundImageGraphics.DrawString("F1 & F2 to ajust size", new Font("Arial", 10), brushText, new PointF(X1, Size.Height - GraphConfig.LowBorder)); //ForeGroundImageGraphics. Image = ForeGroundImageBitmap; }
public void SpectrumPictureBox_MouseLeave(object sender, EventArgs e) { ForeGroundImageGraphics.Clear(Color.Transparent); Image = ForeGroundImageBitmap; }