Esempio n. 1
0
        private void dgvGameState_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.RowIndex >= dgvGameState.RowCount)
            {
                return;
            }
            if (e.ColumnIndex < 0 || e.ColumnIndex >= dgvGameState.Rows[e.RowIndex].Cells.Count)
            {
                return;
            }

            if (!(dgvGameState.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag is State selectedState))
            {
                return;
            }

            if (selectedState.Equals(_model.CommittedState))
            {
                NavigateEvent?.Invoke(sender,
                                      new BoardNavigationEventArgs
                {
                    EventType = NavigationEventType.ClearMove,
                    Selected  = selectedState
                });
            }
            else
            {
                NavigateEvent?.Invoke(sender,
                                      new BoardNavigationEventArgs
                {
                    EventType = NavigationEventType.ShowHistory,
                    Selected  = selectedState
                });
            }
        }
 private void btnSaveEdits_Click(object sender, EventArgs e)
 {
     NavigateEvent?.Invoke(sender,
                           new BoardNavigationEventArgs {
         EventType = NavigationEventType.Editor, Selected = _model.EditorState
     });
 }
Esempio n. 3
0
        private void lstAvailableMoves_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!(lstAvailableMoves.SelectedItem is ProposedState ps))
            {
                return;
            }
            if (!(ps.Action is GameAction ga))
            {
                return;
            }
            moveListClicked = true;
            NavigateEvent?.Invoke(sender, new BoardNavigationEventArgs {
                EventType = NavigationEventType.ClearMove
            });
            if (ga is GameTargetAction gta)
            {
                InputEvent?.Invoke(sender, new BoardLocationEventArgs {
                    Location = ga.Location, MouseEvent = BoardMouseEventType.LeftDragStart
                });
                InputEvent?.Invoke(sender, new BoardLocationEventArgs {
                    Location = gta.Target, MouseEvent = BoardMouseEventType.LeftDragEnd
                });
            }
            else
            {
                InputEvent?.Invoke(sender, new BoardLocationEventArgs {
                    Location = ga.Location, MouseEvent = BoardMouseEventType.LeftClick
                });
            }

            _model.SelectedVariation = ga.Size;
            RedrawBoard();
            BoardEditorUpdate();
            moveListClicked = false;
        }
Esempio n. 4
0
 public override void OnMove(AxisEventData eventData)
 {
     if (OverrideNavigation)
     {
         OnNavigate.Invoke(eventData);
     }
     else
     {
         DoMove(eventData);
     }
 }
 private void btnImportBoard_Click(object sender, EventArgs e)
 {
     try
     {
         NavigateEvent?.Invoke(sender,
                               new BoardNavigationEventArgs
         {
             EventType = NavigationEventType.LoadGame, Selected = StateSerializer.FromString(txtBoardData.Text.Trim())
         });
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.ToString(), "Unable to load board");
     }
 }
Esempio n. 6
0
        private void btnNewGame_Click(object sender, EventArgs e)
        {
            if (_model.EditMode)
            {
                NavigateEvent?.Invoke(sender, new BoardNavigationEventArgs {
                    EventType = NavigationEventType.ToggleEditMode
                });
            }

            NavigateEvent?.Invoke(sender,
                                  new BoardNavigationEventArgs {
                EventType = NavigationEventType.NewGame, Selected = StateManager.Create()
            });
            btnCommitMove.Select();
        }
Esempio n. 7
0
 public void SendNavigateMessage(NavigateMessageArgs args)
 {
     NavigateEvent?.Invoke(this, args);
 }
Esempio n. 8
0
 private void btnCommitMove_Click(object sender, EventArgs e)
 {
     NavigateEvent?.Invoke(sender, new BoardNavigationEventArgs {
         EventType = NavigationEventType.CommitMove
     });
 }
Esempio n. 9
0
 private void btnEditBoard_Click(object sender, EventArgs e)
 {
     NavigateEvent?.Invoke(sender, new BoardNavigationEventArgs {
         EventType = NavigationEventType.ToggleEditMode
     });
 }