private void AutoScrollSelectedImage(MouseMoveArgs mma)
        {
            //we can safely assume the mouse is within the autoscroll margin
            Point vector = new Point(0, 0);

            vector.X = mma.Current.X - (refViewPort.ViewWidth - Globals.ImageBoxProperties.width);
            refVirtualDomain.MoveCamera(vector.X, vector.Y);
            refVirtualDomain.MoveSelectedImages(vector);
        }
        private bool NodeHover(MouseMoveArgs mma)
        {
            refHoveredNode = refVirtualDomain.OnHoverNode(mma.Current.X, mma.Current.Y);

            if (refHoveredNode != null)
            {
                return(true);
            }
            return(false);
        }
        private bool HilightMouseover(MouseMoveArgs mma)
        {
            refHoveredImage = refVirtualDomain.OnHilightImage(mma.Current.X, mma.Current.Y);

            if (refHoveredImage != null)
            {
                return(true);
            }
            return(false);
        }
        public void PerformAction(MouseEvents mouseEvent, EventArgs e)
        {
            MouseMoveArgs mma = (MouseMoveArgs)e;

            foreach (EventCombo combo in ActionTriggers.Keys)
            {
                if (combo.Event == mouseEvent && combo.State == this.State)
                {
                    DoAction(ActionTriggers[combo], mma, mouseEvent);
                    return;
                }
            }
        }
        private bool SelectGroup(MouseMoveArgs mma)
        {
            Rectangle SelectionRect = new Rectangle();

            SelectionRect.X      = System.Math.Min(mma.Current.X, mma.Start.X);
            SelectionRect.Y      = System.Math.Min(mma.Current.Y, mma.Start.Y);
            SelectionRect.Width  = System.Math.Abs(mma.Current.X - mma.Start.X);
            SelectionRect.Height = System.Math.Abs(mma.Current.Y - mma.Start.Y);

            //attempt to activate the one clicked on
            //ActivateMouseover(mma);

            return(refVirtualDomain.OnSelectImageGroup(SelectionRect));
        }
 private void ShowContextMenu(MouseMoveArgs mma)
 {
     //bring up the appropriate menu based on where we right-clicked
     if (ActivateMouseover(mma))
     {
         if (RoomContextMenu != null)
         {
             RoomContextMenu(this, null);
         }
     }
     else
     {
         if (WorkspaceContextMenu != null)
         {
             WorkspaceContextMenu(this, null);
         }
     }
 }
        public void ConnectRoom(MouseMoveArgs mma)
        {
            if (DeactivateDragLine != null)
            {
                DeactivateDragLine(this, null);
            }

            //if we are over another image, attach the connection to that
            if (HilightMouseover(mma))
            {
                //connect
                State = MouseStates.Hover;

                refHoveredNode.SetTarget(refHoveredImage);
                RoomConnectionArgs args = new RoomConnectionArgs(refHoveredNode.Source.RoomName,
                                                                 refHoveredImage.RoomName,
                                                                 refHoveredNode.Direction,
                                                                 ConnectionType.Connect);

                if (SetConnection != null)
                {
                    SetConnection(this, args);
                }
            }
            else
            {
                //disconnect
                State = MouseStates.Normal;
                RoomConnectionArgs args = new RoomConnectionArgs(refHoveredNode.Source.RoomName,
                                                                 refHoveredNode.Target.RoomName,
                                                                 refHoveredNode.Direction,
                                                                 ConnectionType.Disconnect);
                refHoveredNode.SetTarget(null);
                if (RemoveConnection != null)
                {
                    RemoveConnection(this, args);
                }
            }
        }
 private void MoveSelectedImages(MouseMoveArgs mma)
 {
     refVirtualDomain.MoveSelectedImages(new Point(mma.Current.X - mma.Offset.X, mma.Current.Y - mma.Offset.Y));
 }
 private bool PointInGroup(MouseMoveArgs mma)
 {
     return(refVirtualDomain.IsPointInSelectionGroup(mma.Current.X, mma.Current.Y));
 }
示例#10
0
 private bool ActivateMouseover(MouseMoveArgs mma)
 {
     return(refVirtualDomain.OnActivateImage(mma.Current.X, mma.Current.Y));
 }
示例#11
0
        private void DoAction(MouseActions mouseAction, MouseMoveArgs mma, MouseEvents triggeringEvent)
        {
            switch (mouseAction)
            {
            /*
             * Normal
             */
            case MouseActions.NormalOrHover:
            {
                if (NodeHover(mma))
                {
                    State           = MouseStates.NodeHover;
                    PrevState       = State;
                    PrevStateAction = mouseAction;
                    break;
                }
                if (HilightMouseover(mma))
                {
                    State = MouseStates.Hover;
                }
                else
                {
                    State = MouseStates.Normal;
                }
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }

            case MouseActions.Activate:
            {
                if (ActivateMouseover(mma))
                {
                    State = MouseStates.DraggingImage;
                }
                else
                {
                    State = MouseStates.Normal;
                }

                break;
            }

            case MouseActions.MoveImage:
            {
                //state stays as MouseState.DraggingImage
                //MoveSelectedImages(mma);

                //if(mma.Current.X > this.refViewPort.ViewWidth + Globals.ImageBoxProperties.width)
                //    {
                //    //if the mouse is within within the 'auto scroll margin'
                //    //we stay in that state and calculate any movement
                //    State = MouseStates.AutoDragging;
                //    AutoScrollSelectedImage(mma);
                //    }
                //else{
                //    //otherwise go back to regular image draging
                //    State = MouseStates.DraggingImage;
                MoveSelectedImages(mma);
                //	}
                break;
            }

            case MouseActions.EnterHover:
            {
                State           = MouseStates.Hover;
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }

            case MouseActions.EnterNormal:
            {
                State           = MouseStates.Normal;
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }

            case MouseActions.EnterPreviousMode:
            {
                State = PrevState;

                this.DoAction(PrevStateAction, mma, triggeringEvent);
                break;
            }

            case MouseActions.EnterGroupMode:
            {
                State           = MouseStates.GroupMode;
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }

            case MouseActions.Context:
            {
                PrevState       = State;
                State           = MouseStates.ContextMenu;
                PrevState       = State;
                PrevStateAction = mouseAction;
                ShowContextMenu(mma);
                break;
            }

            case MouseActions.DragRect:
            {
                if (ActivateSelectionRect != null)
                {
                    ActivateSelectionRect(this, mma);
                }
                State = MouseStates.DraggingSelectionRect;

                //hilight ones in selection rect
                SelectGroup(mma);
                break;
            }

            case MouseActions.DragLine:
            {
                if (ActivateDragLine != null)
                {
                    ActivateDragLine(this, mma);
                }
                State = MouseStates.DraggingLine;
                break;
            }

            case MouseActions.EndDragLine:
            {
                ConnectRoom(mma);
                break;
            }

            case MouseActions.SelectGroup:
            {
                if (DeactivateSelectionRect != null)
                {
                    DeactivateSelectionRect(this, null);
                }

                if (SelectGroup(mma))
                {
                    State = MouseStates.GroupMode;
                }
                else
                {
                    State = MouseStates.Normal;
                }
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }

            case MouseActions.GrabGroup:
            {
                if (PointInGroup(mma))
                {
                    State = MouseStates.DraggingGroup;
                }
                else
                {
                    //if we didn't select an object in the group, we can still see
                    //if anything was at least activated
                    if (HilightMouseover(mma))
                    {
                        State = MouseStates.Hover;
                        if (ActivateMouseover(mma))
                        {
                            State = MouseStates.DraggingImage;
                        }
                    }
                    else
                    {
                        State = MouseStates.DraggingSelectionRect;
                    }
                }
                break;
            }

            case MouseActions.MoveGroup:
            {
                //state stays MouseStates.DraggingGroup
                MoveSelectedImages(mma);
                break;
            }

            case MouseActions.DeselctAndContext:
            {
                DeselectGroup();
                State = MouseStates.ContextMenu;
                ShowContextMenu(mma);
                break;
            }

            case MouseActions.AutoDrag:
            {
                if (mma.Current.X > this.refViewPort.ViewWidth + Globals.ImageBoxProperties.width)
                {
                    //if the mouse is within within the 'auto scroll margin'
                    //we stay in that state and calculate any movement
                    State = MouseStates.AutoDragging;
                    AutoScrollSelectedImage(mma);
                }
                else
                {
                    //otherwise go back to regular image draging
                    State = MouseStates.DraggingImage;
                    MoveSelectedImages(mma);
                }
                break;
            }

            /*
             * Alternate Modes
             */
            case MouseActions.EnterAltMode:
            {
                State           = MouseStates.AltMode;
                PrevState       = State;
                PrevStateAction = mouseAction;
                //DeselectGroup(); //no hovering in this mode, remove all hilights from imagboxes
                break;
            }

            case MouseActions.EnterDraggingView:
            {
                State = MouseStates.DraggingView;
                break;
            }

            case MouseActions.EnterDraggingViewGroup:
            {
                State = MouseStates.DraggingViewGroup;
                break;
            }

            case MouseActions.MoveView:
            {
                //state stays MouseActions.DraggingView

                //Keep in mind that we want the camera to move the opposite direction
                //of the mouse so that the 'background' appears to move in sync with
                //mouse. That's why we need to use negative offsets.
                refVirtualDomain.MoveCamera((mma.Offset.X - mma.Current.X) / Globals.GUI.ViewDragSpeedModifier, (mma.Offset.Y - mma.Current.Y) / Globals.GUI.ViewDragSpeedModifier);
                break;
            }

            case MouseActions.WheelViewVertically:
            {
                refVirtualDomain.MoveCamera(0, (-mma.Delta) / Globals.GUI.ViewDragSpeedModifier);
                break;
            }

            case MouseActions.EnterShiftedMode:
            {
                State           = MouseStates.ShiftMode;
                PrevState       = State;
                PrevStateAction = mouseAction;
                //DeselectGroup(); //no hovering in this mode, remove all hilights from imagboxes
                break;
            }

            case MouseActions.WheelViewHorizontally:
            {
                refVirtualDomain.MoveCamera((-mma.Delta) / Globals.GUI.ViewDragSpeedModifier, 0);

                break;
            }

            case MouseActions.EnterAltGroupMode:
            {
                State           = MouseStates.AltGroupMode;
                PrevState       = State;
                PrevStateAction = mouseAction;
                break;
            }


            default:
            {
                break;
            }
            }

            if (State == MouseStates.DraggingView)
            {
                refParent.Cursor = System.Windows.Forms.Cursors.NoMove2D;
            }
            else
            {
                refParent.Cursor = System.Windows.Forms.Cursors.Hand;
            }
            return;
        }