Exemplo n.º 1
0
    void ProcessEvent(Event e)
    {
        Vector2 mousePos = e.mousePosition;

        switch (nowState)
        {
        case WindowState.normal:
            if (e.type == EventType.MouseDown)
            {
                if (!leftPanel.HitTest(e) && !rightPanel.HitTest(mousePos))
                {
                    switch (e.button)
                    {
                    case 0:
                        if (!ClickNode(mousePos))
                        {
                            ClickLink(mousePos);
                        }
                        nowState = WindowState.drag;
                        break;

                    case 1:
                        if (ClickNode(mousePos))
                        {
                            NodeDropdown();
                        }
                        else if (!ClickLink(mousePos))
                        {
                            MainDropdown(mousePos);
                        }
                        break;

                    default:
                        nowState = WindowState.move;
                        break;
                    }
                }
            }
            break;

        case WindowState.drag:
            if (e.type == EventType.MouseDrag)
            {
                if (SelectNode != null)
                {
                    SelectNode.FollowMouse(e.delta);
                }
            }
            else if (e.type == EventType.MouseUp)
            {
                nowState = WindowState.normal;
            }
            break;

        case WindowState.move:
            if (e.type == EventType.MouseDrag)
            {
                coordinate += e.delta;
            }
            else if (e.type == EventType.MouseUp)
            {
                nowState = WindowState.normal;
            }
            break;

        case WindowState.popup:
            if (e.type == EventType.MouseDown && e.button == 0)
            {
                PopupEvent(e.mousePosition);
            }
            break;

        case WindowState.link:
            Link(SelectNode.canvasRect.center, mousePos);
            CanvasAutoMove(mousePos);
            if (e.type == EventType.MouseDown && e.button == 0)
            {
                Node originNode = SelectNode;
                if (ClickNode(mousePos))
                {
                    if (SelectNode.GetType() != typeof(SubNode) && SelectNode.GetType() != typeof(StartNode))
                    {
                        originNode.SetConnect(SelectNode);
                    }
                }
                nowState = WindowState.normal;
                ResetSelect();
            }
            break;

        case WindowState.scroll:
            if (e.type == EventType.MouseDrag)
            {
                rightPanel.Scroll(e.delta.y);
            }
            else if (e.type == EventType.MouseUp)
            {
                nowState = WindowState.normal;
            }
            break;
        }
        if (nowState != WindowState.scroll && e.type == EventType.ScrollWheel)
        {
            rightPanel.Scroll(e);
        }
    }