ソースを参照

新增文件备份后还原功能

yuzhengyang 8 年 前
コミット
f7ef5d568c

+ 1 - 1
Fork.Net/Oreo.Plugins/Oreo.FileMan/Commons/R.cs

@@ -44,7 +44,7 @@ namespace Oreo.FileMan.Commons
             {
             {
                 public static string FileManBackup = @"D:\temp\FileManBackup\";//文件备份目录
                 public static string FileManBackup = @"D:\temp\FileManBackup\";//文件备份目录
                 public static int BACK_UP_INTERVAL = 5 * 1000;//备份文件间隔
                 public static int BACK_UP_INTERVAL = 5 * 1000;//备份文件间隔
-                public static int BACK_UP_COUNT = 5;//备份文件版本个数
+                public static int BACK_UP_COUNT = 10;//备份文件版本个数
             }
             }
         }
         }
     }
     }

+ 35 - 34
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileBackupPartial.Designer.cs

@@ -39,15 +39,15 @@
             this.DgvPathSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvPathSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.BtAddPath = new System.Windows.Forms.Button();
             this.BtAddPath = new System.Windows.Forms.Button();
             this.DgvFile = new System.Windows.Forms.DataGridView();
             this.DgvFile = new System.Windows.Forms.DataGridView();
-            this.BtDelPath = new System.Windows.Forms.Button();
-            this.TmReadPaths = new System.Windows.Forms.Timer(this.components);
-            this.LbStatus = new System.Windows.Forms.Label();
-            this.TmStatus = new System.Windows.Forms.Timer(this.components);
             this.DgvFileName = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileName = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileVersionHistory = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileVersionHistory = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileLastBackupTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFileLastBackupTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilePath = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.BtDelPath = new System.Windows.Forms.Button();
+            this.TmReadPaths = new System.Windows.Forms.Timer(this.components);
+            this.LbStatus = new System.Windows.Forms.Label();
+            this.TmStatus = new System.Windows.Forms.Timer(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.DgvPath)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvPath)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFile)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFile)).BeginInit();
             this.SuspendLayout();
             this.SuspendLayout();
@@ -144,36 +144,7 @@
             this.DgvFile.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.DgvFile.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
             this.DgvFile.Size = new System.Drawing.Size(443, 291);
             this.DgvFile.Size = new System.Drawing.Size(443, 291);
             this.DgvFile.TabIndex = 2;
             this.DgvFile.TabIndex = 2;
-            // 
-            // BtDelPath
-            // 
-            this.BtDelPath.Location = new System.Drawing.Point(119, 3);
-            this.BtDelPath.Name = "BtDelPath";
-            this.BtDelPath.Size = new System.Drawing.Size(75, 23);
-            this.BtDelPath.TabIndex = 6;
-            this.BtDelPath.Text = "删除目录";
-            this.BtDelPath.UseVisualStyleBackColor = true;
-            this.BtDelPath.Click += new System.EventHandler(this.BtDelPath_Click);
-            // 
-            // TmReadPaths
-            // 
-            this.TmReadPaths.Interval = 1000;
-            this.TmReadPaths.Tick += new System.EventHandler(this.TmReadPaths_Tick);
-            // 
-            // LbStatus
-            // 
-            this.LbStatus.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.LbStatus.Location = new System.Drawing.Point(365, 6);
-            this.LbStatus.Name = "LbStatus";
-            this.LbStatus.Size = new System.Drawing.Size(266, 16);
-            this.LbStatus.TabIndex = 7;
-            this.LbStatus.Text = "文件备份已开启:已备份 - 个文件";
-            this.LbStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
-            // 
-            // TmStatus
-            // 
-            this.TmStatus.Interval = 1000;
-            this.TmStatus.Tick += new System.EventHandler(this.TmStatus_Tick);
+            this.DgvFile.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DgvFile_CellDoubleClick);
             // 
             // 
             // DgvFileName
             // DgvFileName
             // 
             // 
@@ -216,6 +187,36 @@
             this.DgvFilePath.ReadOnly = true;
             this.DgvFilePath.ReadOnly = true;
             this.DgvFilePath.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.DgvFilePath.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // 
+            // BtDelPath
+            // 
+            this.BtDelPath.Location = new System.Drawing.Point(119, 3);
+            this.BtDelPath.Name = "BtDelPath";
+            this.BtDelPath.Size = new System.Drawing.Size(75, 23);
+            this.BtDelPath.TabIndex = 6;
+            this.BtDelPath.Text = "删除目录";
+            this.BtDelPath.UseVisualStyleBackColor = true;
+            this.BtDelPath.Click += new System.EventHandler(this.BtDelPath_Click);
+            // 
+            // TmReadPaths
+            // 
+            this.TmReadPaths.Interval = 1000;
+            this.TmReadPaths.Tick += new System.EventHandler(this.TmReadPaths_Tick);
+            // 
+            // LbStatus
+            // 
+            this.LbStatus.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.LbStatus.Location = new System.Drawing.Point(365, 6);
+            this.LbStatus.Name = "LbStatus";
+            this.LbStatus.Size = new System.Drawing.Size(266, 16);
+            this.LbStatus.TabIndex = 7;
+            this.LbStatus.Text = "文件备份已开启:已备份 - 个文件";
+            this.LbStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
+            // 
+            // TmStatus
+            // 
+            this.TmStatus.Interval = 1000;
+            this.TmStatus.Tick += new System.EventHandler(this.TmStatus_Tick);
+            // 
             // FileBackupPartial
             // FileBackupPartial
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

+ 10 - 0
Fork.Net/Oreo.Plugins/Oreo.FileMan/Partials/FileBackupPartial.cs

@@ -19,6 +19,7 @@ using System.Windows.Threading;
 using System.Threading;
 using System.Threading;
 using Y.Utils.DataUtils.DateTimeUtils;
 using Y.Utils.DataUtils.DateTimeUtils;
 using Oreo.FileMan.Commons;
 using Oreo.FileMan.Commons;
+using Oreo.FileMan.Views;
 
 
 namespace Oreo.FileMan.Partials
 namespace Oreo.FileMan.Partials
 {
 {
@@ -99,6 +100,14 @@ namespace Oreo.FileMan.Partials
         {
         {
             ShowFileDetails(e.RowIndex);
             ShowFileDetails(e.RowIndex);
         }
         }
+        private void DgvFile_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (e.RowIndex >= 0)
+            {
+                string filepath = DgvFile.Rows[e.RowIndex].Cells["DgvFilePath"].Value.ToString();
+                new FileRestoreForm(filepath).ShowDialog();
+            }
+        }
         /// <summary>
         /// <summary>
         /// 读取备份文件目录
         /// 读取备份文件目录
         /// </summary>
         /// </summary>
@@ -259,6 +268,7 @@ namespace Oreo.FileMan.Partials
                 DgvFile.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                 DgvFile.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
             }));
             }));
         }
         }
+
         #endregion
         #endregion
 
 
 
 

+ 178 - 4
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/FileRestoreForm.Designer.cs

@@ -28,15 +28,36 @@
         /// </summary>
         /// </summary>
         private void InitializeComponent()
         private void InitializeComponent()
         {
         {
+            this.components = new System.ComponentModel.Container();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle();
             this.BtClose = new System.Windows.Forms.Button();
             this.BtClose = new System.Windows.Forms.Button();
             this.DgvFiles = new System.Windows.Forms.DataGridView();
             this.DgvFiles = new System.Windows.Forms.DataGridView();
+            this.LbFileName = new System.Windows.Forms.Label();
+            this.LbPath = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.LbVersion = new System.Windows.Forms.Label();
+            this.BtRestoreToOld = new System.Windows.Forms.Button();
+            this.BtRestoreToNew = new System.Windows.Forms.Button();
+            this.DgvFilesVersion = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilesLastWriteTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilesLastWriteTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilesSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.DgvFilesSize = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.panel1 = new System.Windows.Forms.Panel();
+            this.panel2 = new System.Windows.Forms.Panel();
+            this.TtLabel = new System.Windows.Forms.ToolTip(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.DgvFiles)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFiles)).BeginInit();
+            this.panel1.SuspendLayout();
+            this.panel2.SuspendLayout();
             this.SuspendLayout();
             this.SuspendLayout();
             // 
             // 
             // BtClose
             // BtClose
             // 
             // 
+            this.BtClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
             this.BtClose.FlatAppearance.BorderSize = 0;
             this.BtClose.FlatAppearance.BorderSize = 0;
             this.BtClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.BtClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
             this.BtClose.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.BtClose.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@@ -57,45 +78,187 @@
             this.DgvFiles.AllowUserToResizeRows = false;
             this.DgvFiles.AllowUserToResizeRows = false;
             this.DgvFiles.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.DgvFiles.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.DgvFiles.BackgroundColor = System.Drawing.Color.White;
             this.DgvFiles.BackgroundColor = System.Drawing.Color.White;
+            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            dataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control;
+            dataGridViewCellStyle13.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle13.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle13.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle13.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.DgvFiles.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle13;
             this.DgvFiles.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DgvFiles.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.DgvFiles.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.DgvFiles.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+            this.DgvFilesVersion,
             this.DgvFilesLastWriteTime,
             this.DgvFilesLastWriteTime,
             this.DgvFilesSize});
             this.DgvFilesSize});
+            dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Window;
+            dataGridViewCellStyle17.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle17.ForeColor = System.Drawing.SystemColors.ControlText;
+            dataGridViewCellStyle17.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
+            dataGridViewCellStyle17.SelectionBackColor = System.Drawing.SystemColors.GradientActiveCaption;
+            dataGridViewCellStyle17.SelectionForeColor = System.Drawing.Color.Black;
+            dataGridViewCellStyle17.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
+            this.DgvFiles.DefaultCellStyle = dataGridViewCellStyle17;
+            this.DgvFiles.Dock = System.Windows.Forms.DockStyle.Fill;
             this.DgvFiles.GridColor = System.Drawing.Color.Silver;
             this.DgvFiles.GridColor = System.Drawing.Color.Silver;
-            this.DgvFiles.Location = new System.Drawing.Point(36, 54);
+            this.DgvFiles.Location = new System.Drawing.Point(0, 0);
             this.DgvFiles.Name = "DgvFiles";
             this.DgvFiles.Name = "DgvFiles";
             this.DgvFiles.ReadOnly = true;
             this.DgvFiles.ReadOnly = true;
+            dataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            dataGridViewCellStyle18.BackColor = System.Drawing.SystemColors.Control;
+            dataGridViewCellStyle18.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            dataGridViewCellStyle18.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle18.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle18.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle18.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.DgvFiles.RowHeadersDefaultCellStyle = dataGridViewCellStyle18;
             this.DgvFiles.RowHeadersVisible = false;
             this.DgvFiles.RowHeadersVisible = false;
+            this.DgvFiles.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing;
             this.DgvFiles.RowTemplate.Height = 23;
             this.DgvFiles.RowTemplate.Height = 23;
-            this.DgvFiles.Size = new System.Drawing.Size(352, 150);
+            this.DgvFiles.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+            this.DgvFiles.Size = new System.Drawing.Size(417, 207);
             this.DgvFiles.TabIndex = 21;
             this.DgvFiles.TabIndex = 21;
             // 
             // 
+            // LbFileName
+            // 
+            this.LbFileName.ForeColor = System.Drawing.Color.White;
+            this.LbFileName.Location = new System.Drawing.Point(90, 35);
+            this.LbFileName.Name = "LbFileName";
+            this.LbFileName.Size = new System.Drawing.Size(244, 12);
+            this.LbFileName.TabIndex = 22;
+            this.LbFileName.Text = "文件名";
+            // 
+            // LbPath
+            // 
+            this.LbPath.ForeColor = System.Drawing.Color.White;
+            this.LbPath.Location = new System.Drawing.Point(90, 58);
+            this.LbPath.Name = "LbPath";
+            this.LbPath.Size = new System.Drawing.Size(244, 30);
+            this.LbPath.TabIndex = 23;
+            this.LbPath.Text = "路径\r\n路径";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.ForeColor = System.Drawing.Color.White;
+            this.label1.Location = new System.Drawing.Point(33, 35);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(53, 12);
+            this.label1.TabIndex = 24;
+            this.label1.Text = "文件名:";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.ForeColor = System.Drawing.Color.White;
+            this.label2.Location = new System.Drawing.Point(33, 58);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(41, 12);
+            this.label2.TabIndex = 25;
+            this.label2.Text = "路径:";
+            // 
+            // LbVersion
+            // 
+            this.LbVersion.AutoSize = true;
+            this.LbVersion.ForeColor = System.Drawing.Color.White;
+            this.LbVersion.Location = new System.Drawing.Point(362, 76);
+            this.LbVersion.Name = "LbVersion";
+            this.LbVersion.Size = new System.Drawing.Size(47, 12);
+            this.LbVersion.TabIndex = 26;
+            this.LbVersion.Text = "共 - 版";
+            // 
+            // BtRestoreToOld
+            // 
+            this.BtRestoreToOld.Location = new System.Drawing.Point(234, 11);
+            this.BtRestoreToOld.Name = "BtRestoreToOld";
+            this.BtRestoreToOld.Size = new System.Drawing.Size(150, 23);
+            this.BtRestoreToOld.TabIndex = 28;
+            this.BtRestoreToOld.Text = "还原到原始目录";
+            this.BtRestoreToOld.UseVisualStyleBackColor = true;
+            this.BtRestoreToOld.Click += new System.EventHandler(this.BtRestoreToOld_Click);
+            // 
+            // BtRestoreToNew
+            // 
+            this.BtRestoreToNew.Location = new System.Drawing.Point(32, 11);
+            this.BtRestoreToNew.Name = "BtRestoreToNew";
+            this.BtRestoreToNew.Size = new System.Drawing.Size(150, 23);
+            this.BtRestoreToNew.TabIndex = 29;
+            this.BtRestoreToNew.Text = "还原到指定目录...";
+            this.BtRestoreToNew.UseVisualStyleBackColor = true;
+            this.BtRestoreToNew.Click += new System.EventHandler(this.BtRestoreToNew_Click);
+            // 
+            // DgvFilesVersion
+            // 
+            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.DgvFilesVersion.DefaultCellStyle = dataGridViewCellStyle14;
+            this.DgvFilesVersion.FillWeight = 50F;
+            this.DgvFilesVersion.HeaderText = "版本";
+            this.DgvFilesVersion.Name = "DgvFilesVersion";
+            this.DgvFilesVersion.ReadOnly = true;
+            // 
             // DgvFilesLastWriteTime
             // DgvFilesLastWriteTime
             // 
             // 
+            dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.DgvFilesLastWriteTime.DefaultCellStyle = dataGridViewCellStyle15;
             this.DgvFilesLastWriteTime.HeaderText = "最后修改时间";
             this.DgvFilesLastWriteTime.HeaderText = "最后修改时间";
             this.DgvFilesLastWriteTime.Name = "DgvFilesLastWriteTime";
             this.DgvFilesLastWriteTime.Name = "DgvFilesLastWriteTime";
             this.DgvFilesLastWriteTime.ReadOnly = true;
             this.DgvFilesLastWriteTime.ReadOnly = true;
+            this.DgvFilesLastWriteTime.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             // 
             // 
             // DgvFilesSize
             // DgvFilesSize
             // 
             // 
+            dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
+            this.DgvFilesSize.DefaultCellStyle = dataGridViewCellStyle16;
+            this.DgvFilesSize.FillWeight = 80F;
             this.DgvFilesSize.HeaderText = "文件大小";
             this.DgvFilesSize.HeaderText = "文件大小";
             this.DgvFilesSize.Name = "DgvFilesSize";
             this.DgvFilesSize.Name = "DgvFilesSize";
             this.DgvFilesSize.ReadOnly = true;
             this.DgvFilesSize.ReadOnly = true;
+            this.DgvFilesSize.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            // 
+            // panel1
+            // 
+            this.panel1.Controls.Add(this.BtRestoreToOld);
+            this.panel1.Controls.Add(this.BtRestoreToNew);
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.panel1.Location = new System.Drawing.Point(0, 299);
+            this.panel1.Name = "panel1";
+            this.panel1.Size = new System.Drawing.Size(417, 47);
+            this.panel1.TabIndex = 30;
+            // 
+            // panel2
+            // 
+            this.panel2.Controls.Add(this.DgvFiles);
+            this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
+            this.panel2.Location = new System.Drawing.Point(0, 92);
+            this.panel2.Name = "panel2";
+            this.panel2.Size = new System.Drawing.Size(417, 207);
+            this.panel2.TabIndex = 31;
             // 
             // 
             // FileRestoreForm
             // FileRestoreForm
             // 
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(43)))), ((int)(((byte)(54)))));
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(43)))), ((int)(((byte)(54)))));
-            this.ClientSize = new System.Drawing.Size(421, 282);
-            this.Controls.Add(this.DgvFiles);
+            this.CancelButton = this.BtClose;
+            this.ClientSize = new System.Drawing.Size(417, 346);
+            this.Controls.Add(this.panel2);
+            this.Controls.Add(this.panel1);
+            this.Controls.Add(this.LbVersion);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.LbPath);
+            this.Controls.Add(this.LbFileName);
             this.Controls.Add(this.BtClose);
             this.Controls.Add(this.BtClose);
             this.Name = "FileRestoreForm";
             this.Name = "FileRestoreForm";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
             this.Text = "FileRestoreForm";
             this.Text = "FileRestoreForm";
             this.Load += new System.EventHandler(this.FileRestoreForm_Load);
             this.Load += new System.EventHandler(this.FileRestoreForm_Load);
             ((System.ComponentModel.ISupportInitialize)(this.DgvFiles)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.DgvFiles)).EndInit();
+            this.panel1.ResumeLayout(false);
+            this.panel2.ResumeLayout(false);
             this.ResumeLayout(false);
             this.ResumeLayout(false);
+            this.PerformLayout();
 
 
         }
         }
 
 
@@ -103,7 +266,18 @@
 
 
         private System.Windows.Forms.Button BtClose;
         private System.Windows.Forms.Button BtClose;
         private System.Windows.Forms.DataGridView DgvFiles;
         private System.Windows.Forms.DataGridView DgvFiles;
+        private System.Windows.Forms.Label LbFileName;
+        private System.Windows.Forms.Label LbPath;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label LbVersion;
+        private System.Windows.Forms.Button BtRestoreToOld;
+        private System.Windows.Forms.Button BtRestoreToNew;
+        private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilesVersion;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilesLastWriteTime;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilesLastWriteTime;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilesSize;
         private System.Windows.Forms.DataGridViewTextBoxColumn DgvFilesSize;
+        private System.Windows.Forms.Panel panel1;
+        private System.Windows.Forms.Panel panel2;
+        private System.Windows.Forms.ToolTip TtLabel;
     }
     }
 }
 }

+ 57 - 2
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/FileRestoreForm.cs

@@ -1,31 +1,86 @@
-using System;
+using Oreo.FileMan.DatabaseEngine;
+using Oreo.FileMan.Models;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel;
 using System.Data;
 using System.Data;
 using System.Drawing;
 using System.Drawing;
+using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 using System.Windows.Forms;
 using Y.Skin.YoForm.NoTitle;
 using Y.Skin.YoForm.NoTitle;
+using Y.Utils.DataUtils.Collections;
+using Y.Utils.DataUtils.UnitConvertUtils;
+using Y.Utils.IOUtils.PathUtils;
 
 
 namespace Oreo.FileMan.Views
 namespace Oreo.FileMan.Views
 {
 {
     public partial class FileRestoreForm : NoTitleForm
     public partial class FileRestoreForm : NoTitleForm
     {
     {
-        public FileRestoreForm()
+        public string FilePath { get; set; }
+        public List<BackupFiles> Files { get; set; }
+        public FileRestoreForm(string path)
         {
         {
             InitializeComponent();
             InitializeComponent();
+            FilePath = path;
         }
         }
 
 
         private void FileRestoreForm_Load(object sender, EventArgs e)
         private void FileRestoreForm_Load(object sender, EventArgs e)
         {
         {
+            //读取该文件的备份记录
+            using (var db = new Muse())
+            {
+                Files = db.Gets<BackupFiles>(x => x.FullPath == FilePath, null).OrderBy(x => x.Id).ToList();
+            }
+            if (ListTool.HasElements(Files))
+            {
+                //获取文件名及路径信息
+                var first = Files.FirstOrDefault();
+                LbFileName.Text = Path.GetFileName(first.FullPath);
+                LbPath.Text = first.FullPath;
+                LbVersion.Text = "共 " + Files.Count + " 版";
 
 
+                TtLabel.SetToolTip(LbFileName, Path.GetFileName(first.FullPath));
+                TtLabel.SetToolTip(LbPath, first.FullPath);
+
+                //显示所有备份记录
+                int index = 1;
+                foreach (var file in Files)
+                {
+                    DgvFiles.Rows.Add(string.Format("第 {0} 版", index++), file.LastWriteTime, ByteConvertTool.Fmt(file.Size));
+                }
+            }
         }
         }
 
 
         private void BtClose_Click(object sender, EventArgs e)
         private void BtClose_Click(object sender, EventArgs e)
         {
         {
             Close();
             Close();
         }
         }
+
+        private void BtRestoreToNew_Click(object sender, EventArgs e)
+        {
+            if (DgvFiles.CurrentRow != null && DgvFiles.CurrentRow.Index >= 0)
+            {
+                var file = Files[DgvFiles.CurrentRow.Index];
+            }
+        }
+
+        private void BtRestoreToOld_Click(object sender, EventArgs e)
+        {
+            if (DgvFiles.CurrentRow != null && DgvFiles.CurrentRow.Index >= 0)
+            {
+                BackupFiles file = Files[DgvFiles.CurrentRow.Index];
+                string title = string.Format("文件还原", file.LastWriteTime);
+                string text = string.Format("您确定将文件:{0} [ {1} ]{2}还原到:{2}{3} 吗?", Path.GetFileName(file.FullPath), file.LastWriteTime, Environment.NewLine, file.FullPath);
+                if (MessageBox.Show(text, title, MessageBoxButtons.OKCancel) == DialogResult.OK)
+                {
+                    string from = file.BackupFullPath;
+                    string to = file.FullPath;
+                    File.Copy(from, to, true);
+                }
+            }
+        }
     }
     }
 }
 }

+ 6 - 0
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/FileRestoreForm.resx

@@ -117,10 +117,16 @@
   <resheader name="writer">
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
   </resheader>
+  <metadata name="DgvFilesVersion.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="DgvFilesLastWriteTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   <metadata name="DgvFilesLastWriteTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
     <value>True</value>
   </metadata>
   </metadata>
   <metadata name="DgvFilesSize.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
   <metadata name="DgvFilesSize.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
     <value>True</value>
   </metadata>
   </metadata>
+  <metadata name="TtLabel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
 </root>
 </root>