/// <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();
        }
Ejemplo n.º 2
0
        public MaterialsRepositoryDialog()
        {
            InitializeComponent();

            _settingsManager       = ServiceLocator.Default.ResolveType <ISettingsManager>();
            _gameControllerFactory = ServiceLocator.Default.ResolveType <IGameControllerFactory>();
            _modTools      = ServiceLocator.Default.ResolveType <ModTools>();
            _progress      = ServiceLocator.Default.ResolveType <IProgressService <double> >();
            _loggerService = ServiceLocator.Default.ResolveType <ILoggerService>();

            _archivesFolderPath = Path.Combine(_settingsManager.GetRED4GameRootDir(), "archive", "pc", "content");
            MaterialsDepotPath  = _settingsManager.MaterialRepositoryPath;
            MaterialsTextBox.SetCurrentValue(System.Windows.Controls.TextBox.TextProperty, _settingsManager.MaterialRepositoryPath);
        }
Ejemplo n.º 3
0
        private DocumentViewModel()
        {
            State = DockState.Document;


            _gameControllerFactory = ServiceLocator.Default.ResolveType <IGameControllerFactory>();
            _projectManager        = ServiceLocator.Default.ResolveType <IProjectManager>();
            _modTools             = ServiceLocator.Default.ResolveType <ModTools>();
            _wolvenkitFileService = ServiceLocator.Default.ResolveType <Red4ParserService>();

            IsDirty = false;

            OpenEditorCommand = new RelayCommand(ExecuteOpenEditor);
            OpenBufferCommand = new RelayCommand(ExecuteOpenBuffer);
            OpenImportCommand = new DelegateCommand <ICR2WImport>(ExecuteOpenImport);

            OpenImportCommand = new RelayCommand(ExecuteViewImports, CanViewImports);
        }
        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);
                }
            });
        }
Ejemplo n.º 5
0
        public FinalizeSetupViewModel(
            IServiceLocator serviceLocator,
            IProjectManager projectManager,
            IOpenFileService openFileService,
            IGameControllerFactory gameControllerFactory
            )
        {
            Argument.IsNotNull(() => serviceLocator);
            Argument.IsNotNull(() => projectManager);
            Argument.IsNotNull(() => openFileService);

            _projectManager        = projectManager;
            _gameControllerFactory = gameControllerFactory;
            _openFileService       = openFileService;

            PublishWizardModel = serviceLocator.ResolveType <PublishWizardModel>();

            PublishProject = new TaskCommand(PublishProjectExecuteAsync);
            Cancel         = new TaskCommand(CancelExecuteAsync);
        }
Ejemplo n.º 6
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;
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public WorkSpaceViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IMessageService messageService,
            ICommandManager commandManager,
            IGameControllerFactory gameControllerFactory
            )
        {
            #region dependency injection

            _projectManager        = projectManager;
            _loggerService         = loggerService;
            _messageService        = messageService;
            _gameControllerFactory = gameControllerFactory;

            #endregion dependency injection

            #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);
            ShowBulkEditorCommand      = new RelayCommand(ExecuteBulkEditor, CanShowBulkEditor);
            ShowCsvEditorCommand       = new RelayCommand(ExecuteCsvEditor, CanShowCsvEditor);
            ShowJournalEditorCommand   = new RelayCommand(ExecuteJournalEditor, CanShowJournalEditor);
            ShowVisualEditorCommand    = new RelayCommand(ExecuteVisualEditor, CanShowVisualEditor);
            ShowAnimationToolCommand   = new RelayCommand(ExecuteAnimationTool, CanShowAnimationTool);
            ShowMimicsToolCommand      = new RelayCommand(ExecuteMimicsTool, CanShowMimicsTool);
            //ShowAudioToolCommand = new RelayCommand(ExecuteAudioTool, CanShowAudioTool);
            ShowVideoToolCommand  = new RelayCommand(ExecuteVideoTool, CanShowVideoTool);
            ShowCodeEditorCommand = new RelayCommand(ExecuteCodeEditor, CanShowCodeEditor);

            ShowImportExportToolCommand = new RelayCommand(ExecuteImportExportTool, CanShowImportExportTool);

            ShowImporterToolCommand     = new RelayCommand(ExecuteImporterTool, CanShowImporterTool);
            ShowCR2WToTextToolCommand   = new RelayCommand(ExecuteCR2WToTextTool, CanShowCR2WToTextTool);
            ShowGameDebuggerToolCommand = new RelayCommand(ExecuteGameDebuggerTool, CanShowGameDebuggerTool);
            ShowMenuCreatorToolCommand  = new RelayCommand(ExecuteMenuCreatorTool, CanShowMenuCreatorTool);
            ShowPluginManagerCommand    = new RelayCommand(ExecutePluginManagerTool, CanShowPluginManagerTool);
            ShowWccToolCommand          = new RelayCommand(ExecuteWccTool, CanShowWccTool);

            ShowPackageInstallerCommand = new RelayCommand(ExecuteShowInstaller, CanShowInstaller);

            OpenFileCommand = new DelegateCommand <FileModel>(async(p) => await ExecuteOpenFile(p), CanOpenFile);
            NewFileCommand  = new RelayCommand(ExecuteNewFile, CanNewFile);

            PackModCommand    = new RelayCommand(ExecutePackMod, CanPackMod);
            BackupModCommand  = new RelayCommand(ExecuteBackupMod, CanBackupMod);
            PublishModCommand = new RelayCommand(ExecutePublishMod, CanPublishMod);

            SaveFileFileCommand = new RelayCommand(ExecuteSaveFile, CanSaveFile);
            SaveAllCommand      = new RelayCommand(ExecuteSaveAll, CanSaveAll);

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

            // register as application-wide commands
            RegisterCommands(commandManager);

            #endregion commands

            Tools = new ObservableCollection <IDockElement> {
                Log,
                ProjectExplorer,
                PropertiesViewModel,
                AssetBrowserVM,
                ImportExportToolVM,

                ImportViewModel,
                BulkEditorVM,
                CsvEditorVM,
                //CodeEditorVM,
                JournalEditorVM,
                VisualEditorVM,
                AnimationToolVM,
                //AudioToolVM,
                ImporterToolVM,
                CR2WToTextToolVM,
                GameDebuggerToolVM,
                MenuCreatorToolVM,
                PluginManagerVM,
                WccToolVM,
                MimicsToolVM,
            };
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public AppViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IGameControllerFactory gameControllerFactory,
            IUpdateService updateService,
            ISettingsManager settingsManager,
            INotificationService notificationService,
            IRecentlyUsedItemsService recentlyUsedItemsService
            )
        {
            _updateService            = updateService;
            _projectManager           = projectManager;
            _loggerService            = loggerService;
            _gameControllerFactory    = gameControllerFactory;
            _settingsManager          = settingsManager;
            _notificationService      = notificationService;
            _recentlyUsedItemsService = recentlyUsedItemsService;

            #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);

            OpenFileCommand = new DelegateCommand <FileModel>(async(p) => await ExecuteOpenFile(p), CanOpenFile);

            PackModCommand = new RelayCommand(ExecutePackMod, CanPackMod);
            //BackupModCommand = new RelayCommand(ExecuteBackupMod, CanBackupMod);
            //PublishModCommand = new RelayCommand(ExecutePublishMod, CanPublishMod);

            NewFileCommand  = new DelegateCommand <string>(ExecuteNewFile, CanNewFile);
            SaveFileCommand = new RelayCommand(ExecuteSaveFile, 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.CreateFromTask(NewProjectAsync);

            #endregion commands

            OnStartup();

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

            _settingsManager
            .WhenAnyValue(x => x.UpdateChannel)
            .Subscribe(_ =>
            {
                _updateService.SetUpdateChannel((WolvenManager.Installer.Models.EUpdateChannel)_settingsManager.UpdateChannel);
                Task.Run(() => _updateService.CheckForUpdatesAsync());
            });
        }
Ejemplo n.º 9
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;
                //}
            });
        }
Ejemplo n.º 10
0
        public AssetBrowserViewModel(
            IProjectManager projectManager,
            INotificationService notificationService,
            IGameControllerFactory gameController,
            IArchiveManager archiveManager,
            ISettingsManager settings,
            IProgressService <double> progressService
            ) : base(ToolTitle)
        {
            _projectManager      = projectManager;
            _notificationService = notificationService;
            _gameController      = gameController;
            _archiveManager      = archiveManager;
            _settings            = settings;
            _progressService     = progressService;

            ContentId = ToolContentId;

            TogglePreviewCommand      = new RelayCommand(ExecuteTogglePreview, CanTogglePreview);
            OpenFileSystemItemCommand = new RelayCommand(ExecuteOpenFile, CanOpenFile);
            AddSelectedCommand        = new RelayCommand(ExecuteAddSelected, CanAddSelected);
            ToggleModBrowserCommand   = new RelayCommand(ExecuteToggleModBrowser, CanToggleModBrowser);
            OpenFileLocationCommand   = new RelayCommand(ExecuteOpenFileLocationCommand, CanOpenFileLocationCommand);

            ExpandAll   = ReactiveCommand.Create(() => { });
            CollapseAll = ReactiveCommand.Create(() => { });
            Collapse    = ReactiveCommand.Create(() => { });
            Expand      = ReactiveCommand.Create(() => { });

            AddSearchKeyCommand = ReactiveCommand.Create <string>(x => SearchBarText += $" {x}:");
            FindUsingCommand    = ReactiveCommand.CreateFromTask(FindUsing);

            archiveManager.ConnectGameRoot()
            .ObserveOn(RxApp.MainThreadScheduler)
            .Bind(out _boundRootNodes)
            .Subscribe(
                _ =>
            {
                // binds only the root node
                LeftItems = new ObservableCollection <RedFileSystemModel>(_boundRootNodes);
            });

            _archiveManager
            .WhenAnyValue(x => x.IsManagerLoaded)
            .Subscribe(loaded =>
            {
                LoadVisibility = loaded ? Visibility.Collapsed : Visibility.Visible;
                if (loaded)
                {
                    _notificationService.Success($"Asset Browser is initialized");
                    NoProjectBorderVisibility = Visibility.Collapsed;
                }
            });
            _projectManager
            .WhenAnyValue(_ => _.IsProjectLoaded)
            .Subscribe(loaded =>
            {
                NoProjectBorderVisibility = loaded ? Visibility.Collapsed : Visibility.Visible;
            });


            Classes = _gameController
                      .GetController()
                      .GetAvaliableClasses();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public WorkSpaceViewModel(
            IProjectManager projectManager,
            ILoggerService loggerService,
            IMessageService messageService,
            ICommandManager commandManager,
            IGameControllerFactory gameControllerFactory,
            IUpdateService updateService
            )
        {
            _updateService         = updateService;
            _projectManager        = projectManager;
            _loggerService         = loggerService;
            _messageService        = messageService;
            _gameControllerFactory = gameControllerFactory;

            #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);

            OpenFileCommand = new DelegateCommand <FileModel>(async(p) => await ExecuteOpenFile(p), CanOpenFile);
            NewFileCommand  = new RelayCommand(ExecuteNewFile, CanNewFile);

            PackModCommand    = new RelayCommand(ExecutePackMod, CanPackMod);
            BackupModCommand  = new RelayCommand(ExecuteBackupMod, CanBackupMod);
            PublishModCommand = new RelayCommand(ExecutePublishMod, CanPublishMod);

            SaveFileFileCommand = new RelayCommand(ExecuteSaveFile, CanSaveFile);
            SaveAllCommand      = new RelayCommand(ExecuteSaveAll, CanSaveAll);

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

            // register as application-wide commands
            RegisterCommands(commandManager);

            #endregion commands

            Tools = new ObservableCollection <IDockElement> {
                Log,
                ProjectExplorer,
                PropertiesViewModel,
                AssetBrowserVM,
                ImportExportToolVM,

                ImportViewModel,
                //CodeEditorVM,
                //VisualEditorVM,
            };

            OnStartup();
        }