Replace FrmBase64 with FrmCoder

This commit is contained in:
2017-12-24 18:28:47 +01:00
parent 6b86874af5
commit 56f1222c31
9 changed files with 308 additions and 194 deletions

View File

@@ -0,0 +1,26 @@
using System;
using System.Text;
namespace VAR.Toolbox.Code
{
public class CoderBase64 : ICoder
{
public string Decode(string input, string key)
{
byte[] encodedDataAsBytes
= Convert.FromBase64String(input);
string returnValue =
Encoding.ASCII.GetString(encodedDataAsBytes);
return returnValue;
}
public string Encode(string input, string key)
{
byte[] toEncodeAsBytes
= Encoding.ASCII.GetBytes(input);
string returnValue
= Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}
}
}

View File

@@ -0,0 +1,8 @@
namespace VAR.Toolbox.Code
{
public interface ICoder
{
string Encode(string input, string key);
string Decode(string input, string key);
}
}

View File

@@ -1,135 +0,0 @@
namespace VAR.Toolbox.UI
{
partial class FrmBase64
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtInput = new System.Windows.Forms.TextBox();
this.btnDecodeBase64 = new System.Windows.Forms.Button();
this.txtOutput = new System.Windows.Forms.TextBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.btnEncodeBase64 = new System.Windows.Forms.Button();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// txtInput
//
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtInput.Location = new System.Drawing.Point(12, 14);
this.txtInput.Multiline = true;
this.txtInput.Name = "txtInput";
this.txtInput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtInput.Size = new System.Drawing.Size(353, 364);
this.txtInput.TabIndex = 0;
//
// btnDecodeBase64
//
this.btnDecodeBase64.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnDecodeBase64.Location = new System.Drawing.Point(12, 384);
this.btnDecodeBase64.Name = "btnDecodeBase64";
this.btnDecodeBase64.Size = new System.Drawing.Size(105, 23);
this.btnDecodeBase64.TabIndex = 1;
this.btnDecodeBase64.Text = "Decode Base64";
this.btnDecodeBase64.UseVisualStyleBackColor = true;
this.btnDecodeBase64.Click += new System.EventHandler(this.btnDecodeBase64_Click);
//
// txtOutput
//
this.txtOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtOutput.Location = new System.Drawing.Point(3, 14);
this.txtOutput.Multiline = true;
this.txtOutput.Name = "txtOutput";
this.txtOutput.ReadOnly = true;
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtOutput.Size = new System.Drawing.Size(356, 364);
this.txtOutput.TabIndex = 2;
//
// splitContainer1
//
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.btnEncodeBase64);
this.splitContainer1.Panel1.Controls.Add(this.btnDecodeBase64);
this.splitContainer1.Panel1.Controls.Add(this.txtInput);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.txtOutput);
this.splitContainer1.Size = new System.Drawing.Size(743, 418);
this.splitContainer1.SplitterDistance = 368;
this.splitContainer1.TabIndex = 3;
//
// btnEncodeBase64
//
this.btnEncodeBase64.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnEncodeBase64.Location = new System.Drawing.Point(123, 384);
this.btnEncodeBase64.Name = "btnEncodeBase64";
this.btnEncodeBase64.Size = new System.Drawing.Size(107, 23);
this.btnEncodeBase64.TabIndex = 3;
this.btnEncodeBase64.Text = "Encode Base64";
this.btnEncodeBase64.UseVisualStyleBackColor = true;
this.btnEncodeBase64.Click += new System.EventHandler(this.btnEncodeBase64_Click);
//
// frmBase64
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(743, 417);
this.Controls.Add(this.splitContainer1);
this.Name = "frmBase64";
this.Text = "Base64";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TextBox txtInput;
private System.Windows.Forms.Button btnDecodeBase64;
private System.Windows.Forms.TextBox txtOutput;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button btnEncodeBase64;
}
}

View File

@@ -1,42 +0,0 @@
using System;
using System.Text;
using System.Windows.Forms;
namespace VAR.Toolbox.UI
{
public partial class FrmBase64 : Form
{
public FrmBase64()
{
InitializeComponent();
}
static public string Base64Encode(string toEncode)
{
byte[] toEncodeAsBytes
= Encoding.ASCII.GetBytes(toEncode);
string returnValue
= System.Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}
static public string Base64Decode(string encodedData)
{
byte[] encodedDataAsBytes
= System.Convert.FromBase64String(encodedData);
string returnValue =
Encoding.ASCII.GetString(encodedDataAsBytes);
return returnValue;
}
private void btnDecodeBase64_Click(object sender, EventArgs e)
{
txtOutput.Text = Base64Decode(txtInput.Text);
}
private void btnEncodeBase64_Click(object sender, EventArgs e)
{
txtOutput.Text = Base64Encode(txtInput.Text);
}
}
}

190
VAR.Toolbox/UI/FrmCoder.Designer.cs generated Normal file
View File

@@ -0,0 +1,190 @@
namespace VAR.Toolbox.UI
{
partial class FrmCoder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtInput = new System.Windows.Forms.TextBox();
this.btnDecode = new System.Windows.Forms.Button();
this.txtOutput = new System.Windows.Forms.TextBox();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.btnEncode = new System.Windows.Forms.Button();
this.cboCode = new System.Windows.Forms.ComboBox();
this.btnSwap = new System.Windows.Forms.Button();
this.txtKey = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// txtInput
//
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtInput.Location = new System.Drawing.Point(13, 14);
this.txtInput.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtInput.Multiline = true;
this.txtInput.Name = "txtInput";
this.txtInput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtInput.Size = new System.Drawing.Size(527, 463);
this.txtInput.TabIndex = 0;
//
// btnDecode
//
this.btnDecode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnDecode.Location = new System.Drawing.Point(219, 593);
this.btnDecode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnDecode.Name = "btnDecode";
this.btnDecode.Size = new System.Drawing.Size(94, 35);
this.btnDecode.TabIndex = 1;
this.btnDecode.Text = "Decode";
this.btnDecode.UseVisualStyleBackColor = true;
this.btnDecode.Click += new System.EventHandler(this.btnDecodeBase64_Click);
//
// txtOutput
//
this.txtOutput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtOutput.Location = new System.Drawing.Point(11, 14);
this.txtOutput.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtOutput.Multiline = true;
this.txtOutput.Name = "txtOutput";
this.txtOutput.ReadOnly = true;
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtOutput.Size = new System.Drawing.Size(533, 558);
this.txtOutput.TabIndex = 2;
//
// splitContainer1
//
this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.txtKey);
this.splitContainer1.Panel1.Controls.Add(this.cboCode);
this.splitContainer1.Panel1.Controls.Add(this.btnEncode);
this.splitContainer1.Panel1.Controls.Add(this.btnDecode);
this.splitContainer1.Panel1.Controls.Add(this.txtInput);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.btnSwap);
this.splitContainer1.Panel2.Controls.Add(this.txtOutput);
this.splitContainer1.Size = new System.Drawing.Size(1114, 643);
this.splitContainer1.SplitterDistance = 551;
this.splitContainer1.SplitterWidth = 6;
this.splitContainer1.TabIndex = 3;
//
// btnEncode
//
this.btnEncode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnEncode.Location = new System.Drawing.Point(321, 593);
this.btnEncode.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnEncode.Name = "btnEncode";
this.btnEncode.Size = new System.Drawing.Size(94, 35);
this.btnEncode.TabIndex = 3;
this.btnEncode.Text = "Encode";
this.btnEncode.UseVisualStyleBackColor = true;
this.btnEncode.Click += new System.EventHandler(this.btnEncodeBase64_Click);
//
// cboCode
//
this.cboCode.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.cboCode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboCode.FormattingEnabled = true;
this.cboCode.Items.AddRange(new object[] {
"Base64"});
this.cboCode.Location = new System.Drawing.Point(18, 597);
this.cboCode.Name = "cboCode";
this.cboCode.Size = new System.Drawing.Size(194, 28);
this.cboCode.TabIndex = 4;
this.cboCode.SelectedIndexChanged += new System.EventHandler(this.cboCode_SelectedIndexChanged);
//
// btnSwap
//
this.btnSwap.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnSwap.Location = new System.Drawing.Point(4, 593);
this.btnSwap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnSwap.Name = "btnSwap";
this.btnSwap.Size = new System.Drawing.Size(94, 35);
this.btnSwap.TabIndex = 4;
this.btnSwap.Text = "Swap";
this.btnSwap.UseVisualStyleBackColor = true;
this.btnSwap.Click += new System.EventHandler(this.btnSwap_Click);
//
// txtKey
//
this.txtKey.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtKey.Location = new System.Drawing.Point(13, 487);
this.txtKey.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.txtKey.Multiline = true;
this.txtKey.Name = "txtKey";
this.txtKey.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtKey.Size = new System.Drawing.Size(527, 89);
this.txtKey.TabIndex = 5;
//
// FrmCoder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1114, 642);
this.Controls.Add(this.splitContainer1);
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Name = "FrmCoder";
this.Text = "Coder";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TextBox txtInput;
private System.Windows.Forms.Button btnDecode;
private System.Windows.Forms.TextBox txtOutput;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button btnEncode;
private System.Windows.Forms.ComboBox cboCode;
private System.Windows.Forms.Button btnSwap;
private System.Windows.Forms.TextBox txtKey;
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Windows.Forms;
using VAR.Toolbox.Code;
namespace VAR.Toolbox.UI
{
public partial class FrmCoder : Form
{
public FrmCoder()
{
InitializeComponent();
cboCode.SelectedItem = "Base64";
}
private ICoder _coder = null;
private void btnDecodeBase64_Click(object sender, EventArgs e)
{
string output = string.Empty;
try
{
output = _coder.Decode(txtInput.Text, txtKey.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
txtOutput.Text = output;
}
private void btnEncodeBase64_Click(object sender, EventArgs e)
{
string output = string.Empty;
try
{
output = _coder.Encode(txtInput.Text, txtKey.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
txtOutput.Text = output;
}
private void btnSwap_Click(object sender, EventArgs e)
{
string temp = txtOutput.Text;
txtOutput.Text = txtInput.Text;
txtInput.Text = temp;
}
private void cboCode_SelectedIndexChanged(object sender, EventArgs e)
{
string code = (string)cboCode.SelectedItem;
if(code == "Base64")
{
txtKey.Enabled = false;
_coder = new CoderBase64();
return;
}
}
}
}

View File

@@ -29,7 +29,7 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.btnBase64 = new System.Windows.Forms.Button(); this.btnCoder = new System.Windows.Forms.Button();
this.btnProxyCmd = new System.Windows.Forms.Button(); this.btnProxyCmd = new System.Windows.Forms.Button();
this.btnWebcam = new System.Windows.Forms.Button(); this.btnWebcam = new System.Windows.Forms.Button();
this.btnTunnelTCP = new System.Windows.Forms.Button(); this.btnTunnelTCP = new System.Windows.Forms.Button();
@@ -44,16 +44,16 @@
this.btnIPScan = new System.Windows.Forms.Button(); this.btnIPScan = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnBase64 // btnCoder
// //
this.btnBase64.Location = new System.Drawing.Point(14, 80); this.btnCoder.Location = new System.Drawing.Point(14, 80);
this.btnBase64.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnCoder.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.btnBase64.Name = "btnBase64"; this.btnCoder.Name = "btnCoder";
this.btnBase64.Size = new System.Drawing.Size(248, 52); this.btnCoder.Size = new System.Drawing.Size(248, 52);
this.btnBase64.TabIndex = 0; this.btnCoder.TabIndex = 0;
this.btnBase64.Text = "Base64"; this.btnCoder.Text = "Coder";
this.btnBase64.UseVisualStyleBackColor = true; this.btnCoder.UseVisualStyleBackColor = true;
this.btnBase64.Click += new System.EventHandler(this.btnBase64_Click); this.btnCoder.Click += new System.EventHandler(this.btnCoder_Click);
// //
// btnProxyCmd // btnProxyCmd
// //
@@ -192,7 +192,7 @@
this.Controls.Add(this.pnlCover1); this.Controls.Add(this.pnlCover1);
this.Controls.Add(this.btnWebcam); this.Controls.Add(this.btnWebcam);
this.Controls.Add(this.btnProxyCmd); this.Controls.Add(this.btnProxyCmd);
this.Controls.Add(this.btnBase64); this.Controls.Add(this.btnCoder);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.MaximizeBox = false; this.MaximizeBox = false;
@@ -207,7 +207,7 @@
#endregion #endregion
private System.Windows.Forms.Button btnBase64; private System.Windows.Forms.Button btnCoder;
private System.Windows.Forms.Button btnProxyCmd; private System.Windows.Forms.Button btnProxyCmd;
private System.Windows.Forms.Button btnWebcam; private System.Windows.Forms.Button btnWebcam;
private PnlCover pnlCover1; private PnlCover pnlCover1;

View File

@@ -75,9 +75,9 @@ namespace VAR.Toolbox.UI
WindowState = FormWindowState.Normal; WindowState = FormWindowState.Normal;
} }
private void btnBase64_Click(object sender, EventArgs e) private void btnCoder_Click(object sender, EventArgs e)
{ {
CreateWindow(typeof(FrmBase64)); CreateWindow(typeof(FrmCoder));
} }
private void btnProxyCmd_Click(object sender, EventArgs e) private void btnProxyCmd_Click(object sender, EventArgs e)

View File

@@ -53,6 +53,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Code\CoderBase64.cs" />
<Compile Include="Code\DirectShow\CameraControlProperty.cs" /> <Compile Include="Code\DirectShow\CameraControlProperty.cs" />
<Compile Include="Code\DirectShow\IAMCameraControl.cs" /> <Compile Include="Code\DirectShow\IAMCameraControl.cs" />
<Compile Include="Code\DirectShow\IAMCrossbar.cs" /> <Compile Include="Code\DirectShow\IAMCrossbar.cs" />
@@ -84,6 +85,7 @@
<Compile Include="Code\DirectShow\Uuids.cs" /> <Compile Include="Code\DirectShow\Uuids.cs" />
<Compile Include="Code\DirectShow\Win32.cs" /> <Compile Include="Code\DirectShow\Win32.cs" />
<Compile Include="Code\GDI32.cs" /> <Compile Include="Code\GDI32.cs" />
<Compile Include="Code\ICoder.cs" />
<Compile Include="Code\IOutputHandler.cs" /> <Compile Include="Code\IOutputHandler.cs" />
<Compile Include="Code\IProxyCmdExecutor.cs" /> <Compile Include="Code\IProxyCmdExecutor.cs" />
<Compile Include="Code\Logger.cs" /> <Compile Include="Code\Logger.cs" />
@@ -98,11 +100,11 @@
<Compile Include="Controls\CtrImageViewer.cs"> <Compile Include="Controls\CtrImageViewer.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="UI\FrmBase64.cs"> <Compile Include="UI\FrmCoder.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="UI\FrmBase64.Designer.cs"> <Compile Include="UI\FrmCoder.Designer.cs">
<DependentUpon>FrmBase64.cs</DependentUpon> <DependentUpon>FrmCoder.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="UI\FrmCover.cs"> <Compile Include="UI\FrmCover.cs">
<SubType>Form</SubType> <SubType>Form</SubType>