@@ -111,7 +111,7 @@ private void ExportLog_Click(object sender, EventArgs e)
111
111
{
112
112
string logPath = "FileAES-" + DateTime . UtcNow . Subtract ( new DateTime ( 1970 , 1 , 1 ) ) . TotalSeconds . ToString ( ) + ".log" ;
113
113
114
- _overrideLogPath = Program . settingsManager . GetLogPath ( ) ;
114
+ _overrideLogPath = Program . programManager . GetLogPath ( ) ;
115
115
116
116
_overrideLogPath = _overrideLogPath . Replace ( '/' , '\\ ' ) . TrimStart ( '/' , '\\ ' ) ;
117
117
@@ -129,11 +129,11 @@ private void ExportLog_Click(object sender, EventArgs e)
129
129
try
130
130
{
131
131
File . WriteAllText ( logPath , consoleTextBox . Text ) ;
132
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] Log Exported! ({0})" , logPath ) ) ;
132
+ Logging . Log ( String . Format ( "Log Exported! ({0})" , logPath ) ) ;
133
133
}
134
134
catch
135
135
{
136
- AppendWithColour ( consoleTextBox , String . Format ( "[WARN] Log file could not be written to '{0}'!" , logPath ) ) ;
136
+ Logging . Log ( String . Format ( "Log file could not be written to '{0}'!" , logPath ) , Severity . WARN ) ;
137
137
}
138
138
}
139
139
@@ -156,31 +156,35 @@ private void CommandInput(RichTextBox textbox)
156
156
{
157
157
string [ ] input = textbox . Text . ToLower ( ) . Split ( ' ' ) ;
158
158
159
- uint csBufferTmp = 0 ;
160
159
if ( input [ 0 ] == "cryptostreambuffer" || input [ 0 ] == "csbuffer" || input [ 0 ] == "buffer" )
161
160
{
161
+ uint csBufferTmp = 0 ;
162
162
if ( input . Length > 1 && ! string . IsNullOrEmpty ( input [ 1 ] ) && uint . TryParse ( input [ 1 ] , out csBufferTmp ) )
163
163
{
164
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] CryptoStream Buffer set to {0} bytes" , csBufferTmp ) ) ;
164
+ Logging . Log ( String . Format ( "CryptoStream Buffer set to {0} bytes" , csBufferTmp ) ) ;
165
165
FileAES_Utilities . SetCryptoStreamBuffer ( csBufferTmp ) ;
166
166
}
167
- else AppendWithColour ( consoleTextBox , String . Format ( "[WARN] Too few arguments provided for the '{0}' command!" , textbox . Text ) ) ;
167
+ else TooFewArgsError ( textbox . Text ) ;
168
168
}
169
169
else if ( input [ 0 ] == "getcryptostreambuffer" || input [ 0 ] == "getcsbuffer" || input [ 0 ] == "getbuffer" )
170
170
{
171
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] CryptoStream Buffer is {0} bytes" , FileAES_Utilities . GetCryptoStreamBuffer ( ) ) ) ;
171
+ Logging . Log ( String . Format ( "CryptoStream Buffer is {0} bytes" , FileAES_Utilities . GetCryptoStreamBuffer ( ) ) ) ;
172
172
}
173
173
else if ( input [ 0 ] == "getfaestempfolder" || input [ 0 ] == "gettemp" || input [ 0 ] == "gettempfolder" )
174
174
{
175
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] FAES Temp Folder is: {0}" , FileAES_Utilities . GetFaesTempFolder ( ) ) ) ;
175
+ Logging . Log ( String . Format ( "FAES Temp Folder is: {0}" , FileAES_Utilities . GetFaesTempFolder ( ) ) ) ;
176
176
}
177
177
else if ( input [ 0 ] == "getfaesversion" || input [ 0 ] == "getfaesver" || input [ 0 ] == "faesver" )
178
178
{
179
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] FAES Version: {0}" , FileAES_Utilities . GetVersion ( ) ) ) ;
179
+ Logging . Log ( String . Format ( "FAES Version: {0}" , FileAES_Utilities . GetVersion ( ) ) ) ;
180
180
}
181
- else if ( input [ 0 ] == "getfaesuiversion" || input [ 0 ] == "getfaesuiver" || input [ 0 ] == "ver" )
181
+ else if ( input [ 0 ] == "getfaesuiversion" || input [ 0 ] == "getfaesguiversion" || input [ 0 ] == " getfaesuiver" || input [ 0 ] == "getfaesguiver" || input [ 0 ] == " ver" || input [ 0 ] == "guiver" || input [ 0 ] == "faesguiver ")
182
182
{
183
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] FAES_GUI Version: {0}" , Program . GetVersion ( ) ) ) ;
183
+ Logging . Log ( String . Format ( "FAES_GUI Version: {0}" , Program . GetVersion ( ) ) ) ;
184
+ }
185
+ else if ( input [ 0 ] == "getssmversion" || input [ 0 ] == "getssmver" || input [ 0 ] == "ssmver" )
186
+ {
187
+ Logging . Log ( String . Format ( "SSM Version: {0}" , SimpleSettingsManager . SSM . GetVersion ( ) ) ) ;
184
188
}
185
189
else if ( input [ 0 ] == "exportlog" || input [ 0 ] == "export" || input [ 0 ] == "log" )
186
190
{
@@ -191,69 +195,62 @@ private void CommandInput(RichTextBox textbox)
191
195
if ( input . Length > 1 && ! string . IsNullOrEmpty ( input [ 1 ] ) )
192
196
{
193
197
_overrideLogPath = input [ 1 ] . Replace ( "\" " , string . Empty ) . Replace ( "\' " , string . Empty ) ;
194
- Program . settingsManager . SetLogPath ( _overrideLogPath ) ;
198
+ Program . programManager . SetLogPath ( _overrideLogPath ) ;
195
199
196
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] Log path changed to: {0}" , _overrideLogPath ) ) ;
200
+ Logging . Log ( String . Format ( "Log path changed to: {0}" , _overrideLogPath ) ) ;
197
201
}
198
- else AppendWithColour ( consoleTextBox , String . Format ( "[WARN] Too few arguments provided for the '{0}' command!" , textbox . Text ) ) ;
202
+ else TooFewArgsError ( textbox . Text ) ;
199
203
}
200
204
else if ( input [ 0 ] == "getlogpath" || input [ 0 ] == "logpath" )
201
205
{
202
- _overrideLogPath = Program . settingsManager . GetLogPath ( ) ;
203
-
204
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] Log path set to: {0}" , _overrideLogPath ) ) ;
206
+ _overrideLogPath = Program . programManager . GetLogPath ( ) ;
207
+ Logging . Log ( String . Format ( "Log path set to: {0}" , _overrideLogPath ) ) ;
205
208
}
206
209
else if ( input [ 0 ] == "resetlogpath" )
207
210
{
208
- Program . settingsManager . ResetLogPath ( ) ;
209
- AppendWithColour ( consoleTextBox , String . Format ( "[INFO] Log path reset!" ) ) ;
211
+ Program . programManager . ResetLogPath ( ) ;
212
+ Logging . Log ( "Log path reset!" ) ;
213
+ }
214
+ else if ( input [ 0 ] == "setdevmode" || input [ 0 ] == "setdevelopermode" || input [ 0 ] == "setdebugmode" || input [ 0 ] == "setdebug" || input [ 0 ] == "setdev" || input [ 0 ] == "setdeveloper" )
215
+ {
216
+ if ( input . Length > 1 && ! string . IsNullOrEmpty ( input [ 1 ] ) )
217
+ {
218
+ bool dev = false ;
219
+ if ( input [ 1 ] == "1" || input [ 1 ] == "true" || input [ 1 ] == "t" || input [ 1 ] == "y" || input [ 1 ] == "yes" ) dev = true ;
220
+
221
+ Program . programManager . SetDevMode ( dev ) ;
222
+
223
+ Logging . Log ( String . Format ( "Developer Mode {0}! (Setting will be applied next launch)" , dev ? "Enabled" : "Disabled" ) ) ;
224
+ }
225
+ else TooFewArgsError ( textbox . Text ) ;
226
+ }
227
+ else if ( input [ 0 ] == "getdevmode" || input [ 0 ] == "getdevelopermode" || input [ 0 ] == "getdebugmode" || input [ 0 ] == "getdebug" || input [ 0 ] == "getdev" || input [ 0 ] == "getdeveloper" || input [ 0 ] == "developer" || input [ 0 ] == "dev" || input [ 0 ] == "debug" )
228
+ {
229
+ Logging . Log ( String . Format ( "Developer Mode is {0}!" , Program . programManager . GetDevMode ( ) ? "Enabled" : "Disabled" ) ) ;
230
+ }
231
+ else if ( input [ 0 ] == "resetdevmode" || input [ 0 ] == "resetdevelopermode" || input [ 0 ] == "resetdebugmode" || input [ 0 ] == "resetdebug" || input [ 0 ] == "resetdev" || input [ 0 ] == "resetdeveloper" )
232
+ {
233
+ Program . programManager . ResetDevMode ( ) ;
234
+ Logging . Log ( "Developer Mode reset!" ) ;
210
235
}
211
236
else if ( input [ 0 ] == "clear" || input [ 0 ] == "cls" )
212
237
{
213
238
clearConsole . PerformClick ( ) ;
214
239
}
215
- else AppendWithColour ( consoleTextBox , String . Format ( "[WARN] Unknown command: {0}" , textbox . Text ) ) ;
240
+ else Logging . Log ( String . Format ( "Unknown command: {0}" , textbox . Text ) , Severity . WARN ) ;
216
241
217
242
textbox . Clear ( ) ;
218
243
}
219
244
220
- private void ConsoleInputTextBox_TextChanged ( object sender , EventArgs e )
245
+ private void TooFewArgsError ( string command )
221
246
{
222
- if ( string . IsNullOrWhiteSpace ( consoleInputTextBox . Text ) )
223
- sendInputButton . Enabled = false ;
224
- else
225
- sendInputButton . Enabled = true ;
247
+ Logging . Log ( String . Format ( "Too few arguments provided for the '{0}' command!" , command ) , Severity . WARN ) ;
226
248
}
227
249
228
- private void AppendWithColour ( RichTextBox textbox , string text )
229
- {
230
- textbox . SelectionColor = Color . LightGray ;
231
- textbox . AppendText ( text . ToString ( ) ) ;
232
- textbox . AppendText ( Environment . NewLine ) ;
233
-
234
- CheckKeyword ( textbox , "[DEBUG]" , Color . Violet ) ;
235
- CheckKeyword ( textbox , "[INFO]" , Color . LightBlue ) ;
236
- CheckKeyword ( textbox , "[WARN]" , Color . Yellow ) ;
237
- CheckKeyword ( textbox , "[ERROR]" , Color . Red ) ;
238
-
239
- textbox . SelectionStart = textbox . TextLength ;
240
- textbox . SelectionLength = 0 ;
241
- textbox . ScrollToCaret ( ) ;
242
- }
243
-
244
- private void CheckKeyword ( RichTextBox textbox , string find , Color color )
250
+ private void ConsoleInputTextBox_TextChanged ( object sender , EventArgs e )
245
251
{
246
- if ( textbox . Text . Contains ( find ) )
247
- {
248
- var matchString = Regex . Escape ( find ) ;
249
- foreach ( Match match in Regex . Matches ( textbox . Text , matchString ) )
250
- {
251
- textbox . Select ( match . Index , find . Length ) ;
252
- textbox . SelectionColor = color ;
253
- textbox . Select ( textbox . TextLength , 0 ) ;
254
- textbox . SelectionColor = Color . LightGray ;
255
- } ;
256
- }
252
+ if ( string . IsNullOrWhiteSpace ( consoleInputTextBox . Text ) ) sendInputButton . Enabled = false ;
253
+ else sendInputButton . Enabled = true ;
257
254
}
258
255
}
259
256
}
0 commit comments