mirror of
https://github.com/Ylianst/MeshCentralRouter
synced 2025-12-06 00:13:33 +00:00
Added file tranfer overwrite warning.
This commit is contained in:
114
FileConfirmOverwriteForm.Designer.cs
generated
Normal file
114
FileConfirmOverwriteForm.Designer.cs
generated
Normal file
@@ -0,0 +1,114 @@
|
||||
namespace MeshCentralRouter
|
||||
{
|
||||
partial class FileConfirmOverwriteForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
25
FileConfirmOverwriteForm.cs
Normal file
25
FileConfirmOverwriteForm.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
FileConfirmOverwriteForm.resx
Normal file
120
FileConfirmOverwriteForm.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -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; }
|
||||
|
||||
@@ -94,6 +94,12 @@
|
||||
<Compile Include="AddRelayMapForm.designer.cs">
|
||||
<DependentUpon>AddRelayMapForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FileConfirmOverwriteForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileConfirmOverwriteForm.Designer.cs">
|
||||
<DependentUpon>FileConfirmOverwriteForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LocalPipe.cs" />
|
||||
<Compile Include="SshUsernameForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
@@ -256,6 +262,9 @@
|
||||
<EmbeddedResource Include="AddRelayMapForm.resx">
|
||||
<DependentUpon>AddRelayMapForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FileConfirmOverwriteForm.resx">
|
||||
<DependentUpon>FileConfirmOverwriteForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="SshUsernameForm.resx">
|
||||
<DependentUpon>SshUsernameForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
Reference in New Issue
Block a user