Exemplo n.º 1
0
        void Worker_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            // pbCalculationProgress.Value = e.ProgressPercentage;
            //  if (e.UserState != null)

            string Buffer = (string)(e.UserState);

            if (Buffer.Length != 65)
            {
                Messages.Items.Add(e.UserState);
            }
            if (Buffer == "Connected")
            {
                Game1.InitializeNewGameData();
                DrawBoardandPawns(Game1.Pawns, Game1.BoardColor);
            }

            if (Buffer.Length == 65)
            {
                bool ok = true;
                foreach (char c in Buffer)
                {
                    if (!(('0'.Equals(c)) || ('1'.Equals(c)) || ('2'.Equals(c)) || ('3'.Equals(c)) || ('4'.Equals(c))))
                    {
                        ok = false;
                    }
                }
                if (ok)
                {
                    Game1.ConvertMessageToPawnsAndRound((string)e.UserState);
                    DeleteBoard();
                    DrawBoardandPawns(Game1.Pawns, Game1.BoardColor);
                    if (Game1.GameStarted)
                    {
                        WinConditionWihoutDisconnect();
                    }
                }
            }
            UpdateInfoBoxes();
        }