diff --git a/ImageEffectsLib/ImageEffectsForm.cs b/ImageEffectsLib/ImageEffectsForm.cs index 1e638029f..275656a4a 100644 --- a/ImageEffectsLib/ImageEffectsForm.cs +++ b/ImageEffectsLib/ImageEffectsForm.cs @@ -323,6 +323,7 @@ private void btnSettingsExport_Click(object sender, EventArgs e) { string json = ImageEffectManager.ExportEffects(imageEffects); ClipboardHelpers.CopyText(json); + MessageBox.Show("Image effects copied to your clipboard.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information); } } diff --git a/UploadersLib/GUI/UploadersConfigForm.Designer.cs b/UploadersLib/GUI/UploadersConfigForm.Designer.cs index 53923ff6b..a24193061 100644 --- a/UploadersLib/GUI/UploadersConfigForm.Designer.cs +++ b/UploadersLib/GUI/UploadersConfigForm.Designer.cs @@ -323,6 +323,8 @@ private void InitializeComponent() this.txtRapidSharePremiumUserName = new System.Windows.Forms.TextBox(); this.ttHelpTip = new System.Windows.Forms.ToolTip(this.components); this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl(); + this.btnCustomUploaderExport = new System.Windows.Forms.Button(); + this.btnCustomUploaderImport = new System.Windows.Forms.Button(); this.tcUploaders.SuspendLayout(); this.tpImageUploaders.SuspendLayout(); this.tcImageUploaders.SuspendLayout(); @@ -3045,7 +3047,9 @@ private void InitializeComponent() // // gbCustomUploaders // + this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderImport); this.gbCustomUploaders.Controls.Add(this.lbCustomUploaderList); + this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderExport); this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderRemove); this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderClear); this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderUpdate); @@ -3084,7 +3088,7 @@ private void InitializeComponent() this.btnCustomUploaderClear.Name = "btnCustomUploaderClear"; this.btnCustomUploaderClear.Size = new System.Drawing.Size(88, 24); this.btnCustomUploaderClear.TabIndex = 5; - this.btnCustomUploaderClear.Text = "Clear fields ->"; + this.btnCustomUploaderClear.Text = "Clear fields -->"; this.btnCustomUploaderClear.UseVisualStyleBackColor = true; this.btnCustomUploaderClear.Click += new System.EventHandler(this.btnCustomUploaderClear_Click); // @@ -3459,6 +3463,26 @@ private void InitializeComponent() this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29); this.actRapidShareAccountType.TabIndex = 16; // + // btnCustomUploaderExport + // + this.btnCustomUploaderExport.Location = new System.Drawing.Point(8, 328); + this.btnCustomUploaderExport.Name = "btnCustomUploaderExport"; + this.btnCustomUploaderExport.Size = new System.Drawing.Size(64, 23); + this.btnCustomUploaderExport.TabIndex = 34; + this.btnCustomUploaderExport.Text = "Export"; + this.btnCustomUploaderExport.UseVisualStyleBackColor = true; + this.btnCustomUploaderExport.Click += new System.EventHandler(this.btnCustomUploaderExport_Click); + // + // btnCustomUploaderImport + // + this.btnCustomUploaderImport.Location = new System.Drawing.Point(80, 328); + this.btnCustomUploaderImport.Name = "btnCustomUploaderImport"; + this.btnCustomUploaderImport.Size = new System.Drawing.Size(64, 23); + this.btnCustomUploaderImport.TabIndex = 35; + this.btnCustomUploaderImport.Text = "Import"; + this.btnCustomUploaderImport.UseVisualStyleBackColor = true; + this.btnCustomUploaderImport.Click += new System.EventHandler(this.btnCustomUploaderImport_Click); + // // UploadersConfigForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -3859,5 +3883,7 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tpGist; private GUI.AccountTypeControl atcGistAccountType; private GUI.OAuth2Control oAuth2Gist; + private System.Windows.Forms.Button btnCustomUploaderImport; + private System.Windows.Forms.Button btnCustomUploaderExport; } } \ No newline at end of file diff --git a/UploadersLib/GUI/UploadersConfigForm.cs b/UploadersLib/GUI/UploadersConfigForm.cs index 01ace0faa..e1fb8fd90 100644 --- a/UploadersLib/GUI/UploadersConfigForm.cs +++ b/UploadersLib/GUI/UploadersConfigForm.cs @@ -817,6 +817,16 @@ private void lbCustomUploaderList_SelectedIndexChanged(object sender, EventArgs } } + private void btnCustomUploaderExport_Click(object sender, EventArgs e) + { + ExportCustomUploader(); + } + + private void btnCustomUploaderImport_Click(object sender, EventArgs e) + { + ImportCustomUploader(); + } + private void cbCustomUploaderRequestType_SelectedIndexChanged(object sender, EventArgs e) { txtCustomUploaderFileForm.Enabled = (CustomUploaderRequestType)cbCustomUploaderRequestType.SelectedIndex == CustomUploaderRequestType.POST; diff --git a/UploadersLib/GUI/UploadersConfigForm.resx b/UploadersLib/GUI/UploadersConfigForm.resx index f66dc80ef..bf427600b 100644 --- a/UploadersLib/GUI/UploadersConfigForm.resx +++ b/UploadersLib/GUI/UploadersConfigForm.resx @@ -117,6 +117,33 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + If URL textbox is empty then 'Response text' or 'Redirection URL' will be automatically used. + +Regex usage for get regex result: $n$ +'n' must be index number from 'Regex from response' list. +Example for get second regex result from list: $2$ + +Regex groups usage: $n,n$ or $n,name$ +Second 'n' here must be group number or group name. +Example: $3,1$ or $2,thumbnail_result$ + + + For image uploader & file uploader: The 'POST' request type is required along with the 'File form name'. + +For text uploader or url shortener: 'POST' with no 'File Form Name' or 'GET' will replace an argument with +value '%input' or '$input$' with the text or URL. + +For text uploader: Specifying 'POST' request type and a 'File Form Name' will upload the input as a file +(useful for very long inputs). + +For example, if the argument name is 'pastebin_text' then a value of '%input' will be automatically +replaced with the text you're going to upload. Same thing applies for url shortener; '%input' +will be replaced with the url in the argument. + @@ -237,28 +264,4 @@ 17, 17 - - If URL textbox is empty then 'Response text' or 'Redirection URL' will be automatically used. - -Regex usage for get regex result: $n$ -'n' must be index number from 'Regex from response' list. -Example for get second regex result from list: $2$ - -Regex groups usage: $n,n$ or $n,name$ -Second 'n' here must be group number or group name. -Example: $3,1$ or $2,thumbnail_result$ - - - For image uploader & file uploader: The 'POST' request type is required along with the 'File form name'. - -For text uploader or url shortener: 'POST' with no 'File Form Name' or 'GET' will replace an argument with -value '%input' or '$input$' with the text or URL. - -For text uploader: Specifying 'POST' request type and a 'File Form Name' will upload the input as a file -(useful for very long inputs). - -For example, if the argument name is 'pastebin_text' then a value of '%input' will be automatically -replaced with the text you're going to upload. Same thing applies for url shortener; '%input' -will be replaced with the url in the argument. - \ No newline at end of file diff --git a/UploadersLib/GUI/UploadersConfigFormHelper.cs b/UploadersLib/GUI/UploadersConfigFormHelper.cs index e10bb7eb2..fd7f30c23 100644 --- a/UploadersLib/GUI/UploadersConfigFormHelper.cs +++ b/UploadersLib/GUI/UploadersConfigFormHelper.cs @@ -24,6 +24,7 @@ #endregion License Information (GPL v3) using HelpersLib; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel; @@ -1183,11 +1184,11 @@ private void UpdateCustomUploader() { int index = lbCustomUploaderList.SelectedIndex; - if (index != -1) + if (index >= 0) { CustomUploaderItem customUploader = GetCustomUploaderFromFields(); - if (!string.IsNullOrEmpty(customUploader.Name)) + if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name)) { Config.CustomUploadersList[index] = customUploader; lbCustomUploaderList.Items[index] = customUploader.Name; @@ -1196,6 +1197,58 @@ private void UpdateCustomUploader() } } + private void ExportCustomUploader() + { + int index = lbCustomUploaderList.SelectedIndex; + + if (index >= 0) + { + CustomUploaderItem customUploader = GetCustomUploaderFromFields(); + + if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name)) + { + try + { + string json = JsonConvert.SerializeObject(customUploader, Formatting.Indented); + ClipboardHelpers.CopyText(json); + MessageBox.Show("Selected custom uploader copied to your clipboard.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception e) + { + DebugHelper.WriteException(e); + } + } + } + } + + private void ImportCustomUploader() + { + if (Clipboard.ContainsText()) + { + string json = Clipboard.GetText(); + + if (!string.IsNullOrEmpty(json)) + { + try + { + CustomUploaderItem customUploader = JsonConvert.DeserializeObject(json); + + if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name)) + { + Config.CustomUploadersList.Add(customUploader); + lbCustomUploaderList.Items.Add(customUploader.Name); + lbCustomUploaderList.SelectedIndex = lbCustomUploaderList.Items.Count - 1; + PrepareCustomUploaderList(); + } + } + catch (Exception e) + { + DebugHelper.WriteException(e); + } + } + } + } + private void CustomUploaderClear() { LoadCustomUploader(new CustomUploaderItem());