Пример #1
0
        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);
        }
Пример #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (this.serverInfo.Password)
            {
                if (this.textboxPassword.Text.Length > 0)
                {
                    ProcessStartInfo processInfo = new ProcessStartInfo();
                    processInfo.FileName         = "samp.exe";
                    processInfo.WorkingDirectory = this.pathGame;
                    processInfo.Arguments        = String.Format("{0} {1}", this.serverInfo.Server.ToString(), this.textboxPassword.Text);
                    Process.Start(processInfo);
                }
                else
                {
                    TitleWarning title = new TitleWarning();
                    string       msg   = "Server zahtjeva lozinku pristupa, molimo vas unesite je!";

                    MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            else
            {
                if (this.textboxUser.Text.Length == 0)
                {
                    TitleWarning title = new TitleWarning();
                    string       msg   = "Molimo vas unesite Nick prije prijave na server.";

                    MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                ProcessStartInfo processInfo = new ProcessStartInfo();
                processInfo.FileName         = "samp.exe";
                processInfo.WorkingDirectory = this.pathGame;
                processInfo.Arguments        = String.Format("{0}", this.serverInfo.Server.ToString());
                Process.Start(processInfo);
            }
        }
Пример #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.sampRegistry = new SampRegistry();

            if (this.sampRegistry.Valid() && this.sampRegistry.Read())
            {
                this.textboxUser.Text = this.sampRegistry.PlayerName;
                this.pathGame         = this.sampRegistry.GetPath();
            }
            else
            {
                TitleWarning title = new TitleWarning();
                string       msg   = "Nemate podesen ili instaliran GTA San Andreas i SAMP.\n" +
                                     "Da li zelite sada odabrati lokaciju instalirane igre?";

                DialogResult result = MessageBoxAdv.Show(msg, title.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (result == DialogResult.Yes)
                {
                    this.sampRegistry.Default();

                    if (folderDialog.ShowDialog() == DialogResult.OK)
                    {
                        this.sampRegistry.SetPath(folderDialog.SelectedPath);
                        this.pathGame = folderDialog.SelectedPath;
                        this.sampRegistry.Write();
                    }
                }

                this.textboxUser.Text = this.sampRegistry.PlayerName;
            }

            this.userFile = new UserFile();

            if (!this.userFile.Read() || this.userFile.Servers.Length == 0)
            {
                EnterForm enter = new EnterForm();
                enter.ShowDialog();

                if (enter.Server != null)
                {
                    serverPing = new ServerPing(serverIp);
                    serverInfo = new ServerInfo(serverIp);

                    workerStatus.RunWorkerAsync(0);
                    return;
                }
            }
            else
            {
                this.serverIp = new ServerIp(this.userFile.Servers[0].Address, this.userFile.Servers[0].Port);

                if (this.serverIp.Address == null)
                {
                    EnterForm enter = new EnterForm();
                    enter.ShowDialog();

                    if (enter.Server != null)
                    {
                        serverPing = new ServerPing(serverIp);
                        serverInfo = new ServerInfo(serverIp);

                        workerStatus.RunWorkerAsync(0);
                        return;
                    }
                }
            }

            serverPing = new ServerPing(serverIp);
            serverInfo = new ServerInfo(serverIp);
            workerStatus.RunWorkerAsync(0);
        }