Use a Factory Shape as part of an NCompositeShape


Author
Message
Mohamed Salti
Mohamed Salti
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
Hello,

I would like to use shapes provided by your shape factory as a part of my NCompositeShape.

According to the documentation I should be able to use the Compose() method provided by the NShape object to do this.

The following code throws the exception: 'The specified node cannot be inserted at index: 0'

//CODE START

NFlowChartingShapesFactory f = new NFlowChartingShapesFactory(NGraphicsUnit.Pixel, 96);
f.DefaultSize = new NSizeF(80, 60);

var zz = f.CreateShape(FlowChartingShapes.Document);
zz.Compose(this); //exception thrown on this line. FYI 'this' inherits from NCompositeShape

//CODE END

Any help with this would be greatly appreciated.

Thanks!
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,

We have just tested a piece code that mimics your scenario and it works fine. Here it is, try it out:

CustomCompositeShape compositeShape = new CustomCompositeShape();

document.ActiveLayer.AddChild(compositeShape);

compositeShape.Initialize();

compositeShape.Location = new NPointF(100, 100);

 

...

 

[Serializable]

public class CustomCompositeShape : NCompositeShape

{

        public void Initialize()

        {

               NBasicShapesFactory factory = new NBasicShapesFactory();

               factory.DefaultSize = new NSizeF(100, 100);

 

               NShape shape1 = factory.CreateShape(BasicShapes.Rectangle);

               shape1.Compose(this);

 

               NShape shape2 = factory.CreateShape(BasicShapes.Circle);

               shape2.Location = new NPointF(100, -50);

               shape2.Compose(this);

 

               UpdateModelBounds();

        }

}



Best Regards,
Nevron Support Team


Mohamed Salti
Mohamed Salti
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)
Group: Forum Members
Posts: 4, Visits: 1
Thanks! I had some dll version issues on my local machine, once fixed my original code worked.

Thanks again!
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