public void OnMouseUp(SelectChangedHandle btnClick) { if (_pressedIndex != -1) { if (_gpBtnArr[_pressedIndex].Pressed) { _gpBtnArr[_pressedIndex].Pressed = false; } if (btnClick != null) { SelectChangeEventArgs evt = new SelectChangeEventArgs(); evt.SelectIndex = _pressedIndex; evt.IsSelected = false; btnClick(this, evt); } _pressedIndex = -1; _ctrl.Invalidate(); } }
public void OnMouseDown(SelectChangedHandle btnSelect) { if (_mouseHoverIndex > -1 && _gpBtnArr[_mouseHoverIndex].Enabled) { bool bSelected = false; _gpBtnArr[_mouseHoverIndex].Pressed = true; _pressedIndex = _mouseHoverIndex; if (_bMultiSelect) { if (_gpBtnArr[_mouseHoverIndex].Selected) { if (_bEnableCancelSelectSelf) { _gpBtnArr[_mouseHoverIndex].Selected = false; bSelected = false; } } else { _gpBtnArr[_mouseHoverIndex].Selected = true; bSelected = true; } } else { if (_selectedIndex == _mouseHoverIndex) { if (_bEnableCancelSelectSelf) { _gpBtnArr[_selectedIndex].Selected = false; _selectedIndex = -1; bSelected = false; } } else { if (_selectedIndex > -1) { _gpBtnArr[_selectedIndex].Selected = false; } _selectedIndex = _mouseHoverIndex; _gpBtnArr[_selectedIndex].Selected = true; bSelected = true; } } if (btnSelect != null) { SelectChangeEventArgs evt = new SelectChangeEventArgs(); evt.SelectIndex = _mouseHoverIndex; evt.IsSelected = bSelected; btnSelect(this, evt); } _ctrl.Invalidate(); } }