private void Button1_Click(object sender, EventArgs e) { if (Enum.TryParse(TextBoxCommandName.Text, out ToolFunctionCommand cmd)) { if (cmd != ToolFunctionCommand.Nothing) { ToolFunction.Invoke(cmd, TextBoxFilePath.Text); } } else { MessageBox.Show("Sorry. That command was not found. Please Select Another One"); } }
static void Main(string[] args) { // the first non self non '/' command // beocmes this. string TargetFileObject; ArgumentExpander.BuildEnv(); TargetFileObject = string.Empty; for (int step = 0; step < args.Length; step++) { { switch (args[step].ToLower().Replace('-', '/')) { case "/safemode": case "/safe": case "/readonly": case "/s": ToolFunction.SafeMode = true; break; case "/ovewrite": case "/o": case "/write": case "/allowwrite": ToolFunction.SafeMode = false; break; case "/exploreresults": case "/showresults": case "/results": ToolFunction.ShowResults = true; break; case "/target": case "/t": if (step + 1 >= args.Length) { Console.WriteLine("Error: Encounted end of argument list looking for /target [File System Item]"); break; } else { step++; TargetFileObject = args[step]; } break; case "/usage": case "/help": case "/?": Usage(); break; case "/showenv": ArgumentExpander.ShowEnv(); break; case "/install": break; case "/uninstall": break; case "/extract": case "/expand": if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.UnZipContents, TargetFileObject); break; case "/zip": case "/compress": if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.ZipContents, TargetFileObject); break; case "/extras": { ToolFunction.Invoke(ToolFunctionCommand.ExtrasMenu, TargetFileObject); break; } case "/filename": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.SetClipboardFileName, TargetFileObject); break; } case "/filepath": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.SetClipboardFilePath, TargetFileObject); break; } case "/cfilename": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.SetClipboardCompleteLocation, TargetFileObject); break; } case "/quotedfilename": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.SetClipboardQuotedCodeCompletePath, TargetFileObject); break; } case "/codefriendlyfilename": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.SetClipboardQuotedCodeCompletePath, TargetFileObject); break; } case "/findme": ToolFunction.Invoke(ToolFunctionCommand.FindMe, TargetFileObject); break; case "/explore": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.Explore, TargetFileObject); break; } case "/command.com": case "/cmd": case "/prompt": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.LaunchCmdWithSetCurrentDirectory, TargetFileObject); break; } case "/admincmd": case "/cmdadmin": { if (string.IsNullOrEmpty(TargetFileObject)) { Console.WriteLine(string.Format("{0} needs a target file system item. Fizzles....", args[step])); break; } ToolFunction.Invoke(ToolFunctionCommand.AdminLaunchCmdWithSetCurrentDirectory, TargetFileObject); break; } default: //MessageBox.Show(string.Format("Unknown Command {0}", args[step])); Console.WriteLine(string.Format("Unknown Command {0}", args[step])); break; } } } /* * Application.EnableVisualStyles(); * Application.SetCompatibleTextRenderingDefault(false); * Application.Run(new Form1());*/ Console.ReadKey(); }