diff --git a/ShareX.UploadersLib/FileUploaders/FTPAccount.cs b/ShareX.UploadersLib/FileUploaders/FTPAccount.cs index 6e528fe97..65737c886 100644 --- a/ShareX.UploadersLib/FileUploaders/FTPAccount.cs +++ b/ShareX.UploadersLib/FileUploaders/FTPAccount.cs @@ -33,12 +33,12 @@ namespace ShareX.UploadersLib { public class FTPAccount : ICloneable { - [Category("Account"), Description("Connection protocol"), DefaultValue(FTPProtocol.FTP)] - public FTPProtocol Protocol { get; set; } - [Category("FTP"), Description("Shown in the list as: Name - Server:Port")] public string Name { get; set; } + [Category("Account"), Description("Connection protocol"), DefaultValue(FTPProtocol.FTP)] + public FTPProtocol Protocol { get; set; } + [Category("FTP"), Description("Host, e.g. google.com")] public string Host { get; set; } @@ -51,6 +51,9 @@ public class FTPAccount : ICloneable [Category("FTP"), PasswordPropertyText(true)] public string Password { get; set; } + [Category("FTP"), Description("Set true for active or false for passive"), DefaultValue(false)] + public bool IsActive { get; set; } + [Category("FTP"), Description("FTP sub folder path, example: Screenshots.\r\nYou can use name parsing: %y = year, %mo = month.")] public string SubFolderPath { get; set; } @@ -66,9 +69,6 @@ public class FTPAccount : ICloneable [Category("FTP"), Description("Don't add file extension to URL"), DefaultValue(false)] public bool HttpHomePathNoExtension { get; set; } - [Category("FTP"), Description("Set true for active or false for passive"), DefaultValue(false)] - public bool IsActive { get; set; } - [Category("FTP"), Description("Protocol://Host:Port"), Browsable(false)] public string FTPAddress { @@ -99,25 +99,13 @@ public string FTPAddress } } - private string exampleFilename = "screenshot.jpg"; + private string exampleFilename = "screenshot.png"; [Category("FTP"), Description("Preview of the FTP path based on the settings above")] - public string PreviewFtpPath - { - get - { - return GetFtpPath(exampleFilename); - } - } + public string PreviewFtpPath => GetFtpPath(exampleFilename); [Category("FTP"), Description("Preview of the HTTP path based on the settings above")] - public string PreviewHttpPath - { - get - { - return GetUriPath(exampleFilename); - } - } + public string PreviewHttpPath => GetUriPath(exampleFilename); [Category("FTPS"), Description("Type of SSL to use. Explicit is TLS, Implicit is SSL."), DefaultValue(FTPSEncryption.Explicit)] public FTPSEncryption FTPSEncryption { get; set; } @@ -126,25 +114,26 @@ public string PreviewHttpPath [Editor(typeof(CertFileNameEditor), typeof(UITypeEditor))] public string FTPSCertificateLocation { get; set; } - [Category("SFTP"), Description("OpenSSH key passphrase"), PasswordPropertyText(true)] - public string Passphrase { get; set; } - [Category("SFTP"), Description("Key location")] [Editor(typeof(KeyFileNameEditor), typeof(UITypeEditor))] public string Keypath { get; set; } + [Category("SFTP"), Description("OpenSSH key passphrase"), PasswordPropertyText(true)] + public string Passphrase { get; set; } + + public FTPAccount() { - Protocol = FTPProtocol.FTP; Name = "New account"; - Host = "host"; + Protocol = FTPProtocol.FTP; + Host = ""; Port = 21; + IsActive = false; SubFolderPath = ""; BrowserProtocol = BrowserProtocol.http; HttpHomePath = ""; HttpHomePathAutoAddSubFolderPath = true; HttpHomePathNoExtension = false; - IsActive = false; FTPSEncryption = FTPSEncryption.Explicit; FTPSCertificateLocation = ""; } @@ -157,13 +146,6 @@ public string GetSubFolderPath(string filename = null, NameParserType nameParser public string GetHttpHomePath() { - // @ deprecated - if (HttpHomePath.StartsWith("@")) - { - HttpHomePath = HttpHomePath.Substring(1); - HttpHomePathAutoAddSubFolderPath = false; - } - return NameParser.Parse(NameParserType.URL, HttpHomePath.Replace("%host", Host)); } @@ -265,7 +247,7 @@ public string GetFtpPath(string filemame) public override string ToString() { - return string.Format("{0} - {1}:{2}", Name, Host, Port); + return $"{Name} ({Host}:{Port})"; } public FTPAccount Clone() diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs index df926403d..c2f30e7e0 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.Designer.cs @@ -191,7 +191,7 @@ private void InitializeComponent() this.lblFTPPort = new System.Windows.Forms.Label(); this.lblFTPTransferMode = new System.Windows.Forms.Label(); this.nudFTPPort = new System.Windows.Forms.NumericUpDown(); - this.lblFTPPreviewOutput = new System.Windows.Forms.Label(); + this.lblFTPURLPreviewValue = new System.Windows.Forms.Label(); this.lblFTPUsername = new System.Windows.Forms.Label(); this.lblFTPURLPreview = new System.Windows.Forms.Label(); this.txtFTPUsername = new System.Windows.Forms.TextBox(); @@ -367,7 +367,7 @@ private void InitializeComponent() this.tpJira = new System.Windows.Forms.TabPage(); this.txtJiraIssuePrefix = new System.Windows.Forms.TextBox(); this.lblJiraIssuePrefix = new System.Windows.Forms.Label(); - this.gpJiraServer = new System.Windows.Forms.GroupBox(); + this.gbJiraServer = new System.Windows.Forms.GroupBox(); this.txtJiraConfigHelp = new System.Windows.Forms.TextBox(); this.txtJiraHost = new System.Windows.Forms.TextBox(); this.lblJiraHost = new System.Windows.Forms.Label(); @@ -454,12 +454,12 @@ private void InitializeComponent() this.cbUpleaIsPremium = new System.Windows.Forms.CheckBox(); this.txtUpleaEmailAddress = new System.Windows.Forms.TextBox(); this.tpPlik = new System.Windows.Forms.TabPage(); - this.gpPlikSettings = new System.Windows.Forms.GroupBox(); + this.gbPlikSettings = new System.Windows.Forms.GroupBox(); this.cbPlikOneShot = new System.Windows.Forms.CheckBox(); this.txtPlikComment = new System.Windows.Forms.TextBox(); this.cbPlikComment = new System.Windows.Forms.CheckBox(); this.cbPlikRemovable = new System.Windows.Forms.CheckBox(); - this.gpPlikLoginCredentials = new System.Windows.Forms.GroupBox(); + this.gbPlikLoginCredentials = new System.Windows.Forms.GroupBox(); this.nudPlikTTL = new System.Windows.Forms.NumericUpDown(); this.cbxPlikTTLUnit = new System.Windows.Forms.ComboBox(); this.lblPlikTTL = new System.Windows.Forms.Label(); @@ -684,7 +684,7 @@ private void InitializeComponent() this.gbMinusUserPass.SuspendLayout(); this.gbMinusUpload.SuspendLayout(); this.tpJira.SuspendLayout(); - this.gpJiraServer.SuspendLayout(); + this.gbJiraServer.SuspendLayout(); this.tpLambda.SuspendLayout(); this.tpPomf.SuspendLayout(); this.tpSeafile.SuspendLayout(); @@ -699,8 +699,8 @@ private void InitializeComponent() this.gbUpleaLoginCredentials.SuspendLayout(); this.gbUpleaUserInformation.SuspendLayout(); this.tpPlik.SuspendLayout(); - this.gpPlikSettings.SuspendLayout(); - this.gpPlikLoginCredentials.SuspendLayout(); + this.gbPlikSettings.SuspendLayout(); + this.gbPlikLoginCredentials.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPlikTTL)).BeginInit(); this.tpSharedFolder.SuspendLayout(); this.tpEmail.SuspendLayout(); @@ -1821,7 +1821,7 @@ private void InitializeComponent() this.gbFTPAccount.Controls.Add(this.lblFTPPort); this.gbFTPAccount.Controls.Add(this.lblFTPTransferMode); this.gbFTPAccount.Controls.Add(this.nudFTPPort); - this.gbFTPAccount.Controls.Add(this.lblFTPPreviewOutput); + this.gbFTPAccount.Controls.Add(this.lblFTPURLPreviewValue); this.gbFTPAccount.Controls.Add(this.lblFTPUsername); this.gbFTPAccount.Controls.Add(this.lblFTPURLPreview); this.gbFTPAccount.Controls.Add(this.txtFTPUsername); @@ -1841,6 +1841,7 @@ private void InitializeComponent() resources.ApplyResources(this.cbFTPAppendRemoteDirectory, "cbFTPAppendRemoteDirectory"); this.cbFTPAppendRemoteDirectory.Name = "cbFTPAppendRemoteDirectory"; this.cbFTPAppendRemoteDirectory.UseVisualStyleBackColor = true; + this.cbFTPAppendRemoteDirectory.CheckedChanged += new System.EventHandler(this.cbFTPAppendRemoteDirectory_CheckedChanged); // // btnFTPTest // @@ -1864,11 +1865,13 @@ private void InitializeComponent() resources.ApplyResources(this.cbFTPRemoveFileExtension, "cbFTPRemoveFileExtension"); this.cbFTPRemoveFileExtension.Name = "cbFTPRemoveFileExtension"; this.cbFTPRemoveFileExtension.UseVisualStyleBackColor = true; + this.cbFTPRemoveFileExtension.CheckedChanged += new System.EventHandler(this.cbFTPRemoveFileExtension_CheckedChanged); // // txtFTPName // resources.ApplyResources(this.txtFTPName, "txtFTPName"); this.txtFTPName.Name = "txtFTPName"; + this.txtFTPName.TextChanged += new System.EventHandler(this.txtFTPName_TextChanged); // // lblFTPHost // @@ -1895,6 +1898,7 @@ private void InitializeComponent() resources.ApplyResources(this.rbFTPTransferModeActive, "rbFTPTransferModeActive"); this.rbFTPTransferModeActive.Name = "rbFTPTransferModeActive"; this.rbFTPTransferModeActive.UseVisualStyleBackColor = true; + this.rbFTPTransferModeActive.CheckedChanged += new System.EventHandler(this.rbFTPTransferModeActive_CheckedChanged); // // rbFTPTransferModePassive // @@ -1903,6 +1907,7 @@ private void InitializeComponent() this.rbFTPTransferModePassive.Name = "rbFTPTransferModePassive"; this.rbFTPTransferModePassive.TabStop = true; this.rbFTPTransferModePassive.UseVisualStyleBackColor = true; + this.rbFTPTransferModePassive.CheckedChanged += new System.EventHandler(this.rbFTPTransferModePassive_CheckedChanged); // // btnFTPClient // @@ -1915,6 +1920,7 @@ private void InitializeComponent() // resources.ApplyResources(this.txtFTPHost, "txtFTPHost"); this.txtFTPHost.Name = "txtFTPHost"; + this.txtFTPHost.TextChanged += new System.EventHandler(this.txtFTPHost_TextChanged); // // pFTPProtocol // @@ -1931,18 +1937,21 @@ private void InitializeComponent() this.rbFTPProtocolFTP.Name = "rbFTPProtocolFTP"; this.rbFTPProtocolFTP.TabStop = true; this.rbFTPProtocolFTP.UseVisualStyleBackColor = true; + this.rbFTPProtocolFTP.CheckedChanged += new System.EventHandler(this.rbFTPProtocolFTP_CheckedChanged); // // rbFTPProtocolFTPS // resources.ApplyResources(this.rbFTPProtocolFTPS, "rbFTPProtocolFTPS"); this.rbFTPProtocolFTPS.Name = "rbFTPProtocolFTPS"; this.rbFTPProtocolFTPS.UseVisualStyleBackColor = true; + this.rbFTPProtocolFTPS.CheckedChanged += new System.EventHandler(this.rbFTPProtocolFTPS_CheckedChanged); // // rbFTPProtocolSFTP // resources.ApplyResources(this.rbFTPProtocolSFTP, "rbFTPProtocolSFTP"); this.rbFTPProtocolSFTP.Name = "rbFTPProtocolSFTP"; this.rbFTPProtocolSFTP.UseVisualStyleBackColor = true; + this.rbFTPProtocolSFTP.CheckedChanged += new System.EventHandler(this.rbFTPProtocolSFTP_CheckedChanged); // // lblFTPPort // @@ -1973,11 +1982,12 @@ private void InitializeComponent() 0, 0, 0}); + this.nudFTPPort.ValueChanged += new System.EventHandler(this.nudFTPPort_ValueChanged); // - // lblFTPPreviewOutput + // lblFTPURLPreviewValue // - resources.ApplyResources(this.lblFTPPreviewOutput, "lblFTPPreviewOutput"); - this.lblFTPPreviewOutput.Name = "lblFTPPreviewOutput"; + resources.ApplyResources(this.lblFTPURLPreviewValue, "lblFTPURLPreviewValue"); + this.lblFTPURLPreviewValue.Name = "lblFTPURLPreviewValue"; // // lblFTPUsername // @@ -1993,15 +2003,15 @@ private void InitializeComponent() // resources.ApplyResources(this.txtFTPUsername, "txtFTPUsername"); this.txtFTPUsername.Name = "txtFTPUsername"; + this.txtFTPUsername.TextChanged += new System.EventHandler(this.txtFTPUsername_TextChanged); // // cbFTPURLPathProtocol // this.cbFTPURLPathProtocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbFTPURLPathProtocol.FormattingEnabled = true; - this.cbFTPURLPathProtocol.Items.AddRange(new object[] { - resources.GetString("cbFTPURLPathProtocol.Items")}); resources.ApplyResources(this.cbFTPURLPathProtocol, "cbFTPURLPathProtocol"); this.cbFTPURLPathProtocol.Name = "cbFTPURLPathProtocol"; + this.cbFTPURLPathProtocol.SelectedIndexChanged += new System.EventHandler(this.cbFTPURLPathProtocol_SelectedIndexChanged); // // lblFTPPassword // @@ -2012,12 +2022,14 @@ private void InitializeComponent() // resources.ApplyResources(this.txtFTPURLPath, "txtFTPURLPath"); this.txtFTPURLPath.Name = "txtFTPURLPath"; + this.txtFTPURLPath.TextChanged += new System.EventHandler(this.txtFTPURLPath_TextChanged); // // txtFTPPassword // resources.ApplyResources(this.txtFTPPassword, "txtFTPPassword"); this.txtFTPPassword.Name = "txtFTPPassword"; this.txtFTPPassword.UseSystemPasswordChar = true; + this.txtFTPPassword.TextChanged += new System.EventHandler(this.txtFTPPassword_TextChanged); // // lblFTPURLPath // @@ -2033,6 +2045,7 @@ private void InitializeComponent() // resources.ApplyResources(this.txtFTPRemoteDirectory, "txtFTPRemoteDirectory"); this.txtFTPRemoteDirectory.Name = "txtFTPRemoteDirectory"; + this.txtFTPRemoteDirectory.TextChanged += new System.EventHandler(this.txtFTPRemoteDirectory_TextChanged); // // btnFTPDuplicate // @@ -3185,7 +3198,7 @@ private void InitializeComponent() // this.tpJira.Controls.Add(this.txtJiraIssuePrefix); this.tpJira.Controls.Add(this.lblJiraIssuePrefix); - this.tpJira.Controls.Add(this.gpJiraServer); + this.tpJira.Controls.Add(this.gbJiraServer); this.tpJira.Controls.Add(this.oAuthJira); resources.ApplyResources(this.tpJira, "tpJira"); this.tpJira.Name = "tpJira"; @@ -3202,14 +3215,14 @@ private void InitializeComponent() resources.ApplyResources(this.lblJiraIssuePrefix, "lblJiraIssuePrefix"); this.lblJiraIssuePrefix.Name = "lblJiraIssuePrefix"; // - // gpJiraServer + // gbJiraServer // - this.gpJiraServer.Controls.Add(this.txtJiraConfigHelp); - this.gpJiraServer.Controls.Add(this.txtJiraHost); - this.gpJiraServer.Controls.Add(this.lblJiraHost); - resources.ApplyResources(this.gpJiraServer, "gpJiraServer"); - this.gpJiraServer.Name = "gpJiraServer"; - this.gpJiraServer.TabStop = false; + this.gbJiraServer.Controls.Add(this.txtJiraConfigHelp); + this.gbJiraServer.Controls.Add(this.txtJiraHost); + this.gbJiraServer.Controls.Add(this.lblJiraHost); + resources.ApplyResources(this.gbJiraServer, "gbJiraServer"); + this.gbJiraServer.Name = "gbJiraServer"; + this.gbJiraServer.TabStop = false; // // txtJiraConfigHelp // @@ -3814,21 +3827,21 @@ private void InitializeComponent() // // tpPlik // - this.tpPlik.Controls.Add(this.gpPlikSettings); - this.tpPlik.Controls.Add(this.gpPlikLoginCredentials); + this.tpPlik.Controls.Add(this.gbPlikSettings); + this.tpPlik.Controls.Add(this.gbPlikLoginCredentials); resources.ApplyResources(this.tpPlik, "tpPlik"); this.tpPlik.Name = "tpPlik"; this.tpPlik.UseVisualStyleBackColor = true; // - // gpPlikSettings + // gbPlikSettings // - this.gpPlikSettings.Controls.Add(this.cbPlikOneShot); - this.gpPlikSettings.Controls.Add(this.txtPlikComment); - this.gpPlikSettings.Controls.Add(this.cbPlikComment); - this.gpPlikSettings.Controls.Add(this.cbPlikRemovable); - resources.ApplyResources(this.gpPlikSettings, "gpPlikSettings"); - this.gpPlikSettings.Name = "gpPlikSettings"; - this.gpPlikSettings.TabStop = false; + this.gbPlikSettings.Controls.Add(this.cbPlikOneShot); + this.gbPlikSettings.Controls.Add(this.txtPlikComment); + this.gbPlikSettings.Controls.Add(this.cbPlikComment); + this.gbPlikSettings.Controls.Add(this.cbPlikRemovable); + resources.ApplyResources(this.gbPlikSettings, "gbPlikSettings"); + this.gbPlikSettings.Name = "gbPlikSettings"; + this.gbPlikSettings.TabStop = false; // // cbPlikOneShot // @@ -3858,23 +3871,23 @@ private void InitializeComponent() this.cbPlikRemovable.UseVisualStyleBackColor = true; this.cbPlikRemovable.CheckedChanged += new System.EventHandler(this.cbPlikRemovable_CheckedChanged); // - // gpPlikLoginCredentials + // gbPlikLoginCredentials // - this.gpPlikLoginCredentials.Controls.Add(this.nudPlikTTL); - this.gpPlikLoginCredentials.Controls.Add(this.cbxPlikTTLUnit); - this.gpPlikLoginCredentials.Controls.Add(this.lblPlikTTL); - this.gpPlikLoginCredentials.Controls.Add(this.txtPlikURL); - this.gpPlikLoginCredentials.Controls.Add(this.lblPlikURL); - this.gpPlikLoginCredentials.Controls.Add(this.cbPlikIsSecured); - this.gpPlikLoginCredentials.Controls.Add(this.lblPlikAPIKey); - this.gpPlikLoginCredentials.Controls.Add(this.txtPlikAPIKey); - this.gpPlikLoginCredentials.Controls.Add(this.lblPlikPassword); - this.gpPlikLoginCredentials.Controls.Add(this.lblPlikUsername); - this.gpPlikLoginCredentials.Controls.Add(this.txtPlikPassword); - this.gpPlikLoginCredentials.Controls.Add(this.txtPlikLogin); - resources.ApplyResources(this.gpPlikLoginCredentials, "gpPlikLoginCredentials"); - this.gpPlikLoginCredentials.Name = "gpPlikLoginCredentials"; - this.gpPlikLoginCredentials.TabStop = false; + this.gbPlikLoginCredentials.Controls.Add(this.nudPlikTTL); + this.gbPlikLoginCredentials.Controls.Add(this.cbxPlikTTLUnit); + this.gbPlikLoginCredentials.Controls.Add(this.lblPlikTTL); + this.gbPlikLoginCredentials.Controls.Add(this.txtPlikURL); + this.gbPlikLoginCredentials.Controls.Add(this.lblPlikURL); + this.gbPlikLoginCredentials.Controls.Add(this.cbPlikIsSecured); + this.gbPlikLoginCredentials.Controls.Add(this.lblPlikAPIKey); + this.gbPlikLoginCredentials.Controls.Add(this.txtPlikAPIKey); + this.gbPlikLoginCredentials.Controls.Add(this.lblPlikPassword); + this.gbPlikLoginCredentials.Controls.Add(this.lblPlikUsername); + this.gbPlikLoginCredentials.Controls.Add(this.txtPlikPassword); + this.gbPlikLoginCredentials.Controls.Add(this.txtPlikLogin); + resources.ApplyResources(this.gbPlikLoginCredentials, "gbPlikLoginCredentials"); + this.gbPlikLoginCredentials.Name = "gbPlikLoginCredentials"; + this.gbPlikLoginCredentials.TabStop = false; // // nudPlikTTL // @@ -5246,8 +5259,8 @@ private void InitializeComponent() this.gbMinusUpload.PerformLayout(); this.tpJira.ResumeLayout(false); this.tpJira.PerformLayout(); - this.gpJiraServer.ResumeLayout(false); - this.gpJiraServer.PerformLayout(); + this.gbJiraServer.ResumeLayout(false); + this.gbJiraServer.PerformLayout(); this.tpLambda.ResumeLayout(false); this.tpLambda.PerformLayout(); this.tpPomf.ResumeLayout(false); @@ -5273,10 +5286,10 @@ private void InitializeComponent() this.gbUpleaUserInformation.ResumeLayout(false); this.gbUpleaUserInformation.PerformLayout(); this.tpPlik.ResumeLayout(false); - this.gpPlikSettings.ResumeLayout(false); - this.gpPlikSettings.PerformLayout(); - this.gpPlikLoginCredentials.ResumeLayout(false); - this.gpPlikLoginCredentials.PerformLayout(); + this.gbPlikSettings.ResumeLayout(false); + this.gbPlikSettings.PerformLayout(); + this.gbPlikLoginCredentials.ResumeLayout(false); + this.gbPlikLoginCredentials.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudPlikTTL)).EndInit(); this.tpSharedFolder.ResumeLayout(false); this.tpSharedFolder.PerformLayout(); @@ -5493,7 +5506,7 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox cboMinusFolders; private System.Windows.Forms.TextBox txtJiraIssuePrefix; private System.Windows.Forms.Label lblJiraIssuePrefix; - private System.Windows.Forms.GroupBox gpJiraServer; + private System.Windows.Forms.GroupBox gbJiraServer; private System.Windows.Forms.TextBox txtJiraConfigHelp; private System.Windows.Forms.TextBox txtJiraHost; private System.Windows.Forms.Label lblJiraHost; @@ -5869,11 +5882,11 @@ private void InitializeComponent() private System.Windows.Forms.Label lblAzureStorageContainer; private System.Windows.Forms.Button btnAzureStoragePortal; internal System.Windows.Forms.TabPage tpPlik; - private System.Windows.Forms.GroupBox gpPlikSettings; + private System.Windows.Forms.GroupBox gbPlikSettings; private System.Windows.Forms.TextBox txtPlikComment; private System.Windows.Forms.CheckBox cbPlikComment; private System.Windows.Forms.CheckBox cbPlikRemovable; - private System.Windows.Forms.GroupBox gpPlikLoginCredentials; + private System.Windows.Forms.GroupBox gbPlikLoginCredentials; private System.Windows.Forms.CheckBox cbPlikIsSecured; private System.Windows.Forms.Label lblPlikAPIKey; private System.Windows.Forms.TextBox txtPlikAPIKey; @@ -5909,7 +5922,7 @@ private void InitializeComponent() private System.Windows.Forms.RadioButton rbFTPProtocolFTPS; private System.Windows.Forms.RadioButton rbFTPProtocolSFTP; private System.Windows.Forms.Label lblFTPTransferMode; - private System.Windows.Forms.Label lblFTPPreviewOutput; + private System.Windows.Forms.Label lblFTPURLPreviewValue; private System.Windows.Forms.Label lblFTPURLPreview; private System.Windows.Forms.ComboBox cbFTPURLPathProtocol; private System.Windows.Forms.TextBox txtFTPURLPath; diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs index 763123c23..c55aa10ec 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.cs @@ -98,7 +98,9 @@ private void InitializeControls() CodeMenu.Create(txtCustomUploaderArgValue, CodeMenuEntryFilename.n, CodeMenuEntryFilename.t, CodeMenuEntryFilename.pn); CodeMenu.Create(txtCustomUploaderHeaderValue, CodeMenuEntryFilename.n, CodeMenuEntryFilename.t, CodeMenuEntryFilename.pn); - txtCustomUploaderLog.AddContextMenu(); + // FTP + cbFTPURLPathProtocol.Items.AddRange(Helpers.GetEnumDescriptions()); + eiFTP.ObjectType = typeof(FTPAccount); // Localhost ucLocalhostAccounts.btnAdd.Click += LocalhostAccountAddButton_Click; @@ -107,9 +109,9 @@ private void InitializeControls() ucLocalhostAccounts.btnTest.Visible = false; ucLocalhostAccounts.pgSettings.PropertyValueChanged += SettingsGrid_LocalhostPropertyValueChanged; - eiFTP.ObjectType = typeof(FTPAccount); + // Custom uploader + txtCustomUploaderLog.AddContextMenu(); eiCustomUploaders.ObjectType = typeof(CustomUploaderItem); - txtCustomUploaderName.HandleCreated += (sender, e) => txtCustomUploaderName.SetWatermark("Name"); AddCustomUploaderDestinationTypes(); cbCustomUploaderRequestType.Items.AddRange(Enum.GetNames(typeof(CustomUploaderRequestType))); @@ -324,15 +326,13 @@ public void LoadSettings() if (Config.FTPAccountList == null || Config.FTPAccountList.Count == 0) { FTPUpdateControls(new List()); + FTPClearFields(); } else { FTPUpdateControls(); - - if (cbFTPAccounts.Items.Count > 0) - { - cbFTPAccounts.SelectedIndex = cbFTPImage.SelectedIndex; - } + cbFTPAccounts.SelectedIndex = cbFTPImage.SelectedIndex; + FTPUpdateEnabledStates(); } // Dropbox @@ -1303,15 +1303,22 @@ private void btnFTPRemove_Click(object sender, EventArgs e) { int selected = cbFTPAccounts.SelectedIndex; - cbFTPAccounts.Items.RemoveAt(selected); - Config.FTPAccountList.RemoveAt(selected); - - if (cbFTPAccounts.Items.Count > 0) + if (selected > -1) { - cbFTPAccounts.SelectedIndex = selected == cbFTPAccounts.Items.Count ? cbFTPAccounts.Items.Count - 1 : selected; - } + cbFTPAccounts.Items.RemoveAt(selected); + Config.FTPAccountList.RemoveAt(selected); - FTPUpdateControls(); + if (cbFTPAccounts.Items.Count > 0) + { + cbFTPAccounts.SelectedIndex = selected == cbFTPAccounts.Items.Count ? cbFTPAccounts.Items.Count - 1 : selected; + } + else + { + FTPClearFields(); + } + + FTPUpdateControls(); + } } private void btnFTPDuplicate_Click(object sender, EventArgs e) @@ -1327,6 +1334,148 @@ private void btnFTPDuplicate_Click(object sender, EventArgs e) } } + private void txtFTPName_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Name = txtFTPName.Text; + } + } + + private void rbFTPProtocolFTP_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Protocol = FTPProtocol.FTP; + } + } + + private void rbFTPProtocolFTPS_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Protocol = FTPProtocol.FTPS; + } + } + + private void rbFTPProtocolSFTP_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Protocol = FTPProtocol.SFTP; + } + } + + private void txtFTPHost_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Host = txtFTPHost.Text; + FTPUpdateURLPreview(); + } + } + + private void nudFTPPort_ValueChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Port = (int)nudFTPPort.Value; + FTPUpdateURLPreview(); + } + } + + private void txtFTPUsername_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Username = txtFTPUsername.Text; + } + } + + private void txtFTPPassword_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.Password = txtFTPPassword.Text; + } + } + + private void rbFTPTransferModePassive_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.IsActive = false; + } + } + + private void rbFTPTransferModeActive_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.IsActive = true; + } + } + + private void txtFTPRemoteDirectory_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.SubFolderPath = txtFTPRemoteDirectory.Text; + FTPUpdateURLPreview(); + } + } + + private void cbFTPURLPathProtocol_SelectedIndexChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.BrowserProtocol = (BrowserProtocol)cbFTPURLPathProtocol.SelectedIndex; + FTPUpdateURLPreview(); + } + } + + private void txtFTPURLPath_TextChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.HttpHomePath = txtFTPURLPath.Text; + FTPUpdateURLPreview(); + } + } + + private void cbFTPAppendRemoteDirectory_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.HttpHomePathAutoAddSubFolderPath = cbFTPAppendRemoteDirectory.Checked; + FTPUpdateURLPreview(); + } + } + + private void cbFTPRemoveFileExtension_CheckedChanged(object sender, EventArgs e) + { + FTPAccount account = FTPGetSelectedAccount(); + if (account != null) + { + account.HttpHomePathNoExtension = cbFTPRemoveFileExtension.Checked; + FTPUpdateURLPreview(); + } + } + private void btnFTPTest_Click(object sender, EventArgs e) { FTPAccount account = FTPGetSelectedAccount(); diff --git a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx index 0dcf776a8..5b52d71e1 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigForm.resx +++ b/ShareX.UploadersLib/Forms/UploadersConfigForm.resx @@ -5464,31 +5464,31 @@ store.book[0].title 14 - + True - + 157, 264 - - 159, 13 + + 178, 13 - + 33 - - https://example.com/image.png + + http://example.com/screenshot.png - - lblFTPPreviewOutput + + lblFTPURLPreviewValue - + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + gbFTPAccount - + 15 @@ -5566,9 +5566,6 @@ store.book[0].title 18 - - https:// - 160, 188 @@ -5621,7 +5618,7 @@ store.book[0].title 240, 188 - 288, 20 + 368, 20 30 @@ -5717,7 +5714,7 @@ store.book[0].title 160, 164 - 288, 20 + 448, 20 28 @@ -5735,7 +5732,7 @@ store.book[0].title 25 - 16, 80 + 16, 72 776, 384 @@ -5762,10 +5759,10 @@ store.book[0].title NoControl - 616, 51 + 696, 43 - 75, 23 + 96, 23 41 @@ -5786,10 +5783,10 @@ store.book[0].title 1 - 536, 51 + 592, 43 - 75, 23 + 96, 23 26 @@ -5810,10 +5807,10 @@ store.book[0].title 2 - 456, 51 + 488, 43 - 75, 23 + 96, 23 25 @@ -5834,10 +5831,10 @@ store.book[0].title 3 - 160, 52 + 128, 44 - 288, 21 + 352, 21 24 @@ -5858,7 +5855,7 @@ store.book[0].title True - 13, 56 + 13, 48 55, 13 @@ -7954,16 +7951,16 @@ store.book[0].title 1 - - gpJiraServer + + gbJiraServer - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpJira - + 2 @@ -8740,28 +8737,28 @@ store.book[0].title 24 - - gpPlikSettings + + gbPlikSettings - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpPlik - + 0 - - gpPlikLoginCredentials + + gbPlikLoginCredentials - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpPlik - + 1 @@ -13114,7 +13111,7 @@ store.book[0].title System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 0 @@ -13126,7 +13123,7 @@ store.book[0].title System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 1 @@ -13138,33 +13135,33 @@ store.book[0].title System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 2 - + 13, 13 - + 451, 358 - + 0 - + Jira server - - gpJiraServer + + gbJiraServer - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpJira - + 2 @@ -13192,7 +13189,7 @@ store.book[0].title System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 0 @@ -13216,7 +13213,7 @@ store.book[0].title System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 1 @@ -13246,7 +13243,7 @@ store.book[0].title System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpJiraServer + gbJiraServer 2 @@ -15485,7 +15482,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 0 @@ -15497,7 +15494,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 1 @@ -15509,7 +15506,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 2 @@ -15521,33 +15518,33 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 3 - + 292, 19 - + 344, 247 - + 14 - + Other settings - - gpPlikSettings + + gbPlikSettings - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpPlik - + 0 @@ -15575,7 +15572,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 0 @@ -15599,7 +15596,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 1 @@ -15629,7 +15626,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 2 @@ -15659,7 +15656,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikSettings + gbPlikSettings 3 @@ -15671,7 +15668,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 0 @@ -15683,7 +15680,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 1 @@ -15695,7 +15692,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 2 @@ -15707,7 +15704,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 3 @@ -15719,7 +15716,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 4 @@ -15731,7 +15728,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 5 @@ -15743,7 +15740,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 6 @@ -15755,7 +15752,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 7 @@ -15767,7 +15764,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 8 @@ -15779,7 +15776,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 9 @@ -15791,7 +15788,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 10 @@ -15803,33 +15800,33 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 11 - + 15, 19 - + 271, 247 - + 13 - + Login Credentials - - gpPlikLoginCredentials + + gbPlikLoginCredentials - + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + tpPlik - + 1 @@ -15848,7 +15845,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 0 @@ -15878,7 +15875,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 1 @@ -15908,7 +15905,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 2 @@ -15929,7 +15926,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 3 @@ -15959,7 +15956,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 4 @@ -15989,7 +15986,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 5 @@ -16019,7 +16016,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 6 @@ -16040,7 +16037,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 7 @@ -16070,7 +16067,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 8 @@ -16100,7 +16097,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 9 @@ -16124,7 +16121,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 10 @@ -16145,7 +16142,7 @@ Using an encrypted library disables sharing. System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - gpPlikLoginCredentials + gbPlikLoginCredentials 11 diff --git a/ShareX.UploadersLib/Forms/UploadersConfigFormHelper.cs b/ShareX.UploadersLib/Forms/UploadersConfigFormHelper.cs index 157de18e5..01260ea04 100644 --- a/ShareX.UploadersLib/Forms/UploadersConfigFormHelper.cs +++ b/ShareX.UploadersLib/Forms/UploadersConfigFormHelper.cs @@ -1005,12 +1005,18 @@ private void FTPUpdateControls(List accounts) cbFTPImage.SelectedIndex = Config.FTPSelectedImage.Between(0, Config.FTPAccountList.Count - 1); cbFTPText.SelectedIndex = Config.FTPSelectedText.Between(0, Config.FTPAccountList.Count - 1); cbFTPFile.SelectedIndex = Config.FTPSelectedFile.Between(0, Config.FTPAccountList.Count - 1); - - FTPLoadSelectedAccount(); } + + FTPUpdateEnabledStates(); } } + private void FTPUpdateEnabledStates() + { + cbFTPImage.Enabled = cbFTPText.Enabled = cbFTPFile.Enabled = cbFTPAccounts.Enabled = cbFTPAccounts.Items.Count > 0; + btnFTPRemove.Enabled = btnFTPDuplicate.Enabled = gbFTPAccount.Enabled = cbFTPAccounts.SelectedIndex > -1; + } + public void FTPLoadSelectedAccount() { FTPAccount account = FTPGetSelectedAccount(); @@ -1053,13 +1059,32 @@ public void FTPLoadAccount(FTPAccount account) } txtFTPRemoteDirectory.Text = account.SubFolderPath; - - // cbFTPURLPathProtocol - + cbFTPURLPathProtocol.SelectedIndex = (int)account.BrowserProtocol; txtFTPURLPath.Text = account.HttpHomePath; cbFTPAppendRemoteDirectory.Checked = account.HttpHomePathAutoAddSubFolderPath; cbFTPRemoveFileExtension.Checked = account.HttpHomePathNoExtension; - lblFTPPreviewOutput.Text = account.PreviewHttpPath; + lblFTPURLPreviewValue.Text = account.PreviewHttpPath; + } + + public void FTPClearFields() + { + FTPAccount account = new FTPAccount() + { + Name = "", + HttpHomePathAutoAddSubFolderPath = false + }; + + FTPLoadAccount(account); + } + + public void FTPUpdateURLPreview() + { + FTPAccount account = FTPGetSelectedAccount(); + + if (account != null) + { + lblFTPURLPreviewValue.Text = account.PreviewHttpPath; + } } public void FTPTestAccountAsync(FTPAccount account)