Hello Telerik,
I'm working with a RadDiagram.
In my case, I have a red rectangle to show to user the limit of the diagram. If he moves a Shape outside of the red rectangle body, we replace the shape inside the rectangle (with an algorithm).
For all shape types, is working find, but not for RadDiagramConnection.
My sub :
Private Sub MoveShape(p_shape As RadDiagramItem) If (p_shape Is Nothing) Then Exit Sub If Me._moveShapeCount >= 8 Then 'Used to fix a bug with infinite loop (StackOverFlowException) ! Me._moveShapeCount = 0 Exit Sub End If Try 'Memory Dim shapeAsRectangle As Rect = p_shape.GetActualBounds() 'Used to have the good values when shape is rotated Dim isRectangleRotated As Boolean = False Dim isShapePositionModified As Boolean = False 'Rotation management If TryCast(p_shape, RadDiagramShape) IsNot Nothing Then 'Image / Elipse isRectangleRotated = (Not ListMissOutAngles.Exists(Function(a) a = DirectCast(p_shape, RadDiagramShape).RotationAngle)) ElseIf TryCast(p_shape, RadDiagramConnection) IsNot Nothing Then 'Me.ReplaceConnectorShape(p_shape) 'Specific treatment because Connection not has rotation angle and can have 2 points inside the line 'Exit Sub ElseIf TryCast(p_shape, RadDiagramTextShape) IsNot Nothing Then 'Boite de texte isRectangleRotated = (Not ListMissOutAngles.Exists(Function(a) a = DirectCast(p_shape, RadDiagramTextShape).RotationAngle)) Else 'Kc / Gap / Ref / Calculation / Adiru / FSI isRectangleRotated = (Not ListMissOutAngles.Exists(Function(a) a = DirectCast(p_shape, RadDiagramShapeBase).RotationAngle)) End If 'Width management If p_shape.Bounds.Width < (MinX + Me.BoundariesWidth) Then 'Manage cases only if shape width is < to red rectangle width (infinite loop risk) If shapeAsRectangle.Left < MinX Then If isRectangleRotated Then p_shape.Position = New Point((p_shape.Bounds.X + (MinX - shapeAsRectangle.Left)), p_shape.Bounds.Y) Else p_shape.Position = New Point((MinX + 2), p_shape.Bounds.Y) End If isShapePositionModified = True End If If shapeAsRectangle.Right > (MinX + BoundariesWidth) Then p_shape.Position = New Point((p_shape.Bounds.X + ((Me.BoundariesWidth + MinX) - shapeAsRectangle.Right)), p_shape.Bounds.Y) isShapePositionModified = True End If Else Exit Sub End If 'Height management If p_shape.Bounds.Height < (MinY + BoundariesHeight) Then 'Manage cases only if shape height is < to red rectangle height (infinite loop risk) If shapeAsRectangle.Top < MinY Then If isRectangleRotated Then p_shape.Position = New Point(p_shape.Bounds.X, (p_shape.Bounds.Y + (MinY - shapeAsRectangle.Top))) Else p_shape.Position = New Point(p_shape.Bounds.X, (MinY + 2)) End If isShapePositionModified = True End If If shapeAsRectangle.Bottom > (MinY + BoundariesHeight) Then If isRectangleRotated Then p_shape.Position = New Point(p_shape.Bounds.X, (p_shape.Bounds.Top - (shapeAsRectangle.Bottom - BoundariesHeight) + MinY)) Else p_shape.Position = New Point(p_shape.Bounds.X, (p_shape.Bounds.Y - (p_shape.Bounds.Bottom - (MinY + BoundariesHeight)) - 2)) End If isShapePositionModified = True End If Else Exit Sub End If If isShapePositionModified Then Me._moveShapeCount += 1 Me.MoveShape(p_shape) End If Catch ex As Exception If Debugger.IsAttached Then Debugger.Break() MAATrace.Log("MoveShape EXCEPTION", "Error in MoveShape() (top-left position : '" + p_shape.Position.ToString() + "') : " + ex.Message) End TryEnd Sub
For example, consider the first case => If shapeAsRectangle.Left < MinX
For all shapes, the p_shape.Position is set to 22, but for RadDiagramConnection, the value is not updated.
Do you know why the position is not updated for RadDiagramConnection ? And how can I resolve it ?
Furthermore, I should to be able to know if there is a rotation for the shape which encircle the RadDiagramConnection (the If, elseif, elseif... is a draft copy)
Thanks a lot.