private void SetupCaptureCanvas(PictureBox canvas) { _canvas.BackgroundImage = new Bitmap(canvas.Size.Width, canvas.Size.Height); canvas.Image = new Bitmap(canvas.Size.Width, canvas.Size.Height); _selectionDrawer = new SelectionDrawer(new PictureBoxCanvasDecorator(canvas)); }
private void InitialiseEverythingFromScratch(Rectangle updatedRectangle) { Location = updatedRectangle.Location; Size = updatedRectangle.Size; _backgroundPictureBox.Size = Size; _backgroundPictureBox.BackgroundImage = new Bitmap(_backgroundPictureBox.Size.Width, _backgroundPictureBox.Size.Height); _backgroundPictureBox.Image = new Bitmap(_backgroundPictureBox.Size.Width, _backgroundPictureBox.Size.Height); _canvas.Size = Size; _canvas.BackgroundImage = new Bitmap(_canvas.Size.Width, _canvas.Size.Height); _canvas.Image = new Bitmap(_canvas.Size.Width, _canvas.Size.Height); _canvas.Parent = _backgroundPictureBox; _canvas.BackColor = Color.Transparent; var pictureBoxMouseEvents = new ControlMouseEvents(_canvas); _onOffSelectionMouseEvents = new OnOffMouseEvents(pictureBoxMouseEvents) { On = true }; _selectionDrawer = new SelectionDrawer(new PictureBoxImageCanvas(_canvas), _onOffSelectionMouseEvents); _onOffDrawingMouseEvents = new OnOffMouseEvents(pictureBoxMouseEvents) { On = false }; _drawingMagic = new DrawingMagic(new PictureBoxImageCanvas(_backgroundPictureBox), new PictureBoxBackgroundCanvas(_canvas), _onOffDrawingMouseEvents); _drawingMagic.OperationFinished += (sender, args) => { _onOffSelectionMouseEvents.On = true; _onOffDrawingMouseEvents.On = false; }; }