Example #1
0
        private async Task UpdateMainWindowDialogModelAsync(MainWindowDialogModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            // modifying/replacing the ObservableCollection freezes the UI for a short time, do it only when its absolutely necessary
            if (!viewModel.Applications.SequenceEqual(_configurationService.Configuration.Applications, (oldItem, newItem) => oldItem.EntityId == newItem.Id))
            {
                viewModel.Applications.Clear();
                foreach (var applicationViewModel in CreateApplicationViewModels(viewModel))
                {
                    viewModel.Applications.Add(applicationViewModel);
                }
            }

            try
            {
                await Task.Run(() => _productService.RefreshInstalledProducts());
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception exception)
            {
                Log.Error("Getting installed products failed", exception);
            }
#pragma warning restore CA1031 // Do not catch general exception types

            await Task.WhenAll(viewModel.Applications.Select(async application => await UpdateViewModelAsync(application)));
        }
Example #2
0
        private void SaveMainWindowDialogModel(MainWindowDialogModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException(nameof(viewModel));
            }

            _configurationService.Configuration.SelectedTheme = viewModel.CurrentTheme;
            viewModel.IsDirty = false;
        }
Example #3
0
        private MainWindowDialogModel CreateMainWindowDialogModel(IViewModel?parent = null)
        {
            var viewModel = new MainWindowDialogModel(_themeService)
            {
                Parent = parent,
                Title  = Assembly.GetEntryAssembly().GetName().Name,
                RefreshApplicationsCommand          = new RefreshApplicationsCommand(this),
                AddApplicationCommand               = new AddApplicationCommand(_dialogService, this),
                ShowInfoDialogCommand               = new ShowInfoDialogCommand(_dialogService, this),
                ChangeThemeCommand                  = new ChangeThemeCommand(this),
                ShowRecentInstallationResultCommand = new ShowRecentInstallationResultCommand(_dialogService),
                ShowUpdateDialogCommand             = new ShowUpdateDialogCommand(_dialogService)
            };

            foreach (var application in CreateApplicationViewModels(viewModel))
            {
                viewModel.Applications.Add(application);
            }

            viewModel.IsDirty = false;
            return(viewModel);
        }
Example #4
0
        private async Task CheckForUpdate(IUpdateService updateService, INotificationService notificationService, MainWindowDialogModel mainDialogModel)
        {
            var updateResult = await updateService.IsUpdateAvailable();

            if (!updateResult.IsUpdateAvailable)
            {
                mainDialogModel.AvailableUpdate = null;
                return;
            }

            mainDialogModel.AvailableUpdate = _viewModelService.CreateViewModel <UpdateDialogModel>(mainDialogModel, updateResult);
            notificationService.ShowInfo(Strings.UpdateAvailableDescription, () =>
            {
                mainDialogModel.ShowUpdateDialogCommand.Execute(null);
            });
        }