初步添加用户头像支持,仍需要完善

This commit is contained in:
dathlin
2017-07-06 22:04:52 +08:00
parent 5b75e2d0eb
commit 0089df2e15
7 changed files with 351 additions and 142 deletions

View File

@@ -37,6 +37,22 @@
this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabel_time = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel_right = new System.Windows.Forms.Panel();
this.label_file_count = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
@@ -61,26 +77,13 @@
this.panel_left = new System.Windows.Forms.Panel();
this.label10 = new System.Windows.Forms.Label();
this.panel_main = new System.Windows.Forms.Panel();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.statusStrip1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.panel_right.SuspendLayout();
this.panel_left.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// statusStrip1
@@ -158,6 +161,135 @@
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// 管理员ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.Team_32xLG;
this.ToolStripMenuItem.Name = "管理员ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(100, 31);
this.ToolStripMenuItem.Text = "管理员";
//
// 更改公告ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更改公告ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "更改公告";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 日志查看ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "日志查看ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "日志查看";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 远程更新ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "远程更新ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "远程更新";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 注册账号ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "注册账号ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "注册账号";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 消息发送ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "消息发送ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "消息发送";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 开发中心ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "开发中心ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "开发中心";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 设置ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.PickAxe_32xLG;
this.ToolStripMenuItem.Name = "设置ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(80, 31);
this.ToolStripMenuItem.Text = "设置";
//
// 修改密码ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "修改密码ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "修改密码";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 留言板ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "留言板ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "留言板";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.ASCube_32xLG;
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(80, 31);
this.ToolStripMenuItem.Text = "关于";
//
// 关于本软件ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "关于本软件ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "关于本软件";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 更新日志ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更新日志ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "更新日志";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 版本号说明ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本号说明ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "版本号说明";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 意见反馈ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "意见反馈ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "意见反馈";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// panel_right
//
this.panel_right.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@@ -376,7 +508,7 @@
this.label_Announcement.ForeColor = System.Drawing.Color.Red;
this.label_Announcement.Location = new System.Drawing.Point(283, 0);
this.label_Announcement.Name = "label_Announcement";
this.label_Announcement.Size = new System.Drawing.Size(638, 33);
this.label_Announcement.Size = new System.Drawing.Size(593, 33);
this.label_Announcement.TabIndex = 3;
this.label_Announcement.Text = "[公告]";
this.label_Announcement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@@ -407,139 +539,28 @@
this.panel_main.Size = new System.Drawing.Size(557, 419);
this.panel_main.TabIndex = 5;
//
// 管理员ToolStripMenuItem
// 更换头像ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.Team_32xLG;
this.ToolStripMenuItem.Name = "管理员ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(100, 31);
this.ToolStripMenuItem.Text = "管理员";
this.ToolStripMenuItem.Name = "更换头像ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "更换头像";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 更改公告ToolStripMenuItem
// pictureBox1
//
this.ToolStripMenuItem.Name = "更改公告ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "更改公告";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 日志查看ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "日志查看ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "日志查看";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 账户管理ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "账户管理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "账户管理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 远程更新ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "远程更新ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "远程更新";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 注册账号ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "注册账号ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "注册账号";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 消息发送ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "消息发送ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "消息发送";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 设置ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.PickAxe_32xLG;
this.ToolStripMenuItem.Name = "设置ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(80, 31);
this.ToolStripMenuItem.Text = "设置";
//
// 修改密码ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "修改密码ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "修改密码";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 留言板ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "留言板ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "留言板";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 关于ToolStripMenuItem
//
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem,
this.ToolStripMenuItem});
this.ToolStripMenuItem.Image = global::.Properties.Resources.ASCube_32xLG;
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(80, 31);
this.ToolStripMenuItem.Text = "关于";
//
// 关于本软件ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "关于本软件ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "关于本软件";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 更新日志ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "更新日志ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "更新日志";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 版本号说明ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "版本号说明ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "版本号说明";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 意见反馈ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "意见反馈ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(184, 32);
this.ToolStripMenuItem.Text = "意见反馈";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
//
// 开发中心ToolStripMenuItem
//
this.ToolStripMenuItem.Name = "开发中心ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(164, 32);
this.ToolStripMenuItem.Text = "开发中心";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(887, 1);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(32, 32);
this.pictureBox1.TabIndex = 6;
this.pictureBox1.TabStop = false;
//
// FormMainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(921, 476);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.panel_main);
this.Controls.Add(this.panel_left);
this.Controls.Add(this.label_Announcement);
@@ -561,6 +582,7 @@
this.panel_right.ResumeLayout(false);
this.panel_right.PerformLayout();
this.panel_left.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -617,6 +639,8 @@
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem ToolStripMenuItem;
private System.Windows.Forms.PictureBox pictureBox1;
}
}

View File

@@ -116,6 +116,8 @@ namespace 软件系统客户端模版
}
//启动定时器
TimeTickInitilization();
//显示头像
DownloadUserPortraint();
}
private void FormMainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
@@ -294,6 +296,12 @@ namespace 软件系统客户端模版
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangePortrait();
}
#endregion
#region
@@ -609,8 +617,104 @@ namespace 软件系统客户端模版
#endregion
#region
private string GetPortraitPath()
{
string path = Application.StartupPath + @"\Portrait\" + UserClient.UserAccount.UserName;
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
}
return path;
}
private void ChangePortrait()
{
using (FormPortraitSelect fps = new FormPortraitSelect())
{
if (fps.ShowDialog() == DialogResult.OK)
{
string path = GetPortraitPath();
string guid = Guid.NewGuid().ToString("N");
string path300 = path + @"\" + PortraitSupport.LargePortraitHead + guid + ".png";
string path32 = path + @"\" + PortraitSupport.SmallPortraitHead + guid + ".png";
Bitmap bitmap300 = (Bitmap)fps.GetSpecifiedSizeImage(300);
bitmap300.Save(path300);
Bitmap bitmap32 = (Bitmap)fps.GetSpecifiedSizeImage(32);
bitmap32.Save(path32);
//传送服务器
bitmap300.Dispose();
bitmap32.Dispose();
using (FormFileOperate ffo = new FormFileOperate(CommonHeadCode.KeyToken, new System.Net.IPEndPoint(
System.Net.IPAddress.Parse(UserClient.ServerIp), CommonLibrary.CommonLibrary.Port_Portrait_Server),
new string[]
{
path300,
path32
}, "Files", "Portrait", UserClient.UserAccount.UserName))
{
ffo.ShowDialog();
}
DownloadUserPortraint();
}
}
}
private void DownloadUserPortraint()
{
string path = GetPortraitPath();
//获取服务器文件名称
OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
if(result.IsSuccess)
{
if(result.Content[0]=='Y')
{
//服务器存在头像
string fileName = PortraitSupport.GetSmallPortraitFileName(path);
string serverName = result.Content.Substring(1);
if (!string.IsNullOrEmpty(fileName))
{
if (PortraitSupport.GetSmallPortraitFileName(path).Contains(serverName))
{
//加载本地头像
pictureBox1.LoadAsync(fileName);
}
else
{
//头像已经换了
P1:
result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode., UserClient.UserAccount.UserName);
if(result.IsSuccess)
{
byte[] data = Convert.FromBase64String(result.Content);
System.IO.File.WriteAllBytes(path + @"\" + serverName, data);
pictureBox1.LoadAsync(path + @"\" + serverName);
}
}
}
else
{
//客户端不存在头像
goto P1;
}
}
else
{
//服务器不存在头像,本次加载结束
}
}
}
#endregion
}
}