Exemplo n.º 1
0
        protected override void OnStartup(object sender, StartupEventArgs eventArgs)
        {
            if (WindowsHelper.IsInDesignMode)
            {
                return;
            }

            if (_configurationFailed)
            {
                // The editor configuration has failed.
                // The Application is running and waits until the Exception window is closed.
                return;
            }

            bool isFirstInstance = SingleInstanceApplication.Initialize(UniqueName, OnOtherInstanceStarted);

            if (!isFirstInstance)
            {
                // If the command-line arguments are empty, then start new application instance.
                // But if a "file" was specified on the command-line, then open the document in
                // the first instance.
                if (_editor.CommandLineResult.ParsedArguments["file"] != null)
                {
                    // Notify first instance.
                    SingleInstanceApplication.SignalFirstInstance();

                    // Shutdown application.
                    Application.Shutdown(_editor.ExitCode);
                    return;
                }
            }

            // Start editor.
            bool success = _editor.Startup();

            if (!success)
            {
                Application.Shutdown(_editor.ExitCode);
                return;
            }

            // Set About dialog information.
            var aboutService = _serviceContainer.GetInstance <IAboutService>();

            if (aboutService != null)
            {
                aboutService.Copyright = "© 2008-2016 DigitalRune GmbH";
                aboutService.Icon      = _editor.ApplicationIcon;
                var additionalInfo = new TextBlock();
                additionalInfo.Inlines.Add(new Run("Additional information and support: "));
                var link = new Hyperlink(new Run("http://www.digitalrune.com/"))
                {
                    NavigateUri = new Uri("http://www.digitalrune.com/")
                };
                link.Click += delegate { Process.Start(new ProcessStartInfo(link.NavigateUri.ToString())); };
                additionalInfo.Inlines.Add(link);
                aboutService.Information         = additionalInfo;
                aboutService.InformationAsString = "Additional information and support: http://www.digitalrune.com/";
            }

            // Show window.
            var windowService = _serviceContainer.GetInstance <IWindowService>().ThrowIfMissing();

            windowService.ShowWindow(_editor, null, false);
        }