private void Initialize()
 {
     commandExecutor.Initialize(commandsToExecute);
     commandExecutor.OnCommandStartedExecution += (c) => OnCommandStartedExecution?.Invoke(c);
     commandExecutor.OnCommandCompleted        += (c) => OnCommandCompleted?.Invoke(c);
     commandExecutor.OnCommandFailed           += (c, e) => OnCommandFailed?.Invoke(c, e);
     commandExecutor.OnCommandProgressChanged  += (c, p) => OnCommandProgressChanged?.Invoke(c, p);
     commandExecutor.OnAllCompleted            += (wasErrors) => OnLoadingCompleted?.Invoke();
 }
コード例 #2
0
        protected override async void Execute(object parameter)
        {
            try
            {
                var location = parameter as string;
                var filter   = "Witcher 3 Project (*.w3modproj)|*.w3modproj| Cyberpunk 2077 Project (*.cpmodproj)|*.cpmodproj";
                if (location == null && parameter is ProjectWizardModel.TypeAndPath)
                {
                    var res = parameter as ProjectWizardModel.TypeAndPath;
                    location = res.Path;
                    if (res.Type == ProjectWizardModel.WitcherGameName)
                    {
                        filter = "Witcher 3 Project (*.w3modproj)|*.w3modproj";
                    }
                    else if (res.Type == ProjectWizardModel.CyberpunkGameName)
                    {
                        filter = "Cyberpunk 2077 Project (*.cpmodproj)|*.cpmodproj";
                    }
                }

                var result = await _saveFileService.DetermineFileAsync(new DetermineSaveFileContext()
                {
                    Filter           = filter,
                    Title            = "Please select a location to save your WolvenKit project",
                    InitialDirectory = location,
                });

                if (result.Result)
                {
                    location = result.FileName;
                }

                if (!string.IsNullOrWhiteSpace(location) && result.Result)
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        switch (Path.GetExtension(location))
                        {
                        case ".w3modproj":
                        {
                            var np = new Tw3Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new W3Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        case ".cpmodproj":
                        {
                            var np = new Cp77Project(location)
                            {
                                Name = Path.GetFileNameWithoutExtension(location),
                                Data = new CP77Mod()
                                {
                                    FileName = location,
                                    Name     = Path.GetFileNameWithoutExtension(location),
                                    Author   = "WolvenKit",
                                    Email    = "",
                                    Version  = "1.0"
                                }
                            };
                            np.Save(location);
                            np.CreateDefaultDirectories();
                            break;
                        }

                        default:
                            _loggerService.LogString("Invalid project path!", Logtype.Error);
                            break;
                        }
                    }
                    await _projectManager.LoadAsync(location);
                }
            }
            catch (Exception ex)
            {
                _loggerService.LogString(ex.Message, Logtype.Error);
                _loggerService.LogString("Failed to create a new project!", Logtype.Error);
            }

            OnCommandCompleted?.Invoke();
        }
コード例 #3
0
 private void OnCommandCompletedHandler()
 {
     UnsubscribeCommand(Current);
     OnCommandCompleted?.Invoke(Current);
     StartExecution();
 }