ComponentFactory.Krypton.Toolkit.RenderProfessional.DrawGrabHandleGlyph C# (CSharp) Метод

DrawGrabHandleGlyph() защищенный Метод

Internal rendering method.
protected DrawGrabHandleGlyph ( RenderContext context, Rectangle displayRect, Orientation orientation, PaletteState state ) : void
context RenderContext
displayRect System.Drawing.Rectangle
orientation Orientation
state PaletteState
Результат void
        protected virtual void DrawGrabHandleGlyph(RenderContext context,
                                                   Rectangle displayRect,
                                                   Orientation orientation,
                                                   PaletteState state)
        {
            // Is there enough room to draw the at least one grab handle?
            if ((displayRect.Height >= _grabSquareMinSpace) && (displayRect.Width >= _grabSquareMinSpace))
            {
                // Reduce rectangle to remove the border around the display area edges
                displayRect.Inflate(-_grabSquareGap, -_grabSquareGap);

                // Find how much space is available for drawing grab handles in the orientation
                int orientationSpace = (orientation == Orientation.Horizontal ? displayRect.Width : displayRect.Height);

                // Try to display the maximum allowed number of handles, but show less if not possible
                for (int i = _grabSquareCount; i > 0; i--)
                {
                    // Calculate how much space this number of grab handles takes up
                    int requiredSpace = (i * _grabSquareTotal) + (i > 1 ? (i - 1) * _grabSquareGap : 0);

                    // Is there enough space all the grab handles?
                    if (requiredSpace <= orientationSpace)
                    {
                        // Find offset before showing the first handle
                        int offset = (orientationSpace - requiredSpace) / 2;

                        Point draw;

                        // Find location of first handle
                        if (orientation == Orientation.Horizontal)
                            draw = new Point(displayRect.X + offset, displayRect.Y + (displayRect.Height - _grabSquareTotal) / 2);
                        else
                            draw = new Point(displayRect.X + (displayRect.Width - _grabSquareTotal) / 2, displayRect.Y + offset);

                        using (Brush lightBrush = new SolidBrush(_grabHandleLight),
                                     darkBrush = new SolidBrush(_grabHandleDark))
                        {
                            // Draw each grab handle in turn
                            for (int j = 0; j < i; j++)
                            {
                                // Draw the light colored square
                                context.Graphics.FillRectangle(lightBrush,
                                                               draw.X + _grabSquareOffset,
                                                               draw.Y + _grabSquareOffset,
                                                               _grabSquareLength,
                                                               _grabSquareLength);

                                // Draw the dark colored square overlapping the dark
                                context.Graphics.FillRectangle(darkBrush,
                                                               draw.X,
                                                               draw.Y,
                                                               _grabSquareLength,
                                                               _grabSquareLength);

                                // Move to the next handle position
                                if (orientation == Orientation.Horizontal)
                                    draw.X += _grabSquareTotal + _grabSquareGap;
                                else
                                    draw.Y += _grabSquareTotal + _grabSquareGap;
                            }
                        }

                        // Finished
                        break;
                    }
                }
            }
        }