Ejemplo n.º 1
0
        [STAThread]        //required because we may be creating a GUI
        public static void Main(string[] args)
        {
            //initialize GDAL
            Gdal.AllRegister();
            //suppress warnings reported by GDAL (erroneously reports warnings because GDAL fails to create useless auxiliary files during processing)
            Gdal.SetErrorHandler(null);

            if (args.Length == 0)              //no arguments specified, so start GUI
            //hide console if we're using a GUI and the window belongs to this program (i.e. has an empty console)
            {
                if (Console.CursorLeft == 0 && Console.CursorTop == 0)
                {
                    IntPtr handle = GetConsoleWindow();
                    ShowWindow(handle, SW_HIDE);
                }

                //run GUI
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());

                return;         //exit after GUI closes
            }
            else                //arguments were specified, so run program as console command
                                //parse input arguments into a convenient form (ToLookup allows duplicate keys)
            {
                CommandArgField[] ops = CommandUtilities.parseArgs(args);
                Lookup <string, CommandArgField> lup = (Lookup <string, CommandArgField>)ops.ToLookup(p => p.argname);

                //display usage info and quit if -help specified
                if (lup.Contains("-help") == true)
                {
                    printHelp();
                    return;
                }

                //run file calibration
                runConvertCommand(lup);
            }
        }