public override void UpdateCursor(System.Windows.Forms.Form mainForm, IView view) { ICursorLocation cursorLocation = model.ThisPlayer.CursorLocation; if (cursorLocation is IBoardCursorLocation) { IBoardCursorLocation location = (IBoardCursorLocation)cursorLocation; mainForm.Cursor = (location.Piece == null ? (model.CurrentSelection == null || model.CurrentSelection.Empty ? view.HandCursor : System.Windows.Forms.Cursors.Cross) : view.FingerCursor); /* * mainForm.Cursor = (location.Piece == null ? * (model.CurrentSelection == null || model.CurrentSelection.Empty ? * (model.CurrentGameBox.Reference == model.GameLibrary.DefaultGameBox ? System.Windows.Forms.Cursors.WaitCursor : view.HandCursor) : * System.Windows.Forms.Cursors.Cross) : * view.FingerCursor); */ } else if (cursorLocation is IStackInspectorCursorLocation) { IStackInspectorCursorLocation location = (IStackInspectorCursorLocation)cursorLocation; mainForm.Cursor = (location.Piece == null && location.Icon == StackInspectorIcon.None ? System.Windows.Forms.Cursors.Default : view.FingerCursor); } else if (cursorLocation is IDiceBagCursorLocation) { IDiceBagCursorLocation location = (IDiceBagCursorLocation)cursorLocation; mainForm.Cursor = (location.DiceCount == 0 ? System.Windows.Forms.Cursors.Default : view.FingerDoubleCursor); } else if (cursorLocation is ITabsCursorLocation) { ITabsCursorLocation location = (ITabsCursorLocation)cursorLocation; mainForm.Cursor = (location.Tab == null && location.Icon == TabsIcon.None ? System.Windows.Forms.Cursors.Default : view.FingerCursor); } else if (cursorLocation is IMenuCursorLocation) { IMenuCursorLocation location = (IMenuCursorLocation)cursorLocation; mainForm.Cursor = (location.Item == null ? System.Windows.Forms.Cursors.Default : view.FingerCursor); } else if (cursorLocation is IHandCursorLocation) { IHandCursorLocation location = (IHandCursorLocation)cursorLocation; mainForm.Cursor = (location.Piece == null && location.Icon == HandIcon.None ? System.Windows.Forms.Cursors.Default : (location.Icon == HandIcon.Resize ? System.Windows.Forms.Cursors.HSplit : view.FingerCursor)); } else { mainForm.Cursor = System.Windows.Forms.Cursors.Default; } }
public override void HandleLeftMouseButtonDown() { // over the board if (model.ThisPlayer.CursorLocation is IBoardCursorLocation) { IBoardCursorLocation location = (IBoardCursorLocation)model.ThisPlayer.CursorLocation; // over a piece if (location.Piece != null) { PointF piecePosition = location.Piece.Position; model.ThisPlayer.DragAndDropAnchor = new PointF( location.ModelPosition.X - piecePosition.X, location.ModelPosition.Y - piecePosition.Y); controller.SelectingStackState.StackBottomBeingSelected = location.Piece; controller.State = controller.SelectingStackState; // over an empty space with the stack inspector visible } else if (model.CurrentSelection != null && !model.CurrentSelection.Empty) { controller.State = controller.MovingState; // over an empty space (no stack inspector) } else { controller.State = controller.ScrollingState; } // over the tabs } else if (model.ThisPlayer.CursorLocation is ITabsCursorLocation) { ITabsCursorLocation location = (ITabsCursorLocation)model.ThisPlayer.CursorLocation; // over an icon if (location.Icon != TabsIcon.None) { // Undo if (location.Icon == TabsIcon.Undo) { if (model.CommandManager.CanUndo) { networkClient.Send(new UndoMessage(model.StateChangeSequenceNumber)); } // Redo } else if (location.Icon == TabsIcon.Redo) { if (model.CommandManager.CanRedo) { networkClient.Send(new RedoMessage(model.StateChangeSequenceNumber)); } // Show/Hide hand } else if (location.Icon == TabsIcon.Hand) { if (model.ThisPlayer.Guid != Guid.Empty) { IPlayerHand playerHand = model.CurrentGameBox.CurrentGame.GetPlayerHand(model.ThisPlayer.Guid); if (controller.View.Hand.IsVisible) { controller.View.Hand.IsVisible = false; if (playerHand != null && playerHand.Count == 0) { networkClient.Send(new RemovePlayerHandMessage(model.StateChangeSequenceNumber)); } } else { controller.View.Hand.IsVisible = true; if (playerHand == null) { networkClient.Send(new AddPlayerHandMessage(model.StateChangeSequenceNumber)); } } } // Terrain mode } else if (location.Icon == TabsIcon.TerrainMode) { networkClient.Send(new ChangeModeMessage(model.StateChangeSequenceNumber, (model.CurrentGameBox.CurrentGame.Mode == Mode.Terrain ? Mode.Default : Mode.Terrain))); // Stacking } else if (location.Icon == TabsIcon.Stacking) { networkClient.Send(new ChangeStackingMessage(model.StateChangeSequenceNumber)); // Hide/reveal board } else if (location.Icon == TabsIcon.HideReveal) { Guid visibleBoardOwner = model.CurrentGameBox.CurrentGame.VisibleBoard.Owner; if (model.CurrentGameBox.Reference != model.GameLibrary.DefaultGameBox && model.ThisPlayer.Guid != Guid.Empty) { if (visibleBoardOwner == Guid.Empty || visibleBoardOwner == model.ThisPlayer.Guid) { networkClient.Send(new HideRevealBoardMessage(model.StateChangeSequenceNumber)); } } // Tab scrollers } else if (location.Icon == TabsIcon.FirstTab) { view.Tabs.ShowFirstTab(); } else if (location.Icon == TabsIcon.PreviousTab) { view.Tabs.ShowPreviousTab(); } else if (location.Icon == TabsIcon.NextTab) { view.Tabs.ShowNextTab(); } else if (location.Icon == TabsIcon.LastTab) { view.Tabs.ShowLastTab(); } // over a tab } else if (location.Tab != null) { networkClient.Send(new VisibleBoardChangedMessage(model.StateChangeSequenceNumber, location.Tab.Id)); } // over the stack inspector } else if (model.ThisPlayer.CursorLocation is IStackInspectorCursorLocation) { IStackInspectorCursorLocation location = (IStackInspectorCursorLocation)model.ThisPlayer.CursorLocation; // over an icon if (location.Icon != StackInspectorIcon.None) { // Close if (location.Icon == StackInspectorIcon.Close) { if (model.CurrentSelection != null) { SelectionChangedMessage.SelectionInfo selectionInfo = new SelectionChangedMessage.SelectionInfo(); selectionInfo.StackId = -1; networkClient.Send(new SelectionChangedMessage(model.StateChangeSequenceNumber, selectionInfo)); } // Recycle } else if (location.Icon == StackInspectorIcon.Recycle) { if (model.CurrentSelection != null && !model.CurrentSelection.Empty && !model.CurrentSelection.Stack.AttachedToCounterSection) { // assumption: the stack will remain unchanged in the meantime if (!model.AnimationManager.IsBeingAnimated(model.CurrentSelection.Stack)) { networkClient.Send(new UnpunchSelectionMessage(model.StateChangeSequenceNumber)); } } // Shuffle } else if (location.Icon == StackInspectorIcon.Shuffle) { if (model.CurrentSelection != null && model.CurrentSelection.Stack.Pieces.Length > 1) { // assumption: the stack will remain unchanged in the meantime if (!model.AnimationManager.IsBeingAnimated(model.CurrentSelection.Stack)) { networkClient.Send(new ShuffleMessage(model.StateChangeSequenceNumber)); } } // Invert } else if (location.Icon == StackInspectorIcon.Invert) { if (model.CurrentSelection != null && model.CurrentSelection.Stack.Pieces.Length > 1) { // assumption: the stack will remain unchanged in the meantime if (!model.AnimationManager.IsBeingAnimated(model.CurrentSelection.Stack)) { networkClient.Send(new InvertMessage(model.StateChangeSequenceNumber)); } } } // over a piece } else if (location.Piece != null) { model.ThisPlayer.DragAndDropAnchor = location.AnchorPosition; controller.SelectingPieceState.PieceBeingSelected = location.Piece; controller.State = controller.SelectingPieceState; } // over the hand } else if (model.ThisPlayer.CursorLocation is IHandCursorLocation) { IHandCursorLocation location = (IHandCursorLocation)model.ThisPlayer.CursorLocation; // over an icon if (location.Icon != HandIcon.None) { // Resize handle if (location.Icon == HandIcon.Resize) { controller.State = controller.ResizingHandState; // Pin/Unpin } else if (location.Icon == HandIcon.Pin) { view.Hand.IsPinned = !view.Hand.IsPinned; } // over a piece } else if (location.Piece != null) { model.ThisPlayer.DragAndDropAnchor = location.AnchorPosition; controller.SelectingPieceState.PieceBeingSelected = location.Piece; controller.State = controller.SelectingPieceState; } // over a menu item } else if (model.ThisPlayer.CursorLocation is IMenuCursorLocation) { IMenuCursorLocation location = (IMenuCursorLocation)model.ThisPlayer.CursorLocation; if (!location.Item.IsDisabled && location.Item.UserData != null) { ((ZunTzu.Control.Menu.IMenuItem)location.Item.UserData).Select(controller); } } }