-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm3.cs.txt
More file actions
69 lines (63 loc) · 2.13 KB
/
Form3.cs.txt
File metadata and controls
69 lines (63 loc) · 2.13 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace Nintenlord.UPSpatcher
{
public partial class PatchReader
{
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Title = "Select a patch";
open.Filter = "UPS files|*.ups";
open.Multiselect = false;
open.ShowDialog();
if (open.FileNames.Length > 0)
{
textBox1.Text = open.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (!File.Exists(textBox1.Text))
{
MessageBox.Show("Patch doesn't exist.");
return;
}
UPSfile UPSFile = new UPSfile(textBox1.Text);
int[,] details = UPSFile.getData();
UPSFile = null;
List<string> lines = new List<string>(details.Length + 1);
lines.Add(textBox2.Lines[0]);
string offsets = "Offsets ";
string lenghts = "Lenghts";
lines.Add(offsets);
int longestOffsetLenght = offsets.Length;
for (int i = 0; i < details.Length / 2; i++)
{
string line = Convert.ToString(details[i, 0], 16);
if (line.Length + 1 > longestOffsetLenght)
longestOffsetLenght = line.Length + 1;
lines.Add(line);
}
for (int i = 1; i < lines.Count; i++)
lines[i] += "\t";
lines[1] += lenghts;
for (int i = 2; i < lines.Count; i++)
{
lines[i] += Convert.ToString(details[i - 2, 1], 16);
lines[i] = lines[i].ToUpper();
}
textBox2.Lines = lines.ToArray();
}
private void button3_Click(object sender, EventArgs e)
{
this.Close();
}
}
}