Exemplo n.º 1
0
        private void Main()
        {
            // check cmdline args
            string[] args = Environment.GetCommandLineArgs();

            Tools.FixDLLFoldersAndConfig(rootFolder);
            Tools.ForceDotCultureSeparator();

            if (args.Length > 1)
            {
                AttachConsole(ATTACH_PARENT_PROCESS);

                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("\n::: " + appname + " :::\n");
                Console.ForegroundColor = ConsoleColor.White;

                // check args, null here because we get the args later
                var importSettings = ArgParser.Parse(null, rootFolder);

                // if have files, process them
                if (importSettings != null)
                {
                    ProcessAllFiles(importSettings);
                }

                // end output
                Console.WriteLine("Exit");

                FreeConsole();
                Environment.Exit(0);
            }

            // regular WPF starts from here
            this.Title = appname;

            // disable accesskeys without alt
            CoreCompatibilityPreferences.IsAltKeyRequiredInAccessKeyDefaultScope = true;

            LoadSettings();
        }
Exemplo n.º 2
0
        void StartProcess(bool skipProcess = true)
        {
            // get args from GUI settings, TODO could directly create new import settings..
            var args = new List <string>();

            // add enabled args to list, TODO use binding later?
            args.Add("-input=" + txtInputFile.Text);

            if (cmbImportFormat.SelectedItem != null)
            {
                args.Add("-importformat=" + cmbImportFormat.SelectedItem.ToString());
            }
            if (cmbExportFormat.SelectedItem != null)
            {
                args.Add("-exportformat=" + cmbExportFormat.SelectedItem.ToString());
            }
            args.Add("-output=" + txtOutput.Text);

            if ((bool)chkAutoOffset.IsChecked)
            {
                args.Add("-offset=" + (bool)chkAutoOffset.IsChecked);
            }

            if (cmbExportFormat.SelectedItem.ToString().ToUpper().Contains("PCROOT"))
            {
                args.Add("-gridsize=" + txtGridSize.Text);
            }

            if ((bool)chkUseMinPointCount.IsChecked)
            {
                args.Add("-minpoints=" + txtMinPointCount.Text);
            }
            if ((bool)chkUseScale.IsChecked)
            {
                args.Add("-scale=" + txtScale.Text);
            }
            if ((bool)chkSwapYZ.IsChecked)
            {
                args.Add("-swap=" + (bool)chkSwapYZ.IsChecked);
            }
            if ((bool)chkPackColors.IsChecked)
            {
                args.Add("-pack=" + (bool)chkPackColors.IsChecked);
            }
            if ((bool)chkUsePackMagic.IsChecked)
            {
                args.Add("-packmagic=" + txtPackMagic.Text);
            }
            if ((bool)chkUseMaxImportPointCount.IsChecked)
            {
                args.Add("-limit=" + txtMaxImportPointCount.Text);
            }
            if ((bool)chkUseSkip.IsChecked)
            {
                args.Add("-skip=" + txtSkipEvery.Text);
            }
            if ((bool)chkUseKeep.IsChecked)
            {
                args.Add("-keep=" + txtKeepEvery.Text);
            }
            if ((bool)chkUseMaxFileCount.IsChecked)
            {
                args.Add("-maxfiles=" + txtMaxFileCount.Text);
            }
            args.Add("-randomize=" + (bool)chkRandomize.IsChecked);


            // check input files
            var importSettings = ArgParser.Parse(args.ToArray(), rootFolder);

            // TODO get error messages into log textbox (return in settings?)

            // if have files, process them
            if (importSettings != null)
            {
                // show output settings for commandline
                var cl = string.Join(" ", args);
                txtConsole.Text = cl;
                Console.WriteLine(cl);

                // TODO lock UI, add cancel button, add progress bar
                if (skipProcess == true)
                {
                    ProcessAllFiles(importSettings);
                }
            }
        }