mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
Data directory changes (#10)
* Data Directory Changes 1. Have implemented a new data directory selection window. 2. Have removed the data directory move button from global settings. * Added restart message
This commit is contained in:
parent
d4b8b51362
commit
b0bced67a7
18 changed files with 626 additions and 123 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue