原始碼修改-Menu

來源:互聯網
上載者:User

using System;
using System.Collections.Generic;

namespace 原始碼修改
{
    public enum Command
    {
        R,
        W,
        C,
        H,
        Q,
        WrongCommand
    }

    static public class Menu
    {
        static private string introduce =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃       請將本程式置於原始碼根資料夾\n" +
            "┃       輸入對應命令字元進行操作:\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoAboutcommand =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃        R - 根據原始碼產生待翻譯文檔\n" +
            "┃        W - 根據已翻譯文檔修改原始碼\n" +
            "┃        C - 將原始碼編碼方式改為UTF-8\n" +
            "┃        H - 查看協助\n" +
            "┃        Q - 退出程式\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string errorAboutCommand =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃                   無效的命令!\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoToPacify =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃                     處理中...\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoCommandRExcutedSuccessfully =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃     成功:已在目前的目錄下產生ConstantString.txt!\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoCommandWExcutedSuccessfullyPartA =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃     成功:已根據ConstantString.txt完成了對原始碼的 " ;
        static private string infoCommandWExcutedSuccessfullyPartB =
            " 處修改\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoCommandCExcutedSuccessfullyPartA = 
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃     成功:已將 " ;
        static private string infoCommandCExcutedSuccessfullyPartB =
        " 個原始碼檔案編碼方式改為UTF-8\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoHasNotFoundDocument =
            "┏┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┓\n" +
            "┃        失敗:修改原始碼失敗!\n" +
            "┃        原因:未在本程式所在目錄找到:ConstantString.txt\n" +
            "┗┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┛";
        static private string infoWrongFormat =
            "┏┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┓\n" +
            "┃        失敗:修改原始碼失敗!\n" +
            "┃        原因:ConstantString.txt格式錯誤!\n" +
            "┗┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┛";
        static private string infoFoundAnExistentDocument =
            "┏┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┓\n" +
            "┃        失敗:產生ConstantString.txt失敗!\n" +
            "┃        原因:目前的目錄中已存在格式正確的ConstantString.txt!\n" +
            "┗┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┛";
        static private string infoExit = 
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃               按任意鍵退出程式...\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
        static private string infoHelp =
            "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n" +
            "┃               請查看協助文檔help.txt\n" +
            "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";

        static public void ShowIntroduce()
        {
            Console.WriteLine(introduce);
        }

        static public void ShowCommand()
        {
            Console.WriteLine(infoAboutcommand);
        }

        static public void ShowErrorAboutCommand()
        {
            Console.WriteLine("\n" + errorAboutCommand);
        }

        static public void ShowPacify()
        {
            Console.WriteLine("\n" + infoToPacify);
        }

        static public void ShowCommandRExcutedSuccessfully()
        {
            Console.WriteLine(infoCommandRExcutedSuccessfully);
        }

        static public void ShowCommandWExcutedSuccessfully(int amountOfChanges)
        {
            Console.WriteLine(infoCommandWExcutedSuccessfullyPartA + amountOfChanges + infoCommandWExcutedSuccessfullyPartB);
        }

        static public void ShowCommandCExcutedSuccessfully(int amountOfConverted)
        {
            Console.WriteLine(infoCommandCExcutedSuccessfullyPartA + amountOfConverted + infoCommandCExcutedSuccessfullyPartB);
        }

        static public void ShowHasNotFoundDocument()
        {
            Console.WriteLine(infoHasNotFoundDocument);
            Console.Write('\a');
        }

        static public void ShowErrorOnFormat()
        {
            Console.WriteLine(infoWrongFormat);
            Console.Write('\a');
        }

        static public void ShowFoundAnExistentDocument()
        {
            Console.WriteLine(infoFoundAnExistentDocument);
            Console.Write('\a');
        }

        static public void ShowExit()
        {
            Console.WriteLine(infoExit);
        }

        static public void WaitForExit()
        {
            Console.ReadKey();
        }

        static public void ShowHelp()
        {
            Console.WriteLine("\n" + infoHelp);
        }

        static public Command GetCommand()
        {
            char command = Console.ReadKey().KeyChar;
            command = char.ToUpper(command);

            if (command == char.Parse(Command.R.ToString()))
                return Command.R;
            else if (command == char.Parse(Command.W.ToString()))
                return Command.W;
            else if (command == char.Parse(Command.C.ToString()))
                return Command.C;
            else if (command == char.Parse(Command.H.ToString()))
                return Command.H;
            else if (command == char.Parse(Command.Q.ToString()))
                return Command.Q;
            else
                return Command.WrongCommand;
        }
    }
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.