-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.cs
180 lines (167 loc) · 7.36 KB
/
Settings.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO.Compression;
namespace BDO_Item_Sorter
{
public partial class Settings : Form
{
public Settings()
{
InitializeComponent();
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
private void Settings_Load(object sender, EventArgs e)
{
Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\BDO Item Sorter Data");
string[] temp = File.ReadAllLines(Directory.GetCurrentDirectory() + "\\Position Settings.csv");
foreach (Screen screen in Screen.AllScreens)
{
if (screen.Primary == true)
screenDrop.Items.Add("Primary Screen");
else
screenDrop.Items.Add(screen.DeviceName);
}
int j = 0;
while (j < Screen.AllScreens.Length)
{
screenDrop.SelectedIndex = 0;
if (temp[6] == Screen.AllScreens[j].DeviceName)
{
screenDrop.SelectedIndex = j;
break;
}
j++;
}
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv"))
{
temp = reader.ReadLine().Split(',');
garmothText.Text = temp[1];
delayCounter.Value = Convert.ToDecimal(temp[2]) / 1000M;
}
iconsCheck.Checked = MainMenu.iconsMode;
}
private void screenButton_Click(object sender, EventArgs e)
{
MainMenu.lineEditor(Screen.AllScreens[screenDrop.SelectedIndex].DeviceName, Directory.GetCurrentDirectory() + "\\Position Settings.csv", 6);
}
private void doneButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void alignmentButton_Click(object sender, EventArgs e)
{
screenButton_Click(sender, e);
AlignmentSetter a = new AlignmentSetter();
a.ShowDialog();
}
private void Settings_FormClosing(object sender, FormClosingEventArgs e)
{
screenButton_Click(sender, e);
setIDButton_Click(sender, e);
setDelayButton_Click(sender, e);
}
private void setIDButton_Click(object sender, EventArgs e)
{
string[] temp = new string[5];
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv"))
{
temp = reader.ReadLine().Split(',');
}
MainMenu.lineEditor(temp[0] + ',' + garmothText.Text + ',' + temp[2] + ',' + temp[3], Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv", 0);
}
private void setDelayButton_Click(object sender, EventArgs e)
{
string[] temp = new string[5];
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv"))
{
temp = reader.ReadLine().Split(',');
}
MainMenu.lineEditor(temp[0] + ',' + temp[1] + ',' + Convert.ToString(Convert.ToInt32(delayCounter.Value * 1000M)) + ',' + temp[3], Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv", 0);
}
private void calibrateButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show("This is only needed if you changed your UI Scale.\nDo you wish to proceed?", "Digit Calibration", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
DigitCalibration dc = new DigitCalibration();
dc.ShowDialog();
GC.Collect();
}
}
private void helpButton_Click(object sender, EventArgs e)
{
ProcessStartInfo website = new ProcessStartInfo();
website.FileName = "https://youtu.be/WmSPHVduDfc";
Process.Start(website);
}
private void updateButton_Click(object sender, EventArgs e)
{
updateButton.Enabled = false;
using (WebClient client = new WebClient())
{
try
{
client.DownloadFile("https://github.com/ErisLoona/support-files/raw/main/BDO%20Sorting%20Mode.zip", Directory.GetCurrentDirectory() + "\\sorting.zip");
}
catch
{
MessageBox.Show("The download failed.\nPlease try again later.", "Download error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
using (ZipArchive archive = ZipFile.OpenRead(Directory.GetCurrentDirectory() + "\\sorting.zip"))
{
foreach(ZipArchiveEntry entry in archive.Entries)
{
if (entry.Name == "Grind Location Scripts.csv")
{
try
{
File.Delete(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv");
entry.ExtractToFile(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv");
}
catch
{
MessageBox.Show("The update was downloaded, but file extraction failed.\nYou can extract it yourself and replace the old one.", "Extraction error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
break;
}
}
}
File.Delete(Directory.GetCurrentDirectory() + "\\sorting.zip");
MessageBox.Show("Successfully updated to latest scripts!", "Update complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
updateButton.Enabled = true;
}
private void iconsCheck_Click(object sender, EventArgs e)
{
string[] temp = new string[5];
if (iconsCheck.Checked == true)
MainMenu.iconsMode = true;
else
MainMenu.iconsMode = false;
using (StreamReader reader = new StreamReader(Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv"))
{
temp = reader.ReadLine().Split(',');
}
MainMenu.lineEditor(temp[0] + ',' + temp[1] + ',' + temp[2] + ',' + Convert.ToBoolean(iconsCheck.Checked), Directory.GetCurrentDirectory() + "\\Sorting Mode\\Grind Location Scripts.csv", 0);
}
private void donateButton_Click(object sender, EventArgs e)
{
ProcessStartInfo website = new ProcessStartInfo();
website.FileName = "https://ko-fi.com/erisloona";
Process.Start(website);
}
}
}