Esempio n. 1
0
        /// <summary>
        /// Update, then show the settings Menu.
        /// </summary>
        public static void SettingsMenu()
        {
            Debug.LogMethodStart();
            UpdateSettingsMenu();

            Settings.DisplayItems("Settings Menu", false);
            int choice = Settings.ItemSelect();

            switch (choice)
            {
            case 0:     // Choice was change folder
                Environment.CurrentDirectory = UserInput.GetFolderFromUser();
                break;

            case 1:     // Choice was change log file
                Debug.LogPath       = UserInput.GetFilePathFromUser("log", new string[] { ".log" }, false);
                Utility.isLoggingOn = true;
                break;

            case 2:     // Choice was change enigma machine
                EnigmaSelectionMenu();
                break;

            case 3:     // Choice was change input
                string input = UserInput.GetFilePathFromUser("text input", new string[] { ".txt", ".html" }, true);
                if (input == null)
                {
                    input = "keyboard";
                }
                EnigmaMachine.Current.InputType = Validation.GetInputExtensionType(input);
                EnigmaMachine.Current.FileIn    = Path.ChangeExtension(input, null);
                break;

            case 4:     // Choice was change output
                EnigmaMachine.Current.FileOut = UserInput.GetFilePathFromUser("text output", new string[] { ".html" }, false);
                // assume that if user sets output that they don't want auto-generated output paths anymore
                shouldGenerateOutputPath = false;
                break;

            case 5:     // Choice was change cipher type
                EnigmaMachine.Current.IsDecrypting = !EnigmaMachine.Current.IsDecrypting;
                break;

            case 6:     // Choice was return to main menu
                MainMenu(false);
                break;

            // Final choice (7) is always exit program
            default:     // Choice was invalid (shouldn't be possible since Menu.ItemSelect includes validation)
                break;
            }

            // Generate a new output path for the current enigma machine, unless user has manually set output path
            if (shouldGenerateOutputPath)
            {
                EnigmaMachine.Current.FileOut = EnigmaMachine.GetOutputPath();
            }

            // Display settings menu again if choice was not main menu
            SettingsMenu();
        }