Copy/Paste FailedRolledback


Author
Message
Ron Sawyer
Ron Sawyer
Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)
Group: Forum Members
Posts: 16, Visits: 1

I have created a simple custom shape. When I try to copy and paste it I get the following:

The Paste transaction FailedRolledback
Error Log:
1. Paste failed on a single node: Object reference not set to an instance of an object.

The following shape is a very simplistic-cut-down class to show what I am trying to do:

 

class TestClass : NGroup, ICloneable

{ 

      public TestClass()

      {

            // add a rectangle shape as base

            NRectangleShape rect = new NRectangleShape(new NRectangleF(0, 0, 100, 300));

            rect.DestroyShapeElements(ShapeElementsMask.All);

            rect.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit | AbilitiesMask.Copy);

            Shapes.AddChild(rect); 

 

            // update the model bounds with the rectangle bounds        UpdateModelBounds(rect.Transform.TransformBounds(rect.ModelBounds));

 

            CreateShapeElements(ShapeElementsMask.Labels);

            NRotatedBoundsLabel label = new NRotatedBoundsLabel("", rect.UniqueId, new Nevron.Diagram.NMargins(10));

 

            Labels.AddChild(label);

            Labels.DefaultLabelUniqueId = label.UniqueId; 

      } 

 

      public TestClass(TestClass PassedClass)

      {

            NRectangleShape LclRect = PassedClass.Shapes.GetChildAt(0) as NRectangleShape;

            if (LclRect != null)

            {

                  NRectangleShape TmpRect = LclRect.Clone() as NRectangleShape;

 

                  Shapes.AddChild(TmpRect);

                  UpdateModelBounds(TmpRect.Transform.TransformBounds(LclRect.ModelBounds));

                  NRotatedBoundsLabel label = new NRotatedBoundsLabel("", TmpRect.UniqueId, new Nevron.Diagram.NMargins(10));

                  CreateShapeElements(ShapeElementsMask.Labels);

                  Labels.AddChild(label);

                  Labels.DefaultLabelUniqueId = label.UniqueId;

            }

      }

 

      object ICloneable.Clone()

      {

            return new TestClass(this);

      }

}

 


Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K

Hi,

In order to make your custom class copy/pasteable in the diagram all you have to do is to apply the Serializable attribute to it. Your class should look as this:

 

[Serializable]

class TestClass : NGroup

{

      public TestClass()

      {

            // add a rectangle shape as base

            NRectangleShape rect = new NRectangleShape(new NRectangleF(0, 0, 100, 300));

            rect.DestroyShapeElements(ShapeElementsMask.All);

            rect.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit | AbilitiesMask.Copy);

            Shapes.AddChild(rect);

 

            // update the model bounds with the rectangle bounds

            UpdateModelBounds(rect.Transform.TransformBounds(rect.ModelBounds));

 

            CreateShapeElements(ShapeElementsMask.Labels);

            NRotatedBoundsLabel label = new NRotatedBoundsLabel("", rect.UniqueId, new Nevron.Diagram.NMargins(10));

 

            Labels.AddChild(label);

            Labels.DefaultLabelUniqueId = label.UniqueId;

      }

}

 



Best Regards,
Nevron Support Team


Ron Sawyer
Ron Sawyer
Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)Junior Member (16 reputation)
Group: Forum Members
Posts: 16, Visits: 1
Thanks for the reply. I misunderstood this post:

http://forum.nevron.com/shwmessage.aspx?forumid=3&messageid=2593#bm2603

Your help worked and is much appreciated.
Steve Warner
Steve Warner
Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)Junior Member (15 reputation)
Group: Forum Members
Posts: 15, Visits: 1
I'm having this same issue, but using a NTextShape with a Serializable object as a tag. Any ideas what is causing the Paste failure?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search