diff --git a/src/PBAnaly/Assist/OperatingRecord.cs b/src/PBAnaly/Assist/OperatingRecord.cs new file mode 100644 index 0000000..0a4933b --- /dev/null +++ b/src/PBAnaly/Assist/OperatingRecord.cs @@ -0,0 +1,228 @@ +using PBAnaly.LoginCommon; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PBAnaly.Assist +{ + #region OperatingRecord 操作记录 + /// + /// 操作记录 + /// + public static class OperatingRecord + { + public static event EventHandler OperatingChanged; + private static FileWriter OpWriter = new FileWriter(); + private static int OperatingIndex = 0; + + private const string FILE_HEADER = "ID,Time,Operator,Role,Description,Action"; + + /// + /// 写操作日志 + /// + /// 描述 + /// 动作 + public static void CreateRecord(string s1, string s2) + { + lock (lockObj) + { + try + { + //获取程序运行的根目录 + string directory = AppDomain.CurrentDomain.BaseDirectory + "//OperatingRecord//"; + + + //判断目录是否存在,如果目录不存在,则创建目录 + if (!System.IO.Directory.Exists(directory)) + { + System.IO.Directory.CreateDirectory(directory); + } + + //拼接文件名称 + string fileName = directory + DateTime.Now.ToString("yyyyMMdd") + ".csv"; + + + if (!File.Exists(fileName)) + { + StreamWriter sw = new StreamWriter(fileName, true, Encoding.UTF8); + sw.WriteLine(FILE_HEADER); + sw.Flush(); + sw.Close(); + sw.Dispose(); + } + + if (OpWriter.FileName != fileName) + { + OperatingIndex = File.ReadAllLines(fileName).Length - 1; + OpWriter.Close(); + OpWriter.SetFileName(fileName); + } + + string strlog = string.Format("{0},{1}',{2},{3},{4},{5}", + OperatingIndex, DateTime.Now.ToString("G"), UserManage.LogionUser.Name, + UserManage.LogionUser.Role.ToString(), s1, s2); + + OpWriter.WriteLine(strlog); + OpWriter.Close(); + + OperatingIndex++; + + if (OperatingChanged != null) + { + OperatingChanged(null, EventArgs.Empty); + } + } + catch (Exception ex) + { + + } + } + } + + #region lockObj 创建操作记录方法使用的线程锁对象 + /// + /// 创建操作记录方法使用的线程锁对象 + /// + private static readonly object lockObj = new object(); + #endregion + } + #endregion + + + #region FileWriter 文件操作类,主要用于写MESLog文件,和本地数据保存 + /// + /// 文件操作类,主要用于写MESLog文件,和本地数据保存 + /// 使用方法: + /// 1.实例化对象 + /// 2.调用SetFileName设置文件名 + /// 3.调用WriteLine写文件 + /// 4.调用Close关闭文件 + /// + public class FileWriter + { + public string FileName + { + get { return mStrFileName; } + } + /// + /// 保存文件名 + /// + private string mStrFileName = ""; + /// + /// 用于写文件的写入流 + /// + private System.IO.StreamWriter mStreamWriter = null; + + #region SetFileName 设置文件路径 + /// + /// 设置文件路径 + /// + /// 文件路径 + public void SetFileName(string filePath) + { + mStrFileName = filePath; + if (mStreamWriter == null) + { + mStreamWriter = new System.IO.StreamWriter(mStrFileName, true, Encoding.UTF8); + } + } + #endregion + + #region CheckFileExist 检查文件是否存在 + /// + /// 检查文件是否存在 + /// + /// 文件路 + /// true-文件存在,false-文件不存在 + public bool CheckFileExist(string filePath) + { + return System.IO.File.Exists(filePath); + } + #endregion + + #region WriteLine 向文件中写入一行数据,此方法用于写CSV文件 + /// + /// 向文件中写入一行数据,此方法用于写CSV文件 + /// + /// 将要写入的字符串以“,”号分割 + /// 清理缓存数据,并写入流 + /// true写入成功,false写入失败 + public bool WriteLine(string[] values, bool isFlush = true) + { + StringBuilder stringBuilder = new StringBuilder(); + + for (int index = 0; index < values.Length; index++) + { + stringBuilder.Append(values[index]); + if (index != values.Length - 1) + { + stringBuilder.Append(","); + } + } + + return WriteLine(stringBuilder.ToString(), isFlush); + } + #endregion + + #region WriteLine 向文件中写入一行数据 + /// + /// 向文件中写入一行数据 + /// + /// 向文件中写入的字符串 + /// 是否立即刷新到文件中,默认为立即写入文件,true-立即写入文件 + /// true-写入成功,false-写入失败 + public bool WriteLine(string s, bool isFlush = true) + { + bool isWriteOk; + + //判断文件是否已经打开过,当mStreamWriter==null时,说明流未打开,需要初始化 + if (mStreamWriter == null) + { + //初始化文件流,并打开文件 + mStreamWriter = new System.IO.StreamWriter(mStrFileName, true, Encoding.UTF8); + } + + try + { + //将s写入到文件流中 + mStreamWriter.WriteLine(s); + //是否立即刷新到文件,true为立即写入,false不写入 + if (isFlush) + { + //清理当前缓存,并将缓存数据希尔文件 + mStreamWriter.Flush(); + } + isWriteOk = true; + } + catch (Exception ex) + { + isWriteOk = false; + } + return isWriteOk; + } + #endregion + + #region Close 关闭文件 + /// + /// 关闭文件 + /// + public void Close() + { + //判断文件流是否打开,如果为null则没有打开,如果不为null则文件已打开 + if (mStreamWriter != null) + { + //将缓存数据刷入到文件中 + mStreamWriter.Flush(); + //关闭文件流 + mStreamWriter.Close(); + //将文件流指向null,有利于下次打开时做判断 + mStreamWriter = null; + } + } + #endregion + } + #endregion +} diff --git a/src/PBAnaly/LoginCommon/AccessControl.cs b/src/PBAnaly/LoginCommon/AccessControl.cs index 7edd52b..eb48124 100644 --- a/src/PBAnaly/LoginCommon/AccessControl.cs +++ b/src/PBAnaly/LoginCommon/AccessControl.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using System.Xml.Linq; using System.Xml.Serialization; namespace PBAnaly.LoginCommon @@ -32,10 +33,6 @@ namespace PBAnaly.LoginCommon AccessItems = xs.Deserialize(fs) as List; fs.Close(); } - else - { - System.Windows.Forms.MessageBox.Show("加载配置文件AccessControl.xml不存在。即将推出程序."); - } } catch (Exception ex) { diff --git a/src/PBAnaly/LoginCommon/LoginForm.cs b/src/PBAnaly/LoginCommon/LoginForm.cs index 2708927..38637cd 100644 --- a/src/PBAnaly/LoginCommon/LoginForm.cs +++ b/src/PBAnaly/LoginCommon/LoginForm.cs @@ -1,5 +1,6 @@ using MaterialSkin; using MaterialSkin.Controls; +using PBAnaly.Assist; using ReaLTaiizor.Manager; using System; using System.Collections.Generic; @@ -169,6 +170,9 @@ namespace PBAnaly.LoginCommon //将本次登录更新为上一次登录的用户插入数据库,方便下次登录的时候查看 UserManage.UpDateLastUser(UserName, Password, Remember); isOK = true; + + OperatingRecord.CreateRecord("登录按钮", "用户登录"); + Close(); } else { MessageBox.Show("Password is incorrect, please re-enter"); return; } diff --git a/src/PBAnaly/MainForm.Designer.cs b/src/PBAnaly/MainForm.Designer.cs index 95eb6ae..57f3eff 100644 --- a/src/PBAnaly/MainForm.Designer.cs +++ b/src/PBAnaly/MainForm.Designer.cs @@ -81,17 +81,17 @@ this.metroPanel_RightTop.Dock = System.Windows.Forms.DockStyle.Fill; this.metroPanel_RightTop.HorizontalScrollbarBarColor = true; this.metroPanel_RightTop.HorizontalScrollbarHighlightOnWheel = false; - this.metroPanel_RightTop.HorizontalScrollbarSize = 9; - this.metroPanel_RightTop.Location = new System.Drawing.Point(280, 0); + this.metroPanel_RightTop.HorizontalScrollbarSize = 7; + this.metroPanel_RightTop.Location = new System.Drawing.Point(210, 0); this.metroPanel_RightTop.Margin = new System.Windows.Forms.Padding(0); this.metroPanel_RightTop.Name = "metroPanel_RightTop"; - this.metroPanel_RightTop.Size = new System.Drawing.Size(746, 69); + this.metroPanel_RightTop.Size = new System.Drawing.Size(639, 55); this.metroPanel_RightTop.TabIndex = 12; this.metroPanel_RightTop.Theme = MetroFramework.MetroThemeStyle.Dark; this.metroPanel_RightTop.UseCustomBackColor = true; this.metroPanel_RightTop.VerticalScrollbarBarColor = true; this.metroPanel_RightTop.VerticalScrollbarHighlightOnWheel = false; - this.metroPanel_RightTop.VerticalScrollbarSize = 9; + this.metroPanel_RightTop.VerticalScrollbarSize = 7; // // materialButton_log // @@ -102,11 +102,11 @@ this.materialButton_log.HighEmphasis = true; this.materialButton_log.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_log.Icon"))); this.materialButton_log.Location = new System.Drawing.Point(581, 0); - this.materialButton_log.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_log.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_log.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_log.Name = "materialButton_log"; this.materialButton_log.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_log.Size = new System.Drawing.Size(113, 69); + this.materialButton_log.Size = new System.Drawing.Size(113, 55); this.materialButton_log.TabIndex = 19; this.materialButton_log.Text = "操作日志"; this.materialButton_log.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -123,11 +123,11 @@ this.materialButton_setting.HighEmphasis = true; this.materialButton_setting.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_setting.Icon"))); this.materialButton_setting.Location = new System.Drawing.Point(468, 0); - this.materialButton_setting.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_setting.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_setting.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_setting.Name = "materialButton_setting"; this.materialButton_setting.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_setting.Size = new System.Drawing.Size(113, 69); + this.materialButton_setting.Size = new System.Drawing.Size(113, 55); this.materialButton_setting.TabIndex = 18; this.materialButton_setting.Text = "系统设置"; this.materialButton_setting.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -145,11 +145,11 @@ this.materialButton_curveimage.HighEmphasis = true; this.materialButton_curveimage.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_curveimage.Icon"))); this.materialButton_curveimage.Location = new System.Drawing.Point(339, 0); - this.materialButton_curveimage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_curveimage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_curveimage.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_curveimage.Name = "materialButton_curveimage"; this.materialButton_curveimage.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_curveimage.Size = new System.Drawing.Size(129, 69); + this.materialButton_curveimage.Size = new System.Drawing.Size(129, 55); this.materialButton_curveimage.TabIndex = 17; this.materialButton_curveimage.Text = "泳道波形图"; this.materialButton_curveimage.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -167,11 +167,11 @@ this.materialButton_analyzedata.HighEmphasis = true; this.materialButton_analyzedata.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_analyzedata.Icon"))); this.materialButton_analyzedata.Location = new System.Drawing.Point(226, 0); - this.materialButton_analyzedata.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_analyzedata.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_analyzedata.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_analyzedata.Name = "materialButton_analyzedata"; this.materialButton_analyzedata.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_analyzedata.Size = new System.Drawing.Size(113, 69); + this.materialButton_analyzedata.Size = new System.Drawing.Size(113, 55); this.materialButton_analyzedata.TabIndex = 16; this.materialButton_analyzedata.Text = "分析数据"; this.materialButton_analyzedata.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -189,11 +189,11 @@ this.materialButton_outimage.HighEmphasis = true; this.materialButton_outimage.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_outimage.Icon"))); this.materialButton_outimage.Location = new System.Drawing.Point(113, 0); - this.materialButton_outimage.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_outimage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_outimage.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_outimage.Name = "materialButton_outimage"; this.materialButton_outimage.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_outimage.Size = new System.Drawing.Size(113, 69); + this.materialButton_outimage.Size = new System.Drawing.Size(113, 55); this.materialButton_outimage.TabIndex = 15; this.materialButton_outimage.Text = "导出图像"; this.materialButton_outimage.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -211,11 +211,11 @@ this.materialButton_LoadData.HighEmphasis = true; this.materialButton_LoadData.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_LoadData.Icon"))); this.materialButton_LoadData.Location = new System.Drawing.Point(0, 0); - this.materialButton_LoadData.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); + this.materialButton_LoadData.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.materialButton_LoadData.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_LoadData.Name = "materialButton_LoadData"; this.materialButton_LoadData.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_LoadData.Size = new System.Drawing.Size(113, 69); + this.materialButton_LoadData.Size = new System.Drawing.Size(113, 55); this.materialButton_LoadData.TabIndex = 14; this.materialButton_LoadData.Text = "加载数据"; this.materialButton_LoadData.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -226,9 +226,9 @@ // tableLayoutPanel1 // this.tableLayoutPanel1.ColumnCount = 3; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 280F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 210F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 437F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 248F)); this.tableLayoutPanel1.Controls.Add(this.tl_right_main_view, 1, 2); this.tableLayoutPanel1.Controls.Add(this.metroPanel_RightTop, 1, 0); this.tableLayoutPanel1.Controls.Add(this.CompanyIcon_pictureBox, 0, 0); @@ -236,30 +236,30 @@ this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel2, 1, 1); this.tableLayoutPanel1.Controls.Add(this.pl_right, 2, 1); this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(4, 30); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 24); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 3; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 69F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 39F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 55F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 31F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(1463, 726); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1097, 581); this.tableLayoutPanel1.TabIndex = 18; // // tl_right_main_view // this.tl_right_main_view.ColumnCount = 2; this.tl_right_main_view.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tl_right_main_view.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 432F)); + this.tl_right_main_view.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 324F)); this.tl_right_main_view.Controls.Add(this.DataProcess_panel, 0, 0); this.tl_right_main_view.Dock = System.Windows.Forms.DockStyle.Fill; - this.tl_right_main_view.Location = new System.Drawing.Point(280, 108); + this.tl_right_main_view.Location = new System.Drawing.Point(210, 86); this.tl_right_main_view.Margin = new System.Windows.Forms.Padding(0); this.tl_right_main_view.Name = "tl_right_main_view"; this.tl_right_main_view.RowCount = 2; this.tl_right_main_view.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); this.tl_right_main_view.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); - this.tl_right_main_view.Size = new System.Drawing.Size(746, 618); + this.tl_right_main_view.Size = new System.Drawing.Size(639, 495); this.tl_right_main_view.TabIndex = 0; // // DataProcess_panel @@ -268,12 +268,11 @@ this.tl_right_main_view.SetColumnSpan(this.DataProcess_panel, 2); this.DataProcess_panel.Dock = System.Windows.Forms.DockStyle.Fill; this.DataProcess_panel.EdgeColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(41)))), ((int)(((byte)(50))))); - this.DataProcess_panel.Location = new System.Drawing.Point(4, 4); - this.DataProcess_panel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.DataProcess_panel.Location = new System.Drawing.Point(3, 3); this.DataProcess_panel.Name = "DataProcess_panel"; - this.DataProcess_panel.Padding = new System.Windows.Forms.Padding(7, 6, 7, 6); + this.DataProcess_panel.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); this.tl_right_main_view.SetRowSpan(this.DataProcess_panel, 2); - this.DataProcess_panel.Size = new System.Drawing.Size(738, 610); + this.DataProcess_panel.Size = new System.Drawing.Size(633, 489); this.DataProcess_panel.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; this.DataProcess_panel.TabIndex = 19; this.DataProcess_panel.Text = "panel1"; @@ -284,11 +283,10 @@ this.CompanyIcon_pictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.CompanyIcon_pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.CompanyIcon_pictureBox.Image = global::PBAnaly.Properties.Resources.京仪科技定稿_画板_1_副本2; - this.CompanyIcon_pictureBox.Location = new System.Drawing.Point(4, 4); - this.CompanyIcon_pictureBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.CompanyIcon_pictureBox.Location = new System.Drawing.Point(3, 3); this.CompanyIcon_pictureBox.Name = "CompanyIcon_pictureBox"; this.tableLayoutPanel1.SetRowSpan(this.CompanyIcon_pictureBox, 2); - this.CompanyIcon_pictureBox.Size = new System.Drawing.Size(272, 100); + this.CompanyIcon_pictureBox.Size = new System.Drawing.Size(204, 80); this.CompanyIcon_pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; this.CompanyIcon_pictureBox.TabIndex = 16; this.CompanyIcon_pictureBox.TabStop = false; @@ -303,10 +301,10 @@ this.flowLayoutPanel1.Controls.Add(this.materialButton_correction); this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; - this.flowLayoutPanel1.Location = new System.Drawing.Point(3, 110); - this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.flowLayoutPanel1.Location = new System.Drawing.Point(2, 88); + this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; - this.flowLayoutPanel1.Size = new System.Drawing.Size(274, 614); + this.flowLayoutPanel1.Size = new System.Drawing.Size(206, 491); this.flowLayoutPanel1.TabIndex = 18; // // materialButton_imageProcess @@ -319,12 +317,12 @@ this.materialButton_imageProcess.Font = new System.Drawing.Font("宋体", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.materialButton_imageProcess.HighEmphasis = true; this.materialButton_imageProcess.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_imageProcess.Icon"))); - this.materialButton_imageProcess.Location = new System.Drawing.Point(5, 8); - this.materialButton_imageProcess.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_imageProcess.Location = new System.Drawing.Point(4, 6); + this.materialButton_imageProcess.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_imageProcess.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_imageProcess.Name = "materialButton_imageProcess"; this.materialButton_imageProcess.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_imageProcess.Size = new System.Drawing.Size(267, 60); + this.materialButton_imageProcess.Size = new System.Drawing.Size(200, 48); this.materialButton_imageProcess.TabIndex = 4; this.materialButton_imageProcess.Text = "图像处理"; this.materialButton_imageProcess.TextAlign = System.Drawing.ContentAlignment.MiddleRight; @@ -341,12 +339,12 @@ this.materialButton_acidAnalyze.Depth = 0; this.materialButton_acidAnalyze.HighEmphasis = true; this.materialButton_acidAnalyze.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_acidAnalyze.Icon"))); - this.materialButton_acidAnalyze.Location = new System.Drawing.Point(5, 84); - this.materialButton_acidAnalyze.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_acidAnalyze.Location = new System.Drawing.Point(4, 66); + this.materialButton_acidAnalyze.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_acidAnalyze.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_acidAnalyze.Name = "materialButton_acidAnalyze"; this.materialButton_acidAnalyze.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_acidAnalyze.Size = new System.Drawing.Size(267, 60); + this.materialButton_acidAnalyze.Size = new System.Drawing.Size(200, 48); this.materialButton_acidAnalyze.TabIndex = 5; this.materialButton_acidAnalyze.Text = "泳道分析"; this.materialButton_acidAnalyze.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -362,12 +360,12 @@ this.materialButton_roiAnalyze.Depth = 0; this.materialButton_roiAnalyze.HighEmphasis = true; this.materialButton_roiAnalyze.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_roiAnalyze.Icon"))); - this.materialButton_roiAnalyze.Location = new System.Drawing.Point(5, 160); - this.materialButton_roiAnalyze.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_roiAnalyze.Location = new System.Drawing.Point(4, 126); + this.materialButton_roiAnalyze.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_roiAnalyze.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_roiAnalyze.Name = "materialButton_roiAnalyze"; this.materialButton_roiAnalyze.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_roiAnalyze.Size = new System.Drawing.Size(267, 60); + this.materialButton_roiAnalyze.Size = new System.Drawing.Size(200, 48); this.materialButton_roiAnalyze.TabIndex = 6; this.materialButton_roiAnalyze.Text = "ROIs分析"; this.materialButton_roiAnalyze.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -382,12 +380,12 @@ this.materialButton_miniAnalyze.Depth = 0; this.materialButton_miniAnalyze.HighEmphasis = true; this.materialButton_miniAnalyze.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_miniAnalyze.Icon"))); - this.materialButton_miniAnalyze.Location = new System.Drawing.Point(5, 236); - this.materialButton_miniAnalyze.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_miniAnalyze.Location = new System.Drawing.Point(4, 186); + this.materialButton_miniAnalyze.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_miniAnalyze.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_miniAnalyze.Name = "materialButton_miniAnalyze"; this.materialButton_miniAnalyze.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_miniAnalyze.Size = new System.Drawing.Size(267, 60); + this.materialButton_miniAnalyze.Size = new System.Drawing.Size(200, 48); this.materialButton_miniAnalyze.TabIndex = 7; this.materialButton_miniAnalyze.Text = "微孔版分析"; this.materialButton_miniAnalyze.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -402,12 +400,12 @@ this.materialButton_dotcounts.Depth = 0; this.materialButton_dotcounts.HighEmphasis = true; this.materialButton_dotcounts.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_dotcounts.Icon"))); - this.materialButton_dotcounts.Location = new System.Drawing.Point(5, 312); - this.materialButton_dotcounts.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_dotcounts.Location = new System.Drawing.Point(4, 246); + this.materialButton_dotcounts.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_dotcounts.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_dotcounts.Name = "materialButton_dotcounts"; this.materialButton_dotcounts.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_dotcounts.Size = new System.Drawing.Size(267, 60); + this.materialButton_dotcounts.Size = new System.Drawing.Size(200, 48); this.materialButton_dotcounts.TabIndex = 8; this.materialButton_dotcounts.Text = "菌落计数"; this.materialButton_dotcounts.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -422,12 +420,12 @@ this.materialButton_correction.Depth = 0; this.materialButton_correction.HighEmphasis = true; this.materialButton_correction.Icon = ((System.Drawing.Image)(resources.GetObject("materialButton_correction.Icon"))); - this.materialButton_correction.Location = new System.Drawing.Point(5, 388); - this.materialButton_correction.Margin = new System.Windows.Forms.Padding(5, 8, 5, 8); + this.materialButton_correction.Location = new System.Drawing.Point(4, 306); + this.materialButton_correction.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.materialButton_correction.MouseState = MaterialSkin.MouseState.HOVER; this.materialButton_correction.Name = "materialButton_correction"; this.materialButton_correction.NoAccentTextColor = System.Drawing.Color.Empty; - this.materialButton_correction.Size = new System.Drawing.Size(267, 60); + this.materialButton_correction.Size = new System.Drawing.Size(200, 48); this.materialButton_correction.TabIndex = 9; this.materialButton_correction.Text = "蛋白归一化"; this.materialButton_correction.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; @@ -447,10 +445,10 @@ this.flowLayoutPanel2.Controls.Add(this.materialButton_forward); this.flowLayoutPanel2.Controls.Add(this.materialButton_return); this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.flowLayoutPanel2.Location = new System.Drawing.Point(280, 69); + this.flowLayoutPanel2.Location = new System.Drawing.Point(210, 55); this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Size = new System.Drawing.Size(746, 39); + this.flowLayoutPanel2.Size = new System.Drawing.Size(639, 31); this.flowLayoutPanel2.TabIndex = 19; // // materialButton_changeFormSize @@ -643,12 +641,12 @@ this.pl_right.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(51)))), ((int)(((byte)(63))))); this.pl_right.Dock = System.Windows.Forms.DockStyle.Fill; this.pl_right.EdgeColor = System.Drawing.Color.FromArgb(((int)(((byte)(32)))), ((int)(((byte)(41)))), ((int)(((byte)(50))))); - this.pl_right.Location = new System.Drawing.Point(1029, 71); - this.pl_right.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.pl_right.Location = new System.Drawing.Point(851, 57); + this.pl_right.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.pl_right.Name = "pl_right"; - this.pl_right.Padding = new System.Windows.Forms.Padding(5, 5, 5, 5); + this.pl_right.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tableLayoutPanel1.SetRowSpan(this.pl_right, 2); - this.pl_right.Size = new System.Drawing.Size(431, 653); + this.pl_right.Size = new System.Drawing.Size(244, 522); this.pl_right.SmoothingType = System.Drawing.Drawing2D.SmoothingMode.HighQuality; this.pl_right.TabIndex = 20; this.pl_right.Text = "panel1"; @@ -657,28 +655,26 @@ // this.thunderLabel1.BackColor = System.Drawing.Color.Transparent; this.thunderLabel1.ForeColor = System.Drawing.Color.WhiteSmoke; - this.thunderLabel1.Location = new System.Drawing.Point(12, 6); - this.thunderLabel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.thunderLabel1.Location = new System.Drawing.Point(9, 5); this.thunderLabel1.Name = "thunderLabel1"; - this.thunderLabel1.Size = new System.Drawing.Size(267, 20); + this.thunderLabel1.Size = new System.Drawing.Size(200, 16); this.thunderLabel1.TabIndex = 19; this.thunderLabel1.Text = "PBAnaly v0.1.8"; // // MainForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange; - this.ClientSize = new System.Drawing.Size(1471, 760); + this.ClientSize = new System.Drawing.Size(1103, 608); this.Controls.Add(this.thunderLabel1); this.Controls.Add(this.tableLayoutPanel1); this.DrawerAutoShow = true; this.FormStyle = MaterialSkin.Controls.MaterialForm.FormStyles.ActionBar_None; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.Name = "MainForm"; - this.Padding = new System.Windows.Forms.Padding(4, 30, 4, 4); + this.Padding = new System.Windows.Forms.Padding(3, 24, 3, 3); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "MainForm"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; diff --git a/src/PBAnaly/MainForm.cs b/src/PBAnaly/MainForm.cs index 9dd1a45..d79a595 100644 --- a/src/PBAnaly/MainForm.cs +++ b/src/PBAnaly/MainForm.cs @@ -3,6 +3,7 @@ using MaterialSkin; using MaterialSkin.Controls; using OpenCvSharp.Flann; using OpenTK; +using PBAnaly.Assist; using PBAnaly.LoginCommon; using PBAnaly.Module; using PBAnaly.Properties; @@ -15,6 +16,8 @@ using System.IO; using System.Linq; using System.Threading; using System.Windows.Forms; +using System.Xml.Linq; +using System.Xml.Serialization; using Resources = PBAnaly.Properties.Resources; namespace PBAnaly @@ -77,7 +80,7 @@ namespace PBAnaly UserManage.LogionUserChanged += OnLogionUserChanged; InitAccessControls(); - + LoadAccessFile(); OnLogionUser(); UIInit(); @@ -115,6 +118,90 @@ namespace PBAnaly }; } + #region LoadAccessFile 加载管理控件访问权限的文件,如果文件不存在,就根据界面的设置的控件创建一个 + /// + /// 加载管理控件访问权限的文件,如果文件不存在,就根据界面的设置的控件创建一个 + /// + private void LoadAccessFile() + { + try + { + if (!File.Exists("AccessControl.xml")) + { + CreatAccessControlFlie(); + } + else + { + FileStream fs = new FileStream("AccessControl.xml", FileMode.Open); + XmlSerializer xs = new XmlSerializer(typeof(List)); + AccessControl.AccessItems = xs.Deserialize(fs) as List; + fs.Close(); + + if(AccessControl.AccessItems.Count!= mControls.Length) + { + string currentDirectory = AppDomain.CurrentDomain.BaseDirectory; + string xmlFileName = "AccessControl.xml"; + // 拼接出完整的文件路径 + string filePath = Path.Combine(currentDirectory, xmlFileName); + // 删除文件 + File.Delete(filePath); + + CreatAccessControlFlie(); + + } + } + } + catch (Exception) + { + + } + + } + #endregion + + #region CreatAccessControlFlie 创建管理控件权限访问的文件夹 + /// + /// 创建管理控件权限访问的文件夹 + /// + private void CreatAccessControlFlie() + { + try + { + // 创建XML根节点 + XElement root = new XElement("ArrayOfItem"); + for (int i = 0; i < mControls.Length; i++) + { + + + XElement item = new XElement("item", + new XAttribute("Id", i), + new XAttribute("Operator", "false"), + new XAttribute("Engineer", "false"), + new XAttribute("Administrator", "true"), + new XAttribute("SuperAdministrator", "true"), + new XAttribute("Disible", mControls[i].Text) + ); + root.Add(item); + } + + // 保存XML到文件 + string filePath = "AccessControl.xml"; + root.Save(filePath); + + AccessControl.AccessItems = new List(); + + FileStream fs = new FileStream("AccessControl.xml", FileMode.Open); + XmlSerializer xs = new XmlSerializer(typeof(List)); + AccessControl.AccessItems = xs.Deserialize(fs) as List; + fs.Close(); + } + catch (Exception) + { + + } + } + #endregion + #region OnLogionUserChanged 处理登录用户更改事件 /// /// 处理登录用户更改事件 @@ -433,6 +520,7 @@ namespace PBAnaly private void materialButton_setting_Click(object sender, EventArgs e) { + OperatingRecord.CreateRecord("系统设置按钮", "被点击了一下"); SystemSettingForm system = new SystemSettingForm(); system.ShowDialog(); //if (settingForm != null) @@ -552,13 +640,16 @@ namespace PBAnaly } private void materialButton_log_Click(object sender, EventArgs e) { - if (logForm != null) - return; - - logForm = new LogForm(materialSkinManager,InnerUserID); - logForm.FormClosed += LogForm_FormClosed; - logForm.TopMost = true; + UI.LogForm logForm = new UI.LogForm(materialSkinManager); logForm.Show(); + + //if (logForm != null) + // return; + + //logForm = new LogForm(materialSkinManager,InnerUserID); + //logForm.FormClosed += LogForm_FormClosed; + //logForm.TopMost = true; + //logForm.Show(); } private void LogForm_FormClosed(object sender, FormClosedEventArgs e) diff --git a/src/PBAnaly/PBAnaly.csproj b/src/PBAnaly/PBAnaly.csproj index 1e6b7ac..edba48b 100644 --- a/src/PBAnaly/PBAnaly.csproj +++ b/src/PBAnaly/PBAnaly.csproj @@ -57,6 +57,7 @@ + Form @@ -166,6 +167,12 @@ ImagePanelUser.cs + + Form + + + LogForm.cs + Component @@ -252,6 +259,9 @@ ImagePanelUser.cs + + LogForm.cs + RowMergeView.cs @@ -450,6 +460,7 @@ + diff --git a/src/PBAnaly/Program.cs b/src/PBAnaly/Program.cs index add6041..696d37f 100644 --- a/src/PBAnaly/Program.cs +++ b/src/PBAnaly/Program.cs @@ -77,7 +77,7 @@ namespace PBAnaly string dbPath = "UserManage.db"; string connectionString = $"Data Source={dbPath};Version=3;"; UserManage.ConnectDb(); - AccessControl.LoadConfig();//加载权限 + //AccessControl.LoadConfig();//加载权限 var login = new LoginForm(); login.StartPosition = FormStartPosition.CenterScreen; Application.Run(new MainForm()); diff --git a/src/PBAnaly/Properties/Resources.Designer.cs b/src/PBAnaly/Properties/Resources.Designer.cs index b5f5ee2..961cbfc 100644 --- a/src/PBAnaly/Properties/Resources.Designer.cs +++ b/src/PBAnaly/Properties/Resources.Designer.cs @@ -550,6 +550,16 @@ namespace PBAnaly.Properties { } } + /// + /// 查找 System.Drawing.Bitmap 类型的本地化资源。 + /// + internal static System.Drawing.Bitmap 登录_亮 { + get { + object obj = ResourceManager.GetObject("登录-亮", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// diff --git a/src/PBAnaly/Properties/Resources.resx b/src/PBAnaly/Properties/Resources.resx index ff9aff5..bc4101a 100644 --- a/src/PBAnaly/Properties/Resources.resx +++ b/src/PBAnaly/Properties/Resources.resx @@ -136,17 +136,14 @@ ..\Resources\EtBr_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\壁纸.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\保存图片.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\线段.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\YellowHot_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\饼干.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Black_Green_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Black_Green_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -154,6 +151,9 @@ ..\Resources\Black_Red_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\前台.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\保存.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -172,26 +172,26 @@ ..\Resources\波形设置-未选中.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Gray.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\Black_Blue_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\zoom-in.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\添加用户.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\数据报告 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\线段 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\保存.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\圖片_20240731174523.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\重置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\Black_Red_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -199,8 +199,8 @@ ..\Resources\京仪科技定稿_画板 1 副本2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\数据报告.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\分析.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\zoom-out.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -211,8 +211,11 @@ ..\Resources\风控.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\分析.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\Black_SDS_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\饼干.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\控制窗口.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -244,11 +247,14 @@ ..\Resources\图片管理.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\线段 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\最大化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\執行日誌紀錄.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\主页面-图像编辑-正反片.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -265,29 +271,26 @@ ..\Resources\Pseudo_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Gray.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\线段.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\10矩形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\放大.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\最大化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Black_Green_0.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\執行日誌紀錄.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\YellowHot_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\蛋白质-01.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\壁纸.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\数据报告.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\圆形.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\zoom-in.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\黑白平衡.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -295,16 +298,16 @@ ..\Resources\最小化white.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Black_SDS_1.bmp;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\重置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\前台.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\放大.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\波形图.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\添加用户.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\登录-亮.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/src/PBAnaly/Resources/登录-亮.png b/src/PBAnaly/Resources/登录-亮.png new file mode 100644 index 0000000..8880e07 Binary files /dev/null and b/src/PBAnaly/Resources/登录-亮.png differ diff --git a/src/PBAnaly/UI/LogForm.Designer.cs b/src/PBAnaly/UI/LogForm.Designer.cs new file mode 100644 index 0000000..36243eb --- /dev/null +++ b/src/PBAnaly/UI/LogForm.Designer.cs @@ -0,0 +1,137 @@ +namespace PBAnaly.UI +{ + partial class LogForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView1 + // + this.dataGridView1.AllowUserToAddRows = false; + this.dataGridView1.AllowUserToDeleteRows = false; + this.dataGridView1.AllowUserToResizeColumns = false; + this.dataGridView1.AllowUserToResizeRows = false; + this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; + this.dataGridView1.BackgroundColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Column1, + this.Column2, + this.Column3, + this.Column4, + this.Column5, + this.Column6}); + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Location = new System.Drawing.Point(3, 64); + this.dataGridView1.MultiSelect = false; + this.dataGridView1.Name = "dataGridView1"; + this.dataGridView1.ReadOnly = true; + this.dataGridView1.RowHeadersVisible = false; + this.dataGridView1.RowTemplate.Height = 23; + this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dataGridView1.Size = new System.Drawing.Size(794, 383); + this.dataGridView1.TabIndex = 497; + // + // Column1 + // + this.Column1.HeaderText = "ID"; + this.Column1.Name = "Column1"; + this.Column1.ReadOnly = true; + // + // Column2 + // + this.Column2.HeaderText = "Time"; + this.Column2.Name = "Column2"; + this.Column2.ReadOnly = true; + // + // Column3 + // + this.Column3.HeaderText = "Operator"; + this.Column3.Name = "Column3"; + this.Column3.ReadOnly = true; + // + // Column4 + // + this.Column4.HeaderText = "Role"; + this.Column4.Name = "Column4"; + this.Column4.ReadOnly = true; + // + // Column5 + // + this.Column5.HeaderText = "Description"; + this.Column5.Name = "Column5"; + this.Column5.ReadOnly = true; + // + // Column6 + // + this.Column6.HeaderText = "Action"; + this.Column6.Name = "Column6"; + this.Column6.ReadOnly = true; + // + // LogForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.dataGridView1); + this.Name = "LogForm"; + this.Text = "LogForm"; + this.Load += new System.EventHandler(this.LogForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column1; + private System.Windows.Forms.DataGridViewTextBoxColumn Column2; + private System.Windows.Forms.DataGridViewTextBoxColumn Column3; + private System.Windows.Forms.DataGridViewTextBoxColumn Column4; + private System.Windows.Forms.DataGridViewTextBoxColumn Column5; + private System.Windows.Forms.DataGridViewTextBoxColumn Column6; + } +} \ No newline at end of file diff --git a/src/PBAnaly/UI/LogForm.cs b/src/PBAnaly/UI/LogForm.cs new file mode 100644 index 0000000..92f6c30 --- /dev/null +++ b/src/PBAnaly/UI/LogForm.cs @@ -0,0 +1,100 @@ +using MaterialSkin; +using MaterialSkin.Controls; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PBAnaly.UI +{ + public partial class LogForm : MaterialForm + { + string Inner_UserID; + public LogForm(MaterialSkinManager materialSkinManager) + { + InitializeComponent(); + UIInit(); + } + + public MaterialSkinManager Inn_materialSkinManager; + + public void UIInit() + { + this.Text = string.Format("Current User : {0}", Inner_UserID); + //this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true); + Inn_materialSkinManager = MaterialSkinManager.Instance; // 初始化 MaterialSkinManager 实例 + //Inn_materialSkinManager.AddFormToManage(this); // 将要应用 Material Design 的窗体添加到管理列表中 + //Inn_materialSkinManager.Theme = MaterialSkinManager.Themes.DARK; // Theme 属性用来设置整体的主题 + //Inn_materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.Cyan700, TextShade.WHITE); // ColorScheme 属性来设置配色方案 + + if (Inn_materialSkinManager.Theme == MaterialSkinManager.Themes.DARK) + { + dataGridView1.DefaultCellStyle.BackColor = Color.DimGray; + } + else + { + dataGridView1.DefaultCellStyle.BackColor = Color.LightGray; + } + } + + private void LogForm_Load(object sender, EventArgs e) + { + string filePath = AppDomain.CurrentDomain.BaseDirectory + $"OperatingRecord\\{DateTime.Now.ToString("yyyyMMdd") + ".csv"}"; + LoadCsvData(filePath); + } + + private void LoadCsvData(string filePath) + { + // 检查文件是否存在 + if (File.Exists(filePath)) + { + try + { + // 读取CSV文件的所有行 + var lines = File.ReadAllLines(filePath); + + // 清空DataGridView之前的数据 + dataGridView1.Rows.Clear(); + dataGridView1.Columns.Clear(); + + if (lines.Length > 0) + { + // 使用第一行数据作为列标题 + var headers = lines[0].Split(','); + + // 添加列到DataGridView + foreach (var header in headers) + { + dataGridView1.Columns.Add(header, header); // 第一个参数是列的Name,第二个是列的HeaderText + } + + // 从第二行开始添加数据 + for (int i = 1; i < lines.Length; i++) + { + var row = lines[i].Split(','); + + // 将数据添加到DataGridView中 + dataGridView1.Rows.Add(row); + } + } + } + catch (Exception ex) + { + MessageBox.Show($"读取CSV文件时出错: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + else + { + MessageBox.Show("文件不存在", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + + } +} diff --git a/src/PBAnaly/UI/LogForm.resx b/src/PBAnaly/UI/LogForm.resx new file mode 100644 index 0000000..b851021 --- /dev/null +++ b/src/PBAnaly/UI/LogForm.resx @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/src/PBAnaly/UI/SystemSettingForm.Designer.cs b/src/PBAnaly/UI/SystemSettingForm.Designer.cs index 297c427..95fe6db 100644 --- a/src/PBAnaly/UI/SystemSettingForm.Designer.cs +++ b/src/PBAnaly/UI/SystemSettingForm.Designer.cs @@ -33,11 +33,11 @@ this.tabMain = new System.Windows.Forms.TabControl(); this.tab_UserManage = new System.Windows.Forms.TabPage(); this.pnlMainMenu = new System.Windows.Forms.Panel(); - this.btn_ReadManage = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.btn_Min = new System.Windows.Forms.Button(); this.btn_Max = new System.Windows.Forms.Button(); this.btn_Close = new System.Windows.Forms.Button(); + this.btn_ReadManage = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.panel_mode.SuspendLayout(); this.tabMain.SuspendLayout(); @@ -64,7 +64,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.panel_mode.BackColor = System.Drawing.SystemColors.Control; this.panel_mode.Controls.Add(this.tabMain); - this.panel_mode.Location = new System.Drawing.Point(58, 0); + this.panel_mode.Location = new System.Drawing.Point(59, 0); this.panel_mode.Name = "panel_mode"; this.panel_mode.Size = new System.Drawing.Size(1098, 639); this.panel_mode.TabIndex = 444; @@ -103,19 +103,6 @@ this.pnlMainMenu.Size = new System.Drawing.Size(77, 642); this.pnlMainMenu.TabIndex = 443; // - // btn_ReadManage - // - this.btn_ReadManage.BackColor = System.Drawing.Color.White; - this.btn_ReadManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_ReadManage.Font = new System.Drawing.Font("宋体", 9F); - this.btn_ReadManage.Image = global::PBAnaly.Properties.Resources.添加用户; - this.btn_ReadManage.Location = new System.Drawing.Point(3, 3); - this.btn_ReadManage.Name = "btn_ReadManage"; - this.btn_ReadManage.Size = new System.Drawing.Size(76, 86); - this.btn_ReadManage.TabIndex = 3; - this.btn_ReadManage.TextAlign = System.Drawing.ContentAlignment.BottomCenter; - this.btn_ReadManage.UseVisualStyleBackColor = false; - // // label4 // this.label4.AutoSize = true; @@ -172,6 +159,19 @@ this.btn_Close.UseVisualStyleBackColor = false; this.btn_Close.Click += new System.EventHandler(this.btn_Close_Click); // + // btn_ReadManage + // + this.btn_ReadManage.BackColor = System.Drawing.Color.White; + this.btn_ReadManage.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_ReadManage.Font = new System.Drawing.Font("宋体", 9F); + this.btn_ReadManage.Image = global::PBAnaly.Properties.Resources.登录_亮; + this.btn_ReadManage.Location = new System.Drawing.Point(2, 3); + this.btn_ReadManage.Name = "btn_ReadManage"; + this.btn_ReadManage.Size = new System.Drawing.Size(75, 86); + this.btn_ReadManage.TabIndex = 3; + this.btn_ReadManage.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.btn_ReadManage.UseVisualStyleBackColor = false; + // // SystemSettingForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);