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);
}
}