public void Init() { Text = DestUser.Name + "(" + DestUser.Account + ")"; Tuple <Font, Color> tuple = StyleConfigManager.GetStyleConfig(GlobalClass.CurrentUser.Id); fontDialog.Font = tuple.Item1; colorDialog.Color = tuple.Item2; sendRichBox.Font = tuple.Item1; sendRichBox.ForeColor = tuple.Item2; }
private void changeFontBtn_Click(object sender, EventArgs e) { fontDialog.ShowDialog(); sendRichBox.Font = fontDialog.Font; StyleConfigManager.UpdateFont(fontDialog.Font, GlobalClass.CurrentUser.Id); }
private void changeColorBtn_Click(object sender, EventArgs e) { colorDialog.ShowDialog(); sendRichBox.ForeColor = colorDialog.Color; StyleConfigManager.UpdateColor(colorDialog.Color.ToArgb(), GlobalClass.CurrentUser.Id); }
private void okBtn_Click(object sender, EventArgs e) { string account = accTB.Text; string pwd = pwdTB.Text; string conPwd = conTB.Text; string name = nameTB.Text; DateTime birth = birthTP.Value; bool maleChecked = male.Checked; bool famaleChecked = famale.Checked; string fileName = pathTB.Text; if (string.IsNullOrEmpty(account)) { MessageBox.Show("请输入账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(pwd)) { MessageBox.Show("请输入密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (pwd.Length < 6) { MessageBox.Show("密码应不低于6位", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(conPwd)) { MessageBox.Show("请输入确认密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (conPwd != pwd) { MessageBox.Show("两次密码不一致", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrEmpty(account)) { MessageBox.Show("请输入昵称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!famaleChecked && !maleChecked) { MessageBox.Show("请选择性别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string headimage = ""; if (!string.IsNullOrEmpty(fileName)) { bool isExistFile = File.Exists(fileName); if (!isExistFile) { MessageBox.Show("头像文件格式不正确或文件不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Tuple <bool, string> tuple = Util.GetBase64StrByImage(fileName); if (tuple.Item1) { MessageBox.Show("文件超过大小的限制", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } headimage = tuple.Item2; } char sex = maleChecked ? '男' : '女'; JObject obj = new JObject(); obj.Add("account", account); obj.Add("password", pwd); obj.Add("name", name); obj.Add("sex", sex); obj.Add("birthday", birth); obj.Add("headimage", headimage); JArray jArray = new JArray(); JObject jObject = new JObject(); jObject.Add("name", "我的好友"); jObject.Add("members", ""); jArray.Add(jObject); obj.Add("friends", jArray.ToString()); string result = HTTPUtil.SendPostRequest(Util.GetHttpUrl() + "/regist", obj.ToString()); if (result != "注册失败!") { MessageBox.Show("注册成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); StyleConfig sc = new StyleConfig() { UserId = int.Parse(result), Color = 0, Size = 12.0f, FontFamily = "楷体", FontStyle = 1 }; StyleConfigManager.AddConfig(sc); this.Close(); } else { MessageBox.Show("result", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }