Device Changed


Node Information
When system devices change one of the events will be fired. If a device is inserted 'Inserted' will be fired, if a device is removed 'Removed' will be fired, and for either 'Inserted/Removed' will be fired.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Inserted OUT RUN MULTIPLE FALSE FALSE
Removed OUT RUN MULTIPLE FALSE FALSE
Inserted/Removed OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Win32.SystemEvents
{
    [IsNode("Device Changed")]
    public class DeviceChangedEvent : Node
    {
        Port inserted = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "Inserted");
        Port removed = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "Removed");
        Port insertedremoved = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "Inserted/Removed");
        public DeviceChangedEvent()
        {
            Name = "Device Changed";
            NodeType = KGraph.NodeType.SystemEvent;
            AddPort(inserted);
            AddPort(removed);
            AddPort(insertedremoved);
            Information = "When system devices change one of the events will be fired. " +
                "If a device is inserted 'Inserted' will be fired, if a device is removed 'Removed' will be fired, " +
                "and for either 'Inserted/Removed' will be fired.";
        }
        public override string Code()
        {
            return
            "\r\n//DeviceAdded/Removed\r\n" +
            "if (m.Msg == 0x0219 && m.LParam.ToInt32() != 0)\r\n" + "{\r\n" +
            GetValue(insertedremoved) + Environment.NewLine +
                "switch (m.WParam.ToInt32())\r\n" +
                "{\r\n" + "case 32768:\r\n" + "//inserted\r\n" +
                        GetValue(inserted) + Environment.NewLine +
                        "break;\r\n" + "case 32772:\r\n" + "//removed\r\n" +
                       GetValue(removed) + Environment.NewLine +
                        "break;\r\n" + "default:\r\n" + "break;\r\n" +
                "}" + Environment.NewLine +
            "}";
        }
    }
}