Пример #1
0
 public static void Initialize()
 {
     files      = FileHandler.GetFiles();
     fileNumber = files.Count();
     TUI.Initialize(files, fileNumber);
     SelectFile();
 }
Пример #2
0
        private static void EncodeFile()
        {
            string result = Encoder.Encode(file);

            FileHandler.WriteFile(result, filePath);
            float compressionRatio = Encoder.CompressionRatio(file.Length, result.Length);

            TUI.DisplayProcess(file, result);
            TUI.DisplayCompressionRatio(compressionRatio);
            Initialize();
        }
Пример #3
0
 private static void DecodeFile()
 {
     if (Encoder.correctFormat(file))
     {
         string result = Encoder.Decode(file);
         FileHandler.WriteFile(result, filePath);
         TUI.DisplayProcess(file, result);
         Initialize();
     }
     else
     {
         TUI.WrongFileFormat();
         Initialize();
     }
 }
Пример #4
0
        private static void SelectProcess()
        {
            TUI.ProcessPrompt();
            ConsoleKey inputChar = Console.ReadKey().Key;

            if (inputChar.ToString().Equals("E"))
            {
                EncodeFile();
            }
            else if (inputChar.ToString().Equals("D"))
            {
                DecodeFile();
            }
            else
            {
                TUI.ProcessError();
                SelectProcess();
            }
        }
Пример #5
0
        private static void SelectFile()
        {
            char inputChar = Console.ReadKey().KeyChar;

            if (Char.IsDigit(inputChar))
            {
                int inputNumber = (int)Char.GetNumericValue(inputChar);
                if (0 < inputNumber && inputNumber <= fileNumber)
                {
                    LoadFile(inputNumber);
                }
                else
                {
                    TUI.NonNumber();
                    SelectFile();
                }
            }
            else
            {
                TUI.NonNumber();
                SelectFile();
            }
        }