Example #1
0
 /// <summary>
 /// This is the trickiest one. It handles all non-switch arguments and must use the value of ParseState to
 /// decide what to do in each case. For example, in the default state it interprets an arg as a /file name.
 /// In each case it needs to know if the switch can take a list or a single parameter.
 /// Ex: '/output outfile' we need to flip back to Default state after a single arg
 /// Ex: '/file f1 f2 f3 ...' we flip back to Default state after a single arg because Default and File are handled the same
 /// Ex: '/filelist fl1 fl2 fl3 ...' we flip to WasInputFile to keep track that fl2, etc need to be treated as such, but to also be ready for other switches
 /// </summary>
 /// <param name="arg"></param>
 /// <returns></returns>
 private bool HandleArgument(string arg)
 {
     if (arg.StartsWith("/"))
     {
         return(false);
     }
     // depending on our state, we pick what to do with the argument.
     if (ParseState == ProcessorState.InputFile || ParseState == ProcessorState.WasInputFile)
     {
         ParseState = ProcessorState.WasInputFile;
         PathFiles.Add(arg);
     }
     else if (ParseState == ProcessorState.OutputFile)
     {
         // this case should be prevented by the logic in HandleOutFile, but it's a harmless check
         if (OutFile != null)
         {
             throw new ArgumentException(String.Format("Already specified output file: {0}."), OutFile);
         }
         OutFile    = arg;
         ParseState = ProcessorState.Default;
     }
     else if (ParseState == ProcessorState.Default || ParseState == ProcessorState.File)
     {
         ParseState = ProcessorState.Default;
         Paths.Add(arg);
     }
     return(true);
 }
Example #2
0
        private void OpenDirectory(object obj)
        {
            Load_indicator = 0;
            TextInFile     = "";
            PathSearchFiles.Clear();
            PathFiles.Clear();
            var files = DirectoryUsing.DirectoryOpen();

            try
            {
                if (files != null)
                {
                    foreach (string filename in files)
                    {
                        PathFiles.Add(new PathFile {
                            FileName = filename
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }