-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
125 lines (110 loc) · 3.67 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
namespace ApeirophobiaCodeCracker
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static string? result;
#region MY_FUNCTIONS
private void CheckForInvalidInput(KeyPressEventArgs e)
{
if (e.Handled = !char.IsDigit(e.KeyChar) && e.KeyChar != (char)Keys.Back)
{
wrongInputErrorProvider.SetError(errorLabel, "Invalid input received.");
errorLabel.Text = "Only input numeric values!";
}
else
{
wrongInputErrorProvider.SetError(errorLabel, "");
errorLabel.Text = "";
}
}
private void CalculateResult()
{
//store textbox inputs as strings (duh)
string red = redTextBox.Text;
string green = greenTextBox.Text;
string blue = blueTextBox.Text;
string grey = greyTextBox.Text;
string yellow = yellowTextBox.Text;
string purple = purpleTextBox.Text;
string orange = orangeTextBox.Text;
#region COLOR_PRIORITIES
/* COLOR TYPE PRIORITIES
*
* RED - 1
* GREEN - 2
* BLUE - 3
* GREY - 4
* YELLOW - 5
* PURPLE - 6
* ORANGE - 7
*/
#endregion
//actual logic (calculate result)
CalculationLogic.RedPhase(red);
CalculationLogic.GreenPhase(green);
CalculationLogic.BluePhase(blue);
CalculationLogic.GreyPhase(grey);
CalculationLogic.YellowPhase(yellow);
CalculationLogic.PurplePhase(purple);
CalculationLogic.OrangePhase(orange);
CalculationLogic.FinishResultCalculation();
if(result != "")
{
codeIntroLabel.Text = "Code:";
resultCodeLabel.Text = result;
copyButton.Visible = true;
}
else
{
errorLabel.Text = "At least one text box must contain a number that isn't 0.";
}
}
#endregion
#region VISUAL_STUDIO_FUNCTIONS
#region CHECK_FOR_NON_NUMERIC_INPUTS
private void redTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void greenTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void blueTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void greyTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void yellowTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void purpleTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
private void orangeTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
CheckForInvalidInput(e);
}
#endregion
private void calculateButton_Click(object sender, EventArgs e)
{
CalculateResult();
//errorLabel.Text = "button clicked!"; //debug test
//resultCodeLabel.Text = "(Code will appear here)"; //also a debug test
}
private void copyButton_Click(object sender, EventArgs e)
{
Clipboard.SetText(result);
}
#endregion
}
}