Пример #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtHostAddress.Text.Length <= 0)
            {
                MessageBoxEx.Show(this, "You must specify a host address.");
                return;
            }

            int    port       = 0;
            string portString = txtPort.Text;

            if (portString.Length <= 0 || !int.TryParse(portString, out port))
            {
                MessageBoxEx.Show(this, "You must specify a valid port.");
                return;
            }

            if (txtServerName.Text.Length <= 0)
            {
                MessageBoxEx.Show(this, "You must specify a server name.");
                return;
            }

            bool allPatchesAreValid = true;

            for (int i = 0; i < lstPatches.Items.Count && allPatchesAreValid; i++)
            {
                allPatchesAreValid = (lstPatches.Items[i].SubItems[0].Text.Length > 0);
            }

            if (!allPatchesAreValid)
            {
                MessageBoxEx.Show(this, "One or more pathes contain invlid paths.");
                return;
            }

            Server.Name             = txtServerName.Text;
            Server.HostAddress      = txtHostAddress.Text;
            Server.Port             = port;
            Server.RemoveEncryption = chkRemoveEnc.Checked;
            Server.HasPatches       = lstPatches.Items.Count > 0;
            Server.Description      = txtDescription.Text;

            _storageService.DeleteLocalPatches((int)Server.Id);

            for (int i = 0; i < lstPatches.Items.Count; i++)
            {
                _storageService.AddLocalPatch(
                    (int)Server.Id,
                    lstPatches.Items[i].SubItems[0].Text,
                    lstPatches.Items[i].SubItems[1].Text.ConvertTo <int>());
            }

            OnShardEditAddComplete(this, EventArgs.Empty);
        }