mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
fixed #12: Added Export/Import custom uploader
This commit is contained in:
parent
0790fbe035
commit
bee7bf7454
5 changed files with 120 additions and 27 deletions
|
@ -323,6 +323,7 @@ private void btnSettingsExport_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string json = ImageEffectManager.ExportEffects(imageEffects);
|
string json = ImageEffectManager.ExportEffects(imageEffects);
|
||||||
ClipboardHelpers.CopyText(json);
|
ClipboardHelpers.CopyText(json);
|
||||||
|
MessageBox.Show("Image effects copied to your clipboard.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
UploadersLib/GUI/UploadersConfigForm.Designer.cs
generated
28
UploadersLib/GUI/UploadersConfigForm.Designer.cs
generated
|
@ -320,6 +320,8 @@ private void InitializeComponent()
|
||||||
this.txtRapidSharePremiumUserName = new System.Windows.Forms.TextBox();
|
this.txtRapidSharePremiumUserName = new System.Windows.Forms.TextBox();
|
||||||
this.ttHelpTip = new System.Windows.Forms.ToolTip(this.components);
|
this.ttHelpTip = new System.Windows.Forms.ToolTip(this.components);
|
||||||
this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl();
|
this.actRapidShareAccountType = new UploadersLib.GUI.AccountTypeControl();
|
||||||
|
this.btnCustomUploaderExport = new System.Windows.Forms.Button();
|
||||||
|
this.btnCustomUploaderImport = new System.Windows.Forms.Button();
|
||||||
this.tcUploaders.SuspendLayout();
|
this.tcUploaders.SuspendLayout();
|
||||||
this.tpImageUploaders.SuspendLayout();
|
this.tpImageUploaders.SuspendLayout();
|
||||||
this.tcImageUploaders.SuspendLayout();
|
this.tcImageUploaders.SuspendLayout();
|
||||||
|
@ -3007,7 +3009,9 @@ private void InitializeComponent()
|
||||||
//
|
//
|
||||||
// gbCustomUploaders
|
// gbCustomUploaders
|
||||||
//
|
//
|
||||||
|
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderImport);
|
||||||
this.gbCustomUploaders.Controls.Add(this.lbCustomUploaderList);
|
this.gbCustomUploaders.Controls.Add(this.lbCustomUploaderList);
|
||||||
|
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderExport);
|
||||||
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderRemove);
|
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderRemove);
|
||||||
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderClear);
|
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderClear);
|
||||||
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderUpdate);
|
this.gbCustomUploaders.Controls.Add(this.btnCustomUploaderUpdate);
|
||||||
|
@ -3046,7 +3050,7 @@ private void InitializeComponent()
|
||||||
this.btnCustomUploaderClear.Name = "btnCustomUploaderClear";
|
this.btnCustomUploaderClear.Name = "btnCustomUploaderClear";
|
||||||
this.btnCustomUploaderClear.Size = new System.Drawing.Size(88, 24);
|
this.btnCustomUploaderClear.Size = new System.Drawing.Size(88, 24);
|
||||||
this.btnCustomUploaderClear.TabIndex = 5;
|
this.btnCustomUploaderClear.TabIndex = 5;
|
||||||
this.btnCustomUploaderClear.Text = "Clear fields ->";
|
this.btnCustomUploaderClear.Text = "Clear fields -->";
|
||||||
this.btnCustomUploaderClear.UseVisualStyleBackColor = true;
|
this.btnCustomUploaderClear.UseVisualStyleBackColor = true;
|
||||||
this.btnCustomUploaderClear.Click += new System.EventHandler(this.btnCustomUploaderClear_Click);
|
this.btnCustomUploaderClear.Click += new System.EventHandler(this.btnCustomUploaderClear_Click);
|
||||||
//
|
//
|
||||||
|
@ -3421,6 +3425,26 @@ private void InitializeComponent()
|
||||||
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
|
this.actRapidShareAccountType.Size = new System.Drawing.Size(214, 29);
|
||||||
this.actRapidShareAccountType.TabIndex = 16;
|
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
|
// UploadersConfigForm
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -3817,5 +3841,7 @@ private void InitializeComponent()
|
||||||
private GUI.AccountTypeControl atcMegaAccountType;
|
private GUI.AccountTypeControl atcMegaAccountType;
|
||||||
private System.Windows.Forms.Button btnMegaRegister;
|
private System.Windows.Forms.Button btnMegaRegister;
|
||||||
private System.Windows.Forms.Button btnMegaRefreshFolders;
|
private System.Windows.Forms.Button btnMegaRefreshFolders;
|
||||||
|
private System.Windows.Forms.Button btnCustomUploaderImport;
|
||||||
|
private System.Windows.Forms.Button btnCustomUploaderExport;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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)
|
private void cbCustomUploaderRequestType_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
txtCustomUploaderFileForm.Enabled = (CustomUploaderRequestType)cbCustomUploaderRequestType.SelectedIndex == CustomUploaderRequestType.POST;
|
txtCustomUploaderFileForm.Enabled = (CustomUploaderRequestType)cbCustomUploaderRequestType.SelectedIndex == CustomUploaderRequestType.POST;
|
||||||
|
|
|
@ -117,6 +117,33 @@
|
||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="ttHelpTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="label1.ToolTip" xml:space="preserve">
|
||||||
|
<value>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$</value>
|
||||||
|
</data>
|
||||||
|
<data name="lblCustomUploaderRequestTypeHelp.ToolTip" xml:space="preserve">
|
||||||
|
<value>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.</value>
|
||||||
|
</data>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="pbDropboxLogo.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="pbDropboxLogo.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
|
@ -237,28 +264,4 @@
|
||||||
<metadata name="ttHelpTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="ttHelpTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="label1.ToolTip" xml:space="preserve">
|
|
||||||
<value>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$</value>
|
|
||||||
</data>
|
|
||||||
<data name="lblCustomUploaderRequestTypeHelp.ToolTip" xml:space="preserve">
|
|
||||||
<value>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.</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
|
@ -24,6 +24,7 @@ You should have received a copy of the GNU General Public License
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using HelpersLib;
|
using HelpersLib;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -1183,11 +1184,11 @@ private void UpdateCustomUploader()
|
||||||
{
|
{
|
||||||
int index = lbCustomUploaderList.SelectedIndex;
|
int index = lbCustomUploaderList.SelectedIndex;
|
||||||
|
|
||||||
if (index != -1)
|
if (index >= 0)
|
||||||
{
|
{
|
||||||
CustomUploaderItem customUploader = GetCustomUploaderFromFields();
|
CustomUploaderItem customUploader = GetCustomUploaderFromFields();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(customUploader.Name))
|
if (customUploader != null && !string.IsNullOrEmpty(customUploader.Name))
|
||||||
{
|
{
|
||||||
Config.CustomUploadersList[index] = customUploader;
|
Config.CustomUploadersList[index] = customUploader;
|
||||||
lbCustomUploaderList.Items[index] = customUploader.Name;
|
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<CustomUploaderItem>(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()
|
private void CustomUploaderClear()
|
||||||
{
|
{
|
||||||
LoadCustomUploader(new CustomUploaderItem());
|
LoadCustomUploader(new CustomUploaderItem());
|
||||||
|
|
Loading…
Reference in a new issue