InkCanvas AddStrokes


Node Information
Adds strokes to the specified InkCanvas.
General Information
• This node doesn't have other available options.
• Some of the ports of this node can change their types and accept types automatically.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Add IN RUN MULTIPLE FALSE FALSE
InkCanvas IN InkCanvas ONE FALSE FALSE
Strokes IN List<Point> ONE TRUE TRUE
Color IN Color ONE FALSE FALSE
FitToCurve IN Boolean ONE FALSE FALSE
IsHighlighter IN Boolean ONE FALSE FALSE
Pressure IN Single ONE FALSE FALSE
Width IN Double ONE FALSE FALSE
Height IN Double ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Advanced.InkCanvas
{
    [IsNode("AddStrokes")]
    public class InkCanvasAddStrokes : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port strokes = new Port(PortType.IN, typeof(List<system.drawing.point>), AcceptsLinks.ONE, "Strokes");
        Port colr = new Port(PortType.IN, typeof(System.Drawing.Color), AcceptsLinks.ONE, "Color");
        Port fit = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "FitToCurve");
        Port ishighligheter = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "IsHighlighter");
        Port pr = new Port(PortType.IN, typeof(float), AcceptsLinks.ONE, "Pressure");
        Port w = new Port(PortType.IN, typeof(double), AcceptsLinks.ONE, "Width");
        Port h = new Port(PortType.IN, typeof(double), AcceptsLinks.ONE, "Height");
        Port control = new Port(PortType.IN, typeof(Korduene.Designer.Advanced.InkCanvas), AcceptsLinks.ONE, "InkCanvas");
        public InkCanvasAddStrokes()
        {
            this.Name = "InkCanvas AddStrokes";
            this.NodeType = NodeType.Method;
            AddPort(run);
            AddPort(control);
            AddPort(strokes);
            AddPort(colr);
            AddPort(fit);
            AddPort(ishighligheter);
            AddPort(pr);
            AddPort(w);
            AddPort(h);
            w.Value = "1";
            h.Value = "1";
            pr.Value = "1";
            strokes.CustomAcception = Accepts;
            Information = "Adds strokes to the specified InkCanvas.";
        }
        bool Accepts(Port port)
        {
            if (port.DataType == typeof(List<system.drawing.point>))
            {
                strokes.Accepts = AcceptsLinks.ONE;
                strokes.EditorEnabled = false;
                strokes.DataType = typeof(List<system.drawing.point>);
                return true;
            }
            if (port.DataType == typeof(System.Drawing.Point))
            {
                strokes.Accepts = AcceptsLinks.MULTIPLE;
                strokes.DataType = typeof(System.Drawing.Point);
                return true;
            }
            else
            {
                return false;
            }
        }
        public override string Code()
        {
            string code = string.Empty;
            string attr = GetValue(colr) + ", " + GetValue(fit) + ", " + GetValue(ishighligheter) + ", " + GetValue(pr) + ", " + GetValue(w) + ", " + GetValue(h);
            if (strokes.Accepts == AcceptsLinks.MULTIPLE)
            {
                string ports = string.Empty;
                foreach (var port in strokes.ConnectedPorts)
                {
#warning InkCanvasAddStrokes: this should be fixed, this is a quick hack
                    ports += port.ParentNode.ID + ", ";
                }
                code = GetValue(control) + ".AddStrokes( new List<system.drawing.point>(){" + ports + "}," + attr + ");";
            }
            else if (strokes.Accepts == AcceptsLinks.ONE)
            {
                code = GetValue(control) + ".AddStrokes(" + GetValue(strokes) + "," + attr + ");";
            }
            return code;
        }
    }
}

</system.drawing.point></system.drawing.point></system.drawing.point></system.drawing.point>