problems with ports of NComposite and NLineShape


Author
Message
Hans Henrik Friis Pedersen...
Hans Henrik Friis Pedersen
Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)
Group: Forum Members
Posts: 28, Visits: 136

Hi,

I would like to add ports to a NComposite but it seems that the method "CreateShapeElements" doesn't
work? When I try to use the "HeatExChanger1.Ports.ChildrenCount(null))" it gives 0??

That means that it fails to use the line.startplug.connect and line.endplug.connect methods. What should I do instead?

 protected NCompositeShape CreateHeatExchanger(NPointF location, float scale)
        {
            NCompositeShape HeatExchanger = new NCompositeShape();
           
            GraphicsPath graphicsPath = new GraphicsPath();
            graphicsPath.StartFigure();
            PointF[] points = new PointF[]
   {
    new PointF(175,140),
    new PointF(175,160),
    new PointF(150,170),
    new PointF(200,170),
                new PointF(175,180),
                new PointF(175,200),
   };

            graphicsPath.AddLines(points);

            NPointF[] points2 = new NPointF[]
   {
    new NPointF(145,140),
    new NPointF(205,140),
    new NPointF(205,200),
    new NPointF(145,200),
   };

            NPolygonPath exterior = new NPolygonPath(points2);

            HeatExchanger.Primitives.AddChild(new NCustomPath(graphicsPath, PathType.OpenFigure));
            HeatExchanger.Primitives.AddChild(exterior);
            HeatExchanger.Style.FillStyle = new NColorFillStyle(Color.Empty);

            HeatExchanger.UpdateModelBounds();

            HeatExchanger.CreateShapeElements(ShapeElementsMask.Ports);


            HeatExchanger.Location = location;
            HeatExchanger.Width = HeatExchanger.Width * scale;
            HeatExchanger.Height = HeatExchanger.Height * scale;

            return HeatExchanger;
        }



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,

The CreateShapeElements method only creates the corresponding diagram element collection for the shape (in your case the Ports collection), but it does not add any children to it. After calling this method, you should create and add as many ports as you like to the Ports collection of the shape. For more information, check out the Ports documentation topic.

Best Regards,
Nevron Support Team


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