protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) { base.OnMouseUp(e); if (_trackMouse) { _trackMouse = false; _mouseStartX = null; _mouseStartY = null; if (_mouseRect.HasValue) { MandelbrotLib.Complex upperLeft = _plot.GetPoint(_mouseRect.Value.Left, _mouseRect.Value.Top); MandelbrotLib.Complex lowerRight = _plot.GetPoint(_mouseRect.Value.Right, _mouseRect.Value.Bottom); _plotStack.Push(_plot); _graphicStack.Push(_buffer); _plot = new MandelbrotLib.Mandelbrot(upperLeft.Real, lowerRight.Real, lowerRight.Imaginary, upperLeft.Imaginary, this.ClientSize.Width, this.ClientSize.Height); _plot.GenerateField(); _mouseRect = null; _buffer = null; this.Invalidate(); } } else { if (e.Button.Equals(MouseButtons.Right)) { if (_plotStack.Count > 0) { _plot = _plotStack.Pop(); _buffer = _graphicStack.Pop(); this.Invalidate(); } } } }
protected override void OnSizeChanged(System.EventArgs e) { if (_buffer != null) { _buffer.Dispose(); _buffer = null; } //this should instead use the screen rectangle and points or something, now that we can zoom. _plot = new MandelbrotLib.Mandelbrot(_xMin, _xMax, _yMin, _yMax, this.ClientSize.Width - 10, this.ClientSize.Height - 10); _plot.GenerateField(); base.OnSizeChanged(e); }
public BrotWindow() { Text = "Mandelbrot Set"; _xMin = -2; _xMax = 1.5; _yMin = -1; _yMax = 1; _plot = new MandelbrotLib.Mandelbrot(_xMin, _xMax, _yMin, _yMax, this.ClientSize.Width - 10, this.ClientSize.Height - 10); _plotStack = new Stack <MandelbrotLib.Mandelbrot>(); _graphicStack = new Stack <Bitmap>(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true ); ResizeRedraw = true; _trackMouse = false; CenterToScreen(); }