Profile Picture

Copy/Paste FailedRolledback

Posted By Ron Sawyer 14 Years Ago
Author
Message
Steve Warner
Posted 13 Years Ago
View Quick Profile
Junior Member

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
Last Active: 10 Years Ago
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?

Ron Sawyer
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 13 Years Ago
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.

Nevron Support
Posted 14 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 days ago @ 1:54 AM
Posts: 3,054, Visits: 4,009

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
Posted 14 Years Ago
View Quick Profile
Junior Member

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
Last Active: 13 Years Ago
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);

      }

}

 





Similar Topics


Reading This Topic