private void buttonOK_Click(object sender, EventArgs e) { string text; this.serverIp = new ServerIp(this.textAddress.Text, (int)this.numericPort.Value); if (this.serverIp.Address == null) { TitleError error = new TitleError(); text = "Server adresa nije validna, pokusajte ponovo unijeti istu."; MessageBoxAdv.Show(text, error.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); serverIp = null; return; } ServerPing sp = new ServerPing(serverIp); if (sp.Ping() > 0) { this.userFile.ServerList.Insert(0, new UserServer(this.textAddress.Text, (int)this.numericPort.Value)); this.userFile.Write(); this.Close(); return; } TitleWarning warn = new TitleWarning(); text = "Server nije odgovorio na zahtjev, pokusajte ponovo potvrditi!"; MessageBoxAdv.Show(text, warn.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning); }
private void buttonOK_Click(object sender, EventArgs e) { workerServer.CancelAsync(); if (gridListServers.SelectedIndex == -1) { TitleError title = new TitleError(); string msg = "Za promjenu servera odaberite isti sa liste prije potvrde!"; MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { int index = gridListServers.SelectedIndex; this.serverIp = serverItems[index].GetServer(); var us = this.userFile.ServerList[index]; this.userFile.ServerList.Remove(userFile.ServerList[index]); this.userFile.ServerList.Insert(0, us); } if (!this.userFile.Write()) { TitleError title = new TitleError(); string msg = "Doslo je do greske prilikom spremanja server liste!"; MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); }
private void buttonAdd_Click(object sender, EventArgs e) { this.Enabled = false; workerServer.CancelAsync(); ServerIp ip = new ServerIp(textAddress.Text, (int)numericPort.Value); if (ip.Address == null) { TitleError title = new TitleError(); string msg = "Server adresa nije validna, molimo vas unesite ispravan ip i port!"; MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } serverInfo = new ServerInfo(ip); if (serverInfo.Info()) { serverItems.Add(new ServerItem(ip, serverInfo.Password, serverInfo.CurrentPlayers, serverInfo.MaxPlayers, serverInfo.Hostname, serverInfo.Gamemode, serverInfo.Language)); } else { serverItems.Add(new ServerItem(ip)); } ListSoruce(); gridListServers.SelectedIndex = -1; buttonDelete.Enabled = false; this.Enabled = true; }