Files
mRemoteNG/mRemoteV1/Controls/ToolStripSplitButton.vb
Riley McArdle d18a510310 Fix issue MR-141 - Add a default protocol option
Fix issue MR-367 - Make the 'Connect' button on the 'Quick Connect' toolbar a forced dropdown
2013-10-06 20:30:38 -05:00

42 lines
1.7 KiB
VB.net

Namespace Controls
Public Class ToolStripSplitButton
Inherits Windows.Forms.ToolStripSplitButton
Public Overloads Property DropDown As ToolStripDropDown
Get
Return MyBase.DropDown
End Get
Set(value As ToolStripDropDown)
If MyBase.DropDown IsNot value Then
MyBase.DropDown = value
AddHandler MyBase.DropDown.Closing, AddressOf DropDown_Closing
End If
End Set
End Property
Private Sub DropDown_Closing(ByVal sender As Object, e As ToolStripDropDownClosingEventArgs)
If Not e.CloseReason = ToolStripDropDownCloseReason.AppClicked Then Return
Dim dropDownButtonBoundsClient As Rectangle = DropDownButtonBounds ' Relative to the ToolStripSplitButton
dropDownButtonBoundsClient.Offset(Bounds.Location) ' Relative to the parent of the ToolStripSplitButton
Dim dropDownButtonBoundsScreen As Rectangle = GetCurrentParent().RectangleToScreen(dropDownButtonBoundsClient) ' Relative to the screen
If dropDownButtonBoundsScreen.Contains(Control.MousePosition) Then e.Cancel = True
End Sub
Protected Overrides Sub OnMouseDown(e As MouseEventArgs)
_dropDownVisibleOnMouseDown = DropDown.Visible
MyBase.OnMouseDown(e)
End Sub
Protected Overrides Sub OnMouseUp(e As MouseEventArgs)
If _dropDownVisibleOnMouseDown Then
DropDown.Close()
Else
MyBase.OnMouseUp(e)
End If
End Sub
Private _dropDownVisibleOnMouseDown As Boolean = False
End Class
End Namespace