@@ -25,15 +25,15 @@ class SettingsViewModel: ChangeNotifier
|
||||
{
|
||||
private Settings _previousSettings;
|
||||
private Settings _settings;
|
||||
private string _errorMessage;
|
||||
private ITopLevelGrabber? _topLevelGrabber;
|
||||
|
||||
public SettingsViewModel(Settings settingsToEdit)
|
||||
public SettingsViewModel(Settings settingsToEdit, ITopLevelGrabber? topLevelGrabber)
|
||||
{
|
||||
_previousSettings = settingsToEdit;
|
||||
_settings = new Settings
|
||||
{
|
||||
LastUsedPath = _previousSettings.LastUsedPath,
|
||||
UseDocnetPDFImageRendering = _previousSettings.UseDocnetPDFImageRendering
|
||||
};
|
||||
_settings = new Settings(settingsToEdit); // clone it
|
||||
_errorMessage = "";
|
||||
_topLevelGrabber = topLevelGrabber;
|
||||
}
|
||||
|
||||
public bool UseDocnetPDFImageRendering
|
||||
@@ -46,6 +46,65 @@ class SettingsViewModel: ChangeNotifier
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveOutputPdfInWorkingDir
|
||||
{
|
||||
get => _settings.SaveOutputPdfInWorkingDir;
|
||||
set
|
||||
{
|
||||
_settings.SaveOutputPdfInWorkingDir = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public string OutputPdfDirPath
|
||||
{
|
||||
get => _settings.OutputPdfDir;
|
||||
set
|
||||
{
|
||||
_settings.OutputPdfDir = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOutputPdfDirValid
|
||||
{
|
||||
get => SaveOutputPdfInWorkingDir || (!SaveOutputPdfInWorkingDir && Directory.Exists(OutputPdfDirPath));
|
||||
}
|
||||
|
||||
public bool HasErrorMessage
|
||||
{
|
||||
get => !string.IsNullOrWhiteSpace(_errorMessage);
|
||||
}
|
||||
|
||||
public string ErrorMessage
|
||||
{
|
||||
get => _errorMessage;
|
||||
set
|
||||
{
|
||||
_errorMessage = value;
|
||||
NotifyPropertyChanged();
|
||||
NotifyPropertyChanged(nameof(HasErrorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
public async void ChooseOutputFolder()
|
||||
{
|
||||
var topLevel = _topLevelGrabber?.GetTopLevel();
|
||||
if (topLevel != null)
|
||||
{
|
||||
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
|
||||
{
|
||||
Title = "Choose where to save your report file...",
|
||||
AllowMultiple = false,
|
||||
});
|
||||
if (folders.Count == 1)
|
||||
{
|
||||
var folder = folders[0];
|
||||
OutputPdfDirPath = folder.Path.LocalPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
DialogHost.Close("DialogHost", null);
|
||||
|
||||
Reference in New Issue
Block a user