protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);             // invoke any delegates.
     using (Graphics g = this.CreateGraphics())
     {
         if (m_menu == null)
         {
             return;
         }
         int targetPos = e.X;
         int xPos      = m_firstButtonOffset;
         foreach (MenuItem item in m_buttonMenuItems)
         {
             if (item is XCore.AdapterMenuItem)
             {
                 XCore.AdapterMenuItem xcoreMenuItem = (item as XCore.AdapterMenuItem);
                 string label = xcoreMenuItem.Text;
                 int    width = (int)g.MeasureString(label, m_hotLinkFont).Width;
                 if (targetPos > xPos && targetPos < xPos + width)
                 {
                     // some menu commands use the current slice to decide what to act on.
                     // It had better be the one the command is expecting it to be.
                     m_slice.ContainingDataTree.CurrentSlice = m_slice;
                     if (xcoreMenuItem.Enabled)
                     {
                         ItemClicked(xcoreMenuItem);
                     }
                     else
                     {
                         MessageBox.Show(this, DetailControlsStrings.ksCmdUnavailable,
                                         DetailControlsStrings.ksCmdDisabled);
                         this.Invalidate();                                 // Make sure command enabling is correct.
                     }
                     break;
                 }
                 else
                 {
                     xPos += width + kGapInBetweenButtons;
                 }
             }
         }
     }
 }
 private void ItemClicked(XCore.AdapterMenuItem item)
 {
     XCore.ChoiceBase c = (XCore.ChoiceBase)item.Tag;
     c.OnClick(item, null);
 }