This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOtherUtils.cs
135 lines (122 loc) · 3.9 KB
/
OtherUtils.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
using System;
using System.IO;
using System.Net.Http;
namespace RobloxTweaker
{
internal class OtherUtils
{
//Copy Folder
public static void CopyFolder(string sourceFolder, string destFolder)
{
if (!Directory.Exists(destFolder))
{
Directory.CreateDirectory(destFolder);
}
string[] files = Directory.GetFiles(sourceFolder);
foreach (string file in files)
{
string name = Path.GetFileName(file);
string dest = Path.Combine(destFolder, name);
File.Copy(file, dest);
}
string[] folders = Directory.GetDirectories(sourceFolder);
foreach (string folder in folders)
{
string name = Path.GetFileName(folder);
string dest = Path.Combine(destFolder, name);
CopyFolder(folder, dest);
}
}
//Continue
public static void Continue(bool clear = false)
{
Console.Write("\n[Press Any key to continue]");
Console.ReadKey();
if (clear)
{
Console.Clear();
}
}
//Clear Previuos Line
public static void ClearPreviousLine()
{
Console.SetCursorPosition(0, Console.CursorTop - 1);
Console.Write(new string(' ', Console.WindowWidth));
Console.SetCursorPosition(0, Console.CursorTop - 1);
}
//Menu
public static int Menu(string title, string[] options, string[] extras, int inputType = 0, int optionZero = -1, string optionsZeroExtra = "")
{
int choice;
int minChoiceNumber = 1;
if (optionZero >= 0)
{
minChoiceNumber = 0;
}
do
{
choice = GenerateMenu(title, options, extras, inputType, optionZero, optionsZeroExtra);
Console.Clear();
} while (choice < minChoiceNumber || choice > options.Length);
return choice;
}
//Generate Menu
public static int GenerateMenu(string title, string[] options, string[] extras, int inputType = 0, int optionZero = -1, string optionsZeroExtra = "")
{
int menu = -1;
Console.Clear();
Console.WriteLine(title);
for (int i = 0; i < options.Length; i++)
{
if (options.Length == 0)
{
break;
}
Console.WriteLine("[{0}] {1}", i + 1, options[i]);
}
if (optionZero > -1)
{
string[] ZeroText = { "Exit", "Cancel", "Go Back" };
Console.WriteLine("[0] {0} {1}", ZeroText[optionZero], optionsZeroExtra);
}
for (int i = 0; i < extras.Length; i++)
{
if (extras.Length == 0)
{
break;
}
Console.WriteLine("{0}", extras[i]);
}
if (inputType == 0)
{
menu = MenuInput();
}
else
{
Continue(true);
}
return menu;
}
//Menu Input
public static int MenuInput()
{
int menu;
Console.Write(">");
try
{
menu = Convert.ToInt16(Console.ReadLine());
} catch (Exception)
{
menu = -1;
}
return menu;
}
//Request
public static HttpResponseMessage RequestURL(string URL)
{
var HTTPClient = new HttpClient();
HTTPClient.DefaultRequestHeaders.Add("User-Agent", "request");
return HTTPClient.GetAsync(URL).Result;
}
}
}