⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 registform.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.btncancel.Location = new System.Drawing.Point(272, 176);
			this.btncancel.Name = "btncancel";
			this.btncancel.Size = new System.Drawing.Size(60, 20);
			this.btncancel.TabIndex = 16;
			this.btncancel.Click += new System.EventHandler(this.btncancel_Click);
			// 
			// lblMessage
			// 
			this.lblMessage.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.lblMessage.ForeColor = System.Drawing.Color.RoyalBlue;
			this.lblMessage.Location = new System.Drawing.Point(24, 192);
			this.lblMessage.Name = "lblMessage";
			this.lblMessage.Size = new System.Drawing.Size(336, 23);
			this.lblMessage.TabIndex = 17;
			// 
			// errorProvider1
			// 
			this.errorProvider1.ContainerControl = this;
			// 
			// cmbserver
			// 
			this.cmbserver.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.cmbserver.BackColor = System.Drawing.SystemColors.Window;
			this.cmbserver.DockPadding.All = 3;
			this.cmbserver.GBorderStyle = gowk.controls.GBorderStyle.Solid;
			this.cmbserver.IsRound = true;
			this.cmbserver.Items.AddRange(new object[] {
														   "Jabber.org"});
			this.cmbserver.Location = new System.Drawing.Point(256, 72);
			this.cmbserver.MaxDropDownItems = 5;
			this.cmbserver.Name = "cmbserver";
			this.cmbserver.SelectedIndex = 0;
			this.cmbserver.SelectedItem = "Jabber.org";
			this.cmbserver.Size = new System.Drawing.Size(80, 22);
			this.cmbserver.TabIndex = 18;
			this.cmbserver.Text = "Jabber.org";
			this.cmbserver.SelectedIndexChanged += new System.EventHandler(this.cmbserver_SelectedIndexChanged);
			// 
			// label7
			// 
			this.label7.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.label7.BackColor = System.Drawing.Color.Transparent;
			this.label7.Location = new System.Drawing.Point(208, 79);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(72, 23);
			this.label7.TabIndex = 19;
			this.label7.Text = "服务器";
			// 
			// RegistForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BorderColor = System.Drawing.Color.Tan;
			this.ClientSize = new System.Drawing.Size(384, 224);
			this.Controls.Add(this.txtEmail);
			this.Controls.Add(this.txtPass2);
			this.Controls.Add(this.txtPass);
			this.Controls.Add(this.txtUser);
			this.Controls.Add(this.cmbserver);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.btncancel);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.lblMessage);
			this.GBorderStyle = gowk.controls.GBorderStyle.DashDotDot;
			this.Name = "RegistForm";
			this.Opacity = 0.8;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "用户注册";
			this.ResumeLayout(false);

		}
		#endregion

		#endregion
		private void ShowMessage(string message)
		{
			this.lblMessage.Text=message;
		}
		private void Callback(gowk.core.JabberEventArgs jea)
		{
			UpdateControls(true);
			if(jea.ReplyPacket==null)
			{
				this.ShowMessage("超时");
			}
			else
			{
				if(jea.ReplyPacket.Type==gowk.core.packets.PacketType.result)
				{
					this.Controls.Clear();
					this.Controls.Add(this.pictureBox1);
					this.Controls.Add(this.lblMessage);
					this.Controls.Add(this.btncancel);
					this.lblMessage.Height=50;
					this.ShowMessage("注册成功!\n要设置个人资料请再设置里面设置!");
					this.Click+=new EventHandler(RegistForm_Click);
				}
				else if(jea.ReplyPacket.Type==gowk.core.packets.PacketType.error)
				{
					this.ShowMessage("错误:"+jea.ReplyPacket.Error.Text);
				}
				else
				{
					this.ShowMessage("未知问题!");
				}
			}
			this.jc.Disconnect();
		}
		protected override void SetRegion()
		{
			this.Region=new Region(this.GetPath(this.GetVirtualRectangle()));
		}
		private void Regist(object user)
		{
			try
			{
				this.ShowMessage("正在连接到服务器...");
				this.jc.Connect();
				this.ShowMessage("已经建立连接!");
			}
			catch(gowk.net.Sockets.ProxyException pe)
			{
				this.ShowMessage("无法连接到代理服务器!");
				this.UpdateControls(true);
				return;
			}
			catch(System.Net.Sockets.SocketException se)
			{
				this.ShowMessage("无法连接到服务器");
				this.UpdateControls(true);
				return;
			}
			//	this.GetRegistFields();
			this.ShowMessage("开始注册....!");
			try
			{
				this.rm.Regist((string)user,this.txtPass.Text,this.txtEmail.Text,new JabberCallBack(this.Callback),20000);
			}
			catch(System.Net.Sockets.SocketException se)
			{
				this.ShowMessage("网络错误,再试一次!");
				System.Threading.Thread.Sleep(200);
				this.jc.Disconnect();
				this.Regist(user);
			}
		}
		private void gButton1_Click(object sender, System.EventArgs e)
		{
			UpdateControls(false);
			this.jc.Jid.Server=this.cmbserver.Text.Trim();
			string user=this.txtUser.Text.Trim();
			System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(this.Regist),user);
		}
		private void UpdateControls(bool canedit)
		{
			this.txtUser.Enabled=this.txtEmail.Enabled=this.txtPass.Enabled=this.txtPass2.Enabled=canedit;
		}
		private void GetRegistFields()
		{
			gowk.core.packets.querys.RegisterQuery rq=new gowk.core.packets.querys.RegisterQuery();
			rq.username=this.txtUser.Text;
		//	rq.password=this.txtPass.Text;
			rq.email=this.txtEmail.Text;
			gowk.core.packets.IQ iq=new IQ();
			iq.To=this.jc.Jid.Server;
			iq.ID=gowk.core.IDGenerator.NewID;
			iq.Type=gowk.core.packets.PacketType.get;
			iq.Query=rq;
			this.rm.Send(iq);
			System.Threading.Thread.Sleep(300);
		}

		private void btncancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	
		public string User
		{
			get{return this.txtUser.Text.Trim()+"@"+this.cmbserver.Text;}
			set{this.txtUser.Text=value;}
		}
		public string Pass
		{
			get{return this.txtPass.Text.Trim();}
			set{this.txtPass.Text=value;}
		}

		private void RegistForm_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void txtUser_Validated(object sender, System.EventArgs e)
		{
			string u=this.txtUser.Text.Trim();
			bool ok=true;
		//	if(u==string.Empty)ok=false;
			if(u.Length<6)ok=false;
			for(int i=0;i<u.Length;i++)
			{
				if("1234567890_qwertyuiopasdfghjklzxcvbnm".IndexOf(u[i])<0)ok=false;
			}
			if(!ok)this.errorProvider1.SetError(this.txtUser, "用户名必须大于6位,并且是英文字母或数字或\"_\"");
			else
				this.errorProvider1.SetError(this.txtUser,null);
		}

		private void txtPass2_Validated(object sender, System.EventArgs e)
		{
			if(this.txtPass.Text.Trim()!=this.txtPass2.Text.Trim() 
				&& this.errorProvider1.GetError(this.txtPass)==string.Empty)
				this.errorProvider1.SetError(this.txtPass2, "密码不一致");
			else
				this.errorProvider1.SetError(this.txtPass2,null);
		}

		private void txtPass_Validated(object sender, System.EventArgs e)
		{
			if(this.txtPass.Text.Trim().Length<6)
				this.errorProvider1.SetError(this.txtPass, "密码必须大于等于六位");
			else
				this.errorProvider1.SetError(this.txtPass,null);
		}

		private void cmbserver_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			this.jc.Jid.Server=this.cmbserver.SelectedItem.ToString().Trim();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -