Пример #1
0
            /// <summary>
            /// Sets the current paint operation of this InternalPictureBox to be of the given type
            /// </summary>
            /// <param name="newPaintTool"></param>
            public void SetPaintOperation(IPaintTool newPaintTool)
            {
                if (_currentPaintTool != null)
                {
                    _owningPanel.FireOperationStatusEvent(_currentPaintTool, "");

                    _currentPaintTool.Destroy();
                }

                _currentPaintTool = newPaintTool;

                if (Image != null)
                {
                    _currentPaintTool.Initialize(this);

                    if (!_mouseOverImage)
                    {
                        _currentPaintTool.MouseLeave(new EventArgs());
                    }

                    Cursor = _currentPaintTool.ToolCursor;
                }

                var operation = _currentPaintTool as ICompositingPaintTool;

                if (operation != null)
                {
                    operation.CompositingMode = _owningPanel._defaultCompositingMode;
                }
                if (_currentPaintTool is IFillModePaintTool)
                {
                    (_currentPaintTool as IFillModePaintTool).FillMode = _owningPanel._defaultFillMode;
                }
            }
Пример #2
0
            /// <summary>
            /// Sets the bitmap being edited
            /// </summary>
            /// <param name="bitmap">The bitmap to edit</param>
            public void SetBitmap(Bitmap bitmap)
            {
                Image = bitmap;

                _buffer?.Dispose();

                _buffer = new Bitmap(bitmap.Width, bitmap.Height, bitmap.PixelFormat);

                // Create the under and over images
                _overImage?.Dispose();
                _underImage?.Dispose();

                _overImage  = new Bitmap(_buffer.Width, _buffer.Height, PixelFormat.Format32bppArgb);
                _underImage = new Bitmap(_buffer.Width, _buffer.Height, PixelFormat.Format32bppArgb);

                if (_currentPaintTool != null)
                {
                    // Initialize the paint operation
                    if (!_currentPaintTool.Loaded)
                    {
                        _currentPaintTool.Initialize(this);

                        Cursor = _currentPaintTool.ToolCursor;
                    }

                    _currentPaintTool.ChangeBitmap(bitmap);
                }
            }