/// <summary>
        /// Save dirty work
        /// </summary>
        /// <param name="filename">File to save on</param>
        protected override void doSave(string filename)
        {
            base.doSave(filename);
            string mode = "";

            if (rdMkr.Checked)
            {
                mode = "MKR";
            }
            else if (rdFlyTo.Checked)
            {
                mode = "FLYTO";
            }

            MSTSConverterFactory factory = new MSTSConverterFactory();
            IConverter           conv    = factory.GetConverter(mode);

            conv.FileOut(GetResult(conv), filename);
        }
Example #2
0
        static void Main(string[] args)
        {
            // Get infos from assembly
            assembly = Assembly.GetExecutingAssembly();
            prgName  = assembly.GetName().Name;

            // locales management
            string locale = ConfigurationManager.AppSettings["locale"];

            if (string.IsNullOrWhiteSpace(locale))
            {
                catalog = new Catalog(prgName, "./locale");
            }
            else
            {
                catalog = new Catalog(prgName, "./locale", new CultureInfo(locale));
            }

            // status vars
            string outputfile = String.Empty;
            string mode       = "";

            nobanner = false;

            // GNU Getopt options
            LongOpt[] longopts = new LongOpt[6];
            longopts[0] = new LongOpt("help", Argument.No, null, 'h');
            longopts[1] = new LongOpt("nobanner", Argument.No, null, 1000);
            longopts[2] = new LongOpt("output_file", Argument.Required, new StringBuilder(), 'o');
            longopts[3] = new LongOpt("text", Argument.No, null, 1001);
            longopts[4] = new LongOpt("markers", Argument.No, null, 1002);
            longopts[5] = new LongOpt("flyto", Argument.No, null, 1003);

            Getopt options = new Getopt(prgName, args, "ho:", longopts);

            int c;

            while ((c = options.getopt()) != -1)
            {
                switch (c)
                {
                case 'h':
                    PrintHelp();
                    Environment.Exit(0);
                    break;

                case ':':
                    Console.Error.WriteLine(catalog.GetString("Doh! You need an argument for option '{0}'", (char)options.getopt()));
                    Environment.Exit(1);
                    break;

                case '?':
                    Console.Error.WriteLine(catalog.GetString("The option '{0}' is not valid", options.Argv[options.Optind - 1]));
                    Environment.Exit(1);
                    break;

                case 'o':
                    outputfile = options.Optarg;
                    break;

                case 1000:
                    nobanner = true;
                    break;

                case 1001:
                    mode = "";
                    break;

                case 1002:
                    mode = "MKR";
                    break;

                case 1003:
                    mode = "FLYTO";
                    break;
                }
            }

            // checks if inputfile is specified
            if (options.Argv.Length <= options.Optind)
            {
                Console.Error.WriteLine(catalog.GetString("No input file specified."));
                Environment.Exit(2);
            }

            PrintBanner();

            // Converter init
            MSTSConverterFactory factory = new MSTSConverterFactory();
            IConverter           conv    = factory.GetConverter(mode);
            string ret = conv.FileHeader();

            // scan for files
            for (int i = options.Optind; i < options.Argv.Length; i++)
            {
                string inputfile = options.Argv[i];
                if (File.Exists(inputfile))
                {
                    conv.SetKml(inputfile);
                    ret += conv.PlacemarkBody();
                    ret += conv.PathBody();
                    ret += conv.PolyBody();
                }
                else
                {
                    Console.Error.WriteLine(catalog.GetString("File '{0}' not found: ignoring.", inputfile));
                }
            }

            conv.FileOut(ret, outputfile);
        }