// ----------------------------------------------------------------------
        void ProcessPicking(iCS_PickInfo pickInfo)
        {
            if (myClickCount < 2)
            {
                return;
            }
            iCS_EditorObject pickedObject = pickInfo.PickedObject;

            switch (pickInfo.PickedPart)
            {
            case iCS_PickPartEnum.Name:
            case iCS_PickPartEnum.Value:
            case iCS_PickPartEnum.EditorObject: {
                if (pickedObject.IsPort)
                {
                    CloseSubEditor();
                    mySubEditor = PortEditor.Create(pickedObject, new Vector2(100, 100));
                }
                else
                {
                    CloseSubEditor();
                    if (pickedObject.IsIconizedInLayout)
                    {
                        iCS_UserCommands.Unfold(pickedObject);
                    }
                    else
                    {
                        mySubEditor = NodeEditor.Create(pickedObject, new Vector2(100, 100));
                    }
                }
                myClickCount = 0;
                break;
            }
            }
        }
 // ----------------------------------------------------------------------
 void MouseUpEvent()
 {
     if (IsDragStarted)
     {
         EndDrag();
     }
     else
     {
         if (ShouldRotateMuxPort)
         {
             RotateSelectedMuxPort();
         }
         if (SelectedObject != null)
         {
             // Process fold/unfold/minimize/maximize click.
             Vector2 mouseGraphPos = GraphMousePosition;
             if (myGraphics.IsFoldIconPicked(SelectedObject, mouseGraphPos))
             {
                 if (SelectedObject.IsFoldedInLayout)
                 {
                     iCS_UserCommands.Unfold(SelectedObject);
                 }
                 else
                 {
                     iCS_UserCommands.Fold(SelectedObject);
                 }
             }
             else if (myGraphics.IsMinimizeIconPicked(SelectedObject, mouseGraphPos))
             {
                 iCS_UserCommands.Iconize(SelectedObject);
             }
             else
             {
                 // Fold/Unfold on double click.
                 if (SelectedObject == SelectedObjectBeforeMouseDown)
                 {
                     if (IsShiftKeyDown)
                     {
                         if (myClickCount >= 2)
                         {
                             ProcessNodeDisplayOptionEvent();
                         }
                     }
                     else
                     {
                         iCS_PickInfo pickInfo = myGraphics.GetPickInfo(GraphMousePosition, IStorage);
                         if (pickInfo != null)
                         {
                             ProcessPicking(pickInfo);
                         }
                     }
                 }
             }
         }
     }
 }
示例#3
0
        // =======================================================================
        // HotZone Processing
        // -----------------------------------------------------------------------
        bool HotZoneMouseClick(Vector2 p, iCS_PickInfo pickInfo)
        {
            bool isUsed = false;

            HotZone[] hotZones = new HotZone[myHotZones.Values.Count];
            myHotZones.Values.CopyTo(hotZones, 0);
            foreach (var hz in hotZones)
            {
                if (hz.IsForeground == true || (pickInfo == null || pickInfo.PickedObject.IsBehaviour))
                {
                    if (hz.Area.Contains(p) && hz.OnMouseClick != null)
                    {
                        hz.OnMouseClick();
                        isUsed = true;
                    }
                }
            }
            return(isUsed);
        }
        // ================================================================================
        // Find object under mouse in VisualEditor, and prepare help.  Use only from onGUI.
        // --------------------------------------------------------------------------------
        void UpdateHelp()
        {
            // -- Update the help information --
            iCS_EditorObject edObj    = null;
            iCS_PickInfo     pickInfo = myGraphics.GetPickInfo(GraphMousePosition, IStorage);

            if (pickInfo != null)
            {
                edObj = pickInfo.PickedObject;
                if (edObj != null)
                {
                    myIsLibraryHelp = false;
                }
                myHelpText = prepareHelpWindowText(edObj);
                // If no specific help was found, show the window help.
                if (String.IsNullOrEmpty(myHelpText))
                {
                    helpWindowChange();
                }
            }
        }
示例#5
0
        // ======================================================================
        // Displays which element is being picked.
        // ----------------------------------------------------------------------
        public iCS_PickInfo GetPickInfo(Vector2 pick, iCS_IStorage iStorage)
        {
            iCS_PickInfo pickInfo = new iCS_PickInfo(iStorage);

            pickInfo.PickedPoint           = pick;
            pickInfo.PickedPointInGUISpace = TranslateAndScale(pick);
            var port = iStorage.GetPortAt(pick);

            if (port != null)
            {
//            Debug.Log("Port: "+port.Name+" is being picked");
                pickInfo.PickedObject            = port;
                pickInfo.PickedPart              = iCS_PickPartEnum.EditorObject;
                pickInfo.PickedPartGraphPosition = port.GlobalRect;
                pickInfo.PickedPartGUIPosition   = TranslateAndScale(pickInfo.PickedPartGraphPosition);
                return(pickInfo);
            }
            var pickedNode = iStorage.GetNodeAt(pick);

            if (pickedNode != null)
            {
                if (IsFoldIconPicked(pickedNode, pick))
                {
//                Debug.Log("Fold icon of: "+pickedNode.Name+" is being picked");
                    pickInfo.PickedObject            = pickedNode;
                    pickInfo.PickedPart              = iCS_PickPartEnum.FoldIcon;
                    pickInfo.PickedPartGraphPosition = GetFoldIconPosition(pickedNode);
                    pickInfo.PickedPartGUIPosition   = TranslateAndScale(pickInfo.PickedPartGraphPosition);
                    return(pickInfo);
                }
                if (IsMinimizeIconPicked(pickedNode, pick))
                {
//                Debug.Log("Minimize icon of: "+pickedNode.Name+" is being picked");
                    pickInfo.PickedObject            = pickedNode;
                    pickInfo.PickedPart              = iCS_PickPartEnum.MinimizeIcon;
                    pickInfo.PickedPartGraphPosition = GetMinimizeIconPosition(pickedNode);
                    pickInfo.PickedPartGUIPosition   = TranslateAndScale(pickInfo.PickedPartGraphPosition);
                    return(pickInfo);
                }
                if (IsNodeNamePicked(pickedNode, pick))
                {
//                Debug.Log("Node name: "+pickedNode.Name+" is being picked");
                    pickInfo.PickedObject = pickedNode;
                    pickInfo.PickedPart   = iCS_PickPartEnum.Name;
                    Rect  namePos  = GetNodeNamePosition(pickedNode);
                    float invScale = 1.0f / Scale;
                    pickInfo.PickedPartGraphPosition = new Rect(namePos.x, namePos.y, namePos.width * invScale, namePos.height * invScale);
                    var guiPos = TranslateAndScale(Math3D.ToVector2(namePos));
                    pickInfo.PickedPartGUIPosition = new Rect(guiPos.x, guiPos.y, namePos.width, namePos.height);
                    return(pickInfo);
                }
                bool result = iStorage.UntilMatchingChildNode(pickedNode,
                                                              c => {
                    if (c.IsIconizedOnDisplay)
                    {
                        if (IsNodeNamePicked(c, pick))
                        {
                            pickInfo.PickedObject            = c;
                            pickInfo.PickedPart              = iCS_PickPartEnum.Name;
                            Rect namePos                     = GetNodeNamePosition(c);
                            float invScale                   = 1.0f / Scale;
                            pickInfo.PickedPartGraphPosition = new Rect(namePos.x, namePos.y, namePos.width * invScale, namePos.height * invScale);
                            var guiPos = TranslateAndScale(Math3D.ToVector2(namePos));
                            pickInfo.PickedPartGUIPosition = new Rect(guiPos.x, guiPos.y, namePos.width, namePos.height);
                            return(true);
                        }
                    }
                    return(false);
                }
                                                              );
                if (result)
                {
                    return(pickInfo);
                }
            }
            var closestPort = iStorage.GetClosestPortAt(pick);

            if (closestPort != null)
            {
                if (IsPortNamePicked(closestPort, pick, iStorage))
                {
                    pickInfo.PickedObject = closestPort;
                    pickInfo.PickedPart   = iCS_PickPartEnum.Name;
                    Rect  namePos  = GetPortNamePosition(closestPort, iStorage);
                    float invScale = 1.0f / Scale;
                    pickInfo.PickedPartGraphPosition = new Rect(namePos.x, namePos.y, namePos.width * invScale, namePos.height * invScale);
                    var guiPos = TranslateAndScale(Math3D.ToVector2(namePos));
                    pickInfo.PickedPartGUIPosition = new Rect(guiPos.x, guiPos.y, namePos.width, namePos.height);
                    return(pickInfo);
                }
                if (IsPortValuePicked(closestPort, pick))
                {
                    pickInfo.PickedObject = closestPort;
                    pickInfo.PickedPart   = iCS_PickPartEnum.Value;
                    Rect  namePos  = GetPortValuePosition(closestPort);
                    float invScale = 1.0f / Scale;
                    pickInfo.PickedPartGraphPosition = new Rect(namePos.x, namePos.y, namePos.width * invScale, namePos.height * invScale);
                    var guiPos = TranslateAndScale(Math3D.ToVector2(namePos));
                    pickInfo.PickedPartGUIPosition = new Rect(guiPos.x, guiPos.y, namePos.width, namePos.height);
                    return(pickInfo);
                }
            }
            if (pickedNode != null)
            {
//            Debug.Log("Node: "+pickedNode.Name+" is being picked");
                pickInfo.PickedObject            = pickedNode;
                pickInfo.PickedPart              = iCS_PickPartEnum.EditorObject;
                pickInfo.PickedPartGraphPosition = pickedNode.GlobalRect;
                pickInfo.PickedPartGUIPosition   = TranslateAndScale(pickInfo.PickedPartGraphPosition);
                return(pickInfo);
            }
            return(null);
        }