Mouse Position (Form)


Node Information
Gets mouse position relative to the form.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Form IN Form ONE FALSE FALSE
X OUT Int32 MULTIPLE FALSE FALSE
Y OUT Int32 MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Form
{
    [IsNode("Get Mouse Position")]
    public class FormMousePosition : Node
    {
        Port frm = new Port(PortType.IN, typeof(System.Windows.Forms.Form), AcceptsLinks.ONE, "Form");
        Port x = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "X");
        Port y = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "Y");
        [System.ComponentModel.Description("if there is no forms connected the value will be set to the current form, which is refered to as 'this'.")]
        public string FormName
        {
            get { return "this"; }
        }
        public FormMousePosition()
        {
            this.Name = "Mouse Position (Form)";
            AddPort(frm);
            AddPort(x);
            AddPort(y);
            x.Instructions = "this.PointToClient(Cursor.Position).X";
            y.Instructions = "this.PointToClient(Cursor.Position).Y";
            Information = "Gets mouse position relative to the form.";
        }
        public override void UpdateResults()
        {
            string formname = "this";
            if (frm.IsConnected)
            {
                formname = GetValue(frm);
            }
            else
            {
                formname = FormName;
            }
            x.Instructions = formname + ".PointToClient(Cursor.Position).X";
            y.Instructions = formname + ".PointToClient(Cursor.Position).Y";
        }
    }
}