-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
139 lines (123 loc) · 4.02 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System.Runtime.InteropServices;
namespace ElvUIExtraction;
public partial class Form1 : Form
{
// Set window as always on top
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
static readonly IntPtr HWND_TOP = new IntPtr(0);
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
public Form1()
{
InitializeComponent();
}
//store folder location
private string _MainFolder = string.Empty;
// Form load method
private void WoW_Prompt(object sender, EventArgs e)
{
SetWindowPos(this.Handle, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
};
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
_MainFolder = folderBrowserDialog.SelectedPath;
}
}
// OpenFileDialog for Zip File
private void ElvUI_OFD(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Title = "Select ElvUI Zip File",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
Filter = "zip files (*.zip)|*.zip",
};
if (ofd.ShowDialog() == DialogResult.OK)
{
ElvUIPath.Text = ofd.FileName;
}
}
// OpenFileDialog for _classic_
private void _classic_Btn_Click(object sender, EventArgs e)
{
FolderBrowserDialog ofd = new FolderBrowserDialog
{
InitialDirectory = _MainFolder
};
if (ofd.ShowDialog(this) == DialogResult.OK)
{
_classic_Path.Text = ofd.SelectedPath;
}
}
// OpenFileDialog for _classic_era_
private void _classic_era_Btn_Click(object sender, EventArgs e)
{
FolderBrowserDialog ofd = new FolderBrowserDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
};
if (ofd.ShowDialog(this) == DialogResult.OK)
{
_classic_era_Path.Text = ofd.SelectedPath;
}
}
// OpenFileDialog for _retail_
private void _retail_Btn_Click(object sender, EventArgs e)
{
FolderBrowserDialog ofd = new FolderBrowserDialog
{
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal),
};
if (ofd.ShowDialog(this) == DialogResult.OK)
{
_retail_Path.Text = ofd.SelectedPath;
}
}
//Extract using System.IO
private void ExtractBtn_Click(object sender, EventArgs e)
{
var zipPath = ElvUIPath.Text;
var extractClassic = _classic_Path.Text;
var extractClassicEra = _classic_era_Path.Text;
var extractRetail = _retail_Path.Text;
if (_classic_Path.Text.Length == 0)
{
// Do Nothing
}
else
{
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractClassic, true);
}
if (_classic_era_Path.Text.Length == 0)
{
// Do Nothing
}
else
{
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractClassicEra, true);
}
if (_retail_Path.Text.Length == 0)
{
// Do Nothing
}
else
{
System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractRetail, true);
}
//Error Handling
if (ElvUIPath.Text.Length == 0)
{
MessageBox.Show("Please Provide ElvUI Zip File");
return;
}
}
}