Exemple #1
0
        /// <summary>
        /// Creates a new entry server entry giving a UI dialog.
        /// </summary>
        /// <returns></returns>
        public static IServer CreateServerEntry()
        {
            EditServerForm form = new EditServerForm();

            form.cbbType.SelectedIndex = 0;

            if (form.ShowDialog() == DialogResult.OK)
            {
                /* Gather the info form the form into the resulting object */
                return new RemoteServer(form.edtServerName.Text, form.edtServerHost.Text,
                    Convert.ToInt32(form.edServerPort.Text), form.edtSecurityKey.Text, (ConnectionType)form.cbbType.SelectedIndex, form.cbIsEnabled.Checked);
            }
            else
                return null;
        }
Exemple #2
0
        /// <summary>
        /// Edits a server entry using edit dialog.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <returns></returns>
        public static IServer EditServerEntry(IServer server)
        {
            EditServerForm form = new EditServerForm();

            if (!(server is RemoteServer))
            {
                /* Unsupported server type */
                return null;
            }

            RemoteServer rServer = (RemoteServer)server;

            form.edtServerName.Text = rServer.Name;
            form.edtServerHost.Text = rServer.Host;
            form.edServerPort.Text = rServer.Port.ToString();
            form.cbIsEnabled.Checked = rServer.Enabled;
            form.edtSecurityKey.Text = rServer.SecurityKey;
            form.cbbType.SelectedIndex = (Int32)rServer.ConnectionType;

            if (rServer.SecurityKey != null && rServer.SecurityKey.Length > 0)
                form.cbSecure.Checked = true;

            if (form.ShowDialog() == DialogResult.OK)
            {
                /* Gather the info form the form into the resulting object */
                rServer.Name = form.edtServerName.Text;
                rServer.Host = form.edtServerHost.Text;
                rServer.Port = Convert.ToInt32(form.edServerPort.Text);
                rServer.Enabled = form.cbIsEnabled.Checked;
                rServer.ConnectionType = (ConnectionType)form.cbbType.SelectedIndex;

                if (form.cbSecure.Checked)
                    rServer.SecurityKey = form.edtSecurityKey.Text;
                else
                    rServer.SecurityKey = null;

                return rServer;
            }
            else
                return null;
        }