Added Icon to Refresh directory in File Manager #262

Added Upload to context menu
This commit is contained in:
MaxXor 2015-08-07 14:32:26 +02:00
parent af3442a954
commit 3be58078cc
4 changed files with 132 additions and 13 deletions

View File

@ -53,7 +53,7 @@
this.groupAutostartItem.Controls.Add(this.lblName);
this.groupAutostartItem.Location = new System.Drawing.Point(12, 12);
this.groupAutostartItem.Name = "groupAutostartItem";
this.groupAutostartItem.Size = new System.Drawing.Size(438, 105);
this.groupAutostartItem.Size = new System.Drawing.Size(653, 105);
this.groupAutostartItem.TabIndex = 0;
this.groupAutostartItem.TabStop = false;
this.groupAutostartItem.Text = "Autostart Item";
@ -73,7 +73,7 @@
this.cmbType.FormattingEnabled = true;
this.cmbType.Location = new System.Drawing.Point(74, 71);
this.cmbType.Name = "cmbType";
this.cmbType.Size = new System.Drawing.Size(358, 21);
this.cmbType.Size = new System.Drawing.Size(573, 21);
this.cmbType.TabIndex = 5;
this.toolTip1.SetToolTip(this.cmbType, "Remote Type of Autostart Item.");
//
@ -81,7 +81,7 @@
//
this.txtPath.Location = new System.Drawing.Point(74, 43);
this.txtPath.Name = "txtPath";
this.txtPath.Size = new System.Drawing.Size(358, 22);
this.txtPath.Size = new System.Drawing.Size(573, 22);
this.txtPath.TabIndex = 3;
this.toolTip1.SetToolTip(this.txtPath, "Remote Path to Autostart Item.");
this.txtPath.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtPath_KeyPress);
@ -91,7 +91,7 @@
this.txtName.Location = new System.Drawing.Point(74, 15);
this.txtName.MaxLength = 64;
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(358, 22);
this.txtName.Size = new System.Drawing.Size(573, 22);
this.txtName.TabIndex = 1;
this.txtName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtName_KeyPress);
//
@ -116,9 +116,9 @@
// btnAdd
//
this.btnAdd.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnAdd.Location = new System.Drawing.Point(375, 123);
this.btnAdd.Location = new System.Drawing.Point(576, 123);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(75, 23);
this.btnAdd.Size = new System.Drawing.Size(89, 23);
this.btnAdd.TabIndex = 1;
this.btnAdd.Text = "&Add";
this.btnAdd.UseVisualStyleBackColor = true;
@ -127,9 +127,9 @@
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(294, 123);
this.btnCancel.Location = new System.Drawing.Point(449, 123);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.Size = new System.Drawing.Size(89, 23);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "&Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
@ -141,7 +141,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(462, 158);
this.ClientSize = new System.Drawing.Size(677, 158);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.groupAutostartItem);

View File

@ -52,6 +52,7 @@ namespace xServer.Forms
this.imgListTransfers = new System.Windows.Forms.ImageList(this.components);
this.TabControlFileManager = new xServer.Controls.DotNetBarTabControl();
this.tabFileExplorer = new System.Windows.Forms.TabPage();
this.btnRefresh = new System.Windows.Forms.Button();
this.lblPath = new System.Windows.Forms.Label();
this.txtPath = new System.Windows.Forms.TextBox();
this.lstDirectory = new xServer.Controls.AeroListView();
@ -66,6 +67,7 @@ namespace xServer.Forms
this.hID = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.hStatus = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.hFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.ctxtUpload = new System.Windows.Forms.ToolStripMenuItem();
this.ctxtMenu.SuspendLayout();
this.botStrip.SuspendLayout();
this.ctxtMenu2.SuspendLayout();
@ -78,6 +80,7 @@ namespace xServer.Forms
//
this.ctxtMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ctxtDownload,
this.ctxtUpload,
this.ctxtLine2,
this.ctxtExecute,
this.ctxtRename,
@ -88,10 +91,11 @@ namespace xServer.Forms
this.ctxtRefresh,
this.ctxtOpenDirectory});
this.ctxtMenu.Name = "ctxtMenu";
this.ctxtMenu.Size = new System.Drawing.Size(240, 176);
this.ctxtMenu.Size = new System.Drawing.Size(240, 220);
//
// ctxtDownload
//
this.ctxtDownload.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.ctxtDownload.Image = global::xServer.Properties.Resources.download;
this.ctxtDownload.Name = "ctxtDownload";
this.ctxtDownload.Size = new System.Drawing.Size(239, 22);
@ -241,6 +245,7 @@ namespace xServer.Forms
// tabFileExplorer
//
this.tabFileExplorer.BackColor = System.Drawing.SystemColors.Control;
this.tabFileExplorer.Controls.Add(this.btnRefresh);
this.tabFileExplorer.Controls.Add(this.lblPath);
this.tabFileExplorer.Controls.Add(this.txtPath);
this.tabFileExplorer.Controls.Add(this.lstDirectory);
@ -253,6 +258,19 @@ namespace xServer.Forms
this.tabFileExplorer.TabIndex = 0;
this.tabFileExplorer.Text = "File Explorer";
//
// btnRefresh
//
this.btnRefresh.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.btnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnRefresh.Image = global::xServer.Properties.Resources.refresh;
this.btnRefresh.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
this.btnRefresh.Location = new System.Drawing.Point(682, 8);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(22, 22);
this.btnRefresh.TabIndex = 5;
this.btnRefresh.UseVisualStyleBackColor = true;
this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
//
// lblPath
//
this.lblPath.AutoSize = true;
@ -270,7 +288,7 @@ namespace xServer.Forms
this.txtPath.Location = new System.Drawing.Point(360, 8);
this.txtPath.Name = "txtPath";
this.txtPath.ReadOnly = true;
this.txtPath.Size = new System.Drawing.Size(346, 22);
this.txtPath.Size = new System.Drawing.Size(323, 22);
this.txtPath.TabIndex = 3;
this.txtPath.Text = "\\";
//
@ -390,6 +408,14 @@ namespace xServer.Forms
this.hFilename.Text = "Filename";
this.hFilename.Width = 337;
//
// ctxtUpload
//
this.ctxtUpload.Image = global::xServer.Properties.Resources.upload;
this.ctxtUpload.Name = "ctxtUpload";
this.ctxtUpload.Size = new System.Drawing.Size(239, 22);
this.ctxtUpload.Text = "Upload";
this.ctxtUpload.Click += new System.EventHandler(this.ctxtUpload_Click);
//
// FrmFileManager
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -457,5 +483,7 @@ namespace xServer.Forms
private System.Windows.Forms.ToolStripStatusLabel stripLblStatus;
private System.Windows.Forms.Label lblPath;
private System.Windows.Forms.TextBox txtPath;
private System.Windows.Forms.Button btnRefresh;
private System.Windows.Forms.ToolStripMenuItem ctxtUpload;
}
}

View File

@ -107,6 +107,92 @@ namespace xServer.Forms
}
}
private void ctxtUpload_Click(object sender, EventArgs e)
{
using (var ofd = new OpenFileDialog())
{
ofd.Title = "Select files to upload";
ofd.Filter = "All files (*.*)|*.*";
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
var remoteDir = _currentDir;
foreach (var filePath in ofd.FileNames)
{
if (!File.Exists(filePath)) continue;
string path = filePath;
new Thread(() =>
{
int id = FileHelper.GetNewTransferId();
if (string.IsNullOrEmpty(path)) return;
AddTransfer(id, "Uploading...", Path.GetFileName(path));
int index = GetTransferIndex(id);
if (index < 0)
return;
FileSplit srcFile = new FileSplit(path);
if (srcFile.MaxBlocks < 0)
{
UpdateTransferStatus(index, "Error reading file", 0);
return;
}
string remotePath = Path.Combine(remoteDir, Path.GetFileName(path));
if (string.IsNullOrEmpty(remotePath)) return;
_limitThreads.WaitOne();
for (int currentBlock = 0; currentBlock < srcFile.MaxBlocks; currentBlock++)
{
if (_connectClient.Value == null || _connectClient.Value.FrmFm == null)
{
_limitThreads.Release();
return; // abort upload when from is closed or client disconnected
}
if (CanceledUploads.ContainsKey(id))
{
UpdateTransferStatus(index, "Canceled", 0);
_limitThreads.Release();
return;
}
decimal progress =
Math.Round((decimal)((double)(currentBlock + 1) / (double)srcFile.MaxBlocks * 100.0), 2);
UpdateTransferStatus(index, string.Format("Uploading...({0}%)", progress), -1);
byte[] block;
if (srcFile.ReadBlock(currentBlock, out block))
{
new Core.Packets.ServerPackets.DoUploadFile(id,
remotePath, block, srcFile.MaxBlocks,
currentBlock).Execute(_connectClient);
}
else
{
UpdateTransferStatus(index, "Error reading file", 0);
_limitThreads.Release();
return;
}
}
_limitThreads.Release();
if (remoteDir == _currentDir)
RefreshDirectory();
UpdateTransferStatus(index, "Completed", 1);
}).Start();
}
}
}
}
private void ctxtExecute_Click(object sender, EventArgs e)
{
foreach (ListViewItem files in lstDirectory.SelectedItems)
@ -358,6 +444,11 @@ namespace xServer.Forms
}
}
private void btnRefresh_Click(object sender, EventArgs e)
{
RefreshDirectory();
}
private void FrmFileManager_KeyDown(object sender, KeyEventArgs e)
{
// refresh when F5 is pressed

View File

@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAW
EwAAAk1TRnQ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