コード例 #1
0
ファイル: Form1.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Constructor for chess form
 /// </summary>
 /// <param name="TheChessGame">Reference to chess game object</param>
 public ChessForm(ChessGame TheChessGame)
 {
     InitializeComponent();
     _Game = TheChessGame;
     Lbl_MyColor.Text = _Game.MyColor.ToString();
     if (_Game.MyColor == PlayerColor.Black)
     {
         Lbl_MyColor.ForeColor = Color.White;
         Lbl_MyColor.BackColor = Color.Black;
     }
     else
     {
         Lbl_MyColor.ForeColor = Color.Black;
         Lbl_MyColor.BackColor = Color.White;
     }
 }
コード例 #2
0
ファイル: ChessProtocol.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Connect to remote chess server
 /// </summary>
 /// <param name="RemoteIP">IP address of remote peer</param>
 /// <param name="RemotePort">Port of remote peer</param>
 public ChessProtocol(IPAddress RemoteIP, int RemotePort)
 {
     IPEndPoint RemoteIPEndPoint = new IPEndPoint(RemoteIP, RemotePort);
     TcpClient ProtocolClient = new TcpClient();
     ProtocolClient.Connect(RemoteIPEndPoint);
     if (ProtocolClient.Connected)
     {
         _ChessNetworkStream = ProtocolClient.GetStream();
         _ChessStreamWriter = new StreamWriter(_ChessNetworkStream);
         _ChessStreamReader = new StreamReader(_ChessNetworkStream);
         _ChessGame = new ChessGame(this, PlayerColor.Black);
         _ChessGame.CreateChessInterface();
         new Thread(new ThreadStart(Read)).Start();
     }
     else
     {
         throw new Exception("Connection to client timed out");
     }
 }
コード例 #3
0
ファイル: GraphicalInterface.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Creates a chessform
 /// </summary>
 /// <param name="TheChessGame">Pointer to the Chessgame</param>
 public void CreateChessForm(ChessGame TheChessGame)
 {
     ChessForm TheChessForm = new ChessForm(TheChessGame);
     TheChessForm.Show();
     TheChessGame.SetChessInterface(TheChessForm);
 }
コード例 #4
0
ファイル: ChessProtocol.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Listen method to be executed by thread
 /// </summary>
 public void Listen()
 {
     TcpListener ChessListener = new TcpListener(_ListenPort);
     ChessListener.Start();
     Socket ChessSocket = ChessListener.AcceptSocket();
     if (ChessSocket.Connected)
     {
         _ChessNetworkStream = new NetworkStream(ChessSocket);
         _ChessStreamReader = new StreamReader(_ChessNetworkStream);
         _ChessStreamWriter = new StreamWriter(_ChessNetworkStream);
         _ChessGame = new ChessGame(this, PlayerColor.White);
         _Nexus.CreateChessFormForChessGame(_ChessGame);
         new Thread(new ThreadStart(Read)).Start();
     }
 }
コード例 #5
0
ファイル: Nexus.cs プロジェクト: szopenfx/code
 /// <summary>
 /// Create a chess form in the main thread using a wretched delegate.
 /// </summary>
 /// <param name="cg">ChessGame</param>
 public void CreateChessFormForChessGame(ChessGame cg)
 {
     CreateChessFormDelegate CreateChessForm
         = new CreateChessFormDelegate(_Interface.CreateChessForm);
     _Interface.Invoke(CreateChessForm, new object[] { cg });
 }