Esempio n. 1
0
        public MainViewModel(IHasherService hasherService, IWatcherService watcherService, IDialogService dialogService, IArgumentService argumentService)
        {
            BrowseCommand  = new DelegateCommand <Window>(_BrowseAction);
            ResetCommand   = new DelegateCommand(_ResetAction);
            CancelCommand  = new DelegateCommand(_CancelAction);
            ComputeCommand = new DelegateCommand(_ComputeAction);

            _hasherService  = hasherService;
            _watcherService = watcherService;
            _dialogService  = dialogService;

            _hasherService.WorkerProgressChanged += _WorkerProgressChanged;
            _hasherService.WorkerRunCompleted    += _WorkerRunCompleted;

            _watcherService.WatcherFileDeleteEvent += _WatcherFileDeleteEvent;
            _watcherService.WatcherFileRenameEvent += _WatcherFileRenameEvent;

            HashName = argumentService.HashName ?? _hasherService.DefaultHasher;
            FilePath = argumentService.FilePath ?? "";

            if (CanCompute && argumentService.ComputeNow)
            {
                _ComputeAction(null);
            }
        }
        public ProjectExplorerViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IWatcherService watcherService,
            IModTools modTools
            ) : base(ToolTitle)
        {
            _projectManager = projectManager;
            _loggerService  = loggerService;
            _watcherService = watcherService;
            _modTools       = modTools;

            SetupCommands();
            SetupToolDefaults();

            _watcherService.Files
            .Connect()
            .ObserveOn(RxApp.MainThreadScheduler)
            .BindToObservableList(out _observableList)
            .Subscribe(OnNext);

            ExpandAll        = ReactiveCommand.Create(() => { });
            CollapseAll      = ReactiveCommand.Create(() => { });
            CollapseChildren = ReactiveCommand.Create(() => { });
            ExpandChildren   = ReactiveCommand.Create(() => { });

            this.WhenAnyValue(x => x.SelectedItem).Subscribe(model =>
            {
                if (model != null)
                {
                    Locator.Current.GetService <AppViewModel>().FileSelectedCommand.SafeExecute(model);
                }
            });
        }
Esempio n. 3
0
 public WardenController(IOrganizationService organizationService,
                         IWardenService wardenService, IWatcherService watcherService)
 {
     _organizationService = organizationService;
     _wardenService       = wardenService;
     _watcherService      = watcherService;
 }
Esempio n. 4
0
        public WatcherControlService(IWatcherService watcher)
        {
            _watcher     = watcher;
            _tokenSource = null;

            //? initial state, before `Start()` or `Stop()` called;
            IsLaunched = false;
        }
        /// <summary>
        /// Import Export ViewModel Constructor
        /// </summary>
        /// <param name="projectManager"></param>
        /// <param name="loggerService"></param>
        /// <param name="messageService"></param>
        /// <param name="watcherService"></param>
        /// <param name="gameController"></param>
        /// <param name="modTools"></param>
        public ImportExportViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IMessageService messageService,
            IWatcherService watcherService,
            IGrowlNotificationService notificationService,
            IGameControllerFactory gameController,
            ISettingsManager settingsManager,
            ModTools modTools
            ) : base(ToolTitle)
        {
            Argument.IsNotNull(() => projectManager);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => loggerService);
            Argument.IsNotNull(() => watcherService);
            Argument.IsNotNull(() => modTools);
            Argument.IsNotNull(() => gameController);
            Argument.IsNotNull(() => notificationService);
            Argument.IsNotNull(() => settingsManager);

            _projectManager      = projectManager;
            _loggerService       = loggerService;
            _messageService      = messageService;
            _watcherService      = watcherService;
            _modTools            = modTools;
            _gameController      = gameController;
            _notificationService = notificationService;
            _settingsManager     = settingsManager;

            SetupToolDefaults();

            ProcessAllCommand              = new TaskCommand(ExecuteProcessAll, CanProcessAll);
            ProcessSelectedCommand         = new TaskCommand(ExecuteProcessSelected, CanProcessSelected);
            CopyArgumentsTemplateToCommand = new DelegateCommand <string>(ExecuteCopyArgumentsTemplateTo, CanCopyArgumentsTemplateTo);
            SetCollectionCommand           = new DelegateCommand <string>(ExecuteSetCollection, CanSetCollection);
            ConfirmCollectionCommand       = new DelegateCommand <string>(ExecuteConfirmCollection, CanConfirmCollection);

            AddItemsCommand    = new DelegateCommand <ObservableCollection <object> >(ExecuteAddItems, CanAddItems);
            RemoveItemsCommand = new DelegateCommand <ObservableCollection <object> >(ExecuteRemoveItems, CanRemoveItems);

            _watcherService.Files
            .Connect()
            .Filter(_ => _.IsImportable)
            .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.RawDirectory))
            .Transform(_ => new ImportableItemViewModel(_))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _importableItems)
            .Subscribe();

            _watcherService.Files
            .Connect()
            .Filter(_ => _.IsExportable)
            .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.ModDirectory))
            .Transform(_ => new ExportableItemViewModel(_))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _exportableItems)
            .Subscribe();
        }
Esempio n. 6
0
        public static IApplicationBuilder UseBionicMonitor(
            this IApplicationBuilder app,
            IApplicationLifetime applicationLifetime
            )
        {
            var rootPath = Path.Combine(Directory.GetCurrentDirectory(), BionicMonitorOptions.DestinationRootDir);

            app.UseStaticFiles(new StaticFileOptions {
                FileProvider        = new PhysicalFileProvider(rootPath),
                ContentTypeProvider = CreateContentTypeProvider(),
                OnPrepareResponse   = SetCacheHeaders
            });

            app.MapWhen(IsNotFrameworkOrBionicDir, childAppBuilder => {
                var destinationDir    = Path.Combine(Directory.GetCurrentDirectory(), BionicMonitorOptions.DestinationRootDir);
                var staticFileOptions = new StaticFileOptions {
                    FileProvider      = new PhysicalFileProvider(destinationDir),
                    OnPrepareResponse = SetCacheHeaders
                };
                childAppBuilder.UseSpa(spa => spa.Options.DefaultPageStaticFileOptions = staticFileOptions);
            });

            var distPaths = new List <string>()
            {
                "3.1", "3.0", "2.1", "2.0"
            };
            var foundDistPath = false;

            distPaths.ForEach(netStdVersion => {
                var distPath = Path.Combine(Directory.GetCurrentDirectory(), $"bin/Debug/netstandard{netStdVersion}/dist");
                if (!Directory.Exists(distPath))
                {
                    return;
                }
                app.UseStaticFiles(new StaticFileOptions {
                    FileProvider        = new PhysicalFileProvider(distPath),
                    ContentTypeProvider = CreateContentTypeProvider(),
                    OnPrepareResponse   = SetCacheHeaders
                });
                foundDistPath = true;
            });

            if (!foundDistPath)
            {
                Console.WriteLine("💀 Bionic Monitor was unable to find a netstandard (3.1, 3.0, 2.1 or 2.0) build directory. Please build project and restart Bionic Monitor.");
            }

            app.UseSignalR(routes => routes.MapHub <ReloadHub>("/reloadHub"));

            app.UseMvc(routes => routes.MapRoute(name: "scripts", template: "{controller=Scripts}"));

            _watcherService = app.ApplicationServices.GetService <IWatcherService>();
            applicationLifetime.ApplicationStarted.Register(ApplicationStarted);

            return(app);
        }
        public ProjectExplorerViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IWatcherService watcherService,
            IProgressService <double> progressService,
            IModTools modTools,
            IGameControllerFactory gameController,
            IPluginService pluginService,
            ISettingsManager settingsManager
            ) : base(ToolTitle)
        {
            _projectManager  = projectManager;
            _loggerService   = loggerService;
            _watcherService  = watcherService;
            _modTools        = modTools;
            _progressService = progressService;
            _gameController  = gameController;
            _pluginService   = pluginService;
            _settingsManager = settingsManager;

            SideInDockedMode = DockSide.Left;

            SetupCommands();
            SetupToolDefaults();

            _watcherService.Files
            .Connect()
            .ObserveOn(RxApp.MainThreadScheduler)
            .BindToObservableList(out _observableList)
            .Subscribe(OnNext);

            ExpandAll        = ReactiveCommand.Create(() => { });
            CollapseAll      = ReactiveCommand.Create(() => { });
            CollapseChildren = ReactiveCommand.Create(() => { });
            ExpandChildren   = ReactiveCommand.Create(() => { });

            this.WhenAnyValue(x => x.SelectedItem).Subscribe(model =>
            {
                if (model != null)
                {
                    Locator.Current.GetService <AppViewModel>().FileSelectedCommand.SafeExecute(model);
                }
            });
        }
Esempio n. 8
0
        /// <summary>
        /// Import Export ViewModel Constructor
        /// </summary>
        /// <param name="projectManager"></param>
        /// <param name="loggerService"></param>
        /// <param name="messageService"></param>
        /// <param name="watcherService"></param>
        /// <param name="gameController"></param>
        /// <param name="modTools"></param>
        public ImportExportViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IProgressService <double> progressService,
            IWatcherService watcherService,
            INotificationService notificationService,
            IGameControllerFactory gameController,
            ISettingsManager settingsManager,
            IModTools modTools,
            MeshTools meshTools,
            IArchiveManager archiveManager
            ) : base(ToolTitle)
        {
            _projectManager      = projectManager;
            _loggerService       = loggerService;
            _progressService     = progressService;
            _watcherService      = watcherService;
            _modTools            = modTools;
            _gameController      = gameController;
            _notificationService = notificationService;
            _settingsManager     = settingsManager;
            _meshTools           = meshTools;
            _archiveManager      = archiveManager;

            SetupToolDefaults();
            SideInDockedMode = DockSide.Tabbed;

            ProcessAllCommand              = ReactiveCommand.CreateFromTask(ExecuteProcessAll);
            ProcessSelectedCommand         = ReactiveCommand.CreateFromTask(ExecuteProcessSelected);
            CopyArgumentsTemplateToCommand = new DelegateCommand <string>(ExecuteCopyArgumentsTemplateTo, CanCopyArgumentsTemplateTo);
            SetCollectionCommand           = new DelegateCommand <string>(ExecuteSetCollection, CanSetCollection);
            ConfirmCollectionCommand       = new DelegateCommand <string>(ExecuteConfirmCollection, CanConfirmCollection);

            AddItemsCommand    = new DelegateCommand <ObservableCollection <object> >(ExecuteAddItems, CanAddItems);
            RemoveItemsCommand = new DelegateCommand <ObservableCollection <object> >(ExecuteRemoveItems, CanRemoveItems);

            _watcherService.Files
            .Connect()
            .Filter(_ => _.IsImportable)
            .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.RawDirectory))
            .Filter(x => CheckForMultiImport(x))
            .Transform(_ => new ImportableItemViewModel(_))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _importableItems)
            .Subscribe();

            _watcherService.Files
            .Connect()
            .Filter(_ => _.IsExportable)
            .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.ModDirectory))
            .Transform(_ => new ExportableItemViewModel(_))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _exportableItems)
            .Subscribe();

            _watcherService.Files
            .Connect()
            .Filter(_ => _.IsConvertable)
            .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.RawDirectory))
            .Transform(_ => new ConvertableItemViewModel(_))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _convertableItems)
            .Subscribe();

            ////=> IsImportsSelected ? SelectedImport : IsExportsSelected ? SelectedExport : SelectedConvert;
            //this.WhenAnyValue(x => x.IsImportsSelected, y => y.IsExportsSelected, z => z.IsConvertsSelected)
            //    .Subscribe(b =>
            //{
            //    SelectedObject = IsImportsSelected ? SelectedImport : IsExportsSelected ? SelectedExport : SelectedConvert;
            //});


            this.WhenAnyValue(x => x.SelectedExport, y => y.SelectedImport, z => z.SelectedConvert)
            .Subscribe(b =>
            {
                var x = b.Item1;
                var y = b.Item2;
                var z = b.Item3;

                SelectedObject = IsImportsSelected ? SelectedImport : IsExportsSelected ? SelectedExport : SelectedConvert;
            });
        }
Esempio n. 9
0
 public WatcherController(IWatcherService watcherService, IOrganizationService organizationService)
 {
     _watcherService      = watcherService;
     _organizationService = organizationService;
 }
Esempio n. 10
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;
                //}
            });
        }
Esempio n. 11
0
 public WatchersController(IWatchersRepository watchersRepository, IWatcherService watcherService)
 {
     _watchersRepository = watchersRepository;
     _watcherService     = watcherService;
 }
Esempio n. 12
0
 public Worker(IWatcherService watcher)
 {
     _watcher = watcher;
 }
Esempio n. 13
0
 public WatcherConnections(IWatcherService watcherService, IWatchersRepository watchersRepository)
 {
     _watcherService     = watcherService;
     _watchersRepository = watchersRepository;
 }