Added auto compute function and toggle.

This commit is contained in:
Chloe Fontenot 🏳️‍⚧️ 2022-10-04 21:48:13 -05:00
parent 7c7f077705
commit e911fc48d2
13 changed files with 106 additions and 50 deletions

View File

@ -46,6 +46,7 @@ namespace WindowsFormsApplication1
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container();
this.computeButton = new System.Windows.Forms.Button(); this.computeButton = new System.Windows.Forms.Button();
this.clearButton = new System.Windows.Forms.Button(); this.clearButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
@ -62,6 +63,8 @@ namespace WindowsFormsApplication1
this.binaryRadioButton = new System.Windows.Forms.RadioButton(); this.binaryRadioButton = new System.Windows.Forms.RadioButton();
this.groupBox4 = new System.Windows.Forms.GroupBox(); this.groupBox4 = new System.Windows.Forms.GroupBox();
this.octalTextBox = new System.Windows.Forms.TextBox(); this.octalTextBox = new System.Windows.Forms.TextBox();
this.autoCompute = new System.Windows.Forms.CheckBox();
this.autoComputeToolTip = new System.Windows.Forms.ToolTip(this.components);
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.binaryGroupBox.SuspendLayout(); this.binaryGroupBox.SuspendLayout();
this.groupBox2.SuspendLayout(); this.groupBox2.SuspendLayout();
@ -71,7 +74,7 @@ namespace WindowsFormsApplication1
// //
// computeButton // computeButton
// //
this.computeButton.Location = new System.Drawing.Point(12, 319); this.computeButton.Location = new System.Drawing.Point(12, 329);
this.computeButton.Name = "computeButton"; this.computeButton.Name = "computeButton";
this.computeButton.Size = new System.Drawing.Size(91, 23); this.computeButton.Size = new System.Drawing.Size(91, 23);
this.computeButton.TabIndex = 5; this.computeButton.TabIndex = 5;
@ -81,7 +84,7 @@ namespace WindowsFormsApplication1
// //
// clearButton // clearButton
// //
this.clearButton.Location = new System.Drawing.Point(109, 319); this.clearButton.Location = new System.Drawing.Point(109, 329);
this.clearButton.Name = "clearButton"; this.clearButton.Name = "clearButton";
this.clearButton.Size = new System.Drawing.Size(85, 23); this.clearButton.Size = new System.Drawing.Size(85, 23);
this.clearButton.TabIndex = 6; this.clearButton.TabIndex = 6;
@ -92,7 +95,7 @@ namespace WindowsFormsApplication1
// groupBox1 // groupBox1
// //
this.groupBox1.Controls.Add(this.hexTextBox); this.groupBox1.Controls.Add(this.hexTextBox);
this.groupBox1.Location = new System.Drawing.Point(12, 72); this.groupBox1.Location = new System.Drawing.Point(10, 72);
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(279, 54); this.groupBox1.Size = new System.Drawing.Size(279, 54);
this.groupBox1.TabIndex = 1; this.groupBox1.TabIndex = 1;
@ -107,11 +110,12 @@ namespace WindowsFormsApplication1
this.hexTextBox.Size = new System.Drawing.Size(261, 20); this.hexTextBox.Size = new System.Drawing.Size(261, 20);
this.hexTextBox.TabIndex = 0; this.hexTextBox.TabIndex = 0;
this.hexTextBox.Text = "0"; this.hexTextBox.Text = "0";
this.hexTextBox.TextChanged += new System.EventHandler(this.hexTextBox_TextChanged);
// //
// binaryGroupBox // binaryGroupBox
// //
this.binaryGroupBox.Controls.Add(this.binaryTextBox); this.binaryGroupBox.Controls.Add(this.binaryTextBox);
this.binaryGroupBox.Location = new System.Drawing.Point(12, 12); this.binaryGroupBox.Location = new System.Drawing.Point(9, 12);
this.binaryGroupBox.Name = "binaryGroupBox"; this.binaryGroupBox.Name = "binaryGroupBox";
this.binaryGroupBox.Size = new System.Drawing.Size(279, 54); this.binaryGroupBox.Size = new System.Drawing.Size(279, 54);
this.binaryGroupBox.TabIndex = 0; this.binaryGroupBox.TabIndex = 0;
@ -126,11 +130,12 @@ namespace WindowsFormsApplication1
this.binaryTextBox.Size = new System.Drawing.Size(261, 20); this.binaryTextBox.Size = new System.Drawing.Size(261, 20);
this.binaryTextBox.TabIndex = 0; this.binaryTextBox.TabIndex = 0;
this.binaryTextBox.Text = "0"; this.binaryTextBox.Text = "0";
this.binaryTextBox.TextChanged += new System.EventHandler(this.binaryTextBox_TextChanged);
// //
// groupBox2 // groupBox2
// //
this.groupBox2.Controls.Add(this.decimalTextBox); this.groupBox2.Controls.Add(this.decimalTextBox);
this.groupBox2.Location = new System.Drawing.Point(12, 192); this.groupBox2.Location = new System.Drawing.Point(10, 192);
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(279, 54); this.groupBox2.Size = new System.Drawing.Size(279, 54);
this.groupBox2.TabIndex = 3; this.groupBox2.TabIndex = 3;
@ -145,10 +150,11 @@ namespace WindowsFormsApplication1
this.decimalTextBox.Size = new System.Drawing.Size(261, 20); this.decimalTextBox.Size = new System.Drawing.Size(261, 20);
this.decimalTextBox.TabIndex = 0; this.decimalTextBox.TabIndex = 0;
this.decimalTextBox.Text = "0"; this.decimalTextBox.Text = "0";
this.decimalTextBox.TextChanged += new System.EventHandler(this.decimalTextBox_TextChanged);
// //
// exitButton // exitButton
// //
this.exitButton.Location = new System.Drawing.Point(200, 319); this.exitButton.Location = new System.Drawing.Point(200, 329);
this.exitButton.Name = "exitButton"; this.exitButton.Name = "exitButton";
this.exitButton.Size = new System.Drawing.Size(91, 23); this.exitButton.Size = new System.Drawing.Size(91, 23);
this.exitButton.TabIndex = 7; this.exitButton.TabIndex = 7;
@ -220,7 +226,7 @@ namespace WindowsFormsApplication1
// groupBox4 // groupBox4
// //
this.groupBox4.Controls.Add(this.octalTextBox); this.groupBox4.Controls.Add(this.octalTextBox);
this.groupBox4.Location = new System.Drawing.Point(12, 132); this.groupBox4.Location = new System.Drawing.Point(9, 132);
this.groupBox4.Name = "groupBox4"; this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(279, 54); this.groupBox4.Size = new System.Drawing.Size(279, 54);
this.groupBox4.TabIndex = 2; this.groupBox4.TabIndex = 2;
@ -235,12 +241,29 @@ namespace WindowsFormsApplication1
this.octalTextBox.Size = new System.Drawing.Size(261, 20); this.octalTextBox.Size = new System.Drawing.Size(261, 20);
this.octalTextBox.TabIndex = 0; this.octalTextBox.TabIndex = 0;
this.octalTextBox.Text = "0"; this.octalTextBox.Text = "0";
this.octalTextBox.TextChanged += new System.EventHandler(this.octalTextBox_TextChanged);
//
// autoCompute
//
this.autoCompute.AutoSize = true;
this.autoCompute.Location = new System.Drawing.Point(16, 310);
this.autoCompute.Name = "autoCompute";
this.autoCompute.Size = new System.Drawing.Size(138, 17);
this.autoCompute.TabIndex = 8;
this.autoCompute.Text = "Automatically compute?";
this.autoCompute.UseVisualStyleBackColor = true;
//
// autoComputeToolTip
//
this.autoComputeToolTip.IsBalloon = true;
//this.autoComputeToolTip.Popup += new System.Windows.Forms.PopupEventHandler(this.autoComputeToolTip_Popup);
// //
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(300, 347); this.ClientSize = new System.Drawing.Size(300, 364);
this.Controls.Add(this.autoCompute);
this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox3);
this.Controls.Add(this.exitButton); this.Controls.Add(this.exitButton);
@ -262,6 +285,7 @@ namespace WindowsFormsApplication1
this.groupBox4.ResumeLayout(false); this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout(); this.groupBox4.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -283,6 +307,8 @@ namespace WindowsFormsApplication1
private System.Windows.Forms.RadioButton octalRadioButton; private System.Windows.Forms.RadioButton octalRadioButton;
private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox octalTextBox; private System.Windows.Forms.TextBox octalTextBox;
private System.Windows.Forms.CheckBox autoCompute;
private System.Windows.Forms.ToolTip autoComputeToolTip;
} }
} }

View File

@ -32,40 +32,12 @@ namespace WindowsFormsApplication1
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
ToolTip toolTip = new ToolTip();
toolTip.SetToolTip(autoCompute, "Automatically computes input based on changes made to textbox contents.");
} }
private void compute()
private void currentFocus(string focusOn) {
switch (focusOn)
{
case "binaryTextBox":
binaryTextBox.Focus();
break;
case "hexTextBox":
hexTextBox.Focus();
break;
case "octalTextBox":
octalTextBox.Focus();
break;
case "decimalTextBox":
decimalTextBox.Focus();
break;
default:
this.Focus();
break;
}
}
private void clearTextboxes()
{
hexTextBox.Text = "0";
binaryTextBox.Text = "0";
octalTextBox.Text = "0";
decimalTextBox.Text = "0";
}
private void computeButton_Click(object sender, EventArgs e)
{ {
// Define variables // Define variables
long decimalNum = 0, hexNum = 0, binNum = 0, octalNum = 0; long decimalNum = 0, hexNum = 0, binNum = 0, octalNum = 0;
@ -93,7 +65,8 @@ namespace WindowsFormsApplication1
//Refocus the textbox when done. //Refocus the textbox when done.
currentFocus("decimalTextBox"); currentFocus("decimalTextBox");
} }
if (octalRadioButton.Checked) { if (octalRadioButton.Checked)
{
// The octal radio button is pressed. // The octal radio button is pressed.
hexNum = octalNum; hexNum = octalNum;
binNum = octalNum; binNum = octalNum;
@ -125,9 +98,39 @@ namespace WindowsFormsApplication1
hexTextBox.Text = hexNum.ToString("X"); hexTextBox.Text = hexNum.ToString("X");
binaryTextBox.Text = Convert.ToString(binNum, 2); binaryTextBox.Text = Convert.ToString(binNum, 2);
octalTextBox.Text = Convert.ToString(octalNum, 8); octalTextBox.Text = Convert.ToString(octalNum, 8);
}
private void currentFocus(string focusOn) {
switch (focusOn)
{
case "binaryTextBox":
binaryTextBox.Focus();
break;
case "hexTextBox":
hexTextBox.Focus();
break;
case "octalTextBox":
octalTextBox.Focus();
break;
case "decimalTextBox":
decimalTextBox.Focus();
break;
default:
this.Focus();
break;
}
}
private void clearTextboxes()
{
hexTextBox.Text = "0";
binaryTextBox.Text = "0";
octalTextBox.Text = "0";
decimalTextBox.Text = "0";
}
private void computeButton_Click(object sender, EventArgs e)
{
compute();
} }
private void clearButton_Click(object sender, EventArgs e) private void clearButton_Click(object sender, EventArgs e)
@ -170,5 +173,29 @@ namespace WindowsFormsApplication1
{ {
currentFocus("octalTextBox"); currentFocus("octalTextBox");
} }
private void binaryTextBox_TextChanged(object sender, EventArgs e)
{
if (autoCompute.Checked)
compute();
}
private void hexTextBox_TextChanged(object sender, EventArgs e)
{
if (autoCompute.Checked)
compute();
}
private void octalTextBox_TextChanged(object sender, EventArgs e)
{
if (autoCompute.Checked)
compute();
}
private void decimalTextBox_TextChanged(object sender, EventArgs e)
{
if (autoCompute.Checked)
compute();
}
} }
} }

View File

@ -117,4 +117,7 @@
<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="autoComputeToolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>

View File

@ -11,7 +11,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>cEX9hsGiiCx0dr+SNR+Qk8kAYHI=</dsig:DigestValue> <dsig:DigestValue>yuucww+k7TDTPDj046KVMAquP4M=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>

View File

@ -52,14 +52,14 @@
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<dependency> <dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="BaseConverter.exe" size="12800"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="BaseConverter.exe" size="13824">
<assemblyIdentity name="BaseConverter" version="1.0.0.0" language="neutral" processorArchitecture="msil" /> <assemblyIdentity name="BaseConverter" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>dZXLG29YzjAwtfDgkFQyhpdG14U=</dsig:DigestValue> <dsig:DigestValue>AZ1RyIR6zUElaFiQPabdRc1KQGU=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>

View File

@ -11,7 +11,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>cEX9hsGiiCx0dr+SNR+Qk8kAYHI=</dsig:DigestValue> <dsig:DigestValue>yuucww+k7TDTPDj046KVMAquP4M=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>

View File

@ -11,7 +11,7 @@
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>cEX9hsGiiCx0dr+SNR+Qk8kAYHI=</dsig:DigestValue> <dsig:DigestValue>yuucww+k7TDTPDj046KVMAquP4M=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>

View File

@ -52,14 +52,14 @@
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
<dependency> <dependency>
<dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="BaseConverter.exe" size="12800"> <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="BaseConverter.exe" size="13824">
<assemblyIdentity name="BaseConverter" version="1.0.0.0" language="neutral" processorArchitecture="msil" /> <assemblyIdentity name="BaseConverter" version="1.0.0.0" language="neutral" processorArchitecture="msil" />
<hash> <hash>
<dsig:Transforms> <dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /> <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms> </dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<dsig:DigestValue>dZXLG29YzjAwtfDgkFQyhpdG14U=</dsig:DigestValue> <dsig:DigestValue>AZ1RyIR6zUElaFiQPabdRc1KQGU=</dsig:DigestValue>
</hash> </hash>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>