Exemple #1
0
        /// <summary>
        /// It handles the StartClient button's click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartClient_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(ServerPortValue.Text))
            {
                MessageBox.Show("Please enter server port.", "Client", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(ServerIPValue.Text))
            {
                MessageBox.Show("Please enter server IP address.", "Client", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            IPAddress ipAddress;

            if (!IPAddress.TryParse(ServerIPValue.Text, out ipAddress))
            {
                MessageBox.Show("Please enter correct server IP address.", "Client", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!GetConnection())
            {
                return;
            }

            StartClient.Enabled = false;
            ShareFolder.Enabled = true;
            Refresh.Enabled     = true;

            XmlDocument doc = new XmlDocument();

            doc.Load("MyConfig.xml");
            XmlElement root = doc.DocumentElement;

            string          userName = root.Attributes["username"].Value;
            int             port     = int.Parse(root.Attributes["port"].Value);
            string          ip       = root.Attributes["ip"].Value;
            DBServiceClient srv      = new DBServiceClient();

            srv.addUserToOnlineUsersTable(userName, port, ip);
        }