bloxstrap/Bloxstrap/UI/ViewModels/Menu/InstallationViewModel.cs
pizzaboxer 8bbad57eb3
Restructuring: Directories -> Paths
shorter and more accurate to what it's describing
2023-07-25 19:43:30 +01:00

44 lines
1.3 KiB
C#

using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;
namespace Bloxstrap.UI.ViewModels.Menu
{
public class InstallationViewModel : NotifyPropertyChangedViewModel
{
private string _originalInstallLocation = App.BaseDirectory;
public ICommand BrowseInstallLocationCommand => new RelayCommand(BrowseInstallLocation);
public ICommand ResetInstallLocationCommand => new RelayCommand(ResetInstallLocation);
public ICommand OpenFolderCommand => new RelayCommand(OpenFolder);
private void BrowseInstallLocation()
{
using var dialog = new System.Windows.Forms.FolderBrowserDialog();
if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
InstallLocation = dialog.SelectedPath;
OnPropertyChanged(nameof(InstallLocation));
}
private void ResetInstallLocation()
{
InstallLocation = _originalInstallLocation;
OnPropertyChanged(nameof(InstallLocation));
}
private void OpenFolder()
{
Process.Start("explorer.exe", Paths.Base);
}
public string InstallLocation
{
get => App.BaseDirectory;
set => App.BaseDirectory = value;
}
}
}