From 59fe9ac873426feed7495f37feb4c1bcaa97b84c Mon Sep 17 00:00:00 2001 From: Manuel Date: Sat, 4 Nov 2023 11:01:14 +0100 Subject: [PATCH] Added description column --- MiniserverForm.Designer.cs | 28 ++++++++++++++++++++-------- MiniserverForm.cs | 29 +++++++++++++++++------------ MiniserverForm.resx | 5 ++++- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/MiniserverForm.Designer.cs b/MiniserverForm.Designer.cs index 1239495..17b4931 100644 --- a/MiniserverForm.Designer.cs +++ b/MiniserverForm.Designer.cs @@ -1,4 +1,4 @@ -using System.Drawing; +using System.Drawing; using System.Windows.Forms; namespace LoxStatEdit @@ -44,6 +44,7 @@ private void InitializeComponent() this._folderTextBox = new System.Windows.Forms.TextBox(); this._dataGridView = new System.Windows.Forms.DataGridView(); this._nameCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this._descriptionCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._yearMonthCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._statusCol = new System.Windows.Forms.DataGridViewTextBoxColumn(); this._downloadCol = new System.Windows.Forms.DataGridViewButtonColumn(); @@ -72,7 +73,7 @@ private void InitializeComponent() // refreshFolderButton // refreshFolderButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - refreshFolderButton.Location = new System.Drawing.Point(632, 38); + refreshFolderButton.Location = new System.Drawing.Point(882, 38); refreshFolderButton.Name = "refreshFolderButton"; refreshFolderButton.Size = new System.Drawing.Size(75, 23); refreshFolderButton.TabIndex = 5; @@ -84,7 +85,7 @@ private void InitializeComponent() // refreshMsButton // refreshMsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - refreshMsButton.Location = new System.Drawing.Point(632, 12); + refreshMsButton.Location = new System.Drawing.Point(882, 12); refreshMsButton.Name = "refreshMsButton"; refreshMsButton.Size = new System.Drawing.Size(75, 23); refreshMsButton.TabIndex = 2; @@ -104,7 +105,7 @@ private void InitializeComponent() // downloadButton // downloadButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - downloadButton.Location = new System.Drawing.Point(596, 527); + downloadButton.Location = new System.Drawing.Point(846, 527); downloadButton.Name = "downloadButton"; downloadButton.Size = new System.Drawing.Size(111, 23); downloadButton.TabIndex = 7; @@ -128,7 +129,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this._urlTextBox.Location = new System.Drawing.Point(100, 14); this._urlTextBox.Name = "_urlTextBox"; - this._urlTextBox.Size = new System.Drawing.Size(526, 20); + this._urlTextBox.Size = new System.Drawing.Size(776, 20); this._urlTextBox.TabIndex = 1; this._urlTextBox.Text = "ftp://adminname:adminpassword@miniserver-ip-or-hostname:21"; this._urlTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this._urlTextBox_KeyDown); @@ -139,7 +140,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this._folderTextBox.Location = new System.Drawing.Point(100, 40); this._folderTextBox.Name = "_folderTextBox"; - this._folderTextBox.Size = new System.Drawing.Size(526, 20); + this._folderTextBox.Size = new System.Drawing.Size(776, 20); this._folderTextBox.TabIndex = 4; this._folderTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this._folderTextBox_KeyDown); // @@ -153,6 +154,7 @@ private void InitializeComponent() this._dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this._dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this._nameCol, + this._descriptionCol, this._yearMonthCol, this._statusCol, this._downloadCol, @@ -162,7 +164,7 @@ private void InitializeComponent() this._dataGridView.Name = "_dataGridView"; this._dataGridView.RowHeadersWidth = 30; this._dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this._dataGridView.Size = new System.Drawing.Size(695, 453); + this._dataGridView.Size = new System.Drawing.Size(945, 453); this._dataGridView.TabIndex = 6; this._dataGridView.VirtualMode = true; this._dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridView_CellContentClick); @@ -177,6 +179,15 @@ private void InitializeComponent() this._nameCol.ReadOnly = true; this._nameCol.Width = 250; // + // _descriptionCol + // + this._descriptionCol.DataPropertyName = "Description"; + this._descriptionCol.HeaderText = "Description"; + this._descriptionCol.MinimumWidth = 8; + this._descriptionCol.Name = "_descriptionCol"; + this._descriptionCol.ReadOnly = true; + this._descriptionCol.Width = 250; + // // _yearMonthCol // this._yearMonthCol.DataPropertyName = "YearMonth"; @@ -258,7 +269,7 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(719, 561); + this.ClientSize = new System.Drawing.Size(969, 561); this.Controls.Add(this.donateLabel); this.Controls.Add(aboutLabel); this.Controls.Add(this.githubLabel); @@ -288,6 +299,7 @@ private void InitializeComponent() private LinkLabel githubLabel; private ToolTip toolTip; private DataGridViewTextBoxColumn _nameCol; + private DataGridViewTextBoxColumn _descriptionCol; private DataGridViewTextBoxColumn _yearMonthCol; private DataGridViewTextBoxColumn _statusCol; private DataGridViewButtonColumn _downloadCol; diff --git a/MiniserverForm.cs b/MiniserverForm.cs index c8b5af2..fe32c00 100644 --- a/MiniserverForm.cs +++ b/MiniserverForm.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -42,7 +42,8 @@ public string Name _name = null; } if(string.IsNullOrEmpty(_name)) - _name = FileName; + //_name = FileName; + _name = "Download to view description"; } return _name; } @@ -136,7 +137,10 @@ private void RefreshGridView() MsFileInfo = msMap[f].FirstOrDefault(), FileInfo = localMap[f].FirstOrDefault(), }). - OrderBy(f => f). + // Order by descriptio + //OrderBy(f => f). + // Order by filename if available else by name + OrderBy(f => f.MsFileInfo?.FileName ?? f.FileInfo?.Name). ToList(); _dataGridView.RowCount = _fileItems.Count; _dataGridView.Refresh(); @@ -299,12 +303,13 @@ private void DataGridView_CellValueNeeded(object sender, DataGridViewCellValueEv var fileItem = _fileItems[e.RowIndex]; switch(e.ColumnIndex) { - case 0: e.Value = fileItem.Name; break; - case 1: e.Value = fileItem.YearMonth; break; - case 2: e.Value = fileItem.Status; break; - case 3: e.Value = "Download"; break; - case 4: e.Value = "Edit"; break; - case 5: e.Value = "Upload"; break; + case 0: e.Value = fileItem.FileName; break; + case 1: e.Value = fileItem.Name; break; + case 2: e.Value = fileItem.YearMonth; break; + case 3: e.Value = fileItem.Status; break; + case 4: e.Value = "Download"; break; + case 5: e.Value = "Edit"; break; + case 6: e.Value = "Upload"; break; default: e.Value = null; break; } } @@ -323,16 +328,16 @@ private void DataGridView_CellContentClick(object sender, DataGridViewCellEventA var fileItem = _fileItems[e.RowIndex]; switch(e.ColumnIndex) { - case 3: //Download + case 4: //Download Download(fileItem); RefreshLocal(); RefreshGridView(); break; - case 4: //Edit + case 5: //Edit using(var form = new LoxStatFileForm(fileItem.FileInfo.FullName)) form.ShowDialog(this); break; - case 5: //Upload + case 6: //Upload Upload(fileItem); RefreshMs(); RefreshGridView(); diff --git a/MiniserverForm.resx b/MiniserverForm.resx index 60cd1ea..c0e6630 100644 --- a/MiniserverForm.resx +++ b/MiniserverForm.resx @@ -1,4 +1,4 @@ - +