-
Notifications
You must be signed in to change notification settings - Fork 0
/
Helper.cs
104 lines (85 loc) · 2.63 KB
/
Helper.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AHK_Visual_2._0
{
class Helper
{
public static void CheckBoxChecker(CheckBox cb, TextBox tb, char character)
{
if (cb.Checked)
{
tb.AppendText(character.ToString());
}
else
{
int startIndex = tb.Text.IndexOf(character);
tb.Text = tb.Text.Remove(startIndex, 1);
}
}
public static void Indent(TextBox tb, int activeLoops, bool indent)
{
if(indent)
{
for (int i = 0; i < activeLoops; i++)
{
tb.AppendText(" ");
}
}
}
public static void DeleteIndent(TextBox tb, int charToDelete)
{
tb.Focus();
for (int i = 0; i < charToDelete; i++)
{
SendKeys.Send("{DELETE}");
}
}
public static String fileParse()
{
List<String> final = new List<String>();
String fs = String.Empty;
using (OpenFileDialog fd = new OpenFileDialog())
{
fd.InitialDirectory = Application.StartupPath;
fd.Filter = "ahk files (*.ahk)|*.ahk";
fd.FilterIndex = 1;
fd.RestoreDirectory = true;
if (fd.ShowDialog() == DialogResult.OK)
{
fs = fd.FileName;
}
}
return fs;
}
public static void WriteToBox(CheckBox insertCheck, CheckBox newLineCheck, CheckBox sendCheck, String toPut, TextBox textBox, int position)
{
StringBuilder sb = new StringBuilder();
String newLine = String.Empty;
String send = String.Empty;
if (newLineCheck.Checked)
{
newLine = "\r\n";
}
if (sendCheck.Checked)
{
send = "Send, ";
}
sb.Append(send);
sb.Append(toPut);
sb.Append(newLine);
if (insertCheck.Checked)
{
textBox.Text = textBox.Text.Insert(position, sb.ToString());
}
else
{
textBox.AppendText(sb.ToString());
}
}
}
}