Esempio n. 1
0
        // Invoked when application is being started up (before MainWindow creation).
        private void App_Startup(object sender, StartupEventArgs e)
        {
            // Set main thread apartment state.
            Thread.CurrentThread.SetApartmentState(ApartmentState.STA);

            // Set AppUserModelId of current process.
            TaskbarHelper.SetAppUserModelId();

            // Create Mutex if this is first instance.
            try
            {
                RunningInstanceMutex = Mutex.OpenExisting(RunningInstanceMutexName);
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                bool created = false;
                RunningInstanceMutex = new Mutex(false, RunningInstanceMutexName, out created);
                if (!created)
                {
                    throw new Exception("Unable to create application mutex");
                }
            }

            // Load persistent data.
            // Take the first not-switch argument as path to the build that will be imported
            var importedBuildPath = e.Args.FirstOrDefault(s => !s.StartsWith("/"));

            PersistentData = PersistentDataSerializationService.CreatePersistentData(importedBuildPath);

            // Initialize localization.
            L10n.Initialize(PersistentData.Options.Language);
        }
Esempio n. 2
0
        // Invoked when application is being started up (before MainWindow creation).
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            AppDomain.CurrentDomain.UnhandledException +=
                (_, args) => OnUnhandledException((Exception)args.ExceptionObject);

            // Create Mutex if this is first instance.
            try
            {
                _runningInstanceMutex = Mutex.OpenExisting(RunningInstanceMutexName);
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                _runningInstanceMutex = new Mutex(false, RunningInstanceMutexName, out var created);
                if (!created)
                {
                    throw new Exception("Unable to create application mutex");
                }
            }

            // Load persistent data.
            // Take the first not-switch argument as path to the build that will be imported
            var importedBuildPath = e.Args.FirstOrDefault(s => !s.StartsWith("/"));

            PersistentData = PersistentDataSerializationService.CreatePersistentData(importedBuildPath);

            // Initialize localization.
            L10n.Initialize(PersistentData.Options.Language);
        }
Esempio n. 3
0
        private async void OptionsOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            string propertyName = args.PropertyName;
            if (propertyName == nameof(Options.Language) ||
                (propertyName == nameof(Options.DownloadMissingItemImages) && !Options.DownloadMissingItemImages))
            {
                await _dialogCoordinator.ShowInfoAsync(this,
                    L10n.Message("You will need to restart the program for all changes to take effect."),
                    title: L10n.Message("Restart is needed"));

                if (propertyName == nameof(Options.Language))
                    L10n.Initialize(Options.Language);
            }
        }
Esempio n. 4
0
        private async Task OptionsChanged(string propertyName)
        {
            if (propertyName == nameof(Options.Language) ||
                (propertyName == nameof(Options.DownloadMissingItemImages) && !Options.DownloadMissingItemImages))
            {
                await _dialogCoordinator.ShowInfoAsync(this,
                                                       L10n.Message("You will need to restart the program for all changes to take effect."),
                                                       title : L10n.Message("Restart is needed"));

                if (propertyName == nameof(Options.Language))
                {
                    L10n.Initialize(Options.Language);
                }
            }
        }
Esempio n. 5
0
        // Invoked when application is being started up (before MainWindow creation).
        private void App_Startup(object sender, StartupEventArgs e)
        {
            // Set main thread apartment state.
            Thread.CurrentThread.SetApartmentState(ApartmentState.STA);

            // Set AppUserModelId of current process.
            TaskbarHelper.SetAppUserModelId();

            // Create Mutex if this is first instance.
            try
            {
                RunningInstanceMutex = Mutex.OpenExisting(RunningInstanceMutexName);
            }
            catch (WaitHandleCannotBeOpenedException)
            {
                bool created = false;
                RunningInstanceMutex = new Mutex(false, RunningInstanceMutexName, out created);
                if (!created)
                {
                    throw new Exception("Unable to create application mutex");
                }
            }

            // Load persistent data.
            try
            {
                PrivatePersistentData.LoadPersistentDataFromFile();
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred during a load operation.\n\n" + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            // Initialize localization.
            L10n.Initialize(PrivatePersistentData);
        }