-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
125 lines (99 loc) · 3.8 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
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;
namespace FL2_to_FLS
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormIsClosing);
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.DocumentText = Properties.Resources.Intro;
}
private void button1_Click(object sender, EventArgs e)
{
MyGlobals.userTempFolder = Path.GetTempPath();
MyGlobals.extractTempFolder = MyGlobals.userTempFolder + @"fl2tofls";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
//Get FL2 file
MyGlobals.filePath = openFileDialog1.FileName;
string zExecPath = "7za.exe";
try
{
ProcessStartInfo pro = new ProcessStartInfo();
pro.WindowStyle = ProcessWindowStyle.Hidden;
pro.FileName = zExecPath;
pro.Arguments = string.Format("x \"{0}\" -y -o\"{1}\"", MyGlobals.filePath, MyGlobals.extractTempFolder);
Process x = Process.Start(pro);
x.WaitForExit();
}
catch (System.Exception Ex)
{
//handle error
MessageBox.Show("Oh no! Something went wrong!");
}
}
else
{
webBrowser1.DocumentText = Properties.Resources.Intro;
return;
}
string showReleaseNotesFolder = MyGlobals.extractTempFolder + @"\ContentDescriptions";
string[] getReleaseNotesHTML = Directory.GetFiles(showReleaseNotesFolder, "*.html");
webBrowser1.Navigate(getReleaseNotesHTML[0]);
string dataImageFolder = MyGlobals.extractTempFolder + @"\DataImages";
string[] getFLSFile = Directory.GetFiles(dataImageFolder);
string destFLSPathAndName = Path.GetDirectoryName(MyGlobals.filePath) + @"\" + Path.GetFileName(getFLSFile[0]);
try
{
File.Copy(getFLSFile[0], destFLSPathAndName, true);
}
catch (System.Exception Ex)
{
//handle error
MessageBox.Show("Oh no! Something went wrong!");
return;
}
MessageBox.Show("FLS file extracted successfully in folder" + Environment.NewLine + Path.GetDirectoryName(MyGlobals.filePath));
}
private void FormIsClosing(object sender, FormClosingEventArgs e)
{
if (Directory.Exists(MyGlobals.extractTempFolder))
{
Directory.Delete(MyGlobals.extractTempFolder, true);
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void aboutBtn_Click(object sender, EventArgs e)
{
var myAboutBox = new AboutBox1();
myAboutBox.Show();
}
private void donateBtn_Click(object sender, EventArgs e)
{
Process.Start("https://www.buymeacoffee.com/ADYsLjqfi");
}
}
public static class MyGlobals
{
public static string filePath;
public static string userTempFolder;
public static string extractTempFolder;
}
}