BitmapNode issues

1) BitmapNode Name

I have problem getting the Node. Name when I use BitmapNode.  For Instance, I have the following declarations :

Dim img1 As New BitmapNode()
Dim img2 As New BitmapNode()

img1.Name="Car"
img2.Name="Train"

On diagram DragDrop event, I try to get the node name with PaletteGrupBar.SelectedNode.GetType()
I always get 'BitmapNode'. How can I get Car when img1 is dragged&droped? Train if img2 is dragged&dropped; Car1 if another img1 is dragged & dropped, etc ?

2) BitmapNode image file & custom class
I have a custom class  that inherits Rectangle for a particular node. 
How can I make the custom class inherit the BitmapNode that takes image file?



3 Replies

NG Naganathan Ganesh Babu Syncfusion Team January 31, 2018 08:44 AM UTC

Hi Allen, 
1) BitmapNode Name 
 
I have problem getting the Node. Name when I use BitmapNode.  For Instance, I have the following declarations : 
Dim img1 As New BitmapNode() 
Dim img2 As New BitmapNode() 
 
img1.Name="Car" 
img2.Name="Train" 
 
On diagram DragDrop event, I try to get the node name with PaletteGrupBar.SelectedNode.GetType() 
I always get 'BitmapNode'. How can I get Car when img1 is dragged&droped? Train if img2 is dragged&dropped; Car1 if another img1 is dragged & dropped, etc ? 
 
A System’s “GetType()” method is used to get the type of the current object and its Name property contains name of the type alone. So we suggest you to use just TryCast(paletteGroupBar1.SelectedNode, Node) to get the node and name of the diagram’s node instead of using System’s “GetType()” method. 
 
2) BitmapNode image file & custom class 
I have a custom class  that inherits Rectangle for a particular node.  
How can I make the custom class inherit the BitmapNode that takes image file? 
 
In order to achieve your requirement, we suggest you to inherit the Diagram’s BitmapNode class and use BitmapNode’s Image property to get the image file. please refer to the below code snippet. 
 
Public Class CustomBitmapNode 
                        Inherits BitmapNode 
                        #Region "initialization" 
                        Public Sub New(ByVal srcbitmap As Bitmap) 
                                    MyBase.New(srcbitmap) 
 
                        End Sub 
                        Public Sub New(ByVal src As BitmapNode) 
                                    MyBase.New(src) 
                        End Sub 
                        Public Sub New(ByVal stream As Stream) 
                                    MyBase.New(stream) 
                        End Sub 
                        Public Sub New(ByVal filename As String) 
                                    MyBase.New(filename) 
                        End Sub 
                        Public Sub New(ByVal src As Bitmap, ByVal rcBounds As RectangleF) 
                                    MyBase.New(src, rcBounds) 
                        End Sub 
                        Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) 
                                    MyBase.New(info, context) 
                        End Sub 
                        #End Region  
 
                        Protected Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) 
                                    MyBase.GetObjectData(info, context) 
                        End Sub 
 
                        Public Overrides Function Clone() As Object 
                                    Return New CustomBitmapNode(Me) 
                        End Function 
            End Class 
 
Please refer to the sample and video.  
Sample: 
Video: 
Regards, 
Naganathan K G 



AL Allen February 1, 2018 08:44 AM UTC

Thank you Naganathan


NG Naganathan Ganesh Babu Syncfusion Team February 2, 2018 04:45 AM UTC

Hi Allen,

Thanks for your update.
 

We are happy to hear that your problem is resolved. Please let us know if you need any further assistance.

Regards,
 

Naganathan K G
 
 


Loader.
Up arrow icon