예제 #1
0
        private void CreateShapeWithLogicalLinePort()
        {
            NPointF[] points = new NPointF[] { new NPointF(151, 291),
                                               new NPointF(151, 316),
                                               new NPointF(123, 336),
                                               new NPointF(151, 350),
                                               new NPointF(158, 319),
                                               new NPointF(180, 312) };

            // create a polyline shape with a logical line port
            NPolylineShape shape = new NPolylineShape(points);

            shape.Name   = "Shape with a Logical Line Port";
            shape.Bounds = base.GetGridCell(5, 1);

            // create the ports
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30);

            shape.Ports.RemoveAllChildren();
            shape.Ports.AddChild(port);
            shape.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            // connect it with the center shape
            document.ActiveLayer.AddChild(shape);
            ConnectShapes(centerShape, shape);

            // descibte it
            NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(5, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
예제 #2
0
        private void CreateArrowShapeWithLogicalLinePort()
        {
            // create a filled graph connector with one logical line port
            NArrowShape shape = new NArrowShape(ArrowType.DoubleArrow, new NPointF(15, 380), new NPointF(55, 420), 10, 45, 30);

            shape.Bounds = base.GetGridCell(6, 1);
            shape.Name   = "Filled shape with Stroke Port";

            // create the ports
            shape.CreateShapeElements(ShapeElementsMask.Ports);

            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30);

            shape.Ports.RemoveAllChildren();
            shape.Ports.AddChild(port);
            shape.Ports.DefaultInwardPortUniqueId = port.UniqueId;

            // connect it with the center shape
            document.ActiveLayer.AddChild(shape);
            ConnectShapes(centerShape, shape);

            // descibte it
            NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(6, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }
예제 #3
0
        private void percentPositionNumeric_ValueChanged(object sender, System.EventArgs e)
        {
            if (EventsHandlingPaused)
            {
                return;
            }

            // get the selected shape
            NShape shape = view.Selection.AnchorNode as NShape;

            if (shape == null || shape.Ports == null)
            {
                return;
            }

            // get a logical line port
            NLogicalLinePort port = (shape.Ports.DefaultInwardPort as NLogicalLinePort);

            if (port == null)
            {
                return;
            }

            PauseEventsHandling();

            // change the percent position of a logical line port
            port.Percent = (float)percentPositionNumeric.Value;

            ResumeEventsHandling();
            document.SmartRefreshAllViews();
        }
예제 #4
0
        private void OnEdgeImported(NDataSourceImporter dataSourceImporter, NShape shape, INDataRecord dataRecord)
        {
            // Set the text of the edge
            shape.Text = dataRecord.GetColumnValue("Desc").ToString();

            // Get the symbol name if any
            object symbol = dataRecord.GetColumnValue("Symbol");

            if (symbol == null || Convert.IsDBNull(symbol))
            {
                return;
            }

            // Add a logical line port
            NLogicalLinePort linePort = new NLogicalLinePort(20);

            shape.CreateShapeElements(ShapeElementsMask.Ports);
            shape.Ports.AddChild(linePort);

            // Attach a custom shape based on the symbol name
            NShape customShape = null;

            switch (symbol.ToString())
            {
            case "Stop":
                customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.StopAccepted);
                break;

            case "Question":
                customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.Question);
                break;
            }

            ((NDrawingDocument)shape.Document).ActiveLayer.AddChild(customShape);

            // Protect the symbol from user interactions
            NAbilities protection = customShape.Protection;

            protection.All         = true;
            customShape.Protection = protection;

            // Add an outward port to the shape
            NRotatedBoundsPort outwardPort = new NRotatedBoundsPort(new NContentAlignment(ContentAlignment.MiddleCenter));

            outwardPort.Type = PortType.Outward;
            customShape.CreateShapeElements(ShapeElementsMask.Ports);
            customShape.Ports.AddChild(outwardPort);

            outwardPort.Connect(linePort);
        }
예제 #5
0
        private void CreateShapeWithAutoLinePort()
        {
            NBezierCurveShape shape = new NBezierCurveShape(new NPointF(0, 0), new NPointF(1, 0), new NPointF(1, 2), new NPointF(2, 2));

            shape.Name              = "Line Port with AutoLine direction";
            shape.Bounds            = base.GetGridCell(5, 1);
            shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108));

            shape.CreateShapeElements(ShapeElementsMask.Ports);
            NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 50);

            port.DirectionMode = LogicalLinePortDirectionMode.AutoLine;
            shape.Ports.AddChild(port);

            document.ActiveLayer.AddChild(shape);

            // describe it
            NTextShape text = new NTextShape("Line Port with AutoLine direction", base.GetGridCell(5, 2, 0, 1));

            document.ActiveLayer.AddChild(text);
        }