示例#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>
            /// Disposes of this InternalPictureBox and all used resources
            /// </summary>
            public new void Dispose()
            {
                _currentPaintTool?.Destroy();

                foreach (PictureBoxDecorator decorator in _pictureBoxDecorators)
                {
                    decorator.Destroy();
                }

                // Create the under and over images
                if (_overImage != null)
                {
                    _overImage.Dispose();
                    _overImage = null;
                }
                if (_underImage != null)
                {
                    _underImage.Dispose();
                    _underImage = null;
                }

                _pictureBoxDecorators.Clear();

                _buffer.Dispose();

                base.Dispose();
            }