Example #1
0
 void SetContextMenuSize()
 {
     if (_contextMenu.Items.OfType <ToolStripItem>().Any(item => item.Available))
     {
         var width = _contextMenu.Items.OfType <ToolStripMenuItem>().Where(item => item.Available)
                     .Max(item => TextRenderer.MeasureText(item.Text, item.Font).Width);
         var height = _contextMenu.GetAvailableItems()
                      .Sum(item => item.Height);
         _contextMenu.Width  = width + 45;
         _contextMenu.Height = height + 5;
     }
 }