public void SetKeyTips(KeyTipInfoList keyTips)
{
// Create a new list of key tip views
_viewList = new List<ViewDrawRibbonKeyTip>();
Rectangle enclosingRect = Rectangle.Empty;
// Create a view per key tip definition
foreach (KeyTipInfo keyTip in keyTips)
{
// Create the initial rect as enclosing just the single point
if (enclosingRect.IsEmpty)
enclosingRect = new Rectangle(keyTip.ScreenPt, new Size(1, 1));
else
{
// Enlarge the rect to enclose the new point
if (keyTip.ScreenPt.X < enclosingRect.Left)
{
int diff = enclosingRect.Left - keyTip.ScreenPt.X;
enclosingRect.Width += diff;
enclosingRect.X -= diff;
}
if (keyTip.ScreenPt.X > enclosingRect.Right)
enclosingRect.Width += (keyTip.ScreenPt.X - enclosingRect.Right);
if (keyTip.ScreenPt.Y < enclosingRect.Top)
{
int diff = enclosingRect.Top - keyTip.ScreenPt.Y;
enclosingRect.Height += diff;
enclosingRect.Y -= diff;
}
if (keyTip.ScreenPt.Y > enclosingRect.Bottom)
enclosingRect.Height += (keyTip.ScreenPt.Y - enclosingRect.Bottom);
}
_viewList.Add(new ViewDrawRibbonKeyTip(keyTip,
_ribbon.StateCommon.RibbonKeyTip.Back,
_ribbon.StateCommon.RibbonKeyTip.Border,
_ribbon.StateCommon.RibbonKeyTip.Content));
}
// Inflate the enclosing rect to account for maximum expected key tip
enclosingRect.Inflate(50, 50);
// Remove any prefix characters
_prefix = string.Empty;
// Our position covers the enclosing rect
SetBounds(enclosingRect.X,
enclosingRect.Y,
enclosingRect.Width,
enclosingRect.Height);
StartTimer();
}