Hi,
Am trying to do the simplest of things in winforms/vb using the RadDiagram ..
My use case is simply changing the color of a shape when the mouse enters it and back again when it leaves it.
I have been experimenting with the events and their behaviors and cannot explain/figure out the following :
- mouse leave event fires correctly on the boundary of the shape (works as expected)
- mouse enter event fires only when the shape is selected and when touching the connector borders (the four default ones - up/down/left/right). the mouse changes to resize cursor when touching the four corner connectors
Below is my simple test code -
Imports
System.Globalization
Imports
System.Math
Imports
System.Drawing.Drawing2D
Imports
System.Drawing.Color
Imports
Telerik.Windows
Imports
Telerik.Windows.Diagrams.Core
Imports
Telerik.WinControls.UI
Imports
Telerik.WinControls.UI.Diagrams
Public
Class
RadForm1
Public
Sub
New
()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End
Sub
Private
Sub
NewItemToolStripMenuItem_Click(sender
As
Object
, e
As
EventArgs)
Handles
NewItemToolStripMenuItem.Click
Dim
shape
As
LayoutShape =
New
LayoutShape()
RadDiagram1.AddShape(shape)
End
Sub
Private
Sub
RadDiagram1_ShapeClicked(sender
As
Object
, e
As
ShapeRoutedEventArgs)
Handles
RadDiagram1.ShapeClicked
Dim
shape
As
LayoutShape = TryCast(e.Shape, LayoutShape)
If
(shape IsNot
Nothing
)
Then
shape.BackColor = Green
' reset
End
If
End
Sub
End
Class
Public
Class
LayoutShape
Inherits
RadDiagramShape
Public
Sub
New
()
IsEditable =
False
Shape =
New
Telerik.WinControls.RoundRectShape(5)
AutoSize =
False
BorderBrush =
New
System.Drawing.SolidBrush(System.Drawing.Color.Red)
ShouldHandleMouseInput =
True
SetBounds(0, 0, 100, 25)
BackColor = Green
Position =
New
Point(100, 100)
IsEditable =
False
AutoToolTip =
False
NotifyParentOnMouseInput =
True
End
Sub
Public
Sub
LayoutShape_MouseLeave(sender
As
Object
, e
As
EventArgs)
Handles
Me
.MouseLeave
Dim
shape
As
LayoutShape = TryCast(sender, LayoutShape)
shape.BackColor = Blue
End
Sub
Private
Sub
LayoutShape_MouseEnter(sender
As
Object
, e
As
EventArgs)
Handles
Me
.MouseEnter
Dim
shape
As
LayoutShape = TryCast(sender, LayoutShape)
shape.BackColor = Yellow
End
Sub
End
Class