示例#1
0
        public static void DrawButton(string caption, Rectangle rectangle, Action action,
                                      string tooltip = null, bool disabled = false)
        {
            bool mo       = Root.IsMouseOver(rectangle) && !disabled;
            bool clicking = mo && Root.Mouse_NewState.LeftButton == ButtonState.Pressed;

            Primitives.FillRectangle(rectangle, clicking ? Color.Blue : (disabled ? Color.Gray : Color.CornflowerBlue));
            Primitives.DrawRectangle(rectangle, disabled ? Color.DarkGray : Color.Blue, 1);
            Primitives.DrawAndFillRectangle(rectangle.Extend(-2, -2),
                                            mo ? Color.White : Color.LightBlue, Color.Blue, 1);
            Writer.DrawString(caption, rectangle.Extend(-5, 0), (disabled ? Color.DarkGray : Color.Black), BitmapFontGroup.Mia24Font, Writer.TextAlignment.Left, degrading: true);
            if (mo)
            {
                MouseOverAction = action;
                if (tooltip != null)
                {
                    Tooltip.DrawTooltipAround(rectangle, tooltip);
                }
            }
        }