diff --git a/src/ARKServerManager/ARKServerManager.csproj b/src/ARKServerManager/ARKServerManager.csproj
index 8d30e72a..c7410cc7 100644
--- a/src/ARKServerManager/ARKServerManager.csproj
+++ b/src/ARKServerManager/ARKServerManager.csproj
@@ -208,6 +208,9 @@
AddUserWindow.xaml
+
+ DataDirectoryWindow.xaml
+
PlayerListWindow.xaml
@@ -391,6 +394,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/src/ARKServerManager/App.config b/src/ARKServerManager/App.config
index 5c237c8e..605e2a65 100644
--- a/src/ARKServerManager/App.config
+++ b/src/ARKServerManager/App.config
@@ -344,6 +344,9 @@
version.txt
+
+ asmdata
+
diff --git a/src/ARKServerManager/App.xaml.cs b/src/ARKServerManager/App.xaml.cs
index 80da3fb6..6df4b3e8 100644
--- a/src/ARKServerManager/App.xaml.cs
+++ b/src/ARKServerManager/App.xaml.cs
@@ -410,69 +410,15 @@ namespace ServerManagerTool
ApplicationStarted = true;
- // Initial configuration setting
- if (String.IsNullOrWhiteSpace(Config.Default.DataDir))
- {
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectoryLabel"), _globalizer.GetResourceString("Application_DataDirectoryTitle"), MessageBoxButton.OK, MessageBoxImage.Information);
+ if (string.IsNullOrWhiteSpace(Config.Default.DataDir))
+ {
+ var dataDirectoryWindow = new DataDirectoryWindow();
+ dataDirectoryWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
+ var result = dataDirectoryWindow.ShowDialog();
- var installationFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
- if (!installationFolder.EndsWith(@"\"))
- installationFolder += @"\";
-
- var desktopFolder1 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- var desktopFolder2 = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
-
- while (String.IsNullOrWhiteSpace(Config.Default.DataDir))
+ if (!result.HasValue || !result.Value)
{
- var dialog = new CommonOpenFileDialog
- {
- EnsureFileExists = true,
- IsFolderPicker = true,
- Multiselect = false,
- Title = _globalizer.GetResourceString("Application_DataDirectory_DialogTitle"),
- InitialDirectory = Path.GetPathRoot(installationFolder)
- };
-
- if (dialog.ShowDialog() != CommonFileDialogResult.Ok)
- {
- Environment.Exit(0);
- }
-
- MessageBoxResult confirm = MessageBoxResult.Cancel;
-
- // check if the folder is under the installation folder
- var newDataFolder = dialog.FileName;
- if (!newDataFolder.EndsWith(@"\"))
- newDataFolder += @"\";
-
- if (newDataFolder.StartsWith(installationFolder))
- {
- confirm = MessageBoxResult.No;
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinInstallFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
- }
- else if (newDataFolder.StartsWith(desktopFolder1) || newDataFolder.StartsWith(desktopFolder2))
- {
- confirm = MessageBoxResult.No;
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinDesktopFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
- }
- else
- {
- confirm = MessageBox.Show(String.Format(_globalizer.GetResourceString("Application_DataDirectory_ConfirmLabel"), Path.Combine(newDataFolder, Config.Default.ProfilesDir), Path.Combine(newDataFolder, Config.Default.SteamCmdDir)), _globalizer.GetResourceString("Application_DataDirectory_ConfirmTitle"), MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- }
-
- if (confirm == MessageBoxResult.Cancel)
- {
- Environment.Exit(0);
- }
- else if (confirm == MessageBoxResult.Yes)
- {
- if (newDataFolder.EndsWith(@"\"))
- newDataFolder = newDataFolder.Substring(0, newDataFolder.Length -1);
-
- Config.Default.DataDir = newDataFolder;
- ReconfigureLogging();
- break;
- }
+ Environment.Exit(0);
}
}
diff --git a/src/ARKServerManager/Config.Designer.cs b/src/ARKServerManager/Config.Designer.cs
index e4c1ef54..dbac3d1f 100644
--- a/src/ARKServerManager/Config.Designer.cs
+++ b/src/ARKServerManager/Config.Designer.cs
@@ -2803,5 +2803,14 @@ namespace ServerManagerTool {
this["MainWindow_Top"] = value;
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("asmdata")]
+ public string DefaultDataDirectoryName {
+ get {
+ return ((string)(this["DefaultDataDirectoryName"]));
+ }
+ }
}
}
diff --git a/src/ARKServerManager/Config.settings b/src/ARKServerManager/Config.settings
index ea5d849e..72345566 100644
--- a/src/ARKServerManager/Config.settings
+++ b/src/ARKServerManager/Config.settings
@@ -776,5 +776,8 @@
50
+
+ asmdata
+
\ No newline at end of file
diff --git a/src/ARKServerManager/Globalization/en-US/en-US.xaml b/src/ARKServerManager/Globalization/en-US/en-US.xaml
index c8c83020..49ab73d1 100644
--- a/src/ARKServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ARKServerManager/Globalization/en-US/en-US.xaml
@@ -165,6 +165,25 @@
Processor
+
+ Data Folder Selection
+ It appears you do not have a data directory set. The data directory is where your profiles and SteamCMD will be stored. It is not the same as the server installation directory, which you can choose for each profile.
+ Select the drive where the data folder should be located.
+ Data Folder Name:
+ The name of the server manager data folder.
+ Local Disk
+ {0} free of {1}
+
+ Ok
+ Cancel
+ Refresh
+
+ Data Directory Selection Error
+ The data folder name you have entered is not valid.
+ Server Manager Restart Required
+ The data folder has been set, you must now restart the server manager to use the new settings.
+
+
Close
diff --git a/src/ARKServerManager/Windows/DataDirectoryWindow.xaml b/src/ARKServerManager/Windows/DataDirectoryWindow.xaml
new file mode 100644
index 00000000..6a7e6bf3
--- /dev/null
+++ b/src/ARKServerManager/Windows/DataDirectoryWindow.xaml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ARKServerManager/Windows/DataDirectoryWindow.xaml.cs b/src/ARKServerManager/Windows/DataDirectoryWindow.xaml.cs
new file mode 100644
index 00000000..8f0d708c
--- /dev/null
+++ b/src/ARKServerManager/Windows/DataDirectoryWindow.xaml.cs
@@ -0,0 +1,169 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Windows;
+using WPFSharp.Globalizer;
+
+namespace ServerManagerTool.Windows
+{
+ ///
+ /// Interaction logic for DriveSelectionWindow.xaml
+ ///
+ public partial class DataDirectoryWindow : Window
+ {
+ private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
+
+ public static readonly DependencyProperty DriveInformationProperty = DependencyProperty.Register(nameof(DriveInformation), typeof(List), typeof(DataDirectoryWindow), new PropertyMetadata(null));
+ public static readonly DependencyProperty FolderNameProperty = DependencyProperty.Register(nameof(FolderName), typeof(string), typeof(DataDirectoryWindow), new PropertyMetadata(null));
+
+ public DataDirectoryWindow()
+ {
+ InitializeComponent();
+
+ PopulateDriveInformation();
+ }
+
+ public List DriveInformation
+ {
+ get { return (List)GetValue(DriveInformationProperty); }
+ set { SetValue(DriveInformationProperty, value); }
+ }
+
+ public string FolderName
+ {
+ get { return (string)GetValue(FolderNameProperty); }
+ set { SetValue(FolderNameProperty, value); }
+ }
+
+ private void PopulateDriveInformation()
+ {
+ this.FolderName = Config.Default.DefaultDataDirectoryName;
+ this.DriveInformation = DriveInfo.GetDrives().Where(d => d.IsReady && d.DriveType == DriveType.Fixed).Select(d => new DriveInfoDisplay(d)).ToList();
+
+ var installationFolder = Path.GetPathRoot(Assembly.GetEntryAssembly().Location);
+ if (!installationFolder.EndsWith(@"\"))
+ installationFolder += @"\";
+
+ foreach (var driveInfo in DriveInformation)
+ {
+ if (driveInfo.DriveInfo.RootDirectory.FullName.Equals(installationFolder))
+ {
+ this.DriveSelectionListBox.SelectedItem = driveInfo;
+ break;
+ }
+ }
+ }
+
+ private void Ok_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var result = CreateDataDirectory();
+ if (result == MessageBoxResult.Yes)
+ {
+ MessageBox.Show(_globalizer.GetResourceString("DataDirectory_RestartLabel"), _globalizer.GetResourceString("DataDirectory_RestartTitle"), MessageBoxButton.OK, MessageBoxImage.Information);
+
+ this.DialogResult = true;
+ this.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, _globalizer.GetResourceString("DataDirectory_ErrorTitle"));
+ }
+ }
+
+ private void Refresh_Click(object sender, RoutedEventArgs e)
+ {
+ PopulateDriveInformation();
+ }
+
+ private MessageBoxResult CreateDataDirectory()
+ {
+ var selectedDrive = this.DriveSelectionListBox.SelectedItem as DriveInfoDisplay;
+ if (selectedDrive is null)
+ {
+ return MessageBoxResult.None;
+ }
+
+ var invalidCharacters = Path.GetInvalidFileNameChars();
+ if (string.IsNullOrWhiteSpace(FolderName) || FolderName.Any(c => invalidCharacters.Contains(c)))
+ {
+ throw new Exception(_globalizer.GetResourceString("DataDirectory_FolderErrorLabel"));
+ }
+
+ var newDataFolder = Path.Combine(selectedDrive.DriveInfo.RootDirectory.FullName, FolderName);
+
+ var confirm = MessageBox.Show(string.Format(_globalizer.GetResourceString("Application_DataDirectory_ConfirmLabel"), Path.Combine(newDataFolder, Config.Default.ProfilesDir), Path.Combine(newDataFolder, Config.Default.SteamCmdDir)), _globalizer.GetResourceString("Application_DataDirectory_ConfirmTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (confirm == MessageBoxResult.Yes)
+ {
+ if (newDataFolder.EndsWith(@"\"))
+ newDataFolder = newDataFolder.Substring(0, newDataFolder.Length - 1);
+
+ Config.Default.DataDir = newDataFolder;
+ }
+
+ return confirm;
+ }
+ }
+
+ public class DriveInfoDisplay
+ {
+ private const decimal DIVISOR = 1024M;
+
+ // Load all suffixes in an array
+ private static readonly string[] suffixes = { "Bytes", "KB", "MB", "GB", "TB", "PB" };
+
+ private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
+
+ public DriveInfoDisplay(DriveInfo driveInfo)
+ {
+ DriveInfo = driveInfo;
+ }
+
+ public DriveInfo DriveInfo
+ {
+ get;
+ set;
+ }
+
+ public string Line1
+ {
+ get
+ {
+ if (DriveInfo is null)
+ return string.Empty;
+
+ var volumeLabel = string.IsNullOrWhiteSpace(DriveInfo.VolumeLabel) ? _globalizer.GetResourceString("DataDirectory_LocalDiskLabel") : DriveInfo.VolumeLabel;
+ return $"{volumeLabel} ({DriveInfo.Name.Replace(@"\", string.Empty)})";
+ }
+ }
+
+ public string Line2
+ {
+ get
+ {
+ if (DriveInfo is null)
+ return string.Empty;
+
+ return string.Format(_globalizer.GetResourceString("DataDirectory_DriveLine2Label"), FormatSize(DriveInfo.TotalFreeSpace), FormatSize(DriveInfo.TotalSize));
+ }
+ }
+
+ public static string FormatSize(long bytes)
+ {
+ var counter = 0;
+ var number = (decimal)bytes;
+
+ while (number / DIVISOR >= 1)
+ {
+ number /= DIVISOR;
+ counter++;
+ }
+
+ return string.Format("{0:n2} {1}", number, suffixes[counter]);
+ }
+ }
+}
diff --git a/src/ARKServerManager/Windows/GlobalSettingsControl.xaml b/src/ARKServerManager/Windows/GlobalSettingsControl.xaml
index cd639d3a..0aff8781 100644
--- a/src/ARKServerManager/Windows/GlobalSettingsControl.xaml
+++ b/src/ARKServerManager/Windows/GlobalSettingsControl.xaml
@@ -71,7 +71,7 @@
-
+
diff --git a/src/ConanServerManager/App.config b/src/ConanServerManager/App.config
index 5924ae7f..5b188135 100644
--- a/src/ConanServerManager/App.config
+++ b/src/ConanServerManager/App.config
@@ -254,6 +254,9 @@
120000
+
+ csmdata
+
diff --git a/src/ConanServerManager/App.xaml.cs b/src/ConanServerManager/App.xaml.cs
index 5141328a..3436c135 100644
--- a/src/ConanServerManager/App.xaml.cs
+++ b/src/ConanServerManager/App.xaml.cs
@@ -393,69 +393,15 @@ namespace ServerManagerTool
this.ApplicationStarted = true;
- // Initial configuration setting
- if (String.IsNullOrWhiteSpace(Config.Default.DataPath))
+ if (string.IsNullOrWhiteSpace(Config.Default.DataPath))
{
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectoryLabel"), _globalizer.GetResourceString("Application_DataDirectoryTitle"), MessageBoxButton.OK, MessageBoxImage.Information);
+ var dataDirectoryWindow = new DataDirectoryWindow();
+ dataDirectoryWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
+ var result = dataDirectoryWindow.ShowDialog();
- var installationFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
- if (!installationFolder.EndsWith(@"\"))
- installationFolder += @"\";
-
- var desktopFolder1 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
- var desktopFolder2 = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
-
- while (String.IsNullOrWhiteSpace(Config.Default.DataPath))
+ if (!result.HasValue || !result.Value)
{
- var dialog = new CommonOpenFileDialog
- {
- EnsureFileExists = true,
- IsFolderPicker = true,
- Multiselect = false,
- Title = _globalizer.GetResourceString("Application_DataDirectory_DialogTitle"),
- InitialDirectory = Path.GetPathRoot(installationFolder)
- };
-
- if (dialog.ShowDialog() != CommonFileDialogResult.Ok)
- {
- Environment.Exit(0);
- }
-
- MessageBoxResult confirm = MessageBoxResult.Cancel;
-
- // check if the folder is under the installation folder
- var newDataFolder = dialog.FileName;
- if (!newDataFolder.EndsWith(@"\"))
- newDataFolder += @"\";
-
- if (newDataFolder.StartsWith(installationFolder))
- {
- confirm = MessageBoxResult.No;
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinInstallFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
- }
- else if (newDataFolder.StartsWith(desktopFolder1) || newDataFolder.StartsWith(desktopFolder2))
- {
- confirm = MessageBoxResult.No;
- MessageBox.Show(_globalizer.GetResourceString("Application_DataDirectory_DataDirectoryWithinDesktopFolderErrorLabel"), _globalizer.GetResourceString("Application_DataDirectory_DataDirectoryFolderErrorTitle"), MessageBoxButton.OK, MessageBoxImage.Error);
- }
- else
- {
- confirm = MessageBox.Show(String.Format(_globalizer.GetResourceString("Application_DataDirectory_ConfirmLabel"), Path.Combine(newDataFolder, Config.Default.ProfilesRelativePath), Path.Combine(newDataFolder, CommonConfig.Default.SteamCmdRelativePath)), _globalizer.GetResourceString("Application_DataDirectory_ConfirmTitle"), MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- }
-
- if (confirm == MessageBoxResult.Cancel)
- {
- Environment.Exit(0);
- }
- else if (confirm == MessageBoxResult.Yes)
- {
- if (newDataFolder.EndsWith(@"\"))
- newDataFolder = newDataFolder.Substring(0, newDataFolder.Length - 1);
-
- Config.Default.DataPath = newDataFolder;
- ReconfigureLogging();
- break;
- }
+ Environment.Exit(0);
}
}
diff --git a/src/ConanServerManager/ConanServerManager.csproj b/src/ConanServerManager/ConanServerManager.csproj
index b1774f7a..2fc84422 100644
--- a/src/ConanServerManager/ConanServerManager.csproj
+++ b/src/ConanServerManager/ConanServerManager.csproj
@@ -180,6 +180,9 @@
CommandLineWindow.xaml
+
+ DataDirectoryWindow.xaml
+
GameDataWindow.xaml
@@ -305,6 +308,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
MSBuild:Compile
Designer
diff --git a/src/ConanServerManager/Config.Designer.cs b/src/ConanServerManager/Config.Designer.cs
index f38a6e61..7239440f 100644
--- a/src/ConanServerManager/Config.Designer.cs
+++ b/src/ConanServerManager/Config.Designer.cs
@@ -1956,5 +1956,14 @@ namespace ServerManagerTool {
this["ServerFilesGridHeight"] = value;
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("csmdata")]
+ public string DefaultDataDirectoryName {
+ get {
+ return ((string)(this["DefaultDataDirectoryName"]));
+ }
+ }
}
}
diff --git a/src/ConanServerManager/Config.settings b/src/ConanServerManager/Config.settings
index 96446bdf..edc93f78 100644
--- a/src/ConanServerManager/Config.settings
+++ b/src/ConanServerManager/Config.settings
@@ -542,5 +542,8 @@
250
+
+ csmdata
+
\ No newline at end of file
diff --git a/src/ConanServerManager/Globalization/en-US/en-US.xaml b/src/ConanServerManager/Globalization/en-US/en-US.xaml
index 43175cce..c1e939f7 100644
--- a/src/ConanServerManager/Globalization/en-US/en-US.xaml
+++ b/src/ConanServerManager/Globalization/en-US/en-US.xaml
@@ -168,6 +168,25 @@
Processor
+
+ Data Folder Selection
+ It appears you do not have a data directory set. The data directory is where your profiles and SteamCMD will be stored. It is not the same as the server installation directory, which you can choose for each profile.
+ Select the drive where the data folder should be located.
+ Data Folder Name:
+ The name of the server manager data folder.
+ Local Disk
+ {0} free of {1}
+
+ Ok
+ Cancel
+ Refresh
+
+ Data Directory Selection Error
+ The data folder name you have entered is not valid.
+ Server Manager Restart Required
+ The data folder has been set, you must now restart the server manager to use the new settings.
+
+
Mod Details
Mod Details - {0}
diff --git a/src/ConanServerManager/Windows/DataDirectoryWindow.xaml b/src/ConanServerManager/Windows/DataDirectoryWindow.xaml
new file mode 100644
index 00000000..6a7e6bf3
--- /dev/null
+++ b/src/ConanServerManager/Windows/DataDirectoryWindow.xaml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ConanServerManager/Windows/DataDirectoryWindow.xaml.cs b/src/ConanServerManager/Windows/DataDirectoryWindow.xaml.cs
new file mode 100644
index 00000000..c2b2a484
--- /dev/null
+++ b/src/ConanServerManager/Windows/DataDirectoryWindow.xaml.cs
@@ -0,0 +1,170 @@
+using ServerManagerTool.Common;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Windows;
+using WPFSharp.Globalizer;
+
+namespace ServerManagerTool.Windows
+{
+ ///
+ /// Interaction logic for DriveSelectionWindow.xaml
+ ///
+ public partial class DataDirectoryWindow : Window
+ {
+ private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
+
+ public static readonly DependencyProperty DriveInformationProperty = DependencyProperty.Register(nameof(DriveInformation), typeof(List), typeof(DataDirectoryWindow), new PropertyMetadata(null));
+ public static readonly DependencyProperty FolderNameProperty = DependencyProperty.Register(nameof(FolderName), typeof(string), typeof(DataDirectoryWindow), new PropertyMetadata(null));
+
+ public DataDirectoryWindow()
+ {
+ InitializeComponent();
+
+ PopulateDriveInformation();
+ }
+
+ public List DriveInformation
+ {
+ get { return (List)GetValue(DriveInformationProperty); }
+ set { SetValue(DriveInformationProperty, value); }
+ }
+
+ public string FolderName
+ {
+ get { return (string)GetValue(FolderNameProperty); }
+ set { SetValue(FolderNameProperty, value); }
+ }
+
+ private void PopulateDriveInformation()
+ {
+ this.FolderName = Config.Default.DefaultDataDirectoryName;
+ this.DriveInformation = DriveInfo.GetDrives().Where(d => d.IsReady && d.DriveType == DriveType.Fixed).Select(d => new DriveInfoDisplay(d)).ToList();
+
+ var installationFolder = Path.GetPathRoot(Assembly.GetEntryAssembly().Location);
+ if (!installationFolder.EndsWith(@"\"))
+ installationFolder += @"\";
+
+ foreach (var driveInfo in DriveInformation)
+ {
+ if (driveInfo.DriveInfo.RootDirectory.FullName.Equals(installationFolder))
+ {
+ this.DriveSelectionListBox.SelectedItem = driveInfo;
+ break;
+ }
+ }
+ }
+
+ private void Ok_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ var result = CreateDataDirectory();
+ if (result == MessageBoxResult.Yes)
+ {
+ MessageBox.Show(_globalizer.GetResourceString("DataDirectory_RestartLabel"), _globalizer.GetResourceString("DataDirectory_RestartTitle"), MessageBoxButton.OK, MessageBoxImage.Information);
+
+ this.DialogResult = true;
+ this.Close();
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, _globalizer.GetResourceString("DataDirectory_ErrorTitle"));
+ }
+ }
+
+ private void Refresh_Click(object sender, RoutedEventArgs e)
+ {
+ PopulateDriveInformation();
+ }
+
+ private MessageBoxResult CreateDataDirectory()
+ {
+ var selectedDrive = this.DriveSelectionListBox.SelectedItem as DriveInfoDisplay;
+ if (selectedDrive is null)
+ {
+ return MessageBoxResult.None;
+ }
+
+ var invalidCharacters = Path.GetInvalidFileNameChars();
+ if (string.IsNullOrWhiteSpace(FolderName) || FolderName.Any(c => invalidCharacters.Contains(c)))
+ {
+ throw new Exception(_globalizer.GetResourceString("DataDirectory_FolderErrorLabel"));
+ }
+
+ var newDataFolder = Path.Combine(selectedDrive.DriveInfo.RootDirectory.FullName, FolderName);
+
+ var confirm = MessageBox.Show(string.Format(_globalizer.GetResourceString("Application_DataDirectory_ConfirmLabel"), Path.Combine(newDataFolder, Config.Default.ProfilesRelativePath), Path.Combine(newDataFolder, CommonConfig.Default.SteamCmdRelativePath)), _globalizer.GetResourceString("Application_DataDirectory_ConfirmTitle"), MessageBoxButton.YesNo, MessageBoxImage.Question);
+ if (confirm == MessageBoxResult.Yes)
+ {
+ if (newDataFolder.EndsWith(@"\"))
+ newDataFolder = newDataFolder.Substring(0, newDataFolder.Length - 1);
+
+ Config.Default.DataPath = newDataFolder;
+ }
+
+ return confirm;
+ }
+ }
+
+ public class DriveInfoDisplay
+ {
+ private const decimal DIVISOR = 1024M;
+
+ // Load all suffixes in an array
+ private static readonly string[] suffixes = { "Bytes", "KB", "MB", "GB", "TB", "PB" };
+
+ private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
+
+ public DriveInfoDisplay(DriveInfo driveInfo)
+ {
+ DriveInfo = driveInfo;
+ }
+
+ public DriveInfo DriveInfo
+ {
+ get;
+ set;
+ }
+
+ public string Line1
+ {
+ get
+ {
+ if (DriveInfo is null)
+ return string.Empty;
+
+ var volumeLabel = string.IsNullOrWhiteSpace(DriveInfo.VolumeLabel) ? _globalizer.GetResourceString("DataDirectory_LocalDiskLabel") : DriveInfo.VolumeLabel;
+ return $"{volumeLabel} ({DriveInfo.Name.Replace(@"\", string.Empty)})";
+ }
+ }
+
+ public string Line2
+ {
+ get
+ {
+ if (DriveInfo is null)
+ return string.Empty;
+
+ return string.Format(_globalizer.GetResourceString("DataDirectory_DriveLine2Label"), FormatSize(DriveInfo.TotalFreeSpace), FormatSize(DriveInfo.TotalSize));
+ }
+ }
+
+ public static string FormatSize(long bytes)
+ {
+ var counter = 0;
+ var number = (decimal)bytes;
+
+ while (number / DIVISOR >= 1)
+ {
+ number /= DIVISOR;
+ counter++;
+ }
+
+ return string.Format("{0:n2} {1}", number, suffixes[counter]);
+ }
+ }
+}
diff --git a/src/ConanServerManager/Windows/GlobalSettingsControl.xaml b/src/ConanServerManager/Windows/GlobalSettingsControl.xaml
index 0d0d2472..1b02776d 100644
--- a/src/ConanServerManager/Windows/GlobalSettingsControl.xaml
+++ b/src/ConanServerManager/Windows/GlobalSettingsControl.xaml
@@ -75,7 +75,7 @@
-
+