diff --git a/FileConfirmOverwriteForm.Designer.cs b/FileConfirmOverwriteForm.Designer.cs
new file mode 100644
index 0000000..05c2f8c
--- /dev/null
+++ b/FileConfirmOverwriteForm.Designer.cs
@@ -0,0 +1,114 @@
+namespace MeshCentralRouter
+{
+ partial class FileConfirmOverwriteForm
+ {
+ ///
+ /// 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()
+ {
+ this.mainGroupBox = new System.Windows.Forms.GroupBox();
+ this.mainLabel = new System.Windows.Forms.Label();
+ this.okButton = new System.Windows.Forms.Button();
+ this.cancelButton = new System.Windows.Forms.Button();
+ this.mainGroupBox.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // mainGroupBox
+ //
+ this.mainGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.mainGroupBox.Controls.Add(this.mainLabel);
+ this.mainGroupBox.Location = new System.Drawing.Point(12, 12);
+ this.mainGroupBox.Name = "mainGroupBox";
+ this.mainGroupBox.Size = new System.Drawing.Size(315, 48);
+ this.mainGroupBox.TabIndex = 6;
+ this.mainGroupBox.TabStop = false;
+ this.mainGroupBox.Text = "Confirm Overwrite";
+ //
+ // mainLabel
+ //
+ this.mainLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.mainLabel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.mainLabel.Location = new System.Drawing.Point(14, 23);
+ this.mainLabel.Name = "mainLabel";
+ this.mainLabel.Size = new System.Drawing.Size(295, 38);
+ this.mainLabel.TabIndex = 1;
+ this.mainLabel.Text = "---";
+ //
+ // okButton
+ //
+ this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.okButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.okButton.Location = new System.Drawing.Point(171, 66);
+ this.okButton.Name = "okButton";
+ this.okButton.Size = new System.Drawing.Size(75, 23);
+ this.okButton.TabIndex = 4;
+ this.okButton.Text = "OK";
+ this.okButton.UseVisualStyleBackColor = true;
+ this.okButton.Click += new System.EventHandler(this.okButton_Click);
+ //
+ // cancelButton
+ //
+ this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.cancelButton.ImeMode = System.Windows.Forms.ImeMode.NoControl;
+ this.cancelButton.Location = new System.Drawing.Point(252, 66);
+ this.cancelButton.Name = "cancelButton";
+ this.cancelButton.Size = new System.Drawing.Size(75, 23);
+ this.cancelButton.TabIndex = 5;
+ this.cancelButton.Text = "Cancel";
+ this.cancelButton.UseVisualStyleBackColor = true;
+ this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+ //
+ // FileConfirmOverwriteForm
+ //
+ this.AcceptButton = this.okButton;
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.CancelButton = this.cancelButton;
+ this.ClientSize = new System.Drawing.Size(339, 101);
+ this.Controls.Add(this.mainGroupBox);
+ this.Controls.Add(this.okButton);
+ this.Controls.Add(this.cancelButton);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
+ this.Name = "FileConfirmOverwriteForm";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.Text = "File Operation";
+ this.mainGroupBox.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox mainGroupBox;
+ private System.Windows.Forms.Label mainLabel;
+ private System.Windows.Forms.Button okButton;
+ private System.Windows.Forms.Button cancelButton;
+ }
+}
\ No newline at end of file
diff --git a/FileConfirmOverwriteForm.cs b/FileConfirmOverwriteForm.cs
new file mode 100644
index 0000000..822fb85
--- /dev/null
+++ b/FileConfirmOverwriteForm.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Windows.Forms;
+
+namespace MeshCentralRouter
+{
+ public partial class FileConfirmOverwriteForm : Form
+ {
+ public FileConfirmOverwriteForm()
+ {
+ InitializeComponent();
+ }
+
+ public string mainTextLabel { get { return mainLabel.Text; } set { mainLabel.Text = value; } }
+
+ private void okButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.OK;
+ }
+
+ private void cancelButton_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ }
+ }
+}
diff --git a/FileConfirmOverwriteForm.resx b/FileConfirmOverwriteForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/FileConfirmOverwriteForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
+
+
\ No newline at end of file
diff --git a/FileViewer.cs b/FileViewer.cs
index 446a4cf..c3db568 100644
--- a/FileViewer.cs
+++ b/FileViewer.cs
@@ -927,7 +927,41 @@ namespace MeshCentralRouter
private void uploadButton_Click(object sender, EventArgs e)
{
+ // If a transfer is currently active, ignore this.
if (uploadActive || downloadActive) return;
+
+ // If any files are going to be overwritten
+ int overWriteCount = 0;
+ foreach (ListViewItem l in leftListView.SelectedItems) {
+ if (l.ImageIndex == 2) {
+ string filename = l.Text;
+
+ foreach (ListViewItem l2 in rightListView.Items)
+ {
+ if (l2.ImageIndex == 2)
+ {
+ string filename2 = l2.Text;
+ if (node.agentid < 5) { filename = filename.ToLower(); filename2 = filename2.ToLower(); }
+ if (filename.Equals(filename2)) { overWriteCount++; }
+ }
+ }
+ }
+ }
+
+ if (overWriteCount > 0)
+ {
+ FileConfirmOverwriteForm f = new FileConfirmOverwriteForm();
+ if (overWriteCount == 1) { f.mainTextLabel = String.Format("Overwrite 1 file?", overWriteCount); } else { f.mainTextLabel = String.Format("Overwrite {0} files?", overWriteCount); }
+ if (f.ShowDialog(this) == DialogResult.OK) { performFileUpload(); }
+ }
+ else
+ {
+ performFileUpload();
+ }
+ }
+
+ private void performFileUpload()
+ {
uploadFileArrayPtr = 0;
uploadFileArray = new ArrayList();
foreach (ListViewItem l in leftListView.SelectedItems) { if (l.ImageIndex == 2) { uploadFileArray.Add(l.Text); } }
@@ -940,10 +974,12 @@ namespace MeshCentralRouter
// Show transfer status dialog
transferStatusForm = new FileTransferStatusForm(this);
transferStatusForm.Show(this);
- }
+ }
private void uploadNextFile()
{
+ if ((uploadFileArray == null) || (uploadFileArray.Count == 0)) return;
+
string localFilePath, localFileName;
if (uploadLocalPath != null)
{
@@ -1019,12 +1055,50 @@ namespace MeshCentralRouter
private void downloadButton_Click(object sender, EventArgs e)
{
+ // If a transfer is currently active, ignore this.
if (uploadActive || downloadActive) return;
+
+ // If any files are going to be overwritten
+ int overWriteCount = 0;
+ foreach (ListViewItem l in rightListView.SelectedItems)
+ {
+ if (l.ImageIndex == 2)
+ {
+ string filename = l.Text;
+
+ foreach (ListViewItem l2 in leftListView.Items)
+ {
+ if (l2.ImageIndex == 2)
+ {
+ string filename2 = l2.Text;
+ if (node.agentid < 5) { filename = filename.ToLower(); filename2 = filename2.ToLower(); }
+ if (filename.Equals(filename2)) { overWriteCount++; }
+ }
+ }
+ }
+ }
+
+ if (overWriteCount > 0)
+ {
+ FileConfirmOverwriteForm f = new FileConfirmOverwriteForm();
+ if (overWriteCount == 1) { f.mainTextLabel = String.Format("Overwrite 1 file?", overWriteCount); } else { f.mainTextLabel = String.Format("Overwrite {0} files?", overWriteCount); }
+ if (f.ShowDialog(this) == DialogResult.OK) { performFileDownload(); }
+ }
+ else
+ {
+ performFileDownload();
+ }
+ }
+
+ private void performFileDownload()
+ {
downloadFileArrayPtr = 0;
downloadFileArray = new ArrayList();
downloadFileSizeArray = new ArrayList();
- foreach (ListViewItem l in rightListView.SelectedItems) {
- if (l.ImageIndex == 2) {
+ foreach (ListViewItem l in rightListView.SelectedItems)
+ {
+ if (l.ImageIndex == 2)
+ {
downloadFileArray.Add(l.Text);
downloadFileSizeArray.Add(int.Parse(l.SubItems[1].Text));
}
@@ -1042,6 +1116,8 @@ namespace MeshCentralRouter
private void downloadNextFile()
{
+ if ((downloadFileArray == null) || (downloadFileArray.Count == 0)) return;
+
string localFilePath;
localFilePath = Path.Combine(downloadLocalPath.FullName, (string)downloadFileArray[downloadFileArrayPtr]);
try { downloadFileStream = File.OpenWrite(localFilePath); } catch (Exception) { return; }
diff --git a/MeshCentralRouter.csproj b/MeshCentralRouter.csproj
index 912e28a..68590ef 100644
--- a/MeshCentralRouter.csproj
+++ b/MeshCentralRouter.csproj
@@ -94,6 +94,12 @@
AddRelayMapForm.cs
+
+ Form
+
+
+ FileConfirmOverwriteForm.cs
+
Form
@@ -256,6 +262,9 @@
AddRelayMapForm.cs
+
+ FileConfirmOverwriteForm.cs
+
SshUsernameForm.cs