private void InitPartita() { _socket.Input(new Utility.Messages.GiocatoreProntoMessageEventArgs(_nomeUtente)); _socket.Output -= MasterHandShake; _currentPartita = new PartitaGiocatore(); _currentPartita.Dock = DockStyle.Fill; _currentPartita.BindComponent(_socket); GestoreSchedeGiocatore gestoreSchede = new GestoreSchedeGiocatore(); gestoreSchede.Carica(_path + CurrentDescrittore.IdPartita); _currentPartita.BindComponent(gestoreSchede); ChatComune chatComune = new ChatComune(); _currentPartita.BindComponent(chatComune); ChatCoordinamentoGiocatore chatCoordinamentoGiocatore = new ChatCoordinamentoGiocatore(); _currentPartita.BindComponent(chatCoordinamentoGiocatore); this.form = new Form(); this.form.FormClosing += gestoreSchede.Salva; this.form.FormClosed += LeavePartita; this.form.Controls.Add(_currentPartita); this.form.Size = new System.Drawing.Size(800, 600); System.Drawing.Rectangle resolution = Screen.PrimaryScreen.Bounds; this.form.Location = new System.Drawing.Point(resolution.Width - 800, resolution.Height - 650); this.form.Text = CurrentDescrittore.Nome; this.form.Show(); }
public override void JoinPartita(DescrittorePartita descrittore) { base.JoinPartita(descrittore); if (_currentPartita == null) { try { _chatComune = new ChatComune(); _chatCoordinamentoMaster = new ChatCoordinamentoMaster(); _gestoreSchede = new GestoreSchedeMaster(); _gestoreSchede.Dock = DockStyle.Fill; _gestoreSchede.Carica(_path + descrittore.IdPartita + "/"); _currentPartita = new PartitaMaster(); _currentPartita.Dock = DockStyle.Fill; _currentPartita.BindComponent(_gestoreSchede); _currentPartita.BindComponent(_chatComune); _currentPartita.BindComponent(_chatCoordinamentoMaster); _serverSocket = new MyServerSocket("127.0.0.1", PortEnum.Master); _currentPartita.BindComponent(_serverSocket); _partitaForm = new Form(); _partitaForm.Controls.Add(_currentPartita); _partitaForm.Size = new System.Drawing.Size(800, 600); System.Drawing.Rectangle resolution = Screen.PrimaryScreen.Bounds; _partitaForm.Location = new System.Drawing.Point(0, resolution.Height - 650); _partitaForm.Text = descrittore.Nome; _partitaForm.FormClosing += _gestoreSchede.Salva; _partitaForm.FormClosed += LeavePartita; _partitaForm.Show(); } catch (SocketException) { MessageBox.Show("Master non trovato", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }