Ejemplo n.º 1
0
        public Size GetSize(Font font, Graphics g)
        {
            MeasureMenuItemEventArgs args = new MeasureMenuItemEventArgs(font, g, Size.Empty);

            OnMeasureItem(args);
            return(args.ItemSize);
        }
Ejemplo n.º 2
0
        protected virtual void OnMeasureItem(MeasureMenuItemEventArgs e)
        {
            EventHandler <MeasureMenuItemEventArgs> eh = MeasureItem;

            eh?.Invoke(this, e);
        }
        protected override void OnMeasureItem(MeasureMenuItemEventArgs e)
        {
            Size textSize = e.Graphics.MeasureString(Text, e.Font).ToSize();

            e.ItemSize = new Size(Math.Max(minimumWidth, textSize.Width), Math.Max(minimumHeight, textSize.Height));
        }