private async void CP77ExecutablePathBtn_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var result = await _openFileService.DetermineFileAsync(new DetermineOpenFileContext()
            {
                Filter = "Exe files|*.exe"
            });

            if (result.Result)
            {
                _settingsManager.CP77ExecutablePath = result.FileName;
            }
        }
        protected override async Task ExecuteAsync(object parameter)
        {
            try
            {
                var location = parameter as string;

                if (string.IsNullOrWhiteSpace(location) || !_fileService.Exists(location))
                {
                    var result = await _openFileService.DetermineFileAsync(new DetermineOpenFileContext
                    {
                        Filter        = "Witcher 3 Project (*.w3modproj)|*.w3modproj| Cyberpunk 2077 Project | *.cpmodproj",
                        IsMultiSelect = false,
                        Title         = "Please select the Wolvenkit project you would like to open"
                    });

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

                if (!string.IsNullOrWhiteSpace(location))
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        await _projectManager.LoadAsync(location);
                    }
                }
            }
            catch (Exception)
            {
                // TODO: Are we intentionally swallowing this?
                //Log.Error(ex, "Failed to open file");
            }
        }
        /// <summary>
        /// Method to invoke when the SelectFile command is executed.
        /// </summary>
        private async Task OnSelectFileExecuteAsync()
        {
            var initialDirectory = GetInitialDirectory();

            if (!string.IsNullOrEmpty(initialDirectory))
            {
                _selectFileService.InitialDirectory = initialDirectory;
            }

            if (!string.IsNullOrEmpty(Filter))
            {
                _selectFileService.Filter = Filter;
            }

            if (await _selectFileService.DetermineFileAsync())
            {
                var oldSelectedFile = SelectedFile;

                SelectedFile = _selectFileService.FileName;

                // See here: https://github.com/WildGums/Orc.Controls/issues/13
                if (!AlwaysInvokeNotifyChanged &&
                    string.Equals(oldSelectedFile, SelectedFile))
                {
                    RaisePropertyChanged(nameof(SelectedFile));
                }
            }
        }
Exemplo n.º 4
0
 private async Task OnOpenExecuteAsync()
 {
     if (await _openFileService.DetermineFileAsync())
     {
         _recentlyUsedItemsService.AddItem(new RecentlyUsedItem(_openFileService.FileName, DateTime.Now));
     }
 }
        protected override async Task ExecuteAsync(object parameter)
        {
            string downloadsPath = new KnownFolder(KnownFolderType.Downloads).Path;

            _openFileService.InitialDirectory = downloadsPath;
            _openFileService.Filter           = "License Files (*.lic)|*.lic";
            _openFileService.FilterIndex      = 1;

            if (await _openFileService.DetermineFileAsync())
            {
                //Get the path of specified file
                var filePath = _openFileService.FileName;

                var validationErrors = _licenseService.UpdateLicense(filePath);

                if (validationErrors.Any())
                {
                    Collection <string> errors = new Collection <string>();

                    errors.Add("The License is not valid!" + Environment.NewLine);
                    foreach (var validationError in validationErrors)
                    {
                        errors.Add($"{validationError.Message}");
                    }

                    await _messageService.ShowErrorAsync(String.Join(Environment.NewLine, errors));
                }
            }
        }
Exemplo n.º 6
0
        protected override async Task ExecuteAsync(object parameter)
        {
            try
            {
                var location = parameter as string;

                if (string.IsNullOrWhiteSpace(location) || !_fileService.Exists(location))
                {
                    _openFileService.Filter        = "Text Files (*.csv)|*csv";
                    _openFileService.IsMultiSelect = false;

                    if (await _openFileService.DetermineFileAsync())
                    {
                        location = _openFileService.FileName;
                    }
                }

                if (!string.IsNullOrWhiteSpace(location))
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        await _projectManager.LoadAsync(location);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to open file");
            }
        }
Exemplo n.º 7
0
        private async Task OpenCsvFileAsync()
        {
            try
            {
                string location = string.Empty;

                _openFileService.Filter        = "Text Files (*.csv)|*csv";
                _openFileService.IsMultiSelect = false;

                if (await _openFileService.DetermineFileAsync())
                {
                    location = _openFileService.FileName;
                }

                if (!string.IsNullOrWhiteSpace(location))
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        await _projectManager.LoadAsync(location);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to open file");
            }
        }
        private async Task OnLoadProjectExecuteAsync()
        {
            _openFileService.InitialDirectory = Path.Combine(Environment.CurrentDirectory, "Data");
            _openFileService.Filter           = TextFilter;

            if (await _openFileService.DetermineFileAsync())
            {
                await _projectManager.LoadAsync(_openFileService.FileName).ConfigureAwait(false);
            }
        }
Exemplo n.º 9
0
        private async Task PickEditorExecuteAsync()
        {
            _openFileService.Filter        = "Program Files (*.exe)|*exe";
            _openFileService.IsMultiSelect = false;

            if (await _openFileService.DetermineFileAsync())
            {
                CustomEditor = _openFileService.FileName;
            }
        }
Exemplo n.º 10
0
        private async Task OnOpenNKSFileExecute()
        {
            try
            {
                _openFileService.Filter        = "NKS Files (*.nksf,*.nksfx)|*.nksf;*.nksfx";
                _openFileService.IsMultiSelect = false;

                if (await _openFileService.DetermineFileAsync())
                {
                    ApplyControllerMapping(_openFileService.FileName);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to open file");
            }
        }
        private async Task OnLoadBankChunkExecute()
        {
            try
            {
                _openFileService.Filter        = "Binary Files (*.*)|*.*";
                _openFileService.IsMultiSelect = false;

                if (await _openFileService.DetermineFileAsync())
                {
                    PluginInstance.SetChunk(File.ReadAllBytes(_openFileService.FileName), false);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to open file");
            }
        }
Exemplo n.º 12
0
        private async Task OnOpenNKSFFileExecute()
        {
            try
            {
                _openFileService.Filter        = "NKS Files (*.nksf,*.nksfx)|*.nksf;*.nksfx";
                _openFileService.IsMultiSelect = false;

                if (await _openFileService.DetermineFileAsync())
                {
                    filePath = _openFileService.FileName;

                    OnParseNKSFFileExecute();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to open file");
            }
        }
Exemplo n.º 13
0
        protected override async Task ExecuteAsync(object parameter)
        {
            try
            {
                var location = parameter as string;

                if (string.IsNullOrWhiteSpace(location) || !_fileService.Exists(location))
                {
                    var result = await _openFileService.DetermineFileAsync(new DetermineOpenFileContext
                    {
                        Filter        = "Cyberpunk 2077 Project | *.cpmodproj|Witcher 3 Project (*.w3modproj)|*.w3modproj",
                        IsMultiSelect = false,
                        Title         = "Please select the WolvenKit project you would like to open."
                    });

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

                if (!string.IsNullOrWhiteSpace(location))
                {
                    using (_pleaseWaitService.PushInScope())
                    {
                        StaticReferences.MainView.OnLoadLayoutAsync();

                        await _projectManager.LoadAsync(location);

                        var btn = StaticReferences.GlobalShell.FindName("ProjectNameDisplay") as System.Windows.Controls.Button;
                        btn?.SetCurrentValue(ContentControl.ContentProperty, Path.GetFileNameWithoutExtension(location));
                        ;
                    }
                }
                RibbonViewModel.GlobalRibbonVM.StartScreenShown = false;
                RibbonViewModel.GlobalRibbonVM.BackstageIsOpen  = false;
            }
            catch (Exception)
            {
                // TODO: Are we intentionally swallowing this?
                //Log.Error(ex, "Failed to open file");
            }
        }
Exemplo n.º 14
0
        private async Task PublishProjectExecuteAsync()
        {
            var dofc = new DetermineOpenFileContext()
            {
                Filter        = "WolvenKit Package | *.wkp | Zip file | *.zip",
                IsMultiSelect = false,
                Title         = "Please select where to save the WolvenKit package."
            };
            var result = await _openFileService.DetermineFileAsync(dofc);

            if (result.Result)
            {
                //result.DirectoryName;
                await _gameControllerFactory.GetController().PackAndInstallProject();

                await _gameControllerFactory.GetController().PackageMod();

                var host = ServiceLocator.Default.ResolveType <UserControlHostWindowViewModel>();
                host?.CloseViewModelAsync(true);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Method to invoke when the SelectFile command is executed.
        /// </summary>
        private async Task OnSelectFileExecuteAsync()
        {
            string initialDirectory = null;
            string fileName         = null;
            string filter           = null;

            if (!string.IsNullOrEmpty(SelectedFile))
            {
                initialDirectory = Directory.GetParent(SelectedFile).FullName;
                fileName         = SelectedFile;
            }

            if (!string.IsNullOrEmpty(Filter))
            {
                filter = Filter;
            }

            var result = await _openFileService.DetermineFileAsync(new DetermineOpenFileContext
            {
                InitialDirectory = initialDirectory,
                FileName         = fileName,
                Filter           = filter,
            });

            if (result.Result)
            {
                var oldSelectedFile = SelectedFile;

                SelectedFile = result.FileName;

                // See here: https://github.com/WildGums/Orc.Controls/issues/13
                if (!AlwaysInvokeNotifyChanged &&
                    string.Equals(oldSelectedFile, SelectedFile))
                {
                    RaisePropertyChanged(nameof(SelectedFile));
                }
            }
        }
        protected override async Task ExecuteAsync(object parameter)
        {
            var location = parameter as string;

            // switch from one active project to another

            if (_projectManager.ActiveProject != null && !string.IsNullOrEmpty(location))
            {
                if (_projectManager.ActiveProject.Location == location)
                {
                    return;
                }
            }

            try
            {
                if (string.IsNullOrWhiteSpace(location) || !File.Exists(location))
                {
                    // file was moved or deleted
                    if (_recentlyUsedItemsService.Items.Items.Any(_ => _.Name == location))
                    {
                        // would you like to locate it?
                        location = await ProjectHelpers.LocateMissingProjectAsync(location);

                        if (string.IsNullOrEmpty(location))
                        {
                            // user canceled locating a project
                            return;
                        }
                    }
                    // open an existing project
                    else
                    {
                        var result = await _openFileService.DetermineFileAsync(new DetermineOpenFileContext
                        {
                            Filter        = "Cyberpunk 2077 Project | *.cpmodproj|Witcher 3 Project (*.w3modproj)|*.w3modproj",
                            IsMultiSelect = false,
                            Title         = "Please select the WolvenKit project you would like to open."
                        });

                        if (!result.Result)
                        {
                            // user canceled locating a project
                            return;
                        }

                        location = result.FileName;
                    }
                }

                // one last check
                if (!File.Exists(location))
                {
                    return;
                }

                RibbonViewModel.GlobalRibbonVM.StartScreenShown = false;
                RibbonViewModel.GlobalRibbonVM.BackstageIsOpen  = false;

                // if a valid location has been set
                //using (_pleaseWaitService.PushInScope())
                {
                    await _projectManager.LoadAsync(location);

                    switch (Path.GetExtension(location))
                    {
                    case ".w3modproj":
                        await _tw3Controller.HandleStartup().ContinueWith(t =>
                        {
                            _notificationService.Success(
                                "Project " + Path.GetFileNameWithoutExtension(location) +
                                " loaded!");
                        }, TaskContinuationOptions.OnlyOnRanToCompletion);

                        break;

                    case ".cpmodproj":
                        await _cp77Controller.HandleStartup().ContinueWith(
                            t =>
                        {
                            _notificationService.Success("Project " +
                                                         Path.GetFileNameWithoutExtension(location) +
                                                         " loaded!");
                        },
                            TaskContinuationOptions.OnlyOnRanToCompletion);

                        break;

                    default:
                        break;
                    }

                    //TODO:ORC
                    //if (StaticReferences.GlobalShell != null)
                    //{
                    //    StaticReferences.GlobalShell.SetCurrentValue(System.Windows.Window.TitleProperty, Path.GetFileNameWithoutExtension(location));
                    //}

                    StaticReferencesVM.GlobalStatusBar.CurrentProject = Path.GetFileNameWithoutExtension(location);
                }
            }
            catch (Exception)
            {
                // TODO: Are we intentionally swallowing this?
                //Log.Error(ex, "Failed to open file");
            }
        }