diff --git a/CommonLibrary/HeadCode.cs b/CommonLibrary/HeadCode.cs index 97c2b5d..b893e46 100644 --- a/CommonLibrary/HeadCode.cs +++ b/CommonLibrary/HeadCode.cs @@ -31,6 +31,7 @@ namespace CommonLibrary public static string 更新公告 { get; } = "A008"; public static string 注册账号 { get; } = "A009"; public static string 更新版本号 { get; } = "A010"; + public static string 请求文件列表 { get; } = "AA01"; diff --git a/软件系统客户端模版/FormMainWindow.Designer.cs b/软件系统客户端模版/FormMainWindow.Designer.cs index 74f9d40..02e6b2d 100644 --- a/软件系统客户端模版/FormMainWindow.Designer.cs +++ b/软件系统客户端模版/FormMainWindow.Designer.cs @@ -50,6 +50,8 @@ this.更新日志ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.版本号说明ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.panel1 = new System.Windows.Forms.Panel(); + this.label_file_count = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); this.linkLabel_logout = new System.Windows.Forms.LinkLabel(); this.label_factory = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); @@ -68,8 +70,6 @@ this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.label_Announcement = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.label_file_count = new System.Windows.Forms.Label(); this.statusStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.panel1.SuspendLayout(); @@ -146,7 +146,7 @@ this.关于ToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(921, 33); + this.menuStrip1.Size = new System.Drawing.Size(921, 35); this.menuStrip1.TabIndex = 1; this.menuStrip1.Text = "menuStrip1"; // @@ -159,41 +159,41 @@ this.远程更新ToolStripMenuItem, this.注册账号ToolStripMenuItem}); this.管理员ToolStripMenuItem.Name = "管理员ToolStripMenuItem"; - this.管理员ToolStripMenuItem.Size = new System.Drawing.Size(84, 29); + this.管理员ToolStripMenuItem.Size = new System.Drawing.Size(84, 31); this.管理员ToolStripMenuItem.Text = "管理员"; // // 更改公告ToolStripMenuItem // this.更改公告ToolStripMenuItem.Name = "更改公告ToolStripMenuItem"; - this.更改公告ToolStripMenuItem.Size = new System.Drawing.Size(164, 30); + 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, 30); + 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, 30); + 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, 30); + 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, 30); + this.注册账号ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); this.注册账号ToolStripMenuItem.Text = "注册账号"; this.注册账号ToolStripMenuItem.Click += new System.EventHandler(this.注册账号ToolStripMenuItem_Click); // @@ -202,13 +202,13 @@ this.设置ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.修改密码ToolStripMenuItem}); this.设置ToolStripMenuItem.Name = "设置ToolStripMenuItem"; - this.设置ToolStripMenuItem.Size = new System.Drawing.Size(64, 29); + this.设置ToolStripMenuItem.Size = new System.Drawing.Size(64, 31); this.设置ToolStripMenuItem.Text = "设置"; // // 修改密码ToolStripMenuItem // this.修改密码ToolStripMenuItem.Name = "修改密码ToolStripMenuItem"; - this.修改密码ToolStripMenuItem.Size = new System.Drawing.Size(164, 30); + this.修改密码ToolStripMenuItem.Size = new System.Drawing.Size(164, 32); this.修改密码ToolStripMenuItem.Text = "修改密码"; this.修改密码ToolStripMenuItem.Click += new System.EventHandler(this.修改密码ToolStripMenuItem_Click); // @@ -219,27 +219,27 @@ this.更新日志ToolStripMenuItem, this.版本号说明ToolStripMenuItem}); this.关于ToolStripMenuItem.Name = "关于ToolStripMenuItem"; - this.关于ToolStripMenuItem.Size = new System.Drawing.Size(64, 29); + this.关于ToolStripMenuItem.Size = new System.Drawing.Size(64, 31); this.关于ToolStripMenuItem.Text = "关于"; // // 关于本软件ToolStripMenuItem // this.关于本软件ToolStripMenuItem.Name = "关于本软件ToolStripMenuItem"; - this.关于本软件ToolStripMenuItem.Size = new System.Drawing.Size(184, 30); + 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, 30); + 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, 30); + this.版本号说明ToolStripMenuItem.Size = new System.Drawing.Size(184, 32); this.版本号说明ToolStripMenuItem.Text = "版本号说明"; this.版本号说明ToolStripMenuItem.Click += new System.EventHandler(this.版本号说明ToolStripMenuItem_Click); // @@ -267,11 +267,32 @@ this.panel1.Controls.Add(this.label1); this.panel1.Dock = System.Windows.Forms.DockStyle.Right; this.panel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.panel1.Location = new System.Drawing.Point(697, 33); + this.panel1.Location = new System.Drawing.Point(697, 35); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(224, 421); + this.panel1.Size = new System.Drawing.Size(224, 419); this.panel1.TabIndex = 2; // + // label_file_count + // + this.label_file_count.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.label_file_count.Cursor = System.Windows.Forms.Cursors.Hand; + this.label_file_count.Location = new System.Drawing.Point(82, 143); + this.label_file_count.Name = "label_file_count"; + this.label_file_count.Size = new System.Drawing.Size(129, 17); + this.label_file_count.TabIndex = 18; + this.label_file_count.Text = "0"; + this.label_file_count.TextAlign = System.Drawing.ContentAlignment.TopRight; + this.label_file_count.Click += new System.EventHandler(this.label_file_count_Click); + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(8, 143); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(68, 17); + this.label8.TabIndex = 17; + this.label8.Text = "文件数量:"; + // // linkLabel_logout // this.linkLabel_logout.AutoSize = true; @@ -321,7 +342,7 @@ this.listBox1.Location = new System.Drawing.Point(11, 183); this.listBox1.Name = "listBox1"; this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.None; - this.listBox1.Size = new System.Drawing.Size(200, 208); + this.listBox1.Size = new System.Drawing.Size(200, 242); this.listBox1.TabIndex = 12; // // label_address @@ -445,25 +466,6 @@ this.label_Announcement.Text = "[公告]"; this.label_Announcement.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(8, 143); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(68, 17); - this.label8.TabIndex = 17; - this.label8.Text = "文件数量:"; - // - // label_file_count - // - this.label_file_count.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.label_file_count.Location = new System.Drawing.Point(82, 143); - this.label_file_count.Name = "label_file_count"; - this.label_file_count.Size = new System.Drawing.Size(129, 17); - this.label_file_count.TabIndex = 18; - this.label_file_count.Text = "0"; - this.label_file_count.TextAlign = System.Drawing.ContentAlignment.TopRight; - // // FormMainWindow // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/软件系统客户端模版/FormMainWindow.cs b/软件系统客户端模版/FormMainWindow.cs index f07f44a..d08073a 100644 --- a/软件系统客户端模版/FormMainWindow.cs +++ b/软件系统客户端模版/FormMainWindow.cs @@ -340,6 +340,15 @@ namespace 软件系统客户端模版 #endregion #region 主界面管理块 + + /// + /// 文件显示的控件 + /// + private UIControls.ShareFilesRender UIControls_Files { get; set; } + + + + /// /// 所有在主界面显示的控件集 /// @@ -354,6 +363,21 @@ namespace 软件系统客户端模版 private void MainRenderInitialization() { //将所有的子集控件添加进去 + + /* + * 例如此处展示了文件控件是如何添加进去的 + * 1.先进行实例化,赋值初始参数 + * 2.添加进项目 + * 3.显示 + */ + + UIControls_Files = new UIControls.ShareFilesRender() + { + Parent = this, + Dock = DockStyle.Fill, + Visible = true, + }; + all_main_render.Add(UIControls_Files); } private void SetShowRenderControl(UserControl control) @@ -379,6 +403,16 @@ namespace 软件系统客户端模版 if (control != null) SetShowRenderControl(control); } + private void label_file_count_Click(object sender, EventArgs e) + { + SetShowRenderControl(UIControls_Files); + UIControls_Files.UpdateFiles(); + } + #endregion + + + + } } diff --git a/软件系统客户端模版/UIControls/ShareFilesRender.Designer.cs b/软件系统客户端模版/UIControls/ShareFilesRender.Designer.cs index 122fbc0..5bcca8c 100644 --- a/软件系统客户端模版/UIControls/ShareFilesRender.Designer.cs +++ b/软件系统客户端模版/UIControls/ShareFilesRender.Designer.cs @@ -29,11 +29,11 @@ private void InitializeComponent() { this.panel1 = new System.Windows.Forms.Panel(); - this.panel2 = new System.Windows.Forms.Panel(); - this.userButton_upload = new BasicFramework.UserButton(); - this.userButton_refresh = new BasicFramework.UserButton(); - this.label1 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.userButton_refresh = new BasicFramework.UserButton(); + this.userButton_upload = new BasicFramework.UserButton(); + this.panel2 = new System.Windows.Forms.Panel(); this.panel1.SuspendLayout(); this.SuspendLayout(); // @@ -51,29 +51,24 @@ this.panel1.Size = new System.Drawing.Size(605, 35); this.panel1.TabIndex = 0; // - // panel2 + // textBox1 // - this.panel2.AutoScroll = true; - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.panel2.Location = new System.Drawing.Point(0, 35); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(605, 291); - this.panel2.TabIndex = 1; + this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.textBox1.Location = new System.Drawing.Point(439, 5); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(161, 23); + this.textBox1.TabIndex = 9; + this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // - // userButton_upload + // label1 // - this.userButton_upload.BackColor = System.Drawing.Color.Transparent; - this.userButton_upload.CustomerInformation = ""; - this.userButton_upload.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); - this.userButton_upload.Font = new System.Drawing.Font("微软雅黑", 9F); - this.userButton_upload.Location = new System.Drawing.Point(3, 4); - this.userButton_upload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.userButton_upload.Name = "userButton_upload"; - this.userButton_upload.Size = new System.Drawing.Size(71, 25); - this.userButton_upload.TabIndex = 6; - this.userButton_upload.UIText = "上传"; - this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click); + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(395, 8); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 17); + this.label1.TabIndex = 8; + this.label1.Text = "搜索:"; // // userButton_refresh // @@ -89,23 +84,29 @@ this.userButton_refresh.UIText = "刷新"; this.userButton_refresh.Click += new System.EventHandler(this.userButton_refresh_Click); // - // label1 + // userButton_upload // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(395, 8); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(44, 17); - this.label1.TabIndex = 8; - this.label1.Text = "搜索:"; + this.userButton_upload.BackColor = System.Drawing.Color.Transparent; + this.userButton_upload.CustomerInformation = ""; + this.userButton_upload.EnableColor = System.Drawing.Color.FromArgb(((int)(((byte)(190)))), ((int)(((byte)(190)))), ((int)(((byte)(190))))); + this.userButton_upload.Font = new System.Drawing.Font("微软雅黑", 9F); + this.userButton_upload.Location = new System.Drawing.Point(3, 4); + this.userButton_upload.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.userButton_upload.Name = "userButton_upload"; + this.userButton_upload.Size = new System.Drawing.Size(71, 25); + this.userButton_upload.TabIndex = 6; + this.userButton_upload.UIText = "上传"; + this.userButton_upload.Click += new System.EventHandler(this.userButton_upload_Click); // - // textBox1 + // panel2 // - this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.textBox1.Location = new System.Drawing.Point(439, 5); - this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(161, 23); - this.textBox1.TabIndex = 9; + this.panel2.AutoScroll = true; + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.panel2.Location = new System.Drawing.Point(0, 35); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(605, 291); + this.panel2.TabIndex = 1; // // ShareFilesRender // @@ -115,6 +116,7 @@ this.Controls.Add(this.panel1); this.Name = "ShareFilesRender"; this.Size = new System.Drawing.Size(605, 326); + this.Load += new System.EventHandler(this.ShareFilesRender_Load); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); this.ResumeLayout(false); diff --git a/软件系统客户端模版/UIControls/ShareFilesRender.cs b/软件系统客户端模版/UIControls/ShareFilesRender.cs index 4921493..1eb9fa4 100644 --- a/软件系统客户端模版/UIControls/ShareFilesRender.cs +++ b/软件系统客户端模版/UIControls/ShareFilesRender.cs @@ -6,6 +6,9 @@ using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; +using IndustryEthernet; +using Newtonsoft.Json.Linq; + namespace 软件系统客户端模版.UIControls { @@ -18,12 +21,115 @@ namespace 软件系统客户端模版.UIControls private void userButton_upload_Click(object sender, EventArgs e) { - // + //上传数据,先对权限进行验证 + if(UserClient.UserAccount.Grade>(); + SetFilesShow(Cache_Files); + } + else + { + MessageBox.Show(result.ToMessageShowString()); + } + } + private void SetFilesShow(List files) + { + panel2.SuspendLayout(); + //清楚缓存 + ClearControls(); + if (files?.Count > 0 && panel2.Width > 20) + { + int location_y = 2; + //添加子控件 + foreach(var m in files) + { + FileItemShow item = new FileItemShow(UserClient.ServerIp, + CommonLibrary.CommonLibrary.Port_Share_File, + () => + { + if (m.UploadName != UserClient.UserAccount.UserName) + { + MessageBox.Show("无法删除不是自己上传的文件。"); + return false; + } + else + { + return true; + } + }); + panel2.Controls.Add(item); + item.Location = new Point(2, location_y); + item.Size = new Size(panel2.Width - 20, item.Size.Height); + item.Anchor = (AnchorStyles)(AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right); + + location_y += item.Height + 2; + FilesControls.Push(item); + } + } + + panel2.ResumeLayout(); + } + + public void UpdateFiles() + { + userButton_refresh.PerformClick(); + } + + private void ClearControls() + { + while (FilesControls.Count > 0) + { + FilesControls.Pop().Dispose(); + } + } + + /// + /// 所有文件信息的缓存,以支持直接的搜索 + /// + private List Cache_Files { get; set; } = new List(); + /// + /// 文件控件的缓存列表,方便清除垃圾 + /// + private Stack FilesControls = new Stack(); + + + private void ShareFilesRender_Load(object sender, EventArgs e) + { + //选择是否禁用上传键 + } + + private void textBox1_TextChanged(object sender, EventArgs e) + { + //搜索时触发的数据 + if(string.IsNullOrEmpty(textBox1.Text)) + { + string pattern = textBox1.Text; + SetFilesShow(Cache_Files.Where(f => f.FileName.Contains(pattern) || f.FileNote.Contains(pattern)).ToList()); + } + else + { + SetFilesShow(Cache_Files); + } } } } diff --git a/软件系统服务端模版/Form1.cs b/软件系统服务端模版/Form1.cs index ce9c8d3..d5fe0ad 100644 --- a/软件系统服务端模版/Form1.cs +++ b/软件系统服务端模版/Form1.cs @@ -19,6 +19,7 @@ using Newtonsoft.Json.Linq; // 版权所有 胡少林 // 授权说明 模版仅授权个人使用,如需商用,请联系hsl200909@163.com洽谈 // 说明 JSON组件引用自james newton-king,遵循MIT授权协议 +// 说明 文件的图标来源于,感谢作者的无私分享 //============================================================================ @@ -387,6 +388,10 @@ namespace 软件系统服务端模版 bool result = UserServer.ServerAccounts.AddNewAccount(object2.Substring(4)); net_simplify_server.SendMessage(object1, result ? "1" : "0"); } + else if(head_code == CommonHeadCode.SimplifyHeadCode.请求文件列表) + { + net_simplify_server.SendMessage(object1, net_simple_file_server.ToJsonString()); + } else { net_simplify_server.SendMessage(object1, object2);