Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Copy / Paste Throws Exception (Read 7489 times)
donalmeida
Junior Member
**
Offline


Yay...

Posts: 65
Joined: Oct 6th, 2009
Copy / Paste Throws Exception
Apr 1st, 2010 at 3:51pm
Print Post  
Styan,
I get an error when I try to copy and paste a node on the diagram. When I copy the debug info seems like it has copied the object, but i cant say for sure. the 
currentDiagram.PasteSelection(copyData, 10, 10); throws this exception:

{MS.Internal.WrappedException: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) ---> System.Exception: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
   at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
   --- End of inner exception stack trace ---}

Please let me kow what other information you would like me send over to debug and trace the source of the problem.

any help would be appreciated,
Thanks, Don Almeida.


  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #1 - Apr 1st, 2010 at 4:55pm
Print Post  
What kind of node is it?
  
Back to top
 
IP Logged
 
donalmeida
Junior Member
**
Offline


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #2 - Apr 1st, 2010 at 5:23pm
Print Post  
it is a container node with two children
1) a Control Node that has a TextBlock and
2) a shapenode.

These are the properties that are used.
public TaskNode(Diagram diagram, Task task, Flow flow, UserMapPreferences preferences)
       {
           const int SUBSCRIPTIONID = -1;
           const bool ISPROPERTIESEDITABLE = true;

           Preferences = preferences;
           FlowDiagram = diagram;
           FlowTask = task;
           Flow = flow;
           Brush anchorBrush = Brushes.White;
           AnchorPattern anchorPattern = new AnchorPattern(new AnchorPoint[]
               {
                   new AnchorPoint(50, 0, true, true, anchorBrush, 1),
                   new AnchorPoint(100, 50, true, true, anchorBrush, 2),
                   new AnchorPoint(50, 100, true, true, anchorBrush, 3),
                   new AnchorPoint(0, 50, true, true, anchorBrush, 4)
               });
           TextBlock taskText = new TextBlock
           {
               FontSize = 12,
               Text = TaskHelper.GetTaskText(FlowTask, Preferences),
               TextAlignment = TextAlignment.Center,
               Margin = new Thickness(0, 0, 0, 0),
               TextWrapping = TextWrapping.Wrap,
               UseLayoutRounding = true,
           };
           ControlNode cn = new ControlNode(FlowDiagram, taskText)
           {
               Bounds = new Rect(FlowTask.XLocation - 100 + 16, FlowTask.YLocation + 30, 200, 25),
               EnabledHandles = AdjustmentHandles.None,
               Locked = true,
           };
           string imageUri = task.Image > 0 ? string.Format(DiagramHelper.GetBaseUrl() + CustomImageHandler, task.Image) : TaskHelper.GetImageUrl(FlowTask);
           ShapeNode node = new ShapeNode(FlowDiagram)
           {
               Bounds = new Rect(FlowTask.XLocation, FlowTask.YLocation, 32, 32),
               Image = new BitmapImage(new Uri(imageUri, UriKind.RelativeOrAbsolute)),
               ImageAlign = ImageAlign.Center,
               Transparent = true,
               Pen = new Pen(Brushes.Black),
               Tag = new TaskNodeTag(FlowTask, SUBSCRIPTIONID, flow, ISPROPERTIESEDITABLE, cn),
               BorderBrush = new SolidColorBrush(Colors.Black),
               BorderThickness = new Thickness(1, 1, 1, 1),
               AnchorPattern = anchorPattern,
               Locked = true,
           };
           TaskImageNode = node;
           TaskTextNode = cn;
           var transparent = new SolidColorBrush(Colors.Transparent);
           Node = new ContainerNode(diagram)
           {
               Bounds = new Rect(FlowTask.XLocation, FlowTask.YLocation, 32, 32),
               Transparent = false,
               BorderThickness = new Thickness(0, 0, 0, 0),
               AllowIncomingLinks = true,
               AllowOutgoingLinks = true,
               Pen = new Pen(transparent, 1),
               EnabledHandles = AdjustmentHandles.Move,
               AllowAddChildren = true,
               AllowRemoveChildren = false
           };
           if (task.Type == TaskType.Start)
           {
               Node.AllowIncomingLinks = false;
               Node.AllowOutgoingLinks = true;
           }
           Node.Children.Add(TaskImageNode);
           Node.Children.Add(TaskTextNode);
       }
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #3 - Apr 2nd, 2010 at 8:31am
Print Post  
I cannot get the error. Please email a test project that reproduces it to support@mindfusion.eu. Also consider defining your TaskNodes though control templates as shown in tutorials 3 and 4.

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


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #4 - Apr 2nd, 2010 at 2:23pm
Print Post  
thanks for the pointers I will look at the tutorial.
I wil prepare the Project and send it over.. However what code did you use to copy paste..

This is what i am doing.. one funciton is called int he copy menuitem command event handler and the other is on the paste menuitem event handler.
SelectionCopy copy = null;
private void CopySelection()
       {
           copy = currentDiagram.CopySelection(false);
           SetStatusMessage("Item Selected", Brushes.White);
       }

private void PasteSelection()
       {
           if (copy != null)
           {
               currentDiagram.PasteSelection(copy, 10, 10);
           }
       }
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #5 - Apr 6th, 2010 at 5:29am
Print Post  
Hi Don,

I used the same code and it worked. Are you by chance calling PasteSelection twice in a row? Currently this is not supported and a SelectionCopy returned by diagram.CopySelection can be pasted just once (though it throws a different exception if called for a second time). You could call Copy from your PasteSelection method to enable consecutive paste operations:

currentDiagram.PasteSelection(copy, 10, 10);
copy = currentDiagram.CopySelection(false);

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


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #6 - Apr 6th, 2010 at 9:29pm
Print Post  
I have managed to reproduce the problem in a sample applicaiotn and i have sent it over to support@mindfusion.eu

Thanks, Don Almeida
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #7 - Apr 7th, 2010 at 8:12am
Print Post  
Hi Don,

This is a known problem where DoubleCollections cannot be shared by different UIElements. That was fixed in a recent release and you can get your upgrade from http://clientsarea.eu/.

If you prefer using the old version, assign a new value to StrokeDashArray after pasting items:

Code
Select All
PasteSelection();
foreach (DiagramItem item in diagram.Selection.Items)
	item.StrokeDashArray = new DoubleCollection(); 



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


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #8 - Apr 7th, 2010 at 2:38pm
Print Post  
This might sound dumb but is Diagramlite 1.4 the latest release for silverlight or  MindFusion.Diagramming for Silverlight V1.3 the lates version for silverlight. I currently have this build number.. 1.3.0.21960 for MindFusion.Diagramming.Silverlight.dll but before this version I used DiagramLite.dll with version 1.2.0.24983.
What version should I upgrade to?
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #9 - Apr 7th, 2010 at 2:55pm
Print Post  
1.4 is the latest DiagramLite release. I still runs on Silverlight 3.
  
Back to top
 
IP Logged
 
donalmeida
Junior Member
**
Offline


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #10 - Apr 7th, 2010 at 3:39pm
Print Post  
Thanks Stoyan for the link.. is it possble to add a a new feature like raise an event whenever a user copies or pastes an object (also Redo/Undo). Currently I will write my own delegate/Event handler as I need to update many other controls (Treeview etc.) when the user copies/pastes/ Undo/Redos an operation.
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #11 - Apr 7th, 2010 at 4:56pm
Print Post  
Ok, we'll add such events for the 1.5 release.
  
Back to top
 
IP Logged
 
donalmeida
Junior Member
**
Offline


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #12 - Apr 7th, 2010 at 5:30pm
Print Post  
You guys are awesome, thanks Don Almeida
  

Don Almeida.
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Copy / Paste Throws Exception
Reply #13 - Apr 28th, 2010 at 2:36pm
Print Post  
Hi Don,

This adds NodePasted, LinkPasted, ActionUndone and ActionRedone events:

https://mindfusion.eu/_beta/diaglite15.zip

The undo events are also raised for the commands contained within a composite command.

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


Yay...

Posts: 65
Joined: Oct 6th, 2009
Re: Copy / Paste Throws Exception
Reply #14 - Apr 28th, 2010 at 6:03pm
Print Post  
Thank you Stoyan.
  

Don Almeida.
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint