public void CallMethod(int numberMethod)
        {
            switch (numberMethod)
            {
            case 0:
            {
                Console.WriteLine($"\r\nReturn to the method selection menu? y/n");
                if (Validation.YesNo() == ConsoleKey.Y)
                {
                    Console.Clear();
                    MenuControl menuControl = new MenuControl();
                    menuControl.CallMenuSelectMethods();
                }
            }
            break;

            case 1:
            {
                Method1Control method1Control = new Method1Control();
                method1Control.Method1();
            }
                goto case 0;

            case 2:
            {
                Method2Control method2Control = new Method2Control();
                method2Control.Method2();
            };
                goto case 0;

            case 3:
            {
                Method3Control method3Control = new Method3Control();
                method3Control.Method3();
            };
                goto case 0;

            case 4:
            {
                Method4Control method4Control = new Method4Control();
                method4Control.Method4();
            };
                goto case 0;
            }
        }
        static void Main(string[] args)
        {
            MenuControl menuControl = new MenuControl();

            menuControl.CallMenuSelectMethods();
        }
Example #3
0
        /// <summary>
        /// Follow the specified path
        /// </summary>
        /// <param name="dirName">Directory path</param>
        /// <param name="root">Root path</param>
        /// <returns>true - stop method, false - continue method</returns>
        private bool NextDir(string dirName, string root)
        {
            try
            {
                if (dirName == "Root")
                {
                    Console.Write("Enter the path root directory: ");
                    dirName = Console.ReadLine();
                    root    = dirName;
                }
                else if (dirName == "Exit")
                {
                    return(true);
                }
                FileInfos = GetDirList(dirName);

                string dirNamePrev = string.Empty;

                //Get prev directory
                if (dirName.Substring(dirName.Length - 1) == "\\")
                {
                    dirNamePrev = dirName.Remove(dirName.Length - 1);
                    dirNamePrev = dirNamePrev.Substring(0, dirNamePrev.LastIndexOf('\\') + 1);
                }
                else
                {
                    dirNamePrev = dirName.Substring(0, dirName.LastIndexOf('\\') + 1);
                }

                int maxId = FileInfos.Max(x => x.Id) + 1;
                if (!string.IsNullOrEmpty(dirNamePrev))
                {
                    FileInfos.Add(new FileInform()
                    {
                        Id = maxId++, Name = dirNamePrev, PrevPath = "Return to previous directory", TypeFile = "Settings"
                    });
                }
                if (!string.IsNullOrEmpty(root))
                {
                    FileInfos.Add(new FileInform()
                    {
                        Id = maxId++, Name = root, PrevPath = "Return to root directory", TypeFile = "Settings"
                    });
                }
                FileInfos.Add(new FileInform()
                {
                    Id = maxId++, Name = "Root", PrevPath = "Change root directory", TypeFile = "Settings"
                });
                FileInfos.Add(new FileInform()
                {
                    Id = maxId++, Name = "Exit", PrevPath = "Exit to the method selection menu", TypeFile = "Settings"
                });

                Console.WriteLine("\r\n-----------------------------------------");
                Console.WriteLine("Navigation:");
                Console.WriteLine("-----------------------------------------");
                foreach (var dirInf in FileInfos.Where(x => x.TypeFile == "Settings"))
                {
                    Console.WriteLine($"id:{dirInf.Id} | {dirInf.PrevPath}");
                    Console.WriteLine("-----------------------------------------");
                }

                Console.WriteLine("\r\nCurrent directory: " + dirName);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception: {ex} \r\n");
                MenuControl menuControl = new MenuControl();
                menuControl.CallMenuSelectMethods();
            }
            return(false);
        }