Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions CPAP-Exporter.Tests/StatusTests.cs

This file was deleted.

41 changes: 0 additions & 41 deletions CPAP-Exporter.Tests/ViewModels/StatusBarViewModelTests.cs

This file was deleted.

9 changes: 0 additions & 9 deletions CPAP-Exporter.UI/Infrastructure/Interfaces/IStatus.cs

This file was deleted.

50 changes: 0 additions & 50 deletions CPAP-Exporter.UI/Infrastructure/Status.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,10 @@ public static class ApplicationComponentProvider
{
static ApplicationComponentProvider()
{
ApplicationComponentProvider.Status = new Status();
ApplicationComponentProvider.PageViewModelProvider = new PageViewModelProvider();
ApplicationComponentProvider.CpapSourceValidator = new CpapSourceValidator();
}

public static IStatus Status
{
get;
#if DEBUG
set;
#endif
}

public static IPageViewModelProvider PageViewModelProvider
{
get;
Expand Down
13 changes: 8 additions & 5 deletions CPAP-Exporter.UI/Pages/OpenFiles/OpenFilesViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace CascadePass.CPAPExporter
{
Expand Down Expand Up @@ -159,8 +161,6 @@ public void Load(string folder)
this.ExportParameters.Reports.Clear();
}

ApplicationComponentProvider.Status.StatusText = string.Format(Resources.ReadingFolder, folder);

this.OnAdvancePage();
}

Expand All @@ -174,13 +174,15 @@ internal bool CanImportFrom(string folder)

if (!Directory.Exists(folder))
{
ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FolderDoesNotExist, folder);
this.StatusContent = new WarningToast(string.Format(Resources.FolderDoesNotExist, folder));
//ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FolderDoesNotExist, folder);
return false;
}

if (!ApplicationComponentProvider.CpapSourceValidator.IsCpapFolderStructure(folder))
{
ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FolderIsNotPAP, folder);
//ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FolderIsNotPAP, folder);
this.StatusContent = new WarningToast(string.Format(Resources.FolderIsNotPAP, folder));
return false;
}

Expand All @@ -202,7 +204,8 @@ internal string FindImportableParentFolder(string folder)

if (dir.Parent is null)
{
ApplicationComponentProvider.Status.StatusText = string.Format(Resources.NoPapData, folder);
//ApplicationComponentProvider.Status.StatusText = string.Format(Resources.NoPapData, folder);
this.StatusContent = new WarningToast(string.Format(Resources.NoPapData, folder));
return null;
}

Expand Down
9 changes: 9 additions & 0 deletions CPAP-Exporter.UI/Pages/SavedFiles/SavedFileType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CascadePass.CPAPExporter
{
public enum SavedFileType
{
None,
FullExport,
EventsExport,
}
}
8 changes: 6 additions & 2 deletions CPAP-Exporter.UI/Pages/SavedFiles/SavedFileViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ public void DeleteFile()
this.IsDeleted = true;
this.OnFileDeleted(this, EventArgs.Empty);

ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FileWasDeleted, this.Filename);
//ApplicationComponentProvider.Status.StatusText = string.Format(Resources.FileWasDeleted, this.Filename);
}
catch (Exception ex)
{
ApplicationComponentProvider.Status.StatusText = ex.Message;
//TODO: Create an Owner property linking back to the SavedFilesVM.
var window = Application.Current?.MainWindow;
var viewModel = window?.DataContext as PageViewModel;

Application.Current.Dispatcher.Invoke(() => { viewModel.StatusContent = new ErrorToast(ex.Message); });
}
}

Expand Down
25 changes: 11 additions & 14 deletions CPAP-Exporter.UI/Pages/SavedFiles/SavedFilesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public void PerformExportAsync(string folder)

public void PerformExport(string folder)
{
ApplicationComponentProvider.Status.StatusText = Resources.Working;
Application.Current.Dispatcher.Invoke(() =>
{
this.StatusContent = new BusyToast();
});

try
{
Expand Down Expand Up @@ -125,16 +128,15 @@ [.. this.ExportParameters.Reports.Where(r => r.IsSelected).Select(r => r.DailyRe
}
catch (Exception ex)
{
ApplicationComponentProvider.Status.StatusText = ex.Message;
Application.Current.Dispatcher.Invoke(() => { this.StatusContent = new ErrorToast(ex.Message); });

if (Debugger.IsAttached)
{
Debugger.Break();
}
}

ApplicationComponentProvider.Status.ProgressBar = null;
ApplicationComponentProvider.Status.StatusText = string.Empty;
Application.Current.Dispatcher.Invoke(() => { this.StatusContent = null; });
}

#region Button click implementations
Expand Down Expand Up @@ -179,21 +181,23 @@ private void FileViewModel_FileDeleted(object sender, EventArgs e)

fileViewModel.PropertyChanged -= this.FileViewModel_PropertyChanged;
fileViewModel.FileDeleted -= this.FileViewModel_FileDeleted;

var fileTypeLabel = fileViewModel.FileType.ToString().Replace("Export", "");
this.StatusContent = new InfoToast(string.Format(Resources.FileWasDeleted, fileTypeLabel, fileViewModel.Filename));
}
}

private void Exporter_Progress(object sender, ExportProgressEventArgs e)
{
if (this.Dispatcher?.CheckAccess() ?? true)
{
ApplicationComponentProvider.Status.ProgressBar = new(0, e.ExpectedRows, e.CurrentRowIndex);
ApplicationComponentProvider.Status.StatusText = string.Format(Resources.RowsWritten, e.CurrentRowIndex.ToString("#,##0"));
// Update progress bar
}
else
{
this.Dispatcher.Invoke(() =>
{
ApplicationComponentProvider.Status.ProgressBar = new(0, e.ExpectedRows, e.CurrentRowIndex);
// Update progress bar
});
}
}
Expand All @@ -202,11 +206,4 @@ private void Exporter_Progress(object sender, ExportProgressEventArgs e)

#endregion
}

public enum SavedFileType
{
None,
FullExport,
EventsExport,
}
}
8 changes: 1 addition & 7 deletions CPAP-Exporter.UI/Pages/SelectNights/SelectNightsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,9 @@ public void LoadFromFolder(string folder, bool replaceExisting)

internal void ConsumeReports(List<DailyReport> reports, string folder)
{
ApplicationComponentProvider.Status.ProgressBar = new(0, reports.Count - 1, 0);

for (int i = 0; i < reports.Count; i++)
{
ApplicationComponentProvider.Status.ProgressBar.Current = i;
// Update progress bar

var report = reports[i];

Expand All @@ -219,16 +217,12 @@ internal void ConsumeReports(List<DailyReport> reports, string folder)
this.AddReport(report, folder);
}
}

ApplicationComponentProvider.Status.ProgressBar = null;
}

internal DailyReportViewModel AddReport(DailyReport report, string folder)
{
ArgumentNullException.ThrowIfNull(report, nameof(report));

ApplicationComponentProvider.Status.StatusText = string.Format(Resources.AddingDate, report.ReportDate);

DailyReportViewModel reportViewModel = new(report, this.IsAllSelected, folder);
this.Reports.Add(reportViewModel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public string GenerateSampleCSV()
catch (Exception ex)
{
#if DEBUG
ApplicationComponentProvider.Status.StatusText = ex.Message;
this.StatusContent = new ErrorToast(ex.Message);
#endif
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ private void ConsumeExportParameters()
}
}

ApplicationComponentProvider.Status.StatusText = string.Format(Resources.SignalsAvailable, this.ExportParameters.Signals.Count);
this.StatusContent = new InfoToast(string.Format(Resources.SignalsAvailable, this.Signals.Count));
}

protected override void OnPropertyChanged(string propertyName)
Expand Down
2 changes: 1 addition & 1 deletion CPAP-Exporter.UI/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CPAP-Exporter.UI/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
<value>Delimiter</value>
</data>
<data name="FileWasDeleted" xml:space="preserve">
<value>{0} was deleted</value>
<value>{0} file {1} was deleted.</value>
</data>
<data name="ReadingFolder" xml:space="preserve">
<value>Reading folder {0}</value>
Expand Down
4 changes: 0 additions & 4 deletions CPAP-Exporter.UI/ViewModels/NavigationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,12 @@ public void ShowSignals()

this.CurrentView = new SelectSignalsView { DataContext = viewModel };
this.CurrentStep = NavigationStep.SelectSignals;

ApplicationComponentProvider.Status.StatusText = string.Format(Resources.SignalsAvailable, viewModel.Signals.Count);
}

public void ShowExportSettings()
{
this.CurrentView = new OptionsView() { DataContext = new ExportOptionsPageViewModel(this.ExportParameters) };
this.CurrentStep = NavigationStep.Settings;

ApplicationComponentProvider.Status.StatusText = Resources.ReadyToExport;
}

public void Export()
Expand Down
Loading
Loading