-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
164 lines (133 loc) · 5.12 KB
/
Copy pathProgram.cs
File metadata and controls
164 lines (133 loc) · 5.12 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
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
using ProxyScanner.Catalogs;
using ProxyScanner.Interfaces;
using ProxyScanner.Other;
using System.Diagnostics;
using System.Net;
using System.Text;
using System.Xml.Linq;
using TextCopy;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;
using static ProxyScanner.Program;
namespace ProxyScanner
{
internal class Program : TextHandler
{
public static int current_postition = 0;
public delegate void CurrentFrame();
public static bool isReadKeyWait = true;
private static IMenu? current_menu { get; set; }
private static CurrentFrame? current_frame { get; set; }
private static Dictionary<string, IMenu> types_menu = new Dictionary<string, IMenu>();
public static ConfigManager? config { get; private set; }
public static Clipboard? clipboard { get; private set; }
const string version = "0.0.2";
static async Task Main(string[] args)
{
Init();
clipboard = new Clipboard();
config = new ConfigManager("config.dat");
Common common = new Common();
types_menu.Add(common.GetType().Name, common);
current_menu = common;
current_frame = common.Menu;
while (true)
{
current_frame?.Invoke();
if (isReadKeyWait)
{
ConsoleKeyInfo key = Console.ReadKey();
switch (key.Key)
{
case ConsoleKey.DownArrow:
{
if (current_postition < current_menu.catalogs.Count - 1)
{
current_postition++;
}
break;
}
case ConsoleKey.UpArrow:
{
if (current_postition > 0)
{
current_postition--;
}
break;
}
case ConsoleKey.LeftArrow:
{
current_menu.HandlerKey(ConsoleKey.LeftArrow);
break;
}
case ConsoleKey.RightArrow:
{
current_menu.HandlerKey(ConsoleKey.RightArrow);
break;
}
case ConsoleKey.Escape:
{
current_menu.HandlerKey(ConsoleKey.Escape);
break;
}
case ConsoleKey.Enter:
{
HandlerMenu(current_menu.catalogs.Values.ToArray()[current_postition]);
break;
}
}
await Task.Delay(50);
}
else
{
await Task.Delay(1000);
}
Console.Clear();
}
}
static void HandlerMenu(Controller type)
{
if (type.gui != null)
{
if (!types_menu.ContainsKey(type.gui.Name))
{
IMenu? menu = Activator.CreateInstance(type.gui) as IMenu;
types_menu.Add(type.gui.Name, menu!);
current_menu = menu!;
current_frame = menu!.Menu;
}
else
{
if (types_menu.TryGetValue(type.gui.Name, out IMenu? menu))
{
current_menu = menu!;
current_frame = menu!.Menu;
}
else
{
Console.WriteLine("Странная ошибка!");
}
}
current_postition = 0;
}
if (type.isCommand)
{
type.Command.Invoke();
}
}
static void Init()
{
Console.Title = "ProxyScanner";
HWND hWnd = new HWND(Process.GetCurrentProcess().MainWindowHandle);
int style = PInvoke.GetWindowLong(hWnd, Windows.Win32.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX.GWL_STYLE);
style &= ~(int)WINDOW_STYLE.WS_SIZEBOX;
style &= ~(int)WINDOW_STYLE.WS_MAXIMIZEBOX;
PInvoke.SetWindowLong(hWnd, WINDOW_LONG_PTR_INDEX.GWL_STYLE, style);
Console.SetBufferSize(120, 30);
Console.CursorVisible = false;
Console.OutputEncoding = Encoding.UTF8;
PInvoke.MessageBox(HWND.Null, $"Version: {version}\nAuthor: KoderTech\nThank you for using the app.", "ProxyScanner", MESSAGEBOX_STYLE.MB_SERVICE_NOTIFICATION);
}
}
}