/// <summary> /// Callback for the selfplay delay timer /// </summary> /// <param name="sender">Timer object</param> /// <param name="e">Ignored</param> private void SelfPlayDelayTick(object sender, EventArgs e) { System.Windows.Forms.Timer timer = sender as System.Windows.Forms.Timer; if (timer != null) { chessGame?.StopEngineSelfPlay(); SelfPlayResultEventArgs spea = new SelfPlayResultEventArgs(true); selfPlayToolStripSelfPlay_Click(sender, spea); timer.Enabled = false; } }
/// <summary> /// Menu handler for File->Self Play /// </summary> /// <param name="sender">Ignored</param> /// <param name="e">Ignored</param> private void selfPlayToolStripSelfPlay_Click(object sender, EventArgs e) { SelfPlayResultEventArgs spea = e as SelfPlayResultEventArgs; // Check if this is an event from our handler if (spea != null && (spea.Continue)) { NewGame(TypeGame.Clasic, String.Empty, PieceColor.White, selfPlayThinkTime); chessGame?.StartEngineSelfPlay(); } else { // Otherwise, pop a new dialog for the thinktime NewGameDialog newGameDialog = new NewGameDialog(NewGameDialog.NewGameType.SelfPlay); DialogResult result = newGameDialog.ShowDialog(this); if (result == DialogResult.OK) { selfPlayThinkTime = newGameDialog.Info.ThinkTime; NewGame(newGameDialog.Info.Type, String.Empty, PieceColor.White, selfPlayThinkTime); chessGame?.StartEngineSelfPlay(); } } }