89 lines
3.0 KiB
C#
89 lines
3.0 KiB
C#
using BS.SharedLauncher.Extensions;
|
|
using BS.SharedLauncher.Information;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace BeWoLauncher.Utils
|
|
{
|
|
public static class BeWoPaths
|
|
{
|
|
private static readonly string planerExeName = "BeWoPlaner.exe";
|
|
|
|
//private static readonly string versionXml = "bewo.version";
|
|
|
|
public static string LoginSelectionPlanerLocation { get; set; }
|
|
public static string ActualPlanerLocation { get; private set; }
|
|
|
|
/// <summary>
|
|
/// Holt den Install Ort aus den Properties Settings.
|
|
/// Sollte dieser nicht verfügbar sein, wird als default - "CurrentBaseDir"/BeWoPlaner - verwendet
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetInstallLocationFromSettingOrDefault()
|
|
{
|
|
var installLocation = Properties.Settings.Default.InstallLocation;
|
|
|
|
if (string.IsNullOrWhiteSpace(installLocation))
|
|
{
|
|
installLocation = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data");
|
|
}
|
|
|
|
return installLocation;
|
|
}
|
|
public static void ChangeLoginSelectedLocation(string newLocation)
|
|
{
|
|
var info = new DirectoryInfo(newLocation);
|
|
|
|
if (LoginSelectionPlanerLocation == newLocation)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (info.GetDirectories().Any() || info.GetFiles().Any())
|
|
{
|
|
MessageBox.Show($"Ordner muss leer sein! Es sind {info.GetDirectories().Count()} Ordner und {info.GetFiles().Count()} Datei(en) enthalten");
|
|
return;
|
|
}
|
|
|
|
// Annahme: Ordner ist leer und neuer Ort
|
|
LoginSelectionPlanerLocation.ClearFolder();
|
|
|
|
LoginSelectionPlanerLocation = newLocation;
|
|
}
|
|
public static void SetAndSaveInstallLocation(string path)
|
|
{
|
|
ActualPlanerLocation = path;
|
|
|
|
Properties.Settings.Default.InstallLocation = ActualPlanerLocation;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
|
|
public static string GetDownloadPath()
|
|
{
|
|
return Path.Combine(new string[] { ActualPlanerLocation, "download" });
|
|
}
|
|
public static string GetApplyPath()
|
|
{
|
|
return Path.Combine(new string[] { ActualPlanerLocation, "apply" });
|
|
}
|
|
public static string GetPlanerExeName() => planerExeName;
|
|
public static string GetPlanerExePath()
|
|
{
|
|
return Path.Combine(GetApplyPath(), GetPlanerExeName());
|
|
}
|
|
|
|
public static string GetApplyPackagePath()
|
|
{
|
|
return Path.Combine(GetApplyPath(), BeWoPathFileConfig.LatestBeWoInfo);
|
|
}
|
|
public static string GetDownloadPackagePath()
|
|
{
|
|
return Path.Combine(GetDownloadPath(), BeWoPathFileConfig.LatestBeWoInfo);
|
|
}
|
|
}
|
|
} |