Browse Source

commit: update HTML code paste helper

HOME 4 years ago
parent
commit
b4a493175c
2 changed files with 21 additions and 4 deletions
  1. 15 2
      MiscToolSet/MainForm.Designer.cs
  2. 6 2
      MiscToolSet/MainForm.cs

+ 15 - 2
MiscToolSet/MainForm.Designer.cs

@@ -112,6 +112,7 @@
             this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
             this.ConvertCodeButton = new System.Windows.Forms.Button();
             this.CopyButton = new System.Windows.Forms.Button();
+            this.PasteCodeButton = new System.Windows.Forms.Button();
             this.tabControl1.SuspendLayout();
             this.tabPage2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.BulkNewGuidUpDown)).BeginInit();
@@ -1129,6 +1130,7 @@
             // 
             // flowLayoutPanel2
             // 
+            this.flowLayoutPanel2.Controls.Add(this.PasteCodeButton);
             this.flowLayoutPanel2.Controls.Add(this.ConvertCodeButton);
             this.flowLayoutPanel2.Controls.Add(this.CopyButton);
             this.flowLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Top;
@@ -1139,7 +1141,7 @@
             // 
             // ConvertCodeButton
             // 
-            this.ConvertCodeButton.Location = new System.Drawing.Point(3, 3);
+            this.ConvertCodeButton.Location = new System.Drawing.Point(107, 3);
             this.ConvertCodeButton.Name = "ConvertCodeButton";
             this.ConvertCodeButton.Size = new System.Drawing.Size(98, 23);
             this.ConvertCodeButton.TabIndex = 0;
@@ -1149,7 +1151,7 @@
             // 
             // CopyButton
             // 
-            this.CopyButton.Location = new System.Drawing.Point(107, 3);
+            this.CopyButton.Location = new System.Drawing.Point(211, 3);
             this.CopyButton.Name = "CopyButton";
             this.CopyButton.Size = new System.Drawing.Size(98, 23);
             this.CopyButton.TabIndex = 0;
@@ -1157,6 +1159,16 @@
             this.CopyButton.UseVisualStyleBackColor = true;
             this.CopyButton.Click += new System.EventHandler(this.CopyButton_Click);
             // 
+            // PasteCodeButton
+            // 
+            this.PasteCodeButton.Location = new System.Drawing.Point(3, 3);
+            this.PasteCodeButton.Name = "PasteCodeButton";
+            this.PasteCodeButton.Size = new System.Drawing.Size(98, 23);
+            this.PasteCodeButton.TabIndex = 0;
+            this.PasteCodeButton.Text = "Paste";
+            this.PasteCodeButton.UseVisualStyleBackColor = true;
+            this.PasteCodeButton.Click += new System.EventHandler(this.PasteCodeButton_Click);
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@@ -1293,6 +1305,7 @@
         private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
         private System.Windows.Forms.Button ConvertCodeButton;
         private System.Windows.Forms.Button CopyButton;
+        private System.Windows.Forms.Button PasteCodeButton;
     }
 }
 

+ 6 - 2
MiscToolSet/MainForm.cs

@@ -231,8 +231,7 @@ namespace MiscToolSet
             {
                 var line = lines[index];
                 var htmlEncode = HttpUtility.HtmlEncode(line);
-                var spaces = line.TakeWhile(p => p == ' ').Count();
-                ConvertedCodeTextBox.AppendText($"<span style=\"padding-left: {spaces / 2.0:00.0}em;\">{htmlEncode}</span>");
+                ConvertedCodeTextBox.AppendText($"{htmlEncode.Replace(" ", "&nbsp;")}");
                 if (index < lines.Length - 1)
                 {
                     ConvertedCodeTextBox.AppendText($"<br />{Environment.NewLine}");
@@ -244,6 +243,11 @@ namespace MiscToolSet
         {
             Clipboard.SetText(ConvertedCodeTextBox.Text);
         }
+
+        private void PasteCodeButton_Click(object sender, EventArgs e)
+        {
+            InputCodeTextBox.Text = Clipboard.GetText();
+        }
     }
 
     internal static class CommonExtensionMetond