diff --git a/src/StatisticsAnalysisTool/Backup/BackupController.cs b/src/StatisticsAnalysisTool/Backup/BackupController.cs
index ec0ede75..d5e8ebc3 100644
--- a/src/StatisticsAnalysisTool/Backup/BackupController.cs
+++ b/src/StatisticsAnalysisTool/Backup/BackupController.cs
@@ -36,7 +36,7 @@ public static bool Save()
_isBackupRunning = true;
var sourceFolderPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.UserDataDirectoryName);
- var backupDirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.BackupDirectoryName);
+ var backupDirPath = SettingsController.CurrentSettings.BackupStorageDirectoryPath;
if (!DirectoryController.CreateDirectoryWhenNotExists(backupDirPath))
{
@@ -80,7 +80,7 @@ private static string GetBackupFileName()
public static bool ExistBackupOnSettingConditions()
{
- var backupDirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.BackupDirectoryName);
+ var backupDirPath = SettingsController.CurrentSettings.BackupStorageDirectoryPath;
if (!Directory.Exists(backupDirPath))
{
@@ -112,7 +112,7 @@ public static bool ExistBackupOnSettingConditions()
public static async Task DeleteOldestBackupsIfNeededAsync()
{
- var backupDirPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.BackupDirectoryName);
+ var backupDirPath = SettingsController.CurrentSettings.BackupStorageDirectoryPath;
if (!Directory.Exists(backupDirPath))
{
diff --git a/src/StatisticsAnalysisTool/Common/UserSettings/SettingsObject.cs b/src/StatisticsAnalysisTool/Common/UserSettings/SettingsObject.cs
index 29b5a5fb..5eba4c5c 100644
--- a/src/StatisticsAnalysisTool/Common/UserSettings/SettingsObject.cs
+++ b/src/StatisticsAnalysisTool/Common/UserSettings/SettingsObject.cs
@@ -19,6 +19,7 @@ public class SettingsObject
public string MainTrackingCharacterName { get; set; }
public int BackupIntervalByDays { get; set; } = 1;
public int MaximumNumberOfBackups { get; set; } = 10;
+ public string BackupStorageDirectoryPath { get; set; }
public bool IsOpenItemWindowInNewWindowChecked { get; set; } = true;
public bool IsInfoWindowShownOnStart { get; set; } = true;
public string SelectedAlertSound { get; set; }
diff --git a/src/StatisticsAnalysisTool/Common/Validation/PathValidationRule.cs b/src/StatisticsAnalysisTool/Common/Validation/PathValidationRule.cs
new file mode 100644
index 00000000..c49d1497
--- /dev/null
+++ b/src/StatisticsAnalysisTool/Common/Validation/PathValidationRule.cs
@@ -0,0 +1,25 @@
+using System.Globalization;
+using System.IO;
+using System.Windows.Controls;
+
+namespace StatisticsAnalysisTool.Common.Validation;
+
+public class PathValidationRule : ValidationRule
+{
+ public override ValidationResult Validate(object value, CultureInfo cultureInfo)
+ {
+ string path = value as string;
+
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ return new ValidationResult(false, "Path cannot be empty.");
+ }
+
+ if (!Directory.Exists(path))
+ {
+ return new ValidationResult(false, "Path does not exist.");
+ }
+
+ return ValidationResult.ValidResult;
+ }
+}
\ No newline at end of file
diff --git a/src/StatisticsAnalysisTool/Localization/localization.json b/src/StatisticsAnalysisTool/Localization/localization.json
index 9e829b49..71cec17e 100644
--- a/src/StatisticsAnalysisTool/Localization/localization.json
+++ b/src/StatisticsAnalysisTool/Localization/localization.json
@@ -37326,6 +37326,19 @@
"seg": "Select the AlbionOnline folder in the steamapps. Usually found under 'C:\\Program Files\\Steam\\steamapps\\common'"
}
]
+ },
+ {
+ "tuid": "BACKUP_STORAGE_DIRECTORY_PATH",
+ "tuv": [
+ {
+ "lang": "de-DE",
+ "seg": "Backup Speicherverzeichnis Pfad"
+ },
+ {
+ "lang": "en-US",
+ "seg": "Backup storage directory path"
+ }
+ ]
}
]
}
\ No newline at end of file
diff --git a/src/StatisticsAnalysisTool/Models/TranslationModel/SettingsWindowTranslation.cs b/src/StatisticsAnalysisTool/Models/TranslationModel/SettingsWindowTranslation.cs
index 5541c548..49948333 100644
--- a/src/StatisticsAnalysisTool/Models/TranslationModel/SettingsWindowTranslation.cs
+++ b/src/StatisticsAnalysisTool/Models/TranslationModel/SettingsWindowTranslation.cs
@@ -61,4 +61,5 @@ public class SettingsWindowTranslation
public static string AnotherAppToStartPath => LocalizationController.Translation("ANOTHER_APP_TO_START_PATH");
public static string Party => LocalizationController.Translation("PARTY");
public static string DeathAlarmSoundUsed => LocalizationController.Translation("DEATH_ALERT_SOUND_USED");
+ public static string BackupStorageDirectoryPath => LocalizationController.Translation("BACKUP_STORAGE_DIRECTORY_PATH");
}
\ No newline at end of file
diff --git a/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml b/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml
index 97aeb99b..2dbb0689 100644
--- a/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml
+++ b/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml
@@ -5,9 +5,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:viewModels="clr-namespace:StatisticsAnalysisTool.ViewModels"
xmlns:common="clr-namespace:StatisticsAnalysisTool.Common"
+ xmlns:validation="clr-namespace:StatisticsAnalysisTool.Common.Validation"
mc:Ignorable="d"
d:DesignHeight="1600" d:DesignWidth="800"
d:DataContext="{d:DesignInstance Type=viewModels:SettingsWindowViewModel}">
+
@@ -182,6 +184,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml.cs b/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml.cs
index 37c94583..94efc4fc 100644
--- a/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml.cs
+++ b/src/StatisticsAnalysisTool/UserControls/SettingsControl.xaml.cs
@@ -76,6 +76,11 @@ private void ResetPlayerSelectionWithSameNameInDb_Click(object sender, RoutedEve
_settingsWindowViewModel.ResetPlayerSelectionWithSameNameInDb();
}
+ private void ResetBackupStorageDirPath_Click(object sender, RoutedEventArgs e)
+ {
+ _settingsWindowViewModel.ResetBackupStorageDirPath();
+ }
+
private void ResetPacketFilter_Click(object sender, RoutedEventArgs e)
{
_settingsWindowViewModel.ResetPacketFilter();
diff --git a/src/StatisticsAnalysisTool/ViewModels/SettingsWindowViewModel.cs b/src/StatisticsAnalysisTool/ViewModels/SettingsWindowViewModel.cs
index faeff759..f93ffadd 100644
--- a/src/StatisticsAnalysisTool/ViewModels/SettingsWindowViewModel.cs
+++ b/src/StatisticsAnalysisTool/ViewModels/SettingsWindowViewModel.cs
@@ -7,6 +7,7 @@
using StatisticsAnalysisTool.Models.TranslationModel;
using StatisticsAnalysisTool.Network.PacketProviders;
using StatisticsAnalysisTool.Notification;
+using StatisticsAnalysisTool.Properties;
using StatisticsAnalysisTool.Views;
using System;
using System.Collections.Generic;
@@ -56,6 +57,7 @@ public class SettingsWindowViewModel : BaseViewModel
private BitmapImage _anotherAppToStartExeIcon;
private string _packetFilter;
private Visibility _packetFilterVisibility = Visibility.Collapsed;
+ private string _backupStorageDirectoryPath;
public SettingsWindowViewModel()
{
@@ -82,6 +84,10 @@ private void InitializeSettings()
InitMaxAmountOfBackups(MaximumNumberOfBackups);
MaximumNumberOfBackupsSelection = MaximumNumberOfBackups.FirstOrDefault(x => x.Value == SettingsController.CurrentSettings.MaximumNumberOfBackups);
+ // Backup storage dir path
+ BackupStorageDirectoryPath = string.IsNullOrEmpty(SettingsController.CurrentSettings.BackupStorageDirectoryPath)
+ ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.BackupDirectoryName) : SettingsController.CurrentSettings.BackupStorageDirectoryPath;
+
// Another app to start path
AnotherAppToStartPath = SettingsController.CurrentSettings.AnotherAppToStartPath;
@@ -141,6 +147,7 @@ public void SaveSettings()
SettingsController.CurrentSettings.IsSuggestPreReleaseUpdatesActive = IsSuggestPreReleaseUpdatesActive;
SettingsController.CurrentSettings.ExactMatchPlayerNamesLineNumber = PlayerSelectionWithSameNameInDb;
+ SetBackupStorageDirPathIfExist(BackupStorageDirectoryPath);
SetAppSettingsAndTranslations();
SetNaviTabVisibilities(mainWindowViewModel);
SetNotificationFilter();
@@ -333,6 +340,35 @@ public static void OpenEventValidationWindow()
}
}
+ private void SetBackupStorageDirPathIfExist(string newPath)
+ {
+ if (string.IsNullOrWhiteSpace(newPath))
+ {
+ BackupStorageDirectoryPath = SettingsController.CurrentSettings.BackupStorageDirectoryPath;
+ return;
+ }
+
+ if (!Directory.Exists(newPath))
+ {
+ BackupStorageDirectoryPath = SettingsController.CurrentSettings.BackupStorageDirectoryPath;
+ return;
+ }
+
+ SettingsController.CurrentSettings.BackupStorageDirectoryPath = newPath;
+ }
+
+ public void ResetBackupStorageDirPath()
+ {
+ string defaultPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.BackupDirectoryName);
+
+ if (BackupStorageDirectoryPath == defaultPath)
+ {
+ return;
+ }
+
+ BackupStorageDirectoryPath = defaultPath;
+ }
+
#region Inits
private void InitLanguageFiles()
@@ -610,6 +646,17 @@ public ObservableCollection MaximumNumberOfBackups
}
}
+ public string BackupStorageDirectoryPath
+ {
+ get => _backupStorageDirectoryPath;
+ set
+ {
+ _backupStorageDirectoryPath = value;
+ OnPropertyChanged();
+ }
+ }
+
+
public SettingDataInformation RefreshRatesSelection
{
get => _refreshRatesSelection;