diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 6cb2e98..df1480c 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -34,14 +34,20 @@ class MainViewModel : BaseViewModel, IFontResolver _baseDir = Path.GetDirectoryName(Environment.ProcessPath) ?? ""; _isCreatingPDF = false; _createPDFLog = "Ready to create PDF! Choose a folder to begin..."; - _reportFiles = new ObservableCollection(); _workingFolder = ""; + _reportFiles = new ObservableCollection(); + _reportFiles.CollectionChanged += ( sender, e ) => { NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); }; } public bool IsCreatingPDF { get => _isCreatingPDF; - set { _isCreatingPDF = value; NotifyPropertyChanged(); } + set { _isCreatingPDF = value; NotifyPropertyChanged(); NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); } + } + + public bool IsCreatePDFButtonEnabled + { + get => !_isCreatingPDF && _reportFiles.Count > 0; } public string CreatePDFLog @@ -121,10 +127,11 @@ class MainViewModel : BaseViewModel, IFontResolver var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger)); } - private async void BuildPDF() + public async void BuildPDF() { try { + // TODO: use already found files await Task.Run(() => CreatePDF(_workingFolder)); } catch (Exception e) { diff --git a/Views/MainView.axaml b/Views/MainView.axaml index 8954ca0..15904c0 100644 --- a/Views/MainView.axaml +++ b/Views/MainView.axaml @@ -10,7 +10,7 @@ xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing" x:DataType="vm:MainViewModel"> + RowDefinitions="Auto, 2*, Auto, Auto, *"> - - - + +