ComponentFactory.Krypton.Ribbon.KeyTipControl.OnPaint C# (CSharp) Method

OnPaint() protected method

Raises the Paint event.
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs An PaintEventArgs containing the event data.
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            using (ViewLayoutContext layoutContext = new ViewLayoutContext(this, _ribbon.Renderer))
                foreach (ViewDrawRibbonKeyTip viewKeyTip in _viewList)
                {
                    // Only interested in correct enabled state items
                    if ((_showDisabled && !viewKeyTip.KeyTipInfo.Enabled) ||
                        (!_showDisabled && viewKeyTip.KeyTipInfo.Enabled))
                    {
                        bool visible = viewKeyTip.KeyTipInfo.Visible;

                        // Only make the view visible if the key tip matches the prefix
                        if (visible && !string.IsNullOrEmpty(_prefix))
                            visible = viewKeyTip.KeyTipInfo.KeyString.StartsWith(_prefix);

                        // Update with latest enabled/visible state
                        viewKeyTip.Visible = visible;
                        viewKeyTip.Enabled = viewKeyTip.KeyTipInfo.Enabled;

                        // Find the requested size
                        Size viewSize = viewKeyTip.GetPreferredSize(layoutContext);

                        // Convert the requested screen point of key tip to client
                        Point clientPt = PointToClient(viewKeyTip.KeyTipInfo.ScreenPt);

                        // Center the child at the requested screen position
                        clientPt.X -= (viewSize.Width / 2);
                        clientPt.Y -= (viewSize.Height / 2);

                        // Position the child at the calculated position
                        layoutContext.DisplayRectangle = new Rectangle(clientPt, viewSize);
                        viewKeyTip.Layout(layoutContext);
                    }
                }

            using (RenderContext renderContext = new RenderContext(this, e.Graphics, e.ClipRectangle, _ribbon.Renderer))
                foreach (ViewDrawRibbonKeyTip viewKeyTip in _viewList)
                    if (viewKeyTip.Visible)
                        viewKeyTip.Render(renderContext);
        }