diff --git a/Gavilya/ViewModels/ExecutableViewModel.cs b/Gavilya/ViewModels/ExecutableViewModel.cs index bccbc14..d5ba736 100644 --- a/Gavilya/ViewModels/ExecutableViewModel.cs +++ b/Gavilya/ViewModels/ExecutableViewModel.cs @@ -36,8 +36,8 @@ public class ExecutableViewModel : ViewModelBase public ICommand ClickCommand { get; } - public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel) - { + public ExecutableViewModel(string name, string filePath, GameEditionViewModel gameEditionViewModel) + { Name = name; FilePath = filePath; _gameEditionViewModel = gameEditionViewModel; diff --git a/Gavilya/ViewModels/GameEditionViewModel.cs b/Gavilya/ViewModels/GameEditionViewModel.cs index 2b1a26d..737aee1 100644 --- a/Gavilya/ViewModels/GameEditionViewModel.cs +++ b/Gavilya/ViewModels/GameEditionViewModel.cs @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE using Gavilya.Helpers; using Gavilya.Models; using Gavilya.Models.Rawg; +using Gavilya.Services; using Microsoft.Win32; using System; using System.Collections.Generic; @@ -163,6 +164,9 @@ public bool CanExecute private bool _isUwpOpen = false; public bool IsUwpOpen { get => _isUwpOpen; set { _isUwpOpen = value; OnPropertyChanged(nameof(IsUwpOpen)); } } + private bool _isExeSelectorOpen = false; + public bool IsExeSelectorOpen { get => _isExeSelectorOpen; set { _isExeSelectorOpen = value; OnPropertyChanged(nameof(IsExeSelectorOpen)); } } + private bool _isRawgOpen = false; public bool IsRawgOpen { get => _isRawgOpen; set { _isRawgOpen = value; OnPropertyChanged(nameof(IsRawgOpen)); } } @@ -194,6 +198,9 @@ public bool CanExecute private List _uwpApps; public List UwpApps { get => _uwpApps; set { _uwpApps = value; OnPropertyChanged(nameof(UwpApps)); } } + private List _exeApps; + public List ExeApps { get => _exeApps; set { _exeApps = value; OnPropertyChanged(nameof(ExeApps)); } } + private Visibility _dragAreaVis = Visibility.Collapsed; public Visibility DragAreaVis { get => _dragAreaVis; set { _dragAreaVis = value; OnPropertyChanged(nameof(DragAreaVis)); } } @@ -229,6 +236,8 @@ public bool CanExecute public ICommand ShowConvertSectionCommand { get; } public ICommand ProcessHelpCommand { get; } public ICommand DropCommand { get; } + public ICommand ScanCommand { get; } + public ICommand CloseExeSelectorCommand { get; } /// /// This constructor is used when editing an exisiting game. @@ -255,6 +264,7 @@ public GameEditionViewModel(Game game, GameList games, List tags, MainViewM ShowConvertSectionCommand = new RelayCommand(ShowConvert); ProcessHelpCommand = new RelayCommand(ShowProcessHelp); DropCommand = new RelayCommand(ExecuteDrop); + ScanCommand = new RelayCommand(Scan); // Load properties Name = game.Name; @@ -322,6 +332,7 @@ public GameEditionViewModel(GameType gameType, GameList games, List tags, M RawgSearchCommand = new RelayCommand(SearchRawg); ProcessHelpCommand = new RelayCommand(ShowProcessHelp); DropCommand = new RelayCommand(ExecuteDrop); + ScanCommand = new RelayCommand(Scan); SelectedTags = new(); @@ -483,4 +494,18 @@ private void ShowProcessHelp(object? obj) { MessageBox.Show(Properties.Resources.ProcessNameHelp, Properties.Resources.Help, MessageBoxButton.OK, MessageBoxImage.Information); } + + private void Scan(object? obj) + { + using System.Windows.Forms.FolderBrowserDialog dialog = new(); + System.Windows.Forms.DialogResult result = dialog.ShowDialog(); + + if (result == System.Windows.Forms.DialogResult.OK) + { + string selectedPath = dialog.SelectedPath; + GameScannerService gameScannerService = new(); + ExeApps = gameScannerService.ScanForExecutables(selectedPath, this); + IsExeSelectorOpen = true; + } + } } diff --git a/Gavilya/Views/GameEditionView.xaml b/Gavilya/Views/GameEditionView.xaml index fdb05e4..53fd895 100644 --- a/Gavilya/Views/GameEditionView.xaml +++ b/Gavilya/Views/GameEditionView.xaml @@ -86,13 +86,79 @@ +