Profile Picture

Attaching control points to a Shape, to change the appearance by dragging them

Posted By Markus Weißenbek 8 Years Ago

Attaching control points to a Shape, to change the appearance by...

Author
Message
Markus Weißenbek
Question Posted 8 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: 3, Visits: 63
Hi,

I'm trying to glue control points (NControl) to a NShape with a rectangular geometry. Unfortunately I can add the control point with the method control.GlueToGeometryVertex(shape.Geometry[0], 0), but the corner of the rectangle does not follow the control point.

How can I achieve the correct behavior, so that the corner point of the geometry follows the control point.

Best regards,

Markus


Nevron Support
Posted 8 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
It looks like you want to achieve a smart geometry that is controlled by a control point. Currently you are gluing (attaching) the control point to a geometry vertex - when the vertex changes the control point location will also change. The following code example achieves the opposite - it has a control point, which when moved will move the first point of the shape geometry. You can expressions to achieve this result, please let us know if you would like the source code of any specific smart shape that comes with NOV Diagram for .NET

using System;
using System.Windows.Forms;
using Nevron.Nov;
using Nevron.Nov.Diagram;
using Nevron.Nov.Dom;
using Nevron.Nov.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            // Apply license for redistribution here. You can skip this code when evaluating NOV.
            // NLicenseManager.Instance.SetLicense(new NLicense("LICENSE KEY"));
            
            // Install NOV with diagram module
            NModule[] modules = new NModule[] {
                NDiagramModule.Instance
            };

            NNovApplicationInstaller.Install(modules);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // clear all controls from the form
            Controls.Clear();

            // add a NOV widget inside the form
            NDrawingView drawingView = new NDrawingView();
            NNovWidgetHost<NDrawingView> host = new NNovWidgetHost<NDrawingView>(drawingView);
            host.Dock = DockStyle.Fill;
            Controls.Add(host);

            // get the active page
            NPage activePage = drawingView.Drawing.ActivePage;

            NShape shape = new NShape();
            activePage.Items.Add(shape);
            shape.Init2DShape();

            NControl control = new NControl();
            control.Tooltip = "Move me to change the first point";
            shape.Controls.Add(control);
 
            NGeometry geomtry = shape.Geometry;
            geomtry.MoveTo(new NBindingFx(control, NControl.XProperty), new NBindingFx(control, NControl.YProperty));
            geomtry.LineTo(new NBindingFx(shape, NShape.WidthProperty), 0);
            geomtry.LineTo(new NBindingFx(shape, NShape.WidthProperty), new NBindingFx(shape, NShape.HeightProperty));
            geomtry.LineTo(0, new NBindingFx(shape, NShape.HeightProperty));
            geomtry.CloseLastFigure = true;

            shape.SetBounds(10, 10, 100, 100);
        }
    }
}

Best Regards,
Nevron Support Team



Markus Weißenbek
Posted 8 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: 3, Visits: 63
Thank you for your reply. That was exactly what we needed. But another thing came up regarding this topic. Until now I set the SelectionMode of the Page to Geometry, which enabled me to also move the Endpoints of the Geometry, but in this mode, the inserted Controls are not visible.

In our perspective the approach that you recommended is more refined, because we can insert Controls and change the number edges at runtime, whereas with the approach of setting only the SelectionMode, we can only move the existing cornerpoints around.

Best regards,

Markus




Similar Topics


Reading This Topic