示例#1
0
        public InstallSelectorWindow(InstallSelectorWindowViewModel viewModel, UpdateChecker.UpdateInformation updateInformation)
        {
            _UpdateInformation = updateInformation;

            InitializeComponent();

            _ViewModel  = viewModel;
            DataContext = _ViewModel;
        }
        public InstallSelectorWindow()
        {
            InitializeComponent();

            _ViewModel  = new InstallSelectorWindowViewModel();
            DataContext = _ViewModel;

            _ViewModel.SelectedPath = Properties.Settings.Default.LastSelectedInstallLocation;

            if (_ViewModel.SelectedPathContainsPSO2Bin)
            {
                _OpenMainWindow();
            }
        }
示例#3
0
        private async void _Application_Startup(object sender, StartupEventArgs e)
        {
            var astraAlreadyRunning = Process.GetProcesses().Any(p => p.ProcessName == Process.GetCurrentProcess().ProcessName&& p.Id != Process.GetCurrentProcess().Id);

            if (astraAlreadyRunning)
            {
                MessageBox.Show(
                    LocaleManager.Instance["Astra_InstanceAlreadyRunning_WindowMessage"],
                    LocaleManager.Instance["PSRTAstra"]);
                Shutdown();
                return;
            }

            await Task.Run(async() => await _DeleteOldExecutableAsync());

            var updateInfo = await _CheckForUpdateAsync();

            if (updateInfo.ShouldUpdate)
            {
                var shouldRunAstra = await _UpdateClientAsync(updateInfo.UpdateInformation);

                if (!shouldRunAstra)
                {
                    Shutdown();
                    return;
                }
            }

            // check if the last path is remembered and valid
            var installSelectorWindowViewModel = new InstallSelectorWindowViewModel();

            installSelectorWindowViewModel.SelectedPath = Settings.Default.LastSelectedInstallLocation;
            if (installSelectorWindowViewModel.SelectedPathContainsPSO2Bin)
            {
                Logger.Info(nameof(App), "Last selected install location is valid, opening main window");
                var mainWindow = new MainWindow(Path.Combine(installSelectorWindowViewModel.SelectedPath, "pso2_bin"), updateInfo.UpdateInformation);
                mainWindow.Show();
            }
            else
            {
                Logger.Info(nameof(App), "No valid last selected install location, opening install selection window");
                var installSelectionWindow = new InstallSelectorWindow(installSelectorWindowViewModel, updateInfo.UpdateInformation);
                installSelectionWindow.Show();
            }
        }