示例#1
0
 public MatchDialog(MatchRequest request) : this()
 {
     userNameTextBox.Text    = request.OpponentName;
     userNameTextBox.Enabled = false;
     if (request.Color == "W")
     {
         whiteButton.Checked = true;
     }
     boardSizeUpDown.Value = request.BoardSize;
     timeUpDown.Value      = request.BaseTime;
     byouyomiUpDown.Value  = request.Byouyomi;
 }
示例#2
0
 public void Match(MatchRequest request)
 {
     if (Games.Count > 0)
     {
         MessageBox.Show("Sorry, but playing multiple games isn't supported yet",
                         "Note",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Asterisk,
                         MessageBoxDefaultButton.Button1);
         return;
     }
     Client.WriteLine("match " +
                      request.OpponentName + " " +
                      request.Color + " " +
                      request.BoardSize + " " +
                      request.BaseTime + " " +
                      request.Byouyomi);
 }
示例#3
0
        public MatchDialog(MatchRequest request,
                           IgsPlayerInfo stats) : this(request)
        {
            if (Environment.OSVersion.Platform == PlatformID.WinCE)
            {
                userNameTextBox.Width = 0;
                var statsButton = new Button()
                {
                    Text   = "?",
                    Height = userNameTextBox.Height,
                    Width  = userNameTextBox.Height
                };

                var innerTable = new LayoutTable(1, 2);
                innerTable.Fill(userNameTextBox, statsButton);
                innerTable.FixRows();
                innerTable.FixColumns(1);

                table.PutLayout(innerTable, 0, 1);
                table.Apply(this, this.ClientRectangle);

                statsButton.Click += delegate { notification.Visible = true; };

                notification = new Notification()
                {
                    Text = "<html><body><form method='GET' action='notify'><hr/>" +
                           "Name: " + stats.Name +
                           "<br/>Rank: " + stats.Rank.ToString() +
                           "<br/>Wins/Losses: " + stats.GamesWon + "/" +
                           stats.GamesLost +
                           "<hr/></form></body></html>",
                    Caption         = "Stats of " + stats.Name,
                    InitialDuration = 10,
                    Icon            = ConfigManager.GetIcon("game")
                };
            }
        }
示例#4
0
        private void ReadInfo(List <string> lines)
        {
            if (lines[0].StartsWith("Match["))
            {
                var data = lines[1];
                Console.WriteLine(data);
                data = data.Substring(data.IndexOf('<') + 1, data.IndexOf('>') - data.IndexOf('<') - 1);
                Console.WriteLine(data);
                var items = data.Split(' ');
                IncomingRequest = new MatchRequest(items[1],
                                                   items[2],
                                                   Convert.ToInt32(items[3]),
                                                   Convert.ToInt32(items[4]),
                                                   Convert.ToInt32(items[5]));
                OnMatchRequestReceived(new EventArgs());
            }
            else if (lines[0].StartsWith("NMatch "))
            {
                var data = lines[0];
                var name = data.Remove(0, 22);
                name = name.Substring(0, name.IndexOf('('));
                Console.WriteLine(data);
                data = data.Substring(data.IndexOf('(') + 1, data.IndexOf(')') - data.IndexOf('(') - 1);
                Console.WriteLine(data);
                var items = data.Split(' ');

                IncomingNRequest = new NMatchRequest(name,
                                                     items[0],
                                                     Convert.ToInt32(items[1]),
                                                     Convert.ToInt32(items[2]),
                                                     Convert.ToInt32(items[3]),
                                                     Convert.ToInt32(items[4]),
                                                     Convert.ToInt32(items[5]));
                OnNMatchRequestReceived(new EventArgs());
            }
            else if (lines[0].EndsWith("Game has been adjourned.") ||
                     lines[0].EndsWith("has resigned the game."))
            {
                OnGameEnded(new IGSGameEventArgs(Games[0]));
                Games.Remove(Games[0]);
                MessageBox.Show(lines[0],
                                "Info",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk,
                                MessageBoxDefaultButton.Button1);
            }
            else if (lines[0].EndsWith("has restored your old game.") ||
                     lines[0].EndsWith("declines your request for a match.") ||
                     lines[0].EndsWith("has typed done.") ||
                     lines[0].StartsWith("Set the komi to") ||
                     (lines[0].IndexOf("wants the komi to be") >= 0))
            {
                MessageBox.Show(lines[0],
                                "Info",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk,
                                MessageBoxDefaultButton.Button1);
            }
            else if (lines[0].EndsWith("Board is restored to what it was when you started scoring"))
            {
                if (Games.Count > 0)
                {
                    Games[0].CurrentNode.Markup.FreeDeadStones();
                    OnGameChanged(new IGSGameEventArgs(Games[0]));
                }
            }
        }