From ba77f6f61ac0890dd1352e16b5e9a888905761a7 Mon Sep 17 00:00:00 2001 From: adnan29979 <148310766+adnan29979@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:44:20 +0600 Subject: [PATCH] added 'Date Modified' column for files (#82) --- src/FileViewer.Designer.cs | 20 ++- src/FileViewer.cs | 26 +-- src/FileViewer.resx | 348 +++++++++++++++++-------------------- 3 files changed, 193 insertions(+), 201 deletions(-) diff --git a/src/FileViewer.Designer.cs b/src/FileViewer.Designer.cs index d547bfc..2993c37 100644 --- a/src/FileViewer.Designer.cs +++ b/src/FileViewer.Designer.cs @@ -1,4 +1,4 @@ -using System.Windows.Forms; +using System.Windows.Forms; namespace MeshCentralRouter { @@ -81,6 +81,8 @@ namespace MeshCentralRouter this.refreshToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.leftTopPanel = new System.Windows.Forms.Panel(); this.localLabel = new System.Windows.Forms.Label(); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.topPanel.SuspendLayout(); this.statusStrip.SuspendLayout(); this.mainTableLayoutPanel.SuspendLayout(); @@ -291,7 +293,8 @@ namespace MeshCentralRouter this.rightListView.AllowDrop = true; this.rightListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader3, - this.columnHeader4}); + this.columnHeader4, + this.columnHeader5}); this.rightListView.ContextMenuStrip = this.remoteContextMenuStrip; resources.ApplyResources(this.rightListView, "rightListView"); this.rightListView.FullRowSelect = true; @@ -397,7 +400,8 @@ namespace MeshCentralRouter this.leftListView.AllowDrop = true; this.leftListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader1, - this.columnHeader2}); + this.columnHeader2, + this.columnHeader6}); this.leftListView.ContextMenuStrip = this.localContextMenuStrip; resources.ApplyResources(this.leftListView, "leftListView"); this.leftListView.FullRowSelect = true; @@ -473,6 +477,14 @@ namespace MeshCentralRouter resources.ApplyResources(this.localLabel, "localLabel"); this.localLabel.Name = "localLabel"; // + // columnHeader5 + // + resources.ApplyResources(this.columnHeader5, "columnHeader5"); + // + // columnHeader6 + // + resources.ApplyResources(this.columnHeader6, "columnHeader6"); + // // FileViewer // resources.ApplyResources(this, "$this"); @@ -552,6 +564,8 @@ namespace MeshCentralRouter private ToolStripMenuItem refreshToolStripMenuItem1; private ToolStripMenuItem compressToolStripMenuItem; private Button remoteZipButton; + private ColumnHeader columnHeader5; + private ColumnHeader columnHeader6; } } diff --git a/src/FileViewer.cs b/src/FileViewer.cs index d0f4aba..bbb76d7 100644 --- a/src/FileViewer.cs +++ b/src/FileViewer.cs @@ -1,4 +1,4 @@ -/* +/* Copyright 2009-2021 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); @@ -88,7 +88,7 @@ namespace MeshCentralRouter this.server = server; UpdateStatus(); - rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 22; + rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 150; // Load the local path from the registry string lp = Settings.GetRegValue("LocalPath", ""); @@ -141,9 +141,10 @@ namespace MeshCentralRouter foreach(FileInfo file in files) { if(file.Attributes.HasFlag(FileAttributes.Hidden)) continue; - string[] si = new string[2]; + string[] si = new string[3]; si[0] = file.Name; si[1] = "" + file.Length; + si[2] = file.LastWriteTime.ToString("dd-MM-yyyy hh:mm:ss tt"); // Add the date information ListViewItem x = new ListViewItem(si, 2); x.Tag = file; leftListView.Items.Add(x); @@ -268,9 +269,10 @@ namespace MeshCentralRouter if(fileIcon == 3) { // File - string[] si = new string[2]; + string[] si = new string[3]; si[0] = fileName; si[1] = "" + fileSize; + si[2] = fileDate != null ? DateTime.TryParse(fileDate, out DateTime parsedDate) ? parsedDate.ToString("dd-MM-yyyy hh:mm:ss tt") : "" : ""; // Add the date information sortlist.Add(new ListViewItem(si, 2)); // File } } @@ -1054,9 +1056,9 @@ namespace MeshCentralRouter private void rightListView_Resize(object sender, EventArgs e) { - if(rightListView.Columns[0].Width != (rightListView.Width - rightListView.Columns[1].Width - 22)) + if(rightListView.Columns[0].Width != (rightListView.Width - rightListView.Columns[1].Width - 150)) { - rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 22; + rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 150; } } @@ -1067,9 +1069,9 @@ namespace MeshCentralRouter bRightCWChangedBusy=true; try { - if(rightListView.Columns[0].Width != (rightListView.Width - rightListView.Columns[1].Width - 22)) + if(rightListView.Columns[0].Width != (rightListView.Width - rightListView.Columns[1].Width - 150)) { - rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 22; + rightListView.Columns[0].Width = rightListView.Width - rightListView.Columns[1].Width - 150; } } catch { } @@ -1078,9 +1080,9 @@ namespace MeshCentralRouter private void leftListView_Resize(object sender, EventArgs e) { - if(leftListView.Columns[0].Width != (leftListView.Width - leftListView.Columns[1].Width - 22)) + if(leftListView.Columns[0].Width != (leftListView.Width - leftListView.Columns[1].Width - 150)) { - leftListView.Columns[0].Width = leftListView.Width - leftListView.Columns[1].Width - 22; + leftListView.Columns[0].Width = leftListView.Width - leftListView.Columns[1].Width - 150; } } @@ -1091,9 +1093,9 @@ namespace MeshCentralRouter bLeftCWChangedBusy=true; try { - if(leftListView.Columns[0].Width != (leftListView.Width - leftListView.Columns[1].Width - 22)) + if(leftListView.Columns[0].Width != (leftListView.Width - leftListView.Columns[1].Width - 150)) { - leftListView.Columns[0].Width = leftListView.Width - leftListView.Columns[1].Width - 22; + leftListView.Columns[0].Width = leftListView.Width - leftListView.Columns[1].Width - 150; } } catch { } diff --git a/src/FileViewer.resx b/src/FileViewer.resx index ff6e973..9a5ad92 100644 --- a/src/FileViewer.resx +++ b/src/FileViewer.resx @@ -1,4 +1,4 @@ - +