Пример #1
0
        public static int Main(string[] args)
        {
            var arguments = ProgramArguments.Parse(args);

            if (arguments == null || (arguments != null && arguments.input == null))
            {
                return((int)FailCode.FailedParsingArguments);
            }

            return(PackSprites(arguments.ToConfig()));
        }
Пример #2
0
        public MainFrm()
        {
            InitializeComponent();

            if (LicenseManager.UsageMode == LicenseUsageMode.Runtime)
            {
                this.Icon = Resources.App;

                //ProfessionalColorTable colorTable = new ProfessionalColorTable();
                //colorTable.UseSystemColors = true;
                //statusStrip1.Renderer = new ToolStripProfessionalRenderer(colorTable);
                //toolStrip1.Renderer = new ToolStripProfessionalRenderer(colorTable);

                Trace.Listeners.Add(_eltl);

                ProgramArguments args = new ProgramArguments();

                try
                {
                    args.Parse(false, Environment.GetCommandLineArgs());

                    if (args.Help)
                    {
                        ShowHelp();
                    }

                    if (args.ComparisonSet.Items.Count > 0)
                    {
                        _set = args.ComparisonSet;

                        this.Show();

                        UpdateCheckStates();
                        UpdateTitleBar();

                        Compare();
                    }
                }
                catch (ArgumentParserException ex)
                {
                    MessageBox.Show(this, ex.Message, "Error Parsing Arguments", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }

                Application.Idle += new EventHandler(Application_Idle);
            }
        }
Пример #3
0
        public static int Launch(string[] args)
        {
            ProgramArguments arguments = ProgramArguments.Parse(args);

            if (arguments == null)
            {
                return((int)FailCode.FailedParsingArguments);
            }
            else
            {
                // make sure we have our list of exporters
                Exporters.Load();

                // try to find matching exporters
                IImageExporter imageExporter = null;
                IMapExporter   mapExporter   = null;

                string imageExtension = Path.GetExtension(arguments.image).Substring(1).ToLower();
                foreach (var exporter in Exporters.ImageExporters)
                {
                    if (exporter.ImageExtension.ToLower() == imageExtension)
                    {
                        imageExporter = exporter;
                        break;
                    }
                }

                if (imageExporter == null)
                {
                    Console.WriteLine("Failed to find exporters for specified image type.");
                    return((int)FailCode.ImageExporter);
                }

                if (!string.IsNullOrEmpty(arguments.map))
                {
                    string mapExtension = Path.GetExtension(arguments.map).Substring(1).ToLower();
                    foreach (var exporter in Exporters.MapExporters)
                    {
                        if (exporter.MapExtension.ToLower() == mapExtension)
                        {
                            mapExporter = exporter;
                            break;
                        }
                    }

                    if (mapExporter == null)
                    {
                        Console.WriteLine("Failed to find exporters for specified map type.");
                        return((int)FailCode.MapExporter);
                    }
                }

                // compile a list of images
                List <string> images = new List <string>();
                FindImages(arguments, images);

                // make sure we found some images
                if (images.Count == 0)
                {
                    Console.WriteLine("No images to pack.");
                    return((int)FailCode.NoImages);
                }

                // make sure no images have the same name if we're building a map
                if (mapExporter != null)
                {
                    for (int i = 0; i < images.Count; i++)
                    {
                        string str1 = Path.GetFileNameWithoutExtension(images[i]);

                        for (int j = i + 1; j < images.Count; j++)
                        {
                            string str2 = Path.GetFileNameWithoutExtension(images[j]);

                            if (str1 == str2)
                            {
                                Console.WriteLine("Two images have the same name: {0} = {1}", images[i], images[j]);
                                return((int)FailCode.ImageNameCollision);
                            }
                        }
                    }
                }

                // generate our output
                ImagePacker imagePacker = new ImagePacker();
                Bitmap      outputImage;
                Dictionary <string, Rectangle> outputMap;

                // pack the image, generating a map only if desired
                int result = imagePacker.PackImage(images, arguments.pow2, arguments.sqr, arguments.mw, arguments.mh, arguments.pad, mapExporter != null, out outputImage, out outputMap);
                if (result != 0)
                {
                    Console.WriteLine("There was an error making the image sheet.");
                    return(result);
                }

                // try to save using our exporters
                try
                {
                    if (File.Exists(arguments.image))
                    {
                        File.Delete(arguments.image);
                    }
                    imageExporter.Save(arguments.image, outputImage);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error saving file: " + e.Message);
                    return((int)FailCode.FailedToSaveImage);
                }

                if (mapExporter != null)
                {
                    try
                    {
                        if (File.Exists(arguments.map))
                        {
                            File.Delete(arguments.map);
                        }
                        mapExporter.Save(arguments.map, outputMap);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Error saving file: " + e.Message);
                        return((int)FailCode.FailedToSaveMap);
                    }
                }
            }

            return(0);
        }
Пример #4
0
 public static IObservable <T> Spawn <T>(string path, string args, Func <string, T> stdoutSelector, Func <string, T> stderrSelector) =>
 Spawner.Default.Spawn(path, ProgramArguments.Parse(args), null, stdoutSelector, stderrSelector);
Пример #5
0
 public static IObservable <KeyValuePair <T, string> > Spawn <T>(string path, string args, string workingDirectory, T stdoutKey, T stderrKey) =>
 Spawner.Default.Spawn(path, ProgramArguments.Parse(args), workingDirectory,
                       stdout => stdoutKey.AsKeyTo(stdout),
                       stderr => stderrKey.AsKeyTo(stderr));
Пример #6
0
 public static IObservable <KeyValuePair <T, string> > Spawn <T>(string path, string args, T stdoutKey, T stderrKey) =>
 Spawner.Default.Spawn(path, ProgramArguments.Parse(args), null, stdoutKey, stderrKey);
Пример #7
0
 public static IObservable <string> Spawn(string path, string args, string workingDirectory) =>
 Spawner.Default.Spawn(path, ProgramArguments.Parse(args), workingDirectory, output => output, null);
Пример #8
0
 public static IObservable <string> Spawn(string path, string args) =>
 Spawner.Default.Spawn(path, ProgramArguments.Parse(args), null);
Пример #9
0
        static int Main(string[] arguments)
        {
            foreach (TraceListener tl in Trace.Listeners)
            {
                if (tl is RelayingTraceListener)
                {
                    ((RelayingTraceListener)tl).Message += new EventHandler <TraceEventArgs>(Program_Message);
                }
            }

            Log.Info("BitDiffer Console");
            Log.Info("Version {0} ({1:d})", Assembly.GetExecutingAssembly().GetName().Version, DateTime.Today);
            Log.Info("");

            ProgramArguments args = new ProgramArguments();

            try
            {
                args.Parse(true, arguments);
            }
            catch (ArgumentParserException ex)
            {
                string message = "ERROR: " + ex.Message;

                if (args.LogFile != null)
                {
                    File.WriteAllText(args.LogFile, message);
                }

                Console.WriteLine(message);
                Console.WriteLine();

                Usage();

                return(-1);
            }

            if (args.Help)
            {
                Usage();

                Console.WriteLine("Press any key to exit...");
                Console.Read();

                return(1);
            }

            if (args.LogFile != null)
            {
                _logFileWriter = new StreamWriter(args.LogFile, false);
            }

            AssemblyComparison ac = new AssemblyComparer().CompareAssemblies(args.ComparisonSet);

            ac.WriteReport(args.ReportFile, AssemblyComparisonXmlWriteMode.Normal);

            if (args.RawFile != null)
            {
                ac.WriteXmlReport(args.RawFile, AssemblyComparisonXmlWriteMode.Raw);
            }

            Log.Info("Done!");

            if (_logFileWriter != null)
            {
                _logFileWriter.Flush();
                _logFileWriter.Close();
            }

            return(0);
        }