From bba312d7116c8b9ba81831545571f8693affb90b Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 8 Apr 2022 23:06:08 +0300 Subject: [PATCH] Added custom uploader syntax test form --- ShareX.HelpersLib/Forms/ImageViewer.cs | 2 +- ShareX.HelpersLib/NameParser/CodeMenu.cs | 6 +- .../CustomUploaderSettingsForm.Designer.cs | 136 ++++++++------- .../Forms/CustomUploaderSettingsForm.cs | 8 + .../Forms/CustomUploaderSettingsForm.resx | 134 ++++++++------- .../CustomUploaderSyntaxTestForm.Designer.cs | 141 ++++++++++++++++ .../Forms/CustomUploaderSyntaxTestForm.cs | 156 ++++++++++++++++++ .../Forms/CustomUploaderSyntaxTestForm.resx | 120 ++++++++++++++ .../ShareX.UploadersLib.csproj | 9 + 9 files changed, 585 insertions(+), 127 deletions(-) create mode 100644 ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.Designer.cs create mode 100644 ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.cs create mode 100644 ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.resx diff --git a/ShareX.HelpersLib/Forms/ImageViewer.cs b/ShareX.HelpersLib/Forms/ImageViewer.cs index 08c42c612..ffb690263 100644 --- a/ShareX.HelpersLib/Forms/ImageViewer.cs +++ b/ShareX.HelpersLib/Forms/ImageViewer.cs @@ -344,7 +344,7 @@ private void InitializeComponent() lblStatus.AutoSize = true; lblStatus.Font = new Font("Arial", 13f); - lblStatus.Padding = new Padding(6); + lblStatus.Padding = new Padding(5); lblStatus.TextAlign = ContentAlignment.MiddleCenter; Controls.Add(lblStatus); diff --git a/ShareX.HelpersLib/NameParser/CodeMenu.cs b/ShareX.HelpersLib/NameParser/CodeMenu.cs index 852c51fc7..195e10f85 100644 --- a/ShareX.HelpersLib/NameParser/CodeMenu.cs +++ b/ShareX.HelpersLib/NameParser/CodeMenu.cs @@ -39,13 +39,15 @@ public Point MenuLocation { if (MenuLocationBottom) { - return new Point(0, textBoxBase.Height + 1); + return new Point(MenuLocationOffset.X, textBoxBase.Height + MenuLocationOffset.Y + 1); } - return new Point(textBoxBase.Width + 1, 0); + return new Point(textBoxBase.Width + MenuLocationOffset.X + 1, MenuLocationOffset.Y); } } + public Point MenuLocationOffset { get; set; } + public bool MenuLocationBottom { get; set; } private TextBoxBase textBoxBase; diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.Designer.cs b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.Designer.cs index 513b6e4f7..87e969f21 100644 --- a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.Designer.cs @@ -30,13 +30,13 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomUploaderSettingsForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle37 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle38 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle39 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle40 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle42 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle41 = new System.Windows.Forms.DataGridViewCellStyle(); this.cbImageUploader = new System.Windows.Forms.ComboBox(); this.btnTextUploaderTest = new System.Windows.Forms.Button(); this.lblURLShortener = new System.Windows.Forms.Label(); @@ -110,6 +110,7 @@ private void InitializeComponent() this.ttHelpTip = new System.Windows.Forms.ToolTip(this.components); this.lblUploaders = new System.Windows.Forms.Label(); this.pMain = new System.Windows.Forms.Panel(); + this.btnTestURLSyntax = new System.Windows.Forms.Button(); this.cmsHelp.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvHeaders)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dgvParameters)).BeginInit(); @@ -302,28 +303,28 @@ private void InitializeComponent() this.dgvHeaders.AllowUserToResizeRows = false; this.dgvHeaders.BackgroundColor = System.Drawing.SystemColors.Window; this.dgvHeaders.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle8.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); - dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvHeaders.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle36.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle36.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle36.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle36.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle36.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); + dataGridViewCellStyle36.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle36.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle36.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvHeaders.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle36; this.dgvHeaders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvHeaders.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.cHeadersName, this.cHeadersValue}); - dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle9.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle9.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); - dataGridViewCellStyle9.SelectionBackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle9.SelectionForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvHeaders.DefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle37.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle37.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle37.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle37.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle37.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); + dataGridViewCellStyle37.SelectionBackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle37.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle37.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvHeaders.DefaultCellStyle = dataGridViewCellStyle37; this.dgvHeaders.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; this.dgvHeaders.GridColor = System.Drawing.SystemColors.ControlLight; resources.ApplyResources(this.dgvHeaders, "dgvHeaders"); @@ -351,28 +352,28 @@ private void InitializeComponent() this.dgvParameters.AllowUserToResizeRows = false; this.dgvParameters.BackgroundColor = System.Drawing.SystemColors.Window; this.dgvParameters.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle10.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle10.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); - dataGridViewCellStyle10.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle10.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvParameters.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle38.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle38.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle38.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle38.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle38.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); + dataGridViewCellStyle38.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle38.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle38.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvParameters.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle38; this.dgvParameters.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvParameters.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.cParametersName, this.cParametersValue}); - dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle11.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); - dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvParameters.DefaultCellStyle = dataGridViewCellStyle11; + dataGridViewCellStyle39.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle39.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle39.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle39.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle39.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); + dataGridViewCellStyle39.SelectionBackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle39.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle39.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvParameters.DefaultCellStyle = dataGridViewCellStyle39; this.dgvParameters.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; this.dgvParameters.GridColor = System.Drawing.SystemColors.ControlLight; resources.ApplyResources(this.dgvParameters, "dgvParameters"); @@ -466,28 +467,28 @@ private void InitializeComponent() this.dgvArguments.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells; this.dgvArguments.BackgroundColor = System.Drawing.SystemColors.Window; this.dgvArguments.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single; - dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle12.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); - dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvArguments.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12; + dataGridViewCellStyle40.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle40.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle40.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle40.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle40.Padding = new System.Windows.Forms.Padding(0, 2, 0, 2); + dataGridViewCellStyle40.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle40.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle40.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvArguments.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle40; this.dgvArguments.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvArguments.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.cArgumentsName, this.cArgumentsValue}); - dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle14.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dataGridViewCellStyle14.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle14.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); - dataGridViewCellStyle14.SelectionBackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle14.SelectionForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle14.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvArguments.DefaultCellStyle = dataGridViewCellStyle14; + dataGridViewCellStyle42.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle42.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle42.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + dataGridViewCellStyle42.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle42.Padding = new System.Windows.Forms.Padding(1, 0, 0, 0); + dataGridViewCellStyle42.SelectionBackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle42.SelectionForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle42.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvArguments.DefaultCellStyle = dataGridViewCellStyle42; this.dgvArguments.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter; this.dgvArguments.GridColor = System.Drawing.SystemColors.ControlLight; resources.ApplyResources(this.dgvArguments, "dgvArguments"); @@ -506,8 +507,8 @@ private void InitializeComponent() // cArgumentsValue // this.cArgumentsValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - dataGridViewCellStyle13.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.cArgumentsValue.DefaultCellStyle = dataGridViewCellStyle13; + dataGridViewCellStyle41.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.cArgumentsValue.DefaultCellStyle = dataGridViewCellStyle41; resources.ApplyResources(this.cArgumentsValue, "cArgumentsValue"); this.cArgumentsValue.Name = "cArgumentsValue"; this.cArgumentsValue.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; @@ -709,6 +710,7 @@ private void InitializeComponent() // // pMain // + this.pMain.Controls.Add(this.btnTestURLSyntax); this.pMain.Controls.Add(this.pResultErrorMessage); this.pMain.Controls.Add(this.dgvHeaders); this.pMain.Controls.Add(this.lblResultErrorMessage); @@ -736,6 +738,13 @@ private void InitializeComponent() resources.ApplyResources(this.pMain, "pMain"); this.pMain.Name = "pMain"; // + // btnTestURLSyntax + // + resources.ApplyResources(this.btnTestURLSyntax, "btnTestURLSyntax"); + this.btnTestURLSyntax.Name = "btnTestURLSyntax"; + this.btnTestURLSyntax.UseVisualStyleBackColor = true; + this.btnTestURLSyntax.Click += new System.EventHandler(this.btnTestURLSyntax_Click); + // // CustomUploaderSettingsForm // this.AllowDrop = true; @@ -865,5 +874,6 @@ private void InitializeComponent() private System.Windows.Forms.Panel pMain; private System.Windows.Forms.DataGridViewTextBoxColumn cArgumentsName; private System.Windows.Forms.DataGridViewTextBoxColumn cArgumentsValue; + private System.Windows.Forms.Button btnTestURLSyntax; } } \ No newline at end of file diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.cs b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.cs index 75d71b877..c3f394685 100644 --- a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.cs +++ b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.cs @@ -1033,6 +1033,14 @@ private void btnCustomUploaderDataMinify_Click(object sender, EventArgs e) CustomUploaderFormatJsonData(Formatting.None); } + private void btnTestURLSyntax_Click(object sender, EventArgs e) + { + using (CustomUploaderSyntaxTestForm syntaxTestForm = new CustomUploaderSyntaxTestForm(null, rtbResultURL.Text)) + { + syntaxTestForm.ShowDialog(); + } + } + private void rtbCustomUploaderURL_TextChanged(object sender, EventArgs e) { CustomUploaderItem uploader = CustomUploaderGetSelected(); diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.resx b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.resx index 8e4c2b8fe..349af20db 100644 --- a/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.resx +++ b/ShareX.UploadersLib/Forms/CustomUploaderSettingsForm.resx @@ -313,7 +313,7 @@ mbHelp - ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=13.7.1.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=13.7.2.0, Culture=neutral, PublicKeyToken=null $this @@ -424,7 +424,7 @@ eiCustomUploaders - ShareX.HelpersLib.ExportImportControl, ShareX.HelpersLib, Version=13.7.1.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.ExportImportControl, ShareX.HelpersLib, Version=13.7.2.0, Culture=neutral, PublicKeyToken=null $this @@ -670,7 +670,7 @@ pMain - 1 + 2 True @@ -703,7 +703,7 @@ pMain - 4 + 5 True @@ -733,7 +733,7 @@ pMain - 8 + 9 True @@ -763,7 +763,7 @@ pMain - 12 + 13 rtbRequestURL @@ -799,7 +799,7 @@ pMain - 16 + 17 Fill @@ -850,7 +850,7 @@ pMain - 17 + 18 True @@ -880,7 +880,7 @@ pMain - 18 + 19 256, 112 @@ -901,7 +901,7 @@ pMain - 19 + 20 True @@ -931,7 +931,7 @@ pMain - 21 + 22 True @@ -961,7 +961,7 @@ pMain - 20 + 21 dgvArguments @@ -1018,7 +1018,7 @@ pMain - 22 + 23 True @@ -1159,7 +1159,7 @@ pMain - 23 + 24 NoControl @@ -1315,7 +1315,7 @@ pMain - 0 + 1 Fill @@ -1375,7 +1375,7 @@ pMain - 2 + 3 rtbResultDeletionURL @@ -1411,7 +1411,7 @@ pMain - 5 + 6 Fill @@ -1474,7 +1474,7 @@ pMain - 7 + 8 rtbResultThumbnailURL @@ -1510,7 +1510,7 @@ pMain - 9 + 10 Fill @@ -1545,6 +1545,27 @@ 0 + + Fill + + + Arial, 9pt + + + 2, 2 + + + False + + + 442, 14 + + + 0 + + + + rtbResultURL @@ -1564,7 +1585,7 @@ 2, 2, 2, 2 - 480, 20 + 448, 20 16 @@ -1579,40 +1600,7 @@ pMain - 11 - - - Fill - - - Arial, 9pt - - - 2, 2 - - - False - - - 474, 14 - - - 0 - - - - - - rtbResultURL - - - System.Windows.Forms.RichTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pResultURL - - - 0 + 12 True @@ -1642,7 +1630,7 @@ pMain - 13 + 14 True @@ -1672,7 +1660,7 @@ pMain - 15 + 16 True @@ -1702,7 +1690,7 @@ pMain - 14 + 15 True @@ -1732,7 +1720,7 @@ pMain - 6 + 7 NoControl @@ -1771,13 +1759,13 @@ mbDestinationType - ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=13.7.1.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=13.7.2.0, Culture=neutral, PublicKeyToken=null pMain - 10 + 11 8, 24 @@ -1798,7 +1786,7 @@ pMain - 3 + 4 True @@ -1905,6 +1893,30 @@ 3 + + 465, 478 + + + 24, 24 + + + 23 + + + T + + + btnTestURLSyntax + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pMain + + + 0 + 264, 0 diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.Designer.cs b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.Designer.cs new file mode 100644 index 000000000..8801aad76 --- /dev/null +++ b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.Designer.cs @@ -0,0 +1,141 @@ +namespace ShareX.UploadersLib +{ + partial class CustomUploaderSyntaxTestForm + { + /// + /// 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.txtResponseText = new System.Windows.Forms.TextBox(); + this.lblResponseText = new System.Windows.Forms.Label(); + this.lblURLSyntax = new System.Windows.Forms.Label(); + this.lblResult = new System.Windows.Forms.Label(); + this.txtResult = new System.Windows.Forms.TextBox(); + this.rtbURLSyntax = new System.Windows.Forms.RichTextBox(); + this.pURLSyntax = new System.Windows.Forms.Panel(); + this.pURLSyntax.SuspendLayout(); + this.SuspendLayout(); + // + // txtResponseText + // + this.txtResponseText.Location = new System.Drawing.Point(16, 32); + this.txtResponseText.Multiline = true; + this.txtResponseText.Name = "txtResponseText"; + this.txtResponseText.Size = new System.Drawing.Size(568, 168); + this.txtResponseText.TabIndex = 5; + // + // lblResponseText + // + this.lblResponseText.AutoSize = true; + this.lblResponseText.Location = new System.Drawing.Point(13, 16); + this.lblResponseText.Name = "lblResponseText"; + this.lblResponseText.Size = new System.Drawing.Size(78, 13); + this.lblResponseText.TabIndex = 4; + this.lblResponseText.Text = "Response text:"; + // + // lblURLSyntax + // + this.lblURLSyntax.AutoSize = true; + this.lblURLSyntax.Location = new System.Drawing.Point(13, 208); + this.lblURLSyntax.Name = "lblURLSyntax"; + this.lblURLSyntax.Size = new System.Drawing.Size(65, 13); + this.lblURLSyntax.TabIndex = 0; + this.lblURLSyntax.Text = "URL syntax:"; + // + // lblResult + // + this.lblResult.AutoSize = true; + this.lblResult.Location = new System.Drawing.Point(13, 256); + this.lblResult.Name = "lblResult"; + this.lblResult.Size = new System.Drawing.Size(40, 13); + this.lblResult.TabIndex = 2; + this.lblResult.Text = "Result:"; + // + // txtResult + // + this.txtResult.Location = new System.Drawing.Point(16, 272); + this.txtResult.Multiline = true; + this.txtResult.Name = "txtResult"; + this.txtResult.ReadOnly = true; + this.txtResult.Size = new System.Drawing.Size(568, 56); + this.txtResult.TabIndex = 3; + // + // rtbURLSyntax + // + this.rtbURLSyntax.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.rtbURLSyntax.DetectUrls = false; + this.rtbURLSyntax.Dock = System.Windows.Forms.DockStyle.Fill; + this.rtbURLSyntax.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.rtbURLSyntax.Location = new System.Drawing.Point(2, 2); + this.rtbURLSyntax.Multiline = false; + this.rtbURLSyntax.Name = "rtbURLSyntax"; + this.rtbURLSyntax.Size = new System.Drawing.Size(562, 14); + this.rtbURLSyntax.TabIndex = 0; + this.rtbURLSyntax.Text = ""; + this.rtbURLSyntax.TextChanged += new System.EventHandler(this.rtbURLSyntax_TextChanged); + // + // pURLSyntax + // + this.pURLSyntax.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pURLSyntax.Controls.Add(this.rtbURLSyntax); + this.pURLSyntax.Location = new System.Drawing.Point(16, 224); + this.pURLSyntax.Name = "pURLSyntax"; + this.pURLSyntax.Padding = new System.Windows.Forms.Padding(2); + this.pURLSyntax.Size = new System.Drawing.Size(568, 20); + this.pURLSyntax.TabIndex = 1; + // + // CustomUploaderSyntaxTestForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(600, 344); + this.Controls.Add(this.pURLSyntax); + this.Controls.Add(this.txtResult); + this.Controls.Add(this.lblResult); + this.Controls.Add(this.lblURLSyntax); + this.Controls.Add(this.lblResponseText); + this.Controls.Add(this.txtResponseText); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "CustomUploaderSyntaxTestForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "ShareX - Custom uploader syntax test"; + this.pURLSyntax.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtResponseText; + private System.Windows.Forms.Label lblResponseText; + private System.Windows.Forms.Label lblURLSyntax; + private System.Windows.Forms.Label lblResult; + private System.Windows.Forms.TextBox txtResult; + private System.Windows.Forms.RichTextBox rtbURLSyntax; + private System.Windows.Forms.Panel pURLSyntax; + } +} \ No newline at end of file diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.cs b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.cs new file mode 100644 index 000000000..cfee86a30 --- /dev/null +++ b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.cs @@ -0,0 +1,156 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2022 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Drawing; +using System.Windows.Forms; + +namespace ShareX.UploadersLib +{ + public partial class CustomUploaderSyntaxTestForm : Form + { + public CustomUploaderSyntaxTestForm() : this(null, null) + { + } + + public CustomUploaderSyntaxTestForm(string responseText, string urlSyntax) + { + InitializeComponent(); + + if (string.IsNullOrEmpty(responseText)) + { + responseText = "{\r\n \"status\": 200,\r\n \"data\": {\r\n \"link\": \"https:\\/\\/example.com\\/image.png\"\r\n }\r\n}"; + } + + if (string.IsNullOrEmpty(urlSyntax)) + { + urlSyntax = "{json:data.link}"; + } + + txtResponseText.Text = responseText; + rtbURLSyntax.Text = urlSyntax; + rtbURLSyntax.Select(rtbURLSyntax.TextLength, 0); + + CodeMenuItem[] outputCodeMenuItems = new CodeMenuItem[] + { + new CodeMenuItem("{response}", "Response text"), + new CodeMenuItem("{responseurl}", "Response/Redirection URL"), + new CodeMenuItem("{header:header_name}", "Response header"), + new CodeMenuItem("{json:path}", "Parse JSON response using JSONPath"), + new CodeMenuItem("{xml:path}", "Parse XML response using XPath"), + new CodeMenuItem("{regex:pattern|group}", "Parse response using Regex"), + new CodeMenuItem("{filename}", "File name used when uploading"), + new CodeMenuItem("{random:input1|input2}", "Random selection from list"), + new CodeMenuItem("{select:input1|input2}", "Lets user to select one input from list"), + new CodeMenuItem("{prompt:title|default_value}", "Lets user to input text"), + new CodeMenuItem("{base64:input}", "Base64 encode input") + }; + + new CodeMenu(rtbURLSyntax, outputCodeMenuItems) + { + MenuLocationOffset = new Point(5, -3) + }; + + rtbURLSyntax.AddContextMenu(); + + ShareXResources.ApplyTheme(this); + + UpdatePreview(); + } + + private void CustomUploaderSyntaxHighlight(RichTextBox rtb) + { + string text = rtb.Text; + + if (!string.IsNullOrEmpty(text)) + { + int start = rtb.SelectionStart; + int length = rtb.SelectionLength; + rtb.BeginUpdate(); + + rtb.SelectionStart = 0; + rtb.SelectionLength = rtb.TextLength; + rtb.SelectionColor = rtb.ForeColor; + + CustomUploaderSyntaxParser parser = new CustomUploaderSyntaxParser(); + + for (int i = 0; i < text.Length; i++) + { + char c = text[i]; + + if (c == parser.SyntaxStart || c == parser.SyntaxEnd || c == parser.SyntaxParameterStart || + c == parser.SyntaxParameterDelimiter || c == parser.SyntaxEscape) + { + rtb.SelectionStart = i; + rtb.SelectionLength = 1; + rtb.SelectionColor = Color.Lime; + } + } + + rtb.SelectionStart = start; + rtb.SelectionLength = length; + rtb.EndUpdate(); + } + } + + private string ParseSyntax(string responseText, string urlSyntax) + { + if (string.IsNullOrEmpty(responseText) || string.IsNullOrEmpty(urlSyntax)) return null; + + ResponseInfo responseInfo = new ResponseInfo(); + responseInfo.ResponseText = responseText; + + CustomUploaderSyntaxParser parser = new CustomUploaderSyntaxParser() + { + FileName = "example.png", + ResponseInfo = responseInfo, + URLEncode = true + }; + + return parser.Parse(urlSyntax); + } + + private void UpdatePreview() + { + CustomUploaderSyntaxHighlight(rtbURLSyntax); + + try + { + string result = ParseSyntax(txtResponseText.Text, rtbURLSyntax.Text); + txtResult.Text = result; + } + catch (Exception ex) + { + txtResult.Text = "Error\r\n" + ex.Message; + } + } + + private void rtbURLSyntax_TextChanged(object sender, EventArgs e) + { + UpdatePreview(); + } + } +} \ No newline at end of file diff --git a/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.resx b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.resx new file mode 100644 index 000000000..1af7de150 --- /dev/null +++ b/ShareX.UploadersLib/Forms/CustomUploaderSyntaxTestForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index ec48bb38e..beeb8145c 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -181,6 +181,12 @@ CustomUploaderSettingsForm.cs + + Form + + + CustomUploaderSyntaxTestForm.cs + Form @@ -539,6 +545,9 @@ CustomUploaderSettingsForm.cs + + CustomUploaderSyntaxTestForm.cs + EmailForm.cs