Esempio n. 1
0
        private async Task CheckForUpdates()
        {
            // 1 API call
            if (!(await _autoInstallerService.CheckForUpdate())
                .Out(out var release))
            {
                _loggerService.Info($"Is update available: {release != null}");
                return;
            }

            _loggerService.Success($"Update available: {release.TagName}");
            Settings.IsUpdateAvailable = true;

            var result = await Interactions.ShowMessageBoxAsync("An update is ready to install for WolvenKit. Exit the app and install it?", "Update available");

            switch (result)
            {
            case WMessageBoxResult.OK:
            case WMessageBoxResult.Yes:
                if (await _autoInstallerService.Update())     // 1 API call
                {
                }
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public AppViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IGameControllerFactory gameControllerFactory,
            ISettingsManager settingsManager,
            INotificationService notificationService,
            IRecentlyUsedItemsService recentlyUsedItemsService,
            IProgressService <double> progressService,
            IWatcherService watcherService,
            AutoInstallerService autoInstallerService
            )
        {
            _projectManager           = projectManager;
            _loggerService            = loggerService;
            _gameControllerFactory    = gameControllerFactory;
            _settingsManager          = settingsManager;
            _notificationService      = notificationService;
            _recentlyUsedItemsService = recentlyUsedItemsService;
            _progressService          = progressService;
            _watcherService           = watcherService;
            _autoInstallerService     = autoInstallerService;

            _homePageViewModel = Locator.Current.GetService <HomePageViewModel>();

            #region commands

            ShowLogCommand             = new RelayCommand(ExecuteShowLog, CanShowLog);
            ShowProjectExplorerCommand = new RelayCommand(ExecuteShowProjectExplorer, CanShowProjectExplorer);
            //ShowImportUtilityCommand = new RelayCommand(ExecuteShowImportUtility, CanShowImportUtility);
            ShowPropertiesCommand = new RelayCommand(ExecuteShowProperties, CanShowProperties);
            ShowAssetsCommand     = new RelayCommand(ExecuteAssetBrowser, CanShowAssetBrowser);
            //ShowVisualEditorCommand = new RelayCommand(ExecuteVisualEditor, CanShowVisualEditor);
            //ShowAudioToolCommand = new RelayCommand(ExecuteAudioTool, CanShowAudioTool);
            //ShowVideoToolCommand = new RelayCommand(ExecuteVideoTool, CanShowVideoTool);
            //ShowCodeEditorCommand = new RelayCommand(ExecuteCodeEditor, CanShowCodeEditor);

            ShowImportExportToolCommand = new RelayCommand(ExecuteImportExportTool, CanShowImportExportTool);
            //ShowPackageInstallerCommand = new RelayCommand(ExecuteShowInstaller, CanShowInstaller);

            ShowPluginCommand = new RelayCommand(ExecuteShowPlugin, CanShowPlugin);

            OpenFileCommand         = new DelegateCommand <FileModel>(p => ExecuteOpenFile(p), CanOpenFile);
            OpenFileAsyncCommand    = ReactiveCommand.CreateFromTask <FileModel, Unit>(OpenFileAsync);
            OpenRedFileAsyncCommand = ReactiveCommand.CreateFromTask <FileEntry, Unit>(OpenRedFileAsync);

            var canExecute = this.WhenAny(x => x._projectManager.ActiveProject, (p) => p != null);
            PackModCommand        = ReactiveCommand.CreateFromTask(ExecutePackMod, canExecute);
            PackInstallModCommand = ReactiveCommand.CreateFromTask(ExecutePackInstallMod, canExecute);
            //BackupModCommand = new RelayCommand(ExecuteBackupMod, CanBackupMod);
            //PublishModCommand = new RelayCommand(ExecutePublishMod, CanPublishMod);

            NewFileCommand  = new DelegateCommand <string>(ExecuteNewFile, CanNewFile);
            SaveFileCommand = new RelayCommand(ExecuteSaveFile, CanSaveFile);
            SaveAsCommand   = new RelayCommand(ExecuteSaveAs, CanSaveFile);
            SaveAllCommand  = new RelayCommand(ExecuteSaveAll, CanSaveAll);

            FileSelectedCommand = new DelegateCommand <FileModel>(async(p) => await ExecuteSelectFile(p), CanSelectFile);

            OpenProjectCommand   = ReactiveCommand.CreateFromTask <string, Unit>(OpenProjectAsync);
            DeleteProjectCommand = ReactiveCommand.Create <string>(DeleteProject);
            NewProjectCommand    = ReactiveCommand.Create(ExecuteNewProject);

            ShowHomePageCommand = new RelayCommand(ExecuteShowHomePage, CanShowHomePage);
            ShowSettingsCommand = new RelayCommand(ExecuteShowSettings, CanShowSettings);

            CloseModalCommand   = new RelayCommand(ExecuteCloseModal, CanCloseModal);
            CloseOverlayCommand = new RelayCommand(ExecuteCloseOverlay, CanCloseOverlay);
            CloseDialogCommand  = new RelayCommand(ExecuteCloseDialog, CanCloseDialog);


            OpenFileAsyncCommand.ThrownExceptions.Subscribe(ex => LogExtended(ex));
            OpenRedFileAsyncCommand.ThrownExceptions.Subscribe(ex => LogExtended(ex));
            PackModCommand.ThrownExceptions.Subscribe(ex => LogExtended(ex));
            PackInstallModCommand.ThrownExceptions.Subscribe(ex => LogExtended(ex));
            OpenProjectCommand.ThrownExceptions.Subscribe(ex => LogExtended(ex));

            #endregion commands

            UpdateTitle();

            if (!TryLoadingArguments())
            {
                SetActiveOverlay(_homePageViewModel);
            }

            OnStartup();

            DockedViews = new ObservableCollection <IDockElement> {
                Log,
                ProjectExplorer,
                PropertiesViewModel,
                AssetBrowserVM,
                ImportExportToolVM,
            };


            _settingsManager
            .WhenAnyValue(x => x.UpdateChannel)
            .Subscribe(async x =>
            {
                _autoInstallerService.UseChannel(x.ToString());

                // 1 API call
                if (!(await _autoInstallerService.CheckForUpdate())
                    .Out(out var release))
                {
                    return;
                }

                if (release.TagName.Equals(_settingsManager.GetVersionNumber()))
                {
                    return;
                }

                _settingsManager.IsUpdateAvailable = true;
                _loggerService.Success($"Update available: {release.TagName}");

                //var result = await Interactions.ShowMessageBoxAsync("An update is available for WolvenKit. Exit the app and install it?", "Update available");
                //switch (result)
                //{
                //    case WMessageBoxResult.OK:
                //    case WMessageBoxResult.Yes:
                //        if (await _autoInstallerService.Update()) // 1 API call
                //        {

                //        }
                //        break;
                //}
            });
        }