Profile Picture

problems with ports of NComposite and NLineShape

Posted By Hans Henrik Friis Pedersen... 10 Years Ago
Author
Message
Hans Henrik Friis Pedersen...
Problem Posted 10 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 8 Years Ago
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
Posted 10 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: Last Week
Posts: 3,054, Visits: 4,009
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





Similar Topics


Reading This Topic