Example #1
0
 private void GamePanel_Load(object sender, EventArgs e)
 {
     Text = $"{Text} ({GameServer.GameAddress}:{GameServer.GamePort})";
     PlayerNameLabel.Text       = PlayerSetting.Username + (PlayerSetting.IsHost ? " (Host)" : "");
     MessageInputText.MaxLength = GameServer.SizeLimit / 2;
     ProtocolProcess.RequestGameSettings();
     ProtocolProcess.OnGameSettingsReceivedEvent += delegate(object o, GameSettingsReceivedEvent ev)
     {
         if (ev.GameSettings != null)
         {
             GameNameText.Invoke((MethodInvoker)(() => GameNameText.Text = ev.GameSettings.GameName));
             PlayerCountLabel.Invoke((MethodInvoker)(() => PlayerCountLabel.Text = $"PLAYERS ({ev.GameSettings.CurrentPlayers}/{ev.GameSettings.GameSize})"));
             StartGameButton.Invoke((MethodInvoker)(() => StartGameButton.Visible = PlayerSetting.IsHost && !ev.GameSettings.GameInProgress));
             PointsRedText.Invoke((MethodInvoker)(() => PointsRedText.Text = ev.GameSettings.DefaultPointValues[0].ToString()));
             PointsBlueText.Invoke((MethodInvoker)(() => PointsBlueText.Text = ev.GameSettings.DefaultPointValues[1].ToString()));
             PointsYellowText.Invoke((MethodInvoker)(() => PointsYellowText.Text = ev.GameSettings.DefaultPointValues[2].ToString()));
             RefreshTimeText.Invoke((MethodInvoker)(() => RefreshTimeText.Text = ev.GameSettings.Timer));
             WinPointText.Invoke((MethodInvoker)(() => WinPointText.Text = ev.GameSettings.Win));
             // TODO: This line would allow for dynamic panel sizing, perhaps figure out the best way to implement this someday?
             // Invoke((MethodInvoker)(() => this.Size = new Size(ev.GameSettings.PanelSize.X, ev.GameSettings.PanelSize.Y)));
         }
     };
 }