diff --git a/HelpersLib/HelpersLib.csproj b/HelpersLib/HelpersLib.csproj index ee59a10dd..6e096e589 100644 --- a/HelpersLib/HelpersLib.csproj +++ b/HelpersLib/HelpersLib.csproj @@ -115,6 +115,7 @@ + diff --git a/UploadersLib/FTPClient/LoginDialog.cs b/HelpersLib/TextBoxTraceListener.cs similarity index 62% rename from UploadersLib/FTPClient/LoginDialog.cs rename to HelpersLib/TextBoxTraceListener.cs index f0854e1ae..71133d5d2 100644 --- a/UploadersLib/FTPClient/LoginDialog.cs +++ b/HelpersLib/TextBoxTraceListener.cs @@ -24,21 +24,35 @@ You should have received a copy of the GNU General Public License #endregion License Information (GPL v3) using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; using System.Windows.Forms; -namespace UploadersLib +namespace HelpersLib { - public partial class LoginDialog : Form + public class TextBoxTraceListener : TraceListener { - public LoginDialog() + private TextBox textBox; + + public TextBoxTraceListener(TextBox textBox) { - InitializeComponent(); + this.textBox = textBox; } - private void btnOK_Click(object sender, EventArgs e) + public override void Write(string message) { - DialogResult = DialogResult.OK; - Close(); + textBox.InvokeSafe(() => + { + string text = string.Format("{0} - {1}", DateTime.Now.ToLongTimeString(), message); + textBox.AppendText(text); + }); + } + + public override void WriteLine(string message) + { + Write(message + "\r\n"); } } } \ No newline at end of file diff --git a/UploadersLib/FTPClient/FTPClientForm.Designer.cs b/UploadersLib/FTPClient/FTPClientForm.Designer.cs index 687bc436e..c8747258c 100644 --- a/UploadersLib/FTPClient/FTPClientForm.Designer.cs +++ b/UploadersLib/FTPClient/FTPClientForm.Designer.cs @@ -50,19 +50,19 @@ private void InitializeComponent() this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel(); + this.lvFTPList = new UploadersLib.ListViewEx(); + this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chFilesize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chFiletype = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.chLastModified = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tcFTP = new System.Windows.Forms.TabControl(); this.tpMain = new System.Windows.Forms.TabPage(); this.tpAccount = new System.Windows.Forms.TabPage(); this.pgAccount = new System.Windows.Forms.PropertyGrid(); this.tpConsole = new System.Windows.Forms.TabPage(); this.scConsole = new System.Windows.Forms.SplitContainer(); - this.rtbConsole = new System.Windows.Forms.RichTextBox(); + this.txtDebug = new System.Windows.Forms.TextBox(); this.txtConsoleWrite = new System.Windows.Forms.TextBox(); - this.lvFTPList = new UploadersLib.ListViewEx(); - this.chFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chFilesize = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chFiletype = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chLastModified = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.cmsRightClickMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); @@ -200,7 +200,7 @@ private void InitializeComponent() this.splitContainer1.Panel2.Controls.Add(this.pConnecting); this.splitContainer1.Panel2.Controls.Add(this.toolStripContainer1); this.splitContainer1.Size = new System.Drawing.Size(952, 557); - this.splitContainer1.SplitterDistance = 23; + this.splitContainer1.SplitterDistance = 25; this.splitContainer1.TabIndex = 0; // // cbDirectoryList @@ -255,11 +255,11 @@ private void InitializeComponent() // toolStripContainer1.ContentPanel // this.toolStripContainer1.ContentPanel.Controls.Add(this.lvFTPList); - this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(952, 483); + this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(952, 481); this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); this.toolStripContainer1.Name = "toolStripContainer1"; - this.toolStripContainer1.Size = new System.Drawing.Size(952, 530); + this.toolStripContainer1.Size = new System.Drawing.Size(952, 528); this.toolStripContainer1.TabIndex = 0; this.toolStripContainer1.Text = "toolStripContainer1"; // @@ -282,6 +282,55 @@ private void InitializeComponent() this.lblStatus.Size = new System.Drawing.Size(38, 17); this.lblStatus.Text = "status"; // + // lvFTPList + // + this.lvFTPList.AllowColumnReorder = true; + this.lvFTPList.AllowDrop = true; + this.lvFTPList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.chFilename, + this.chFilesize, + this.chFiletype, + this.chLastModified}); + this.lvFTPList.ContextMenuStrip = this.cmsRightClickMenu; + this.lvFTPList.Dock = System.Windows.Forms.DockStyle.Fill; + this.lvFTPList.DoubleClickActivation = false; + this.lvFTPList.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lvFTPList.FullRowSelect = true; + this.lvFTPList.GridLines = true; + this.lvFTPList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.lvFTPList.HideSelection = false; + this.lvFTPList.Location = new System.Drawing.Point(0, 0); + this.lvFTPList.Name = "lvFTPList"; + this.lvFTPList.Size = new System.Drawing.Size(952, 481); + this.lvFTPList.TabIndex = 0; + this.lvFTPList.UseCompatibleStateImageBehavior = false; + this.lvFTPList.View = System.Windows.Forms.View.Details; + this.lvFTPList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvFTPList_ItemDrag); + this.lvFTPList.SelectedIndexChanged += new System.EventHandler(this.lvFTPList_SelectedIndexChanged); + this.lvFTPList.DragDrop += new System.Windows.Forms.DragEventHandler(this.lvFTPList_DragDrop); + this.lvFTPList.DragOver += new System.Windows.Forms.DragEventHandler(this.lvFTPList_DragOver); + this.lvFTPList.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvFTPList_MouseDoubleClick); + // + // chFilename + // + this.chFilename.Text = "Filename"; + this.chFilename.Width = 493; + // + // chFilesize + // + this.chFilesize.Text = "Filesize"; + this.chFilesize.Width = 100; + // + // chFiletype + // + this.chFiletype.Text = "Filetype"; + this.chFiletype.Width = 200; + // + // chLastModified + // + this.chLastModified.Text = "Last modified"; + this.chLastModified.Width = 150; + // // tcFTP // this.tcFTP.Controls.Add(this.tpMain); @@ -348,90 +397,37 @@ private void InitializeComponent() // // scConsole.Panel1 // - this.scConsole.Panel1.Controls.Add(this.rtbConsole); + this.scConsole.Panel1.Controls.Add(this.txtDebug); // // scConsole.Panel2 // this.scConsole.Panel2.Controls.Add(this.txtConsoleWrite); this.scConsole.Panel2MinSize = 20; this.scConsole.Size = new System.Drawing.Size(952, 557); - this.scConsole.SplitterDistance = 536; + this.scConsole.SplitterDistance = 531; this.scConsole.SplitterWidth = 1; this.scConsole.TabIndex = 0; // - // rtbConsole + // txtDebug // - this.rtbConsole.BackColor = System.Drawing.Color.White; - this.rtbConsole.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.rtbConsole.Dock = System.Windows.Forms.DockStyle.Fill; - this.rtbConsole.EnableAutoDragDrop = true; - this.rtbConsole.Location = new System.Drawing.Point(0, 0); - this.rtbConsole.Name = "rtbConsole"; - this.rtbConsole.ReadOnly = true; - this.rtbConsole.Size = new System.Drawing.Size(952, 536); - this.rtbConsole.TabIndex = 0; - this.rtbConsole.Text = ""; - this.rtbConsole.WordWrap = false; + this.txtDebug.Dock = System.Windows.Forms.DockStyle.Fill; + this.txtDebug.Location = new System.Drawing.Point(0, 0); + this.txtDebug.Multiline = true; + this.txtDebug.Name = "txtDebug"; + this.txtDebug.ScrollBars = System.Windows.Forms.ScrollBars.Both; + this.txtDebug.Size = new System.Drawing.Size(952, 531); + this.txtDebug.TabIndex = 0; // // txtConsoleWrite // this.txtConsoleWrite.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtConsoleWrite.Dock = System.Windows.Forms.DockStyle.Bottom; - this.txtConsoleWrite.Location = new System.Drawing.Point(0, 0); + this.txtConsoleWrite.Location = new System.Drawing.Point(0, 5); this.txtConsoleWrite.Name = "txtConsoleWrite"; this.txtConsoleWrite.Size = new System.Drawing.Size(952, 20); this.txtConsoleWrite.TabIndex = 0; this.txtConsoleWrite.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtConsoleWrite_KeyDown); // - // lvFTPList - // - this.lvFTPList.AllowColumnReorder = true; - this.lvFTPList.AllowDrop = true; - this.lvFTPList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chFilename, - this.chFilesize, - this.chFiletype, - this.chLastModified}); - this.lvFTPList.ContextMenuStrip = this.cmsRightClickMenu; - this.lvFTPList.Dock = System.Windows.Forms.DockStyle.Fill; - this.lvFTPList.DoubleClickActivation = false; - this.lvFTPList.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lvFTPList.FullRowSelect = true; - this.lvFTPList.GridLines = true; - this.lvFTPList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.lvFTPList.HideSelection = false; - this.lvFTPList.Location = new System.Drawing.Point(0, 0); - this.lvFTPList.Name = "lvFTPList"; - this.lvFTPList.Size = new System.Drawing.Size(952, 483); - this.lvFTPList.TabIndex = 0; - this.lvFTPList.UseCompatibleStateImageBehavior = false; - this.lvFTPList.View = System.Windows.Forms.View.Details; - this.lvFTPList.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvFTPList_ItemDrag); - this.lvFTPList.SelectedIndexChanged += new System.EventHandler(this.lvFTPList_SelectedIndexChanged); - this.lvFTPList.DragDrop += new System.Windows.Forms.DragEventHandler(this.lvFTPList_DragDrop); - this.lvFTPList.DragOver += new System.Windows.Forms.DragEventHandler(this.lvFTPList_DragOver); - this.lvFTPList.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lvFTPList_MouseDoubleClick); - // - // chFilename - // - this.chFilename.Text = "Filename"; - this.chFilename.Width = 493; - // - // chFilesize - // - this.chFilesize.Text = "Filesize"; - this.chFilesize.Width = 100; - // - // chFiletype - // - this.chFiletype.Text = "Filetype"; - this.chFiletype.Width = 200; - // - // chLastModified - // - this.chLastModified.Text = "Last modified"; - this.chLastModified.Width = 150; - // // FTPClientForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -442,7 +438,7 @@ private void InitializeComponent() this.Name = "FTPClientForm"; this.Padding = new System.Windows.Forms.Padding(3); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "FTP client"; + this.Text = "ShareX FTP client"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FTPClient2_FormClosing); this.Resize += new System.EventHandler(this.FTPClient_Resize); this.cmsRightClickMenu.ResumeLayout(false); @@ -463,6 +459,7 @@ private void InitializeComponent() this.tpAccount.ResumeLayout(false); this.tpConsole.ResumeLayout(false); this.scConsole.Panel1.ResumeLayout(false); + this.scConsole.Panel1.PerformLayout(); this.scConsole.Panel2.ResumeLayout(false); this.scConsole.Panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.scConsole)).EndInit(); @@ -505,8 +502,8 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.TabPage tpAccount; private System.Windows.Forms.PropertyGrid pgAccount; - private System.Windows.Forms.RichTextBox rtbConsole; private System.Windows.Forms.SplitContainer scConsole; private System.Windows.Forms.TextBox txtConsoleWrite; + private System.Windows.Forms.TextBox txtDebug; } } \ No newline at end of file diff --git a/UploadersLib/FTPClient/FTPClientForm.cs b/UploadersLib/FTPClient/FTPClientForm.cs index 7e8c0b70d..1b2a779cc 100644 --- a/UploadersLib/FTPClient/FTPClientForm.cs +++ b/UploadersLib/FTPClient/FTPClientForm.cs @@ -54,6 +54,8 @@ public FTPClientForm(FTPAccount account) lblStatus.Text = string.Empty; lvFTPList.SubItemEndEditing += lvFTPList_SubItemEndEditing; + FtpTrace.AddListener(new TextBoxTraceListener(txtDebug)); + Account = account; Client = new FTP(account); @@ -310,17 +312,17 @@ private void FTPNavigateBack() } } - private void AddConsoleMessage(string text, Color color) + private string GetURL(FtpListItem file) { - this.InvokeSafe(() => + if (file != null && file.Type == FtpFileSystemObjectType.File) { - text = string.Format("{0} - {1}\r\n", DateTime.Now.ToLongTimeString(), text); - rtbConsole.AppendText(text); - rtbConsole.SelectionStart = rtbConsole.TextLength - text.Length + 1; - rtbConsole.SelectionLength = text.Length; - rtbConsole.SelectionColor = color; - rtbConsole.ScrollToCaret(); - }); + FTPAccount accountClone = Account.Clone(); + accountClone.SubFolderPath = currentDirectory; + accountClone.HttpHomePathAutoAddSubFolderPath = true; + return accountClone.GetUriPath(file.Name); + } + + return null; } #endregion Methods @@ -532,16 +534,15 @@ private void cbDirectoryList_SelectedIndexChanged(object sender, EventArgs e) private void copyURLsToClipboardToolStripMenuItem_Click(object sender, EventArgs e) { - string path; List list = new List(); foreach (ListViewItem lvi in lvFTPList.SelectedItems) { FtpListItem file = lvi.Tag as FtpListItem; - if (file != null && file.Type == FtpFileSystemObjectType.File) + string url = GetURL(file); + if (!string.IsNullOrEmpty(url)) { - path = Helpers.CombineURL(Account.HttpHomePath, file.FullName); - list.Add(path); + list.Add(url); } } @@ -558,10 +559,8 @@ private void openURLToolStripMenuItem_Click(object sender, EventArgs e) if (lvFTPList.SelectedItems.Count > 0) { FtpListItem file = lvFTPList.SelectedItems[0].Tag as FtpListItem; - if (file != null && file.Type == FtpFileSystemObjectType.File) - { - TaskEx.Run(() => Process.Start(Account.GetUriPath("@" + file.FullName))); - } + string url = GetURL(file); + Helpers.OpenURL(url); } } diff --git a/UploadersLib/FTPClient/LoginDialog.Designer.cs b/UploadersLib/FTPClient/LoginDialog.Designer.cs deleted file mode 100644 index b81751771..000000000 --- a/UploadersLib/FTPClient/LoginDialog.Designer.cs +++ /dev/null @@ -1,130 +0,0 @@ -namespace UploadersLib -{ - partial class LoginDialog - { - /// - /// 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.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtUserName = new System.Windows.Forms.TextBox(); - this.txtServer = new System.Windows.Forms.TextBox(); - this.btnOK = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(31, 21); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(38, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Server"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(9, 53); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(60, 13); - this.label2.TabIndex = 2; - this.label2.Text = "User Name"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(16, 85); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(53, 13); - this.label3.TabIndex = 4; - this.label3.Text = "Password"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(79, 80); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.Size = new System.Drawing.Size(184, 20); - this.txtPassword.TabIndex = 5; - // - // txtUserName - // - this.txtUserName.Location = new System.Drawing.Point(79, 48); - this.txtUserName.Name = "txtUserName"; - this.txtUserName.Size = new System.Drawing.Size(184, 20); - this.txtUserName.TabIndex = 3; - // - // txtServer - // - this.txtServer.Location = new System.Drawing.Point(79, 16); - this.txtServer.Name = "txtServer"; - this.txtServer.Size = new System.Drawing.Size(184, 20); - this.txtServer.TabIndex = 1; - // - // btnOK - // - this.btnOK.Location = new System.Drawing.Point(192, 120); - this.btnOK.Name = "btnOK"; - this.btnOK.Size = new System.Drawing.Size(75, 23); - this.btnOK.TabIndex = 6; - this.btnOK.Text = "&OK"; - this.btnOK.UseVisualStyleBackColor = true; - this.btnOK.Click += new System.EventHandler(this.btnOK_Click); - // - // LoginDialog - // - this.AcceptButton = this.btnOK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(278, 156); - this.Controls.Add(this.btnOK); - this.Controls.Add(this.label3); - this.Controls.Add(this.txtPassword); - this.Controls.Add(this.label2); - this.Controls.Add(this.txtUserName); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtServer); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.Name = "LoginDialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "LoginDialog"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion Windows Form Designer generated code - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button btnOK; - public System.Windows.Forms.TextBox txtServer; - public System.Windows.Forms.TextBox txtUserName; - public System.Windows.Forms.TextBox txtPassword; - } -} \ No newline at end of file diff --git a/UploadersLib/FTPClient/LoginDialog.resx b/UploadersLib/FTPClient/LoginDialog.resx deleted file mode 100644 index 19dc0dd8b..000000000 --- a/UploadersLib/FTPClient/LoginDialog.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/UploadersLib/UploadersLib.csproj b/UploadersLib/UploadersLib.csproj index bbb325014..215d54484 100644 --- a/UploadersLib/UploadersLib.csproj +++ b/UploadersLib/UploadersLib.csproj @@ -122,12 +122,6 @@ Component - - Form - - - LoginDialog.cs - UserControl @@ -297,9 +291,6 @@ FTPClientForm.cs - - LoginDialog.cs - AccountTypeControl.cs