AssetBundleGraph.NodeGUI.HandleNodeEvent C# (CSharp) Method

HandleNodeEvent() private method

private HandleNodeEvent ( ) : void
return void
        private void HandleNodeEvent()
        {
            switch (Event.current.type) {

            /*
                    handling release of mouse drag from this node to another node.
                    this node doesn't know about where the other node is. the master only knows.
                    only emit event.
                */
            case EventType.Ignore: {
                    NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECTION_OVERED, this, Event.current.mousePosition, null));
                    break;
                }

                /*
                    handling drag.
                */
            case EventType.MouseDrag: {
                    NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_MOVING, this, Event.current.mousePosition, null));
                    break;
                }

                /*
                    check if the mouse-down point is over one of the connectionPoint in this node.
                    then emit event.
                */
            case EventType.MouseDown: {
                    ConnectionPointData result = IsOverConnectionPoint(Event.current.mousePosition);

                    if (result != null) {
                        if (scaleFactor == SCALE_MAX) {
                            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECT_STARTED, this, Event.current.mousePosition, result));
                        }
                        break;
                    }
                    break;
                }
            }

            /*
                retrieve mouse events for this node in|out of this AssetGraoh window.
            */
            switch (Event.current.rawType) {
            case EventType.MouseUp: {
                    bool eventRaised = false;
                    // if mouse position is on the connection point, emit mouse raised event.
                    Action<ConnectionPointData> raiseEventIfHit = (ConnectionPointData point) => {
                        // Only one connectionPoint raise event at one mouseup event
                        if(eventRaised) {
                            return;
                        }
            //						var region = point.Region;
            //						var globalConnectonPointRect = new Rect(region.x, region.y, region.width, region.height);
                        if (point.Region.Contains(Event.current.mousePosition)) {
                            NodeGUIUtility.NodeEventHandler(
                                new NodeEvent(NodeEvent.EventType.EVENT_NODE_CONNECTION_RAISED,
                                    this, Event.current.mousePosition, point));
                            eventRaised = true;
                            return;
                        }
                    };
                    m_data.InputPoints.ForEach(raiseEventIfHit);
                    m_data.OutputPoints.ForEach(raiseEventIfHit);
                    if(!eventRaised) {
                        NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_TOUCHED,
                            this, Event.current.mousePosition, null));
                    }
                    break;
                }
            }

            /*
                right click to open Context menu
            */
            if (scaleFactor == SCALE_MAX) {
                if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(
                        new GUIContent("Delete"),
                        false,
                        () => {
                            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CLOSE_TAPPED, this, Vector2.zero, null));
                        }
                    );
                    menu.ShowAsContext();
                    Event.current.Use();
                }
            }
        }