예제 #1
0
 public Position boxShouldSnapToWhichPosition(WordBox box)
 {
     switch (studyController.currentPosition)
     {
         case HaikuStudyPosition.SideBySide:
             {
                 return Position.One;
             }
         case HaikuStudyPosition.Corner:
             {
                 if (HaikuStudyController.positionOneAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                     return Position.One;
                 if (HaikuStudyController.positionTwoAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                     return Position.Four;
                 break;
             }
         case HaikuStudyPosition.OppositeSides:
             {
                 if (HaikuStudyController.positionOneAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                     return Position.One;
                 if (HaikuStudyController.positionTwoAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                     return Position.Three;
                 break;
             }
     }
     return Position.One;
 }
예제 #2
0
파일: WordBox.cs 프로젝트: solson/DSAE
        public static WordBox CreateWordBox(string withWord, float withRotationAngle, WordBoxCategory withCategory)
        {
            WordBox newWordBox = new WordBox();
            newWordBox.textString = withWord;
            newWordBox.rotationAngle = withRotationAngle;
            newWordBox.resizeToFitCurrentWord();

            newWordBox.category = withCategory;
            return newWordBox;
        }
예제 #3
0
파일: Form1.cs 프로젝트: solson/DSAE
        public void toggleWordBoxUnderCursorNumberDragging(int cursorNumber, Point location)
        {
            bool isUser1Dragging = false;
            bool isUser2Dragging = false;

            if (boxBeingDraggedByUser1 == null)
                isUser1Dragging = true;
            if (boxBeingDraggedByUser2 == null)
                isUser2Dragging = true;

            if (cursorNumber == 1)
            {
                if (boxBeingDraggedByUser1 == null)
                {
                    GetChild1(location);
                    if (boxBeingDraggedByUser1 != null)
                    {
                        if (boxBeingDraggedByUser2 == boxBeingDraggedByUser1)
                            boxBeingDraggedByUser2 = null;

                        // Reorder the boxes so the grabbed one is drawn on top
                        currentWordBoxes.Remove(boxBeingDraggedByUser1);
                        currentWordBoxes.Add(boxBeingDraggedByUser1);

                        boxBeingDraggedByUser1.beginDragging(location, 1);
                        studyController.logPickOrDropEvent(location, user2MouseLocation, isUser1Dragging, isUser2Dragging,
                            boxBeingDraggedByUser1, true, 1);
                    }
                }
                else
                {
                    boxBeingDraggedByUser1.dropped();
                    studyController.logPickOrDropEvent(location, user2MouseLocation, isUser1Dragging, isUser2Dragging,
                            boxBeingDraggedByUser1, false, 1);
                    boxBeingDraggedByUser1 = null;
                }
            }
            else if (cursorNumber == 2)
            {
                if (boxBeingDraggedByUser2 == null)
                {
                    GetChild2(location);
                    if (boxBeingDraggedByUser2 != null)
                    {
                        if (boxBeingDraggedByUser1 == boxBeingDraggedByUser2)
                            boxBeingDraggedByUser1 = null;

                        // Reorder the boxes so the grabbed one is drawn on top
                        currentWordBoxes.Remove(boxBeingDraggedByUser2);
                        currentWordBoxes.Add(boxBeingDraggedByUser2);

                        boxBeingDraggedByUser2.beginDragging(location, 2);
                        studyController.logPickOrDropEvent(user1MouseLocation, location, isUser1Dragging, isUser2Dragging,
                            boxBeingDraggedByUser2,true, 2);
                    }
                }
                else
                {
                    boxBeingDraggedByUser2.dropped();
                    studyController.logPickOrDropEvent(user1MouseLocation, location, isUser1Dragging, isUser2Dragging,
                            boxBeingDraggedByUser2, false, 2);
                    boxBeingDraggedByUser2 = null;
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: solson/DSAE
        public void handleMouseUp(bool right, int playerID)
        {
            if (calibratingKinect)
                return;

            if (right)
            {
                if (playerID == 0)
                    user1RightDown = false;
                if (playerID == 1)
                    user2RightDown = false;

                clicks.Send("right up " + playerID);
            }
            else
            {
                if (playerID == 0 && boxBeingDraggedByUser1 != null)
                {
                    boxBeingDraggedByUser1.dropped();
                    boxBeingDraggedByUser1 = null;
                    boxGrabChannel.Send(new BoxGrabMessage(user1MouseLocation.X, user1MouseLocation.Y, true));
                }
                if (playerID == 1 && boxBeingDraggedByUser2 != null)
                {
                    boxBeingDraggedByUser2.dropped();
                    boxBeingDraggedByUser2 = null;
                    boxGrabChannel.Send(new BoxGrabMessage(user2MouseLocation.X, user2MouseLocation.Y, true));
                }

                clicks.Send("left up " + playerID);
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: solson/DSAE
 private void GetChild2(Point MouseLocation)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new GetChildDelegate2(GetChild2), MouseLocation);
     }
     else
     {
         Control clickedControl = this.getWordBoxAtPoint(MouseLocation);
         if (clickedControl != null)
         {
             boxBeingDraggedByUser2 = (WordBox)clickedControl;
             boxBeingDraggedByUser2.BringToFront();
         }
     }
 }
예제 #6
0
파일: Form1.cs 프로젝트: solson/DSAE
        private void boxGrabChannel_MessagesReceived(IObjectChannel channel)
        {
            object obj;
            while ((obj = channel.DequeueMessage(0)) != null)
            {
                BoxGrabMessage msg = (BoxGrabMessage)obj;

                //updateRemoteMousePosition(msg.X, msg.Y);

                if (msg.Dropped)
                {
                    if (playerID == 0 && boxBeingDraggedByUser2 != null)
                    {
                        boxBeingDraggedByUser2.dropped();
                        boxBeingDraggedByUser2 = null;
                    }
                    else if (playerID == 1 && boxBeingDraggedByUser1 != null)
                    {
                        boxBeingDraggedByUser1.dropped();
                        boxBeingDraggedByUser1 = null;
                    }
                }
                else
                {
                    int otherPlayerID = (playerID == 0) ? 2 : 1;
                    toggleWordBoxUnderCursorNumberDragging(otherPlayerID, new Point(msg.X, msg.Y));
                }
            }
        }
예제 #7
0
        private void addWordBoxToCategory(WordBox newWordBox, WordBoxCategory toCategory)
        {
            if (!currentWordBoxes.ContainsKey(toCategory))
                currentWordBoxes[toCategory] = new List<WordBox>();

            currentWordBoxes[toCategory].Add(newWordBox);
        }
예제 #8
0
        public int thisBoxIsOwnedByWhichUser(WordBox box)
        {
            if (HaikuStudyController.positionOneAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                return 1;
            if (HaikuStudyController.positionTwoAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
                return 2;

            return 0;
        }
예제 #9
0
 public bool shouldBoxSnap(WordBox box)
 {
     if (HaikuStudyController.positionOneAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
         return true;
     if (HaikuStudyController.positionTwoAreaRectangle.IntersectsWith(new Rectangle(box.Location, box.Size)))
         return true;
     return false;
 }
예제 #10
0
            public PickOrDropEvent(string conditionOrder, int newSessionID, HaikuStudyCondition newCondition, bool isPickUp, Point location, int userNum, int isInvasion,
                WordBox inBox)
            {
                timestamp = (DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds;
                sessionID = newSessionID;
                currentCondition = newCondition;

                secondsSinceStart = (DateTime.Now - Utilities.experimentBeganAtTime).TotalSeconds;

                if (isPickUp)
                {
                    pickUpEvent = 1;
                    dropEvent = 0;
                }
                else
                {
                    pickUpEvent = 0;
                    dropEvent = 1;
                }

                locationOfEvent = location;

                user = userNum;
                isAnInvasion = isInvasion;

                box = WordBox.CreateWordBox("", -1.0f, WordBoxCategory.None);
                box.Location = new Point(-1, -1);
                box.originalLocation = new Point(-1, -1);

                if (inBox != null)
                {
                    box.Location = inBox.Location;
                    box.originalLocation = inBox.originalLocation;
                    box.setWord(inBox.textString);
                }
            }
예제 #11
0
        public void logPickOrDropEvent(Point mouse1, Point mouse2, bool is1Down, bool is2Down, WordBox box, bool pickUp, int user)
        {
            int isUser1Invading = 0, isUser2Invading = 0;

            if (positionTwoAreaRectangle.Contains(mouse1))
                isUser1Invading = 1;
            if (positionOneAreaRectangle.Contains(mouse2))
                isUser2Invading = 1;

            if (user == 1)
            {
                PickOrDropEvent pdEvent = new PickOrDropEvent(orderOfConditions, sessionID, currentCondition, pickUp, mouse1, user, isUser1Invading, box);
                HaikuStudyController.pickOrDropEventsLog.Add(pdEvent);
            }
            else if (user == 2)
            {
                PickOrDropEvent pdEvent = new PickOrDropEvent(orderOfConditions, sessionID, currentCondition, pickUp, mouse2, user, isUser2Invading, box);
                HaikuStudyController.pickOrDropEventsLog.Add(pdEvent);
            }
        }