public static void Main(string[] argv)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                Logger.LogMessage(String.Format("unhandled exception!!: {0} {1}", sender, args));
                Environment.Exit(1);
            };
            String appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            String edmc    = System.IO.Path.Combine(appdata, "EDMarketConnector");
            String plugins = System.IO.Path.Combine(edmc, "plugins");

            Logger.Setup(System.IO.Path.Combine(plugins, "edmcoverlay.log"));
            Logger.LogMessage("starting..");
            Logger.Subsystem = typeof(EDMCOverlay);
            try
            {
                if (argv.Length > 0)
                {
                    if (argv[0].Equals("--test"))
                    {
                        System.Threading.ThreadPool.QueueUserWorkItem(TestThread);
                    }
                }

                OverlayRenderer renderer = new OverlayRenderer();
                server = new OverlayJsonServer(5010, renderer);

                System.Threading.ThreadPool.QueueUserWorkItem((x) => server.Start());

                EDGlassForm glass = new EDGlassForm(renderer.GetGame());
                renderer.Glass    = glass;
                renderer.Graphics = server.Graphics;
                System.Windows.Forms.Application.Run(renderer.Glass);
            }
            catch (Exception err)
            {
                Logger.LogMessage(String.Format("exiting!: {0}", err.ToString()));
                Environment.Exit(0);
            }
        }
Exemple #2
0
        public static void Main(string[] argv)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
            {
                Logger.LogMessage(String.Format("unhandled exception!!: {0} {1}", sender, args));
                Logger.LogMessage(((Exception)args.ExceptionObject).StackTrace);
                Environment.Exit(1);
            };

            String appdata = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            String edmc    = System.IO.Path.Combine(appdata, "EDMarketConnector");

            Logger.Setup(System.IO.Path.Combine(edmc, "edmcoverlay.log"));
            Logger.LogMessage("starting..");
            Logger.Subsystem = typeof(EDMCOverlay);
            try
            {
                OverlayRenderer renderer = new OverlayRenderer();

                foreach (var arg in argv)
                {
                    if (arg.Equals("--test"))
                    {
                        renderer.TestMode = true;
                        System.Threading.ThreadPool.QueueUserWorkItem(TestThread);
                    }

                    if (arg.Equals("--foreground"))
                    {
                        renderer.ForceRender = true;
                    }

                    if (arg.Equals("--half"))
                    {
                        renderer.HalfSize = true;
                    }

                    if (arg.StartsWith("--geometry="))
                    {
                        // expect --geometry=X,Y,WxH
                        var words = arg.Split(new char[] { '=' }, 1);
                        if (words.Length == 2)
                        {
                            var parts = words[1].Split(new char[] { ',' });
                            if (parts.Length == 3)
                            {
                                var x = Int32.Parse(parts[0]);
                                var y = Int32.Parse(parts[1]);

                                var geo = words[2].Split(new char[] { 'x' }, 1);
                                if (geo.Length == 2)
                                {
                                    var w = Int32.Parse(geo[0]);
                                    var h = Int32.Parse(geo[1]);

                                    renderer.ForceLocation = new System.Drawing.Point(x, y);
                                    renderer.ForceSize     = new System.Drawing.Size(w, h);
                                }
                            }
                        }
                    }

                    if (arg.Equals("--standalone"))
                    {
                        renderer.Standalone = true;
                    }
                }
                server = new OverlayJsonServer(5010, renderer);
                System.Threading.ThreadPool.QueueUserWorkItem((x) => server.Start());
                var game = renderer.GetGame();
                if (game == null)
                {
                    // elite isn't running?
                    // if we are in test mode, just use ourself
                    if (renderer.Standalone || renderer.TestMode || renderer.ForceRender)
                    {
                        Logger.LogMessage("No game running, using fake test window");
                        game = Process.GetCurrentProcess();
                    }
                }

                if (game == null)
                {
                    Logger.LogMessage("No game running, exiting.");
                    Environment.Exit(2);
                }

                EDGlassForm glass = new EDGlassForm(game, renderer.Standalone);
                renderer.Glass    = glass;
                glass.HalfSize    = renderer.HalfSize;
                renderer.Graphics = server.Graphics;
                System.Windows.Forms.Application.Run(renderer.Glass);
            }
            catch (Exception err)
            {
                Logger.LogMessage(String.Format("exiting!: {0}", err.ToString()));
                Console.WriteLine(err.ToString());
                Environment.Exit(3);
            }
        }