Files
WowUp/WowUp.WPF/ViewModels/OptionsViewModel.cs
jliddev e078f47f7f V1.2.4
various improvements and fixes
2020-07-07 11:55:38 -05:00

66 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WowUp.WPF.Services.Contracts;
using WowUp.WPF.Utilities;
namespace WowUp.WPF.ViewModels
{
public class OptionsViewModel : BaseViewModel
{
private readonly IWarcraftService _warcraftService;
private readonly IWowUpService _wowUpService;
private string _wowLocation;
public string WowLocation
{
get => _wowLocation;
set { SetProperty(ref _wowLocation, value); }
}
public Command ShowLogsCommand { get; set; }
public OptionsViewModel(
IWarcraftService warcraftService,
IWowUpService wowUpService)
{
_warcraftService = warcraftService;
_wowUpService = wowUpService;
ShowLogsCommand = new Command(() => ShowLogsFolder());
LoadOptions();
}
private async void LoadOptions()
{
WowLocation = await _warcraftService.GetWowFolderPath();
}
private void ShowLogsFolder()
{
_wowUpService.ShowLogsFolder();
}
public async void SetWowLocation()
{
var selectedPath = DialogUtilities.SelectFolder();
if (string.IsNullOrEmpty(selectedPath))
{
return;
}
var didSet = await _warcraftService.SetWowFolderPath(selectedPath);
if (!didSet)
{
System.Windows.MessageBox.Show($"Unable to set \"{selectedPath}\" as your World of Warcraft folder");
return;
}
WowLocation = selectedPath;
}
}
}