Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Show exception when perform paste operation on shape node,. (Read 11435 times)
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Show exception when perform paste operation on shape node,.
Jul 5th, 2013 at 9:54am
Print Post  
Hi Stoyo,

I working with diagram. i can add any shape in diagram and can perform copy and paste operation on it. For ex circle, rectangle, human etc. shape...  when i am performing copy and paste operation, every thing is fine. For some shape node, I am facing error in paste option.
Exception error:-

{MS.Internal.WrappedException: The given key was not present in the dictionary. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at System.Windows.ResourceManagerWrapper.GetResourceForUri(Uri xamlUri, Type componentType)
   --- End of inner exception stack trace ---}

I am Attaching snap shot of those control in which i am facing error in copy and paste operation.
  

show_execption_.PNG (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Show exception when perform paste operation on shape node,.
Reply #1 - Jul 5th, 2013 at 6:08pm
Print Post  
Hi,

These get copied without problems in our test project:


Check if the problem isn't coming from a NodePasted event handler of yours, or please attach a test app that reproduces it.

Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Show exception when perform paste operation on shape node,.
Reply #2 - Jul 15th, 2013 at 9:49am
Print Post  
Hi Stoyo,

I am attaching sample project to reproduce this bug.

Step:-
1. Run the application
2. Click on Insert Button(at Bottom Left)
3. Click on visual shape.
4. Click on Copy button.
5. Click on Paste button.

Message box will come with error message.
  

CopyPasteOnDiagram.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Show exception when perform paste operation on shape node,.
Reply #3 - Jul 16th, 2013 at 7:52am
Print Post  
You are using neither the built-in clipboard nor cloning methods. If you replace the call to your custom CloneControl method with DiagramItem.Clone, it will work. If you prefer cloning items yourself, you will also have to clone some property values in this loop:

Code
Select All
        For Each p As PropertyInfo In properties
            If p.CanWrite Then
                p.SetValue(retObject, p.GetValue(control, Nothing), Nothing) 



because Silverlight does not allow objects of certain types to be shared between different FrameworkElements. Off top of my head, you must clone DoubleCollection properties (such as StrokeDashArray) and Geomety properties, but there might be more.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Show exception when perform paste operation on shape node,.
Reply #4 - Jul 16th, 2013 at 2:13pm
Print Post  
Hi Stoyo,

As you suggest me, use DiagramItem.Clone(True) or DiagramItem.Clone(False) method to make clone control of diagram node. But it's create another problem, Pasted node has a reference of copied node. i am attaching sample project, you can easily find out the issue , what i doing wrong?  please suggest me something.

Step:-
1. Click on insert button.
2. Click on copy button.
3. Click on insert Text Button.("My Control Text will show on control.")
4 Click on Paste node.

Text will be show on the Pasted control where as  i copied the node without insert text.
  

CopyPasteOnDiagram_001.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Show exception when perform paste operation on shape node,.
Reply #5 - Jul 16th, 2013 at 3:55pm
Print Post  
Hi,

You are cloning from the Paste button handler, and at that moment the original node already has its text changed. You could add clones to CopyNodeList instead of the original node references, in order to keep values from the time when Copy is clicked.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Show exception when perform paste operation on shape node,.
Reply #6 - Jul 17th, 2013 at 5:58am
Print Post  
Hi Stoyo,
Thanks to reply back. No it's not working, I did same thing what you said but Pasted node has reference of copied node. We don not have only one property for shape node, we have more like as Text, Background brush, Border brush Image etc. Please again check my sample project. I have add background property to node.

Thanks in advanced Smiley
  

CopyPasteOnDiagram_002.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Show exception when perform paste operation on shape node,.
Reply #7 - Jul 17th, 2013 at 11:40am
Print Post  
Note that in the Paste handler you are still cloning the original item, not the one you stored in CopyNodeList:

Code
Select All
Dim diagramNodes = diagram.Items.FirstOrDefault(Function(xy) DirectCast(xy, ShapeNode).Id = CopyNodeList.Item(Lop).Id)
NewNode = diagramNodes.Clone(True) 



replace that with following and it will work:

Code
Select All
Dim diagramNodes = CopyNodeList.Item(Lop)
NewNode = diagramNodes.Clone(True) 



Or better use the built-in clipboard functions.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Show exception when perform paste operation on shape node,.
Reply #8 - Jul 18th, 2013 at 9:35am
Print Post  
Hi Stoyo,

It's still not working. i have done to what you said, You can see in sample project. Please can you attach sample project incorporating it's functionality

Thanks in advanced  Smiley
  

CopyPasteOnDiagram_003.rar (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Show exception when perform paste operation on shape node,.
Reply #9 - Jul 19th, 2013 at 10:00am
Print Post  
You are programming by a lot of guesswork, aren't you. Now your copy handler doesn't contain any calls to node.Clone, so CopyNodeList just keeps references to selected items again:

Code
Select All
        Dim Lop As Long
        CopyNodeList = New List(Of Object)
        For Lop = 0 To diagram.Nodes.Count - 1
            If diagram.Nodes(Lop).Selected = True Then
                CopyNodeList.Add(diagram.Nodes(Lop))
            End If
        Next Lop 



Later when you clone them from paste handler, they already have their text and background changed. To fix it, clone the items in copy handler so you keep their initial property values in the clones:

Code
Select All
        Dim Lop As Long
        CopyNodeList = New List(Of Object)
        For Lop = 0 To diagram.Nodes.Count - 1
            If diagram.Nodes(Lop).Selected = True Then
                CopyNodeList.Add(diagram.Nodes(Lop).Clone(True))
            End If
        Next Lop 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Yogendra
Junior Member
**
Offline


I Love MindFusion!

Posts: 68
Joined: Dec 27th, 2012
Re: Show exception when perform paste operation on shape node,.
Reply #10 - Jul 19th, 2013 at 12:27pm
Print Post  
Hi Stoyo,

Thanks for your suggestion and reply.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint