Skip to content

Commit

Permalink
feat(UI): add message-boxes for errors and success
Browse files Browse the repository at this point in the history
  • Loading branch information
wgnf committed Nov 5, 2023
1 parent 6cbb871 commit 317b7d1
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/CsvProc9000.UI.Wpf/States/ConfigurationState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CsvProc9000.UI.Wpf.Settings;
using System;
using System.Collections.Generic;
using System.Windows;

namespace CsvProc9000.UI.Wpf.States;

Expand All @@ -26,15 +27,30 @@ public ConfigurationState(ISettingsManager settingsManager)
/// <inheritdoc />
public void ReadSettings()
{
var settings = _settingsManager.Load(SettingsDirectory);
settings.Rules ??= new List<Rule>();
Settings = settings;
try
{
var settings = _settingsManager.Load(SettingsDirectory);
settings.Rules ??= new List<Rule>();
Settings = settings;
}
catch (Exception exception)
{
MessageBox.Show($"Was unable to load settings.\n\nFollowing was the cause: {exception.Message}", "Unable to load settings", MessageBoxButton.OK, MessageBoxImage.Error);
}
}

/// <inheritdoc />
public void WriteSettings(bool makeBackup)
{
_settingsManager.Write(SettingsDirectory, Settings, makeBackup);
try
{
_settingsManager.Write(SettingsDirectory, Settings, makeBackup);
MessageBox.Show("Successfully written settings", "Success", MessageBoxButton.OK, MessageBoxImage.None);
}
catch (Exception exception)
{
MessageBox.Show($"Was unable to write settings.\n\nFollowing was the cause: {exception.Message}", "Unable to write settings", MessageBoxButton.OK, MessageBoxImage.Error);
}
}

/// <inheritdoc />
Expand Down

0 comments on commit 317b7d1

Please sign in to comment.