Exemple #1
0
        public static void Main(string[] sargs)
        {
            Thread.CurrentThread.CurrentUICulture = Culture;
            CommandArgs args = new CommandArgs(sargs);

            if (args.styles)
            {
                Application.EnableVisualStyles();
            }

            // Damn .NET text rendering
            Application.SetCompatibleTextRenderingDefault(false);

            Directory.SetCurrentDirectory(System.IO.Path.GetDirectoryName(Application.ExecutablePath));

            Localizations = new LocalizationInterface();
            try {
                string[] langfiles = Directory.GetFiles("MGE3", "*.lng");
                foreach (string langfile in langfiles)
                {
                    Localizations.Add(langfile);
                }
            } catch {
            }

            string language     = "English (default)";
            bool   autoLanguage = true;

            try {
                INIFile MGEini = new INIFile(fn_inifile, new INIFile.INIVariableDef [] {
                    INIFile.iniDefEmpty,
                    MainForm.iniLanguage,
                    MainForm.iniAutoLang
                });
                language     = MGEini.getKeyString("Language");
                autoLanguage = (MGEini.getKeyValue("AutoLang") == 1);
            } catch {
            }
            Localizations.Current = language;
            Localizations.ApplyStrings("", strings);

            if (args.mutex && !MutexCheck.PerformCheck())
            {
                MessageBox.Show(strings["MGEguiRunning"], strings["Error"]);
                return;
            }
            Process[] morrowind = Process.GetProcessesByName("Morrowind");
            foreach (Process p in morrowind)
            {
                MessageBox.Show(strings["MWRunning"], strings["Error"]);
                return;
            }

            if (!File.Exists("./morrowind.exe") || !File.Exists("./morrowind.ini") || !Directory.Exists("data files"))
            {
                MessageBox.Show(strings["NotMWDir"], strings["Error"]);
                return;
            }
            if (!Directory.Exists("MGE3") || !File.Exists("./MGE3/MGEfuncs.dll") || !File.Exists("./d3d8.dll") || !File.Exists("./dinput8.dll"))
            {
                MessageBox.Show(strings["MGEMissing"], strings["Error"]);
                return;
            }
            // Morrowind version info
            try {
                FileVersionInfo MorrowVersion = FileVersionInfo.GetVersionInfo("Morrowind.exe");
                if (MorrowVersion.FileMajorPart != 1 || MorrowVersion.FileMinorPart < 6)
                {
                    MessageBox.Show(strings["MWIncompat"], strings["Error"]);
                    return;
                }
            } catch {
                MessageBox.Show(strings["MWCorrupt"], strings["Error"]);
                return;
            }

            runDir = System.Windows.Forms.Application.StartupPath;

            // Create some structures
            for (int i = 0; i < MACROS; i++)
            {
                Macros[i] = new Macro();
            }
            for (int i = 0; i < TRIGGERS; i++)
            {
                Triggers[i] = new Trigger();
            }
            DXMain.GetDeviceCaps();
            mf = new MainForm(autoLanguage);
            Application.Run(mf);
        }
Exemple #2
0
        private void Send(Exception exception, bool silent)
        {
            Exception = exception;

            var    mainAssembly = Assembly.GetEntryAssembly();
            string appTitle     = null;
            var    attributes   = mainAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), true);

            if (attributes.Length > 0)
            {
                appTitle = ((AssemblyTitleAttribute)attributes[0]).Title;
            }

            ApplicationTitle   = !string.IsNullOrEmpty(appTitle) ? appTitle : mainAssembly.GetName().Name;
            ApplicationVersion = ((Type.GetType("Mono.Runtime") == null) && ApplicationDeployment.IsNetworkDeployed)
                ? ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString()
                : mainAssembly.GetName().Version.ToString();
            try
            {
                ScreenShot = $@"{Path.GetTempPath()}\{ApplicationTitle} Crash Screenshot.png";
                if (CaptureScreen)
                {
                    CaptureScreenshot.CaptureScreen(ScreenShot, ImageFormat.Png);
                }
                else
                {
                    CaptureScreenshot.CaptureActiveWindow(ScreenShot, ImageFormat.Png);
                }
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);
            }

            if (!AnalyzeWithDoctorDump)
            {
                if (string.IsNullOrEmpty(FromEmail))
                {
                    throw new ArgumentNullException(@"FromEmail");
                }

                if (string.IsNullOrEmpty(SmtpHost))
                {
                    throw new ArgumentNullException("SmtpHost");
                }
            }

            if (!Application.MessageLoop)
            {
                Application.EnableVisualStyles();
            }

            if (silent)
            {
                SendReport(IncludeScreenshot);
            }
            else
            {
                if (Thread.CurrentThread.GetApartmentState().Equals(ApartmentState.MTA))
                {
                    var thread = new Thread(() => new CrashReport(this).ShowDialog())
                    {
                        IsBackground = false
                    };
                    thread.CurrentCulture = thread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                    thread.Join();
                }
                else
                {
                    new CrashReport(this).ShowDialog();
                }
            }
        }
Exemple #3
0
        private static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            Application.EnableVisualStyles();

            //Prevent crash that occurs when this dll is not present
            if (!File.Exists(Application.StartupPath + "/Octokit.dll"))
            {
                MessageBox.Show("Unable to find Octokit.dll.");
                return;
            }

            bool somethingDone = true;
            Task t;

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "-r":     //overwrite
                    t = Updater.CheckUpdate(true);
                    t.Wait();
                    break;

                case "-n":     // Update in new folder
                    t = Updater.CheckUpdate(false);
                    t.Wait();
                    break;

                case "-bu":     //BrawlCrate update call
                    t = Updater.CheckUpdate(args[1] != "0", args[2], args[3] != "0", args[4], args[5] != "0",
                                            args[6] != "0", args[7] != "0");
                    t.Wait();
                    break;

                case "-buc":     //BrawlCrate Canary update call
                    t = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null,
                                                  args.Length > 2 && args[2] != "0", args[3] != "0", args[4] != "0");
                    t.Wait();
                    break;

                case "-bi":     //BrawlCrate issue call
                    t = IssueReporter.CreateIssue(args[1], args[2], args[3], args[4], args[5]);
                    t.Wait();
                    break;

                case "-bcommitTime":     //Called on build to ensure time is saved
                    string t4arg1 = args.Length > 1 ? args[1] : null;
                    string t4arg2 = args.Length > 2 ? args[2] : null;
                    string t4arg3 = args.Length > 3 ? args[3] : null;
                    string t4arg4 = args.Length > 4 ? args[4] : null;

                    t = Updater.WriteCanaryTime(t4arg1, t4arg2, t4arg3, t4arg4);
                    t.Wait();
                    break;

                case "-dlCanary":     // Force download the latest Canary build
                    Updater.SetCanaryActive();
                    t = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null, false, true, false);
                    t.Wait();
                    break;

                case "-dlStable":     // Force download the latest Stable build
                    Updater.SetCanaryInactive();
                    t = Updater.ForceDownloadStable(args.Length > 1 ? args[1] : null);
                    t.Wait();
                    break;

                case "-dlDoc":     // Force download the latest Documentation build
                    t = Updater.ForceDownloadDocumentation();
                    t.Wait();
                    break;

                case "-canarylog":     // Show changelog for canary
                    t = Updater.ShowCanaryChangelog();
                    t.Wait();
                    break;

                case "-canaryOn":     // Activate canary build
                    Updater.SetCanaryActive();
                    break;

                case "-canaryOff":
                    Updater.SetCanaryInactive();
                    break;

                case "-killAll":
                    t = Updater.KillOpenWindows();
                    t.Wait();
                    break;

                case "-apiUpdate":
                    t = Updater.BrawlAPICheckUpdates(args.Length > 1 && args[1] == "1");
                    t.Wait();
                    break;

                case "-apiInstall":
                    t = Updater.BrawlAPIInstallUpdate(args[1], args[2], args.Length > 3 && args[3] == "1");
                    t.Wait();
                    break;

                case "-apiUninstall":
                    Updater.BrawlAPIUninstall(args[1], args[2], args.Length > 3 && args[3] == "1");
                    break;

                default:
                    somethingDone = false;
                    break;
                }
            }
            else if (args.Length == 0)
            {
#if CANARY
                t = Updater.CheckCanaryUpdate("", true, false, true);
#else
                t = Updater.CheckUpdate(true);
#endif
                t.Wait();
            }

            if (!somethingDone)
            {
                Console.WriteLine(Usage);
            }
        }
Exemple #4
0
 public static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new App());
 }
Exemple #5
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new UI(new domain.Application(new NumberAssembler(), new Calculator())));
 }
Exemple #6
0
        private static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            Application.EnableVisualStyles();

            //Prevent crash that occurs when this dll is not present
            if (!File.Exists(Application.StartupPath + "/Octokit.dll"))
            {
                MessageBox.Show("Unable to find Octokit.dll.");
                return;
            }

            bool somethingDone = false;

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "-r":     //overwrite
                    somethingDone = true;
                    Task t = Updater.CheckUpdate(true);
                    t.Wait();
                    break;

                case "-n":     // Update in new folder
                    somethingDone = true;
                    Task t1 = Updater.CheckUpdate(false);
                    t1.Wait();
                    break;

                case "-bu":     //BrawlCrate update call
                    somethingDone = true;
                    Task t2 = Updater.CheckUpdate(args[1] != "0", args[2], args[3] != "0", args[4], args[5] != "0",
                                                  args[6] != "0");
                    t2.Wait();
                    break;

                case "-buc":     //BrawlCrate Canary update call
                    somethingDone = true;
                    Task t2c = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null,
                                                         args.Length > 2 && args[2] != "0", false);
                    t2c.Wait();
                    break;

                case "-bi":     //BrawlCrate issue call
                    somethingDone = true;
                    Task t3 = BugSquish.CreateIssue(args[1], args[2], args[3], args[4], args[5]);
                    t3.Wait();
                    break;

                case "-bcommitTime":     //Called on build to ensure time is saved
                    somethingDone = true;
                    string t4arg1 = args.Length > 1 ? args[1] : null;
                    string t4arg2 = args.Length > 2 ? args[2] : null;
                    string t4arg3 = args.Length > 3 ? args[3] : null;
                    string t4arg4 = args.Length > 4 ? args[4] : null;

                    Task t4 = Updater.WriteCanaryTime(t4arg1, t4arg2, t4arg3, t4arg4);
                    t4.Wait();
                    break;

                case "-dlCanary":     // Force download the latest Canary build
                    somethingDone = true;
                    Task t5a = Updater.SetCanaryActive();
                    t5a.Wait();
                    Task t5 = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null, false, true);
                    t5.Wait();
                    break;

                case "-dlStable":     // Force download the latest Stable build
                    somethingDone = true;
                    Task t6a = Updater.SetCanaryInactive();
                    t6a.Wait();
                    Task t6 = Updater.ForceDownloadStable(args.Length > 1 ? args[1] : null);
                    t6.Wait();
                    break;

                case "-dlDoc":     // Force download the latest Documentation build
                    somethingDone = true;
                    Task t6d = Updater.ForceDownloadDocumentation();
                    t6d.Wait();
                    break;

                case "-canarylog":     // Show changelog for canary
                    somethingDone = true;
                    Task t7 = Updater.ShowCanaryChangelog();
                    t7.Wait();
                    break;

                case "-canaryOn":     // Activate canary build
                    somethingDone = true;
                    Task t8 = Updater.SetCanaryActive();
                    t8.Wait();
                    break;

                case "-canaryOff":
                    somethingDone = true;
                    Task t9 = Updater.SetCanaryInactive();
                    t9.Wait();
                    break;

                case "-killAll":
                    somethingDone = true;
                    Task t10 = Updater.KillOpenWindows();
                    t10.Wait();
                    break;
                }
            }
            else if (args.Length == 0)
            {
                somethingDone = true;
#if CANARY
                Task t = Updater.CheckCanaryUpdate("", true, false);
#else
                Task t = Updater.CheckUpdate(true);
#endif
                t.Wait();
            }

            if (!somethingDone)
            {
                Console.WriteLine(Usage);
            }
        }
Exemple #7
0
 static void Main(string[] args)
 {
     CApplication.EnableVisualStyles();
     CApplication.SetCompatibleTextRenderingDefault(false);
     CApplication.Run(new MainForm());
 }
Exemple #8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.VisualStyleState = VisualStyleState.ClientAndNonClientAreasEnabled;
            Application.ThreadException += Application_ThreadException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException   += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.FirstChanceException += CurrentDomain_FirstChanceException;

            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            // Permit unmanaged code permissions
            var perm = new SecurityPermission(SecurityPermissionFlag.UnmanagedCode);

            // The method itself is attached with the security permission
            // Deny for unmanaged code, which will override
            // the Assert permission in this stack frame.
            perm.Assert();

#if DEBUG
            System.Windows.Forms.Timer watchdogTimer;
#endif

            ThreadPool.SetMaxThreads(50, 200);
            bool mutexAquired = false;
            using (var mutex = new Mutex(false, mutex_id))
            {
                var logLevel = 0;
#if DEBUG
                logLevel = 5;
#endif
                var args = Environment.GetCommandLineArgs();

                var logLevelStr = GetCommandLineParameter("/loglevel", args);
                if (!string.IsNullOrEmpty(logLevelStr))
                {
                    int.TryParse(logLevelStr, NumberStyles.Any, null, out logLevel);
                }

                Logger.LogLevel = logLevel;

                // Parse logger parameter
                var logFile = GetCommandLineParameter("/log", args);
                if (logFile != null)
                {
                    try
                    {
                        Logger.Out = File.CreateText(logFile);
                    }
                    catch (Exception e)
                    {
                        Logger.LogWarn(e, "Unable to open log file at '{0}'", logFile);
                    }
                }

                if (GetCommandLineSwitch("/DisableExceptionReporter", args))
                {
                    _disableExceptionReporter = true;
                }

                Logger.LogNotice($"ContactPoint IP Phone version: {typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion}");
                Logger.LogNotice($"Main Thread Culture is '{Thread.CurrentThread.CurrentCulture}'");
                Logger.LogNotice($"UI Thread Culture is '{Thread.CurrentThread.CurrentUICulture}'");

#if DEBUG
                if (args.Contains("/debugger", StringComparer.InvariantCultureIgnoreCase))
                {
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                    else
                    {
                        Debugger.Launch();
                    }
                }
#endif

#if DEBUG
                watchdogTimer = new System.Windows.Forms.Timer {
                    Interval = 3000
                };
                watchdogTimer.Tick += (s, e) => { _watcherLastActivity = DateTime.Now; };
                watchdogTimer.Start();

                _watcherTargetThread = Thread.CurrentThread;
                _watcherLastActivity = DateTime.Now;

                ThreadPool.QueueUserWorkItem(WatcherThreadFunc);
#endif

                var makeCallMessage = StartPhoneCallCommand.CreateFromCommandLine(GetCommandLineParameter("/call", args));
                try
                {
                    try
                    {
                        if (!WaitForMutex(mutex))
                        {
                            SharedFileMessageTransportHost.SendMessage(makeCallMessage);
                            return;
                        }
                        else
                        {
                            mutexAquired = true;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.LogError(e);
                        Environment.Exit(0);
                    }

                    using (AppContext = new MainFormApplicationContext())
                    {
                        PartLoading("Initialize Splash Screen UI");
                        _loaderForm = new LoaderForm();
                        ThreadPool.QueueUserWorkItem(StartLoaderForm);
                        CoreLoader.LoadingFailed += LoadingFailed;
                        CoreLoader.PartLoading   += PartLoading;

                        foreach (var assembly in typeof(Program).Assembly.GetReferencedAssemblies())
                        {
                            PartLoading($"Load dependency: {assembly.Name} v{assembly.Version}");
                            AppDomain.CurrentDomain.Load(assembly);
                        }

                        PartLoading("Initialize Exception Reporter");
                        ExceptionReporter = new ExceptionReporter.ExceptionReporter();
                        ExceptionReporter.Config.ShowFlatButtons          = false;
                        ExceptionReporter.Config.ShowLessMoreDetailButton = true;
                        ExceptionReporter.Config.CompanyName  = "ContactPoint";
                        ExceptionReporter.Config.ContactEmail = "*****@*****.**";
                        ExceptionReporter.Config.WebUrl       = "http://www.contactpoint.com.ua/";
#if DEBUG
                        ExceptionReporter.Config.ShowFullDetail = true;
#else
                        ExceptionReporter.Config.ShowFullDetail = false;
#endif
                        PartLoading("Initialize WPF Infrastructure");

                        // Create WPF application in order to let WPF controls work correctly
                        System.Windows.Application wpfApp = null;
                        Window wpfWnd = null;
                        try
                        {
                            PartLoading("Create WPF Application");
                            wpfApp = new System.Windows.Application();

                            PartLoading("Create WPF Window");
                            wpfWnd = new Window
                            {
                                Visibility    = Visibility.Hidden,
                                ShowInTaskbar = false,
                                Width         = 1,
                                Height        = 1
                            };

                            PartLoading("Core infrastructure");
                            using (var core = CoreLoader.CreateCore(AppContext.MainForm))
                            {
                                PartLoading("Audio services");
                                using (new AudioDeviceService(core))
                                {
#if DEBUG
                                    if (args.Contains("/newui"))
                                    {
                                        new PhoneWindow().Show();
                                    }
#endif

                                    PartLoading("Configuring Windows Forms UI");
                                    AppContext.ContactPointForm.Core          = core;
                                    AppContext.ContactPointForm.CallOnStartup = makeCallMessage;

                                    AppContext.ContactPointForm.Shown += MainFormShown;

                                    PartLoading("Starting Windows Forms UI");
                                    Application.Run(AppContext);
                                }
                            }
                        }
                        finally
                        {
                            wpfWnd?.Close();
                            wpfApp?.Shutdown(0);
                        }
                    }
                }
                finally
                {
                    if (mutexAquired)
                    {
                        mutex.ReleaseMutex();
                    }

#if DEBUG
                    _watcherThreadShutdown = true;
                    watchdogTimer.Stop();
#endif
                }
            }
        }
Exemple #9
0
 private static void Main()
 {
     Application.EnableVisualStyles();
     Application.Run(new IsometricDrawingDemo());
 }