/// <summary> /// 设置鼠标icon图标类型 /// </summary> /// <param name="eCursorType"></param> public void SetCursor(enumCursorType eCursorType) { Singleton <CursorManager> .singleton.LeaveCursor(this.m_eCursorTypeLast); Singleton <CursorManager> .singleton.EnterCursor(eCursorType); this.m_eCursorTypeLast = eCursorType; }
protected override void OnMouseMove(MouseEventArgs e) { int nTop = toolBar1.Height; base.OnMouseMove(e); if (e.Y > nTop && e.Y < nTop + nDY && e.X < nDX) { if (cursorType != enumCursorType.Hand) { cursorType = enumCursorType.Hand; this.Cursor = System.Windows.Forms.Cursors.Hand; } } else { if (cursorType != enumCursorType.Default) { cursorType = enumCursorType.Default; this.Cursor = System.Windows.Forms.Cursors.Default; } } }
/// <summary> /// 进入这个鼠标类型 /// </summary> /// <param name="eCursorType"></param> public void EnterCursor(enumCursorType eCursorType) { if (!CommonDefine.IsMobilePlatform) { if (!this.m_listCachedCursorType.Contains(eCursorType))//缓存鼠标不包括这个鼠标类型就加进去 { this.m_listCachedCursorType.Add(eCursorType); this.m_listCachedCursorType.Sort(); this.m_eCursorType = this.m_listCachedCursorType[this.m_listCachedCursorType.Count - 1]; if (this.m_listCachedCursorType.Count > 10)//如果超过10个就报错 { this.m_log.Error("m_listCachedCursorType.Count > 10:" + this.m_listCachedCursorType.Count); } this.RefreshCursor(); } else { //鼠标进入已经进入的鼠标报错 this.m_log.Error(string.Format("m_listCachedCursorType.Contains(eCursorType) == true:{0}", eCursorType)); } } }
/// <summary> /// 离开这个鼠标类型 /// </summary> /// <param name="eCursorType"></param> public void LeaveCursor(enumCursorType eCursorType) { if (!CommonDefine.IsMobilePlatform) { if (!this.m_listCachedCursorType.Contains(eCursorType)) { this.m_log.Error(string.Format("m_listCachedCursorType.Contains(eCursorType) == false:{0}", eCursorType)); } else { this.m_listCachedCursorType.Remove(eCursorType); if (this.m_listCachedCursorType.Count > 0) { this.m_eCursorType = this.m_listCachedCursorType[this.m_listCachedCursorType.Count - 1]; this.RefreshCursor(); } else { this.m_eCursorType = enumCursorType.eCursorType_Default; } } } }
/// <summary> /// 构造函数,默认为normal类型 /// </summary> public CursorManager() { this.m_eCursorType = enumCursorType.eCursorType_Normal; this.m_listCachedCursorType.Add(this.m_eCursorType); }