private void PerformCommand(string strCommand) { Log(strCommand); var args = strCommand.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var parameters = args.Skip(1).ToArray(); if (args.Length != 0) { var firstArg = args[0].ToLower(); if (!Commands.Keys.Contains(firstArg)) { Log("Неверная команда!"); return; } var paramsAndCommand = Commands[firstArg]; int requiredParamsCount = paramsAndCommand.Key; if (requiredParamsCount != parameters.Length) { Log("Неверное число параметров!"); return; } var command = paramsAndCommand.Value; string[] results = command.Invoke(parameters); Log(results); outputTB.AppendText(WorkWithFS.WhereAmI(null)[0]); } }
private void Form1_Load(object sender, EventArgs e) { // открываю ФС thisFSPath = @"E:\ForFS\FS"; WorkWithFS.fs = new FS(thisFSPath); outputTB.Clear(); outputTB.AppendText(helloText + NewLine); outputTB.AppendText(WorkWithFS.WhereAmI(null)[0]); }
private void fsOpenMenuItem_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog() { CheckPathExists = true, InitialDirectory = @"E:\ForFS", Multiselect = false }; var dialogResult = dialog.ShowDialog(); if (dialogResult == DialogResult.OK) { //WorkWithFS.fsToWork?.stream?.Dispose(); thisFSPath = dialog.FileName; WorkWithFS.fs = new FS(dialog.FileName); outputTB.Clear(); outputTB.AppendText(helloText + NewLine); outputTB.AppendText(WorkWithFS.WhereAmI(null)[0]); } }