Ejemplo n.º 1
0
        protected internal virtual void PaintKeyTip(
            Graphics graphics,
            RadKeyTipShowingEventArgs args,
            string keyTip)
        {
            int       num   = 0;
            Size      size  = TextRenderer.MeasureText(keyTip, args.Font);
            Point     point = new Point(args.CustomLocation.X - (size.Width / 2 + num), args.CustomLocation.Y);
            Rectangle rect  = new Rectangle(point.X, point.Y, size.Width + 2 * num, size.Height + 2 * num);

            graphics.FillRectangle((Brush) new SolidBrush(args.BackColor), rect);
            graphics.DrawRectangle(new Pen(args.BorderColor), rect);
            RadRibbonBar radRibbonBar = (RadRibbonBar)null;

            if (this.owner != null && this.owner.ElementTree.Control != null)
            {
                radRibbonBar = this.owner.ElementTree.Control as RadRibbonBar;
            }
            if (radRibbonBar != null && radRibbonBar.CompositionEnabled)
            {
                using (GraphicsPath path = new GraphicsPath())
                {
                    SmoothingMode smoothingMode = graphics.SmoothingMode;
                    graphics.SmoothingMode = SmoothingMode.AntiAlias;
                    float emSize = args.Font.SizeInPoints / 72f * graphics.DpiX;
                    path.AddString(keyTip, args.Font.FontFamily, (int)args.Font.Style, emSize, new Point(point.X + num, point.Y + num), StringFormat.GenericDefault);
                    graphics.FillPath((Brush) new SolidBrush(args.ForeColor), path);
                    graphics.SmoothingMode = smoothingMode;
                }
            }
            else
            {
                TextRenderer.DrawText((IDeviceContext)graphics, keyTip, args.Font, new Point(point.X + num, point.Y + num), args.ForeColor);
            }
        }
Ejemplo n.º 2
0
        protected internal virtual void PaintKeyMap(Graphics graphics)
        {
            List <RadItem> currentKeyMap = this.Behavior.GetCurrentKeyMap(this.Behavior.ActiveKeyMapItem);
            int            num           = 1;

            for (int index1 = 0; index1 < currentKeyMap.Count; ++index1)
            {
                RadItem   currentKeyMapItem = currentKeyMap[index1];
                Rectangle boundingRectangle = currentKeyMapItem.ControlBoundingRectangle;
                if (currentKeyMapItem.ElementTree != null)
                {
                    Point customLocation = Point.Empty;
                    int   y = boundingRectangle.Y + (int)((double)boundingRectangle.Height * 0.66);
                    customLocation = new Point(boundingRectangle.X + (int)((double)boundingRectangle.Width / 2.0), y);
                    RadKeyTipShowingEventArgs args = new RadKeyTipShowingEventArgs(false, customLocation, this.keyTipFont, Color.White, Color.Black, Color.Gray);
                    if (!this.OnKeyTipShowing(currentKeyMapItem, (CancelEventArgs)args) && currentKeyMapItem.Visibility == ElementVisibility.Visible)
                    {
                        Control  control   = currentKeyMapItem.ElementTree.Control;
                        Graphics graphics1 = (Graphics)null;
                        if (control != this)
                        {
                            graphics1 = control.CreateGraphics();
                        }
                        string empty = string.Empty;
                        string keyTip;
                        if (!string.IsNullOrEmpty(currentKeyMapItem.KeyTip))
                        {
                            keyTip = currentKeyMapItem.KeyTip;
                        }
                        else
                        {
                            bool flag;
                            do
                            {
                                RadItem radItem1 = currentKeyMap[index1];
                                keyTip = num >= 10 ? ((char)(65 + num - 10)).ToString() : num.ToString();
                                flag   = false;
                                for (int index2 = 0; index2 < currentKeyMap.Count; ++index2)
                                {
                                    RadItem radItem2 = currentKeyMap[index2];
                                    if (keyTip == radItem2.KeyTip)
                                    {
                                        ++num;
                                        flag = true;
                                        break;
                                    }
                                }
                            }while (flag);
                            currentKeyMapItem.KeyTip = keyTip;
                            ++num;
                        }
                        if (graphics1 != null)
                        {
                            this.PaintKeyTip(graphics1, args, keyTip);
                            graphics1.Dispose();
                        }
                        else
                        {
                            this.PaintKeyTip(graphics, args, keyTip);
                        }
                    }
                }
            }
        }