Exemplo n.º 1
0
        /// <summary>
        /// 鼠标移动事件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseMove(MouseEventArgs e)
        {
            _mousePos = e.Location;
            JdMenuItem item = GetItem(_mousePos);

            if (item == null)
            {
                base.OnMouseMove(e);
                return;
            }
            if (_HoverItem == null)
            {
                _HoverItem = item;
                Invalidate();
            }
            else
            {
                if (item != null && item.Index != _HoverItem.Index)
                {
                    _HoverItem = item;
                    Invalidate();
                }
            }
            base.OnMouseMove(e);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 清空当前列表选择的项
 /// </summary>
 private void ClearSelectItem()
 {
     if (_SelectItem != null)
     {
         this.Invalidate(_SelectItem.Bounds);
         _SelectItem = null;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 绘制菜单项
        /// </summary>
        protected void DrawItem(Graphics g, JdMenuItem item, Rectangle rect)
        {
            if (item.Icon != null)
            {
                g.DrawImage(item.Icon, new Rectangle(rect.X + _IconX, rect.Y + (rect.Height - _IconSize.Height) / 2, _IconSize.Width, _IconSize.Height),
                            new Rectangle(new Point(), item.Icon.Size), GraphicsUnit.Pixel);
            }
            Color fontColor = ForeColor;

            if (_HoverItem != null && item.Index == _HoverItem.Index)
            {
                fontColor = _HoverFontColor;
            }
            if (_SelectItem != null && item.Index == _SelectItem.Index)
            {
                fontColor = _HoverFontColor;
            }
            g.DrawString(item.Text, Font, new SolidBrush(fontColor),
                         new Rectangle(rect.X + 10, rect.Y + (rect.Height - this.Font.Height) / 2, rect.Width, rect.Height), new StringFormat()
            {
                Alignment = StringAlignment.Center
            });
        }
Exemplo n.º 4
0
 /// <summary>
 /// 单击事件
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClick(EventArgs e)
 {
     _SelectItem = GetItem(_mousePos);
     Invalidate();
     base.OnClick(e);
 }
Exemplo n.º 5
0
 protected override void OnMouseLeave(EventArgs e)
 {
     _HoverItem = null;
     Invalidate();
     base.OnMouseLeave(e);
 }