[fix:] inconsistency with config.json
This commit is contained in:
+14
-11
@@ -12,8 +12,8 @@ public class Settings
|
|||||||
public Customers customers = new();
|
public Customers customers = new();
|
||||||
public PdfExportSettings pdfExport { get; set; } = new();
|
public PdfExportSettings pdfExport { get; set; } = new();
|
||||||
|
|
||||||
public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
// public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"logofclient", "config.json");
|
// "logofclient", "config.json");
|
||||||
|
|
||||||
public Settings()
|
public Settings()
|
||||||
{
|
{
|
||||||
@@ -23,23 +23,22 @@ public class Settings
|
|||||||
|
|
||||||
public static void Save()
|
public static void Save()
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
if (!Directory.Exists(Global._instance.config_path))
|
||||||
"logofclient")))
|
|
||||||
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"logofclient"));
|
"logofclient"));
|
||||||
if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
// if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||||
|
|
||||||
var json = JsonConvert.SerializeObject(_instance);
|
var json = JsonConvert.SerializeObject(_instance);
|
||||||
File.WriteAllText(_instance.settingsPath, json);
|
File.WriteAllText(Path.Combine(Global._instance.config_path,"config.json"), json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
//if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var contents = File.ReadAllText(_instance.settingsPath);
|
var contents = File.ReadAllText(Path.Combine(Global._instance.config_path, "config.json"));
|
||||||
_instance = JsonConvert.DeserializeObject<Settings>(contents);
|
_instance = JsonConvert.DeserializeObject<Settings>(contents);
|
||||||
MainWindow._instance.RefreshCustomerItems();
|
MainWindow._instance.RefreshCustomerItems();
|
||||||
}
|
}
|
||||||
@@ -80,11 +79,15 @@ public class Global
|
|||||||
_instance = this;
|
_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string config_path { get; set; } = Path.Combine(
|
public string config_path { get; } = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"logofclient",
|
"logofclient");
|
||||||
"config.json");
|
|
||||||
|
|
||||||
|
public void SetConfigPath(string path)
|
||||||
|
{
|
||||||
|
Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
|
||||||
|
}
|
||||||
public string wiki_storage_path { get; set; } = Path.Combine(
|
public string wiki_storage_path { get; set; } = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"logofclient",
|
"logofclient",
|
||||||
|
|||||||
+1
-1
@@ -389,7 +389,7 @@
|
|||||||
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="5">
|
<StackPanel Grid.Column="1" Orientation="Vertical" Spacing="5">
|
||||||
<StackPanel Orientation="Horizontal" Spacing="5">
|
<StackPanel Orientation="Horizontal" Spacing="5">
|
||||||
<TextBox x:Name="TbConfigPath" HorizontalAlignment="Stretch"
|
<TextBox x:Name="TbConfigPath" HorizontalAlignment="Stretch"
|
||||||
Watermark="/home/username/.config/logofclient/config.json" />
|
Watermark="/home/username/.config/logofclient/" />
|
||||||
<Button x:Name="BtnConfigPath" HorizontalAlignment="Right">
|
<Button x:Name="BtnConfigPath" HorizontalAlignment="Right">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
|||||||
+2
-2
@@ -401,8 +401,8 @@ public partial class MainWindow : Window
|
|||||||
|
|
||||||
if (folder == null || folder.Count == 0) return;
|
if (folder == null || folder.Count == 0) return;
|
||||||
var chosen = folder[0].Path;
|
var chosen = folder[0].Path;
|
||||||
TbConfigPath.Text = chosen.ToString();
|
Global._instance.SetConfigPath(chosen.ToString());
|
||||||
Global._instance.config_path = chosen.ToString();
|
TbConfigPath.Text = Global._instance.config_path;
|
||||||
Global.Save();
|
Global.Save();
|
||||||
|
|
||||||
MessageBox.Show(this, "Bitte starten Sie das Programm neu, um die Änderungen wirksam zu machen.", "Achtung");
|
MessageBox.Show(this, "Bitte starten Sie das Programm neu, um die Änderungen wirksam zu machen.", "Achtung");
|
||||||
|
|||||||
Reference in New Issue
Block a user