REEEEEEEE
This commit is contained in:
@@ -23,6 +23,7 @@ using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
@@ -37,25 +38,27 @@ namespace WindowsFormsApplication1
|
||||
toolTip.SetToolTip(autoCompute, "Automatically computes input based on changes made to textbox contents.");
|
||||
|
||||
}
|
||||
|
||||
private void compute()
|
||||
int paddingOffset = 0, spacingOffset = 0, i = 0;
|
||||
public void compute()
|
||||
{
|
||||
// Define variables
|
||||
long decimalNum = 0, hexNum = 0, binNum = 0, octalNum = 0;
|
||||
int paddingOffset = 0,spacingOffset = 0, i = 0;
|
||||
//int paddingOffset = 0,spacingOffset = 0, i = 0;
|
||||
|
||||
try
|
||||
{ // Extract data from text boxes.
|
||||
|
||||
decimalNum = long.Parse(decimalTextBox.Text);
|
||||
hexNum = Convert.ToInt64(hexTextBox.Text, 16);
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
|
||||
|
||||
binNum = Convert.ToInt64(binaryTextBox.Text, 2);
|
||||
|
||||
hexNum = Convert.ToInt64(hexTextBox.Text, 16);
|
||||
octalNum = Convert.ToInt64(octalTextBox.Text, 8);
|
||||
paddingOffset = int.Parse(paddingOffsetTextBox.Text);
|
||||
spacingOffset = int.Parse(spacingOffsetTextBox.Text);
|
||||
|
||||
}
|
||||
catch (Exception Ex)
|
||||
catch
|
||||
{
|
||||
clearTextboxes();
|
||||
MessageBox.Show("Invalid number entered into one of the textboxes!");
|
||||
@@ -120,9 +123,17 @@ namespace WindowsFormsApplication1
|
||||
{
|
||||
binaryTextBox.Text = Convert.ToString(binNum, 2);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (spacingToggle.Checked)
|
||||
|
||||
hexTextBox.Text = hexNum.ToString("X");
|
||||
octalTextBox.Text = Convert.ToString(octalNum, 8);
|
||||
decimalTextBox.Text = decimalNum.ToString();
|
||||
}
|
||||
public void spacing()
|
||||
{
|
||||
spacingOffset = int.Parse(spacingOffsetTextBox.Text);
|
||||
try
|
||||
{
|
||||
if (spacingToggle.Checked)
|
||||
{
|
||||
string binaryString = binaryTextBox.Text; // Define string to offset
|
||||
int binarySize = binaryString.Length; //count the length of the string.
|
||||
@@ -144,15 +155,14 @@ namespace WindowsFormsApplication1
|
||||
}
|
||||
}
|
||||
binaryTextBox.Text = builder.ToString();
|
||||
builder = null; // null out builder when done
|
||||
//builder = null; // null out builder when done
|
||||
//binaryTextBox.Text = binaryString;
|
||||
}
|
||||
} catch (Exception Ex) {
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Divide by zero");
|
||||
}
|
||||
hexTextBox.Text = hexNum.ToString("X");
|
||||
octalTextBox.Text = Convert.ToString(octalNum, 8);
|
||||
decimalTextBox.Text = decimalNum.ToString();
|
||||
}
|
||||
private void currentFocus(string focusOn)
|
||||
{
|
||||
@@ -185,8 +195,13 @@ namespace WindowsFormsApplication1
|
||||
}
|
||||
|
||||
private void computeButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
compute();
|
||||
{
|
||||
// Remove commas from decimalTextBox before parsing it
|
||||
decimalTextBox.Text = decimalTextBox.Text.Replace(",", "");
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
compute();
|
||||
spacing();
|
||||
}
|
||||
|
||||
private void clearButton_Click(object sender, EventArgs e)
|
||||
@@ -233,29 +248,62 @@ namespace WindowsFormsApplication1
|
||||
private void binaryTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//debugLabel.Text = sender.GetType().ToString();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
compute();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
{
|
||||
// Remove commas from decimalTextBox before parsing it
|
||||
//decimalTextBox.Text = decimalTextBox.Text.Replace(",", "");
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
compute();
|
||||
//spacing();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void hexTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//debugLabel.Text = sender.GetType().ToString();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
compute();
|
||||
}
|
||||
|
||||
private void octalTextBox_TextChanged(object sender, EventArgs e)
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
{
|
||||
// Remove commas from decimalTextBox before parsing it
|
||||
decimalTextBox.Text = decimalTextBox.Text.Replace(",", "");
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
|
||||
compute();
|
||||
spacing();
|
||||
}
|
||||
}
|
||||
private void octalTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//debugLabel.Text = sender.GetType().ToString();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
compute();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
{
|
||||
// Remove commas from decimalTextBox before parsing it
|
||||
decimalTextBox.Text = decimalTextBox.Text.Replace(",", "");
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
|
||||
compute();
|
||||
spacing();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void decimalTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
//debugLabel.Text = sender.GetType().ToString();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
compute();
|
||||
if (autoCompute.Checked & (sender.GetType().ToString().Equals("System.Windows.Forms.TextBox")))
|
||||
{
|
||||
// Remove commas from decimalTextBox before parsing it
|
||||
//decimalTextBox.Text = decimalTextBox.Text.Replace(",", "");
|
||||
// Remove spacing from binaryTextBox before parsing it
|
||||
binaryTextBox.Text = binaryTextBox.Text.Replace(" ", "");
|
||||
|
||||
compute();
|
||||
Thread.Sleep(250);
|
||||
spacing();
|
||||
}
|
||||
}
|
||||
|
||||
private void paddingToggle_CheckedChanged(object sender, EventArgs e)
|
||||
|
Reference in New Issue
Block a user