Exemple #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            //滚动条区域重绘
            if (this._scrollBarHandleDrag)
            {
                //鼠标按下时拖动,更新滑块偏移
                this.Offset -= (int)(1.0 * (e.Y - this._scrollBarHandleDragMouseOffsetY) * this._totleItemHeight / this.ClientSize.Height);
                this._scrollBarHandleDragMouseOffsetY = e.Y;
            }
            else
            {
                //更新滑块的画刷
                bool focusHandle = this._scrollBarHandleBounds.Contains(e.Location);
                if (focusHandle &&
                    this._scrollBarHandleBrush != SCROLLBAR_HANDLE_BRUSH_FOCUSED)
                {
                    //鼠标移动到上面时候绘制Foused的深色
                    this._scrollBarHandleBrush = SCROLLBAR_HANDLE_BRUSH_FOCUSED;
                }
                else if (!focusHandle &&
                         this._scrollBarHandleBrush != SCROLLBAR_HANDLE_BRUSH_NORMAL)
                {
                    this._scrollBarHandleBrush = SCROLLBAR_HANDLE_BRUSH_NORMAL;
                }
            }

            ScrollableListItem item = HitTest(e.Location);

            if (item != null)
            {
                //触发Hover事件
                ItemHoverEventArgs args = new ItemHoverEventArgs(item, e.Location);
                OnItemHover(args);
            }

            this.Invalidate();
        }
Exemple #2
0
 protected virtual void OnItemHover(ItemHoverEventArgs args)
 {
     this.ItemHover?.Invoke(this, args);
 }