2020-05-21 09:05:32 +00:00
|
|
|
using System;
|
|
|
|
using treasurechest.STDIOWrapper;
|
|
|
|
using treasurechest;
|
|
|
|
|
|
|
|
namespace treasurechestCLI
|
|
|
|
{
|
|
|
|
|
2020-05-23 09:51:17 +00:00
|
|
|
internal class EncryptMenu{
|
2020-05-21 09:05:32 +00:00
|
|
|
|
2020-05-23 09:51:17 +00:00
|
|
|
public static void enterMenu(translations.Strings strings) {
|
2020-05-21 09:05:32 +00:00
|
|
|
int choice = 0;
|
2020-05-23 09:51:17 +00:00
|
|
|
int counter = 1;
|
|
|
|
string[] encryptMenuOptions =
|
|
|
|
{
|
|
|
|
strings.ENCRYPT_MENU_ENCRYPT_MESSAGE,
|
|
|
|
strings.ENCRYPT_MENU_ENCRYPT_FILE,
|
|
|
|
strings.RETURN_TO_PREVIOUS_MENU,
|
|
|
|
strings.EXIT
|
|
|
|
};
|
|
|
|
|
|
|
|
while (true){
|
|
|
|
foreach (string option in encryptMenuOptions){
|
2020-05-21 09:05:32 +00:00
|
|
|
STDIO.O(counter.ToString() + ". " + option);
|
|
|
|
counter += 1;
|
|
|
|
}
|
|
|
|
try{
|
|
|
|
choice = Int32.Parse(System.Console.ReadLine());
|
|
|
|
}
|
|
|
|
catch (System.OverflowException){
|
|
|
|
// User being silly with input
|
|
|
|
STDIO.O(strings.MAIN_MENU_SELECT_INTEGER);
|
|
|
|
counter = 1;
|
|
|
|
}
|
|
|
|
catch(System.FormatException){
|
|
|
|
// Too lazy to check strings, force them to use int from menu which is faster anyway
|
|
|
|
STDIO.O(strings.MAIN_MENU_SELECT_INTEGER);
|
|
|
|
counter = 1;
|
|
|
|
}
|
|
|
|
catch(System.ArgumentNullException){
|
|
|
|
// Can happen when stream closes (e.g. ctrl-d)
|
|
|
|
// since menu is intended to be directly human interfaced, user probably wants to exit
|
2020-05-23 09:51:17 +00:00
|
|
|
choice = encryptMenuOptions.Length;
|
|
|
|
}
|
|
|
|
if (choice == 1){
|
|
|
|
EncryptMessageInterface.EncryptMessage();
|
2020-05-21 09:05:32 +00:00
|
|
|
}
|
2020-05-23 09:51:17 +00:00
|
|
|
else if (choice == encryptMenuOptions.Length - 1){
|
|
|
|
return;
|
2020-05-21 09:05:32 +00:00
|
|
|
}
|
2020-05-23 09:51:17 +00:00
|
|
|
else if (choice == encryptMenuOptions.Length){
|
|
|
|
System.Environment.Exit(0);
|
2020-05-21 09:05:32 +00:00
|
|
|
}
|
|
|
|
counter = 1;
|
|
|
|
}
|
2020-05-23 09:51:17 +00:00
|
|
|
|
2020-05-21 09:05:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-05-23 09:51:17 +00:00
|
|
|
|
2020-05-21 09:05:32 +00:00
|
|
|
}
|