Пример #1
0
        private static bool VerifyPackageSetup()
        {
            PackageManager packageManager = new PackageManager();

            // On the first install startup, display a generic license agreement for Duality
            if (packageManager.LocalSetup.IsFirstInstall)
            {
                LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
                {
                    DescriptionText = GeneralRes.LicenseAcceptDialog_FirstStartGeneric,
                    LicenseUrl      = new Uri(DualityMainLicenseUrl)
                };
                DialogResult result = licenseDialog.ShowDialog();
                if (result != DialogResult.OK)
                {
                    return(false);
                }
            }

            // Perform the initial package update - even before initializing the editor
            if (packageManager.IsPackageSyncRequired)
            {
                Logs.Editor.Write("Synchronizing Local Package Setup...");
                Logs.Editor.PushIndent();
                ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog(
                    GeneralRes.TaskInstallPackages_Caption,
                    GeneralRes.TaskInstallPackages_Desc,
                    SynchronizePackages,
                    packageManager);
                setupDialog.ShowInTaskbar      = true;
                setupDialog.MainThreadRequired = false;
                setupDialog.ShowDialog();
                Logs.Editor.PopIndent();
            }

            // Restart to apply the update. This will also trigger when there is a pending
            // update from before that wasn't applied yet.
            if (packageManager.ApplyUpdate())
            {
                return(false);
            }
            // If we have nothing to apply, but still require a sync, something went wrong.
            // Should this happen on our first start, we'll remind the user that the install
            // requires an internet connection and refuse to start.
            else if (packageManager.IsPackageSyncRequired && packageManager.LocalSetup.IsFirstInstall)
            {
                DialogResult result = MessageBox.Show(
                    GeneralRes.Msg_ErrorFirstDualityInstall_Desc,
                    GeneralRes.Msg_ErrorFirstDualityInstall_Caption,
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }
Пример #2
0
        private static void DisplayDefaultLicenseAcceptDialog(PackageLicenseAgreementEventArgs args)
        {
            LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
            {
                DescriptionText = string.Format(GeneralRes.LicenseAcceptDialog_PackageDesc, args.PackageName),
                LicenseUrl      = args.LicenseUrl
            };

            Form         invokeForm = DualityEditorApp.MainForm ?? Application.OpenForms.OfType <Form>().FirstOrDefault();
            DialogResult result     = invokeForm.InvokeEx(main => licenseDialog.ShowDialog());

            if (result == DialogResult.OK)
            {
                args.AcceptLicense();
            }
        }
Пример #3
0
        private static void Main(string[] args)
        {
            // Parse command line arguments
            bool recover = false;

            foreach (string a in args)
            {
                if (a == "debug")
                {
                    System.Diagnostics.Debugger.Launch();
                }
                else if (a == "recover")
                {
                    recover = true;
                }
            }

            // Culture setup
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            // Set up file logging
            StreamWriter        logfileWriter = null;
            TextWriterLogOutput logfileOutput = null;

            try
            {
                // If there is an existing logfile, preserve it under a different name
                if (File.Exists(DualityEditorApp.EditorLogfilePath))
                {
                    if (File.Exists(DualityEditorApp.EditorPrevLogfilePath))
                    {
                        File.Delete(DualityEditorApp.EditorPrevLogfilePath);
                    }
                    File.Move(DualityEditorApp.EditorLogfilePath, DualityEditorApp.EditorPrevLogfilePath);
                }

                // Create a new logfile
                logfileWriter           = new StreamWriter(DualityEditorApp.EditorLogfilePath);
                logfileWriter.AutoFlush = true;
                logfileOutput           = new TextWriterLogOutput(logfileWriter);
                Log.AddGlobalOutput(logfileOutput);
            }
            catch (Exception e)
            {
                Log.Core.WriteWarning("Text Logfile unavailable: {0}", Log.Exception(e));
            }

            // Winforms Setup
            Application.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;

            {
                PackageManager packageManager = new PackageManager();

                // On the first install startup, display a generic license agreement for Duality
                if (packageManager.IsFirstInstall)
                {
                    LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
                    {
                        DescriptionText = GeneralRes.LicenseAcceptDialog_FirstStartGeneric,
                        LicenseUrl      = new Uri(DualityMainLicenseUrl)
                    };
                    DialogResult result = licenseDialog.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        Application.Exit();
                        return;
                    }
                }

                // Perform the initial package update - even before initializing the editor
                if (packageManager.IsPackageSyncRequired)
                {
                    Log.Editor.Write("Updating Packages...");
                    Log.Editor.PushIndent();
                    ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog(
                        GeneralRes.TaskInstallPackages_Caption,
                        GeneralRes.TaskInstallPackages_Desc,
                        SynchronizePackages,
                        packageManager);
                    setupDialog.ShowInTaskbar      = true;
                    setupDialog.MainThreadRequired = false;
                    setupDialog.ShowDialog();
                    Log.Editor.PopIndent();
                }
                if (packageManager.ApplyUpdate())
                {
                    Application.Exit();
                    return;
                }
            }

            // Run the editor
            SplashScreen splashScreen = new SplashScreen(recover);

            splashScreen.Show();
            Application.Run();

            // Clean up the log file
            if (logfileWriter != null)
            {
                Log.RemoveGlobalOutput(logfileOutput);
                logfileWriter.Flush();
                logfileWriter.Close();
                logfileWriter = null;
                logfileOutput = null;
            }
        }
Пример #4
0
        private static void Main(string[] args)
        {
            // Parse command line arguments
            bool recover = false;

            foreach (string a in args)
            {
                if (a == "debug")
                {
                    System.Diagnostics.Debugger.Launch();
                }
                else if (a == "recover")
                {
                    recover = true;
                }
            }

            // Culture setup
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            Application.CurrentCulture = Thread.CurrentThread.CurrentCulture;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += Application_ThreadException;

            {
                PackageManager packageManager = new PackageManager();

                // On the first install startup, display a generic license agreement for Duality
                if (packageManager.IsFirstInstall)
                {
                    LicenseAcceptDialog licenseDialog = new LicenseAcceptDialog
                    {
                        DescriptionText = GeneralRes.LicenseAcceptDialog_FirstStartGeneric,
                        LicenseUrl      = new Uri(DualityMainLicenseUrl)
                    };
                    DialogResult result = licenseDialog.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        Application.Exit();
                        return;
                    }
                }

                // Perform the initial package update - even before initializing the editor
                if (packageManager.IsPackageUpdateRequired)
                {
                    Log.Editor.Write("Updating Packages...");
                    Log.Editor.PushIndent();
                    ProcessingBigTaskDialog setupDialog = new ProcessingBigTaskDialog(
                        GeneralRes.TaskInstallPackages_Caption,
                        GeneralRes.TaskInstallPackages_Desc,
                        FirstTimeSetup,
                        packageManager);
                    setupDialog.ShowInTaskbar      = true;
                    setupDialog.MainThreadRequired = false;
                    setupDialog.ShowDialog();
                    Log.Editor.PopIndent();
                }
                if (packageManager.ApplyUpdate())
                {
                    Application.Exit();
                    return;
                }
            }

            // Run the editor
            SplashScreen splashScreen = new SplashScreen(recover);

            splashScreen.Show();
            Application.Run();
        }