diff --git a/Utils/DataSerialization.cs b/Utils/DataSerialization.cs
index bbfade0..e66489a 100644
--- a/Utils/DataSerialization.cs
+++ b/Utils/DataSerialization.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using System.Text.Json;
using GazpromApp.Models;
@@ -8,12 +9,26 @@ public static class DataSerialization
{
private static void SaveData(string path, string data)
{
- System.IO.File.WriteAllText(path, data);
+ if (!File.Exists(path))
+ {
+ File.WriteAllText(path, data);
+ return;
+ }
+
+ var dir = Path.GetDirectoryName(path) ?? "";
+ var fileName = Path.GetFileNameWithoutExtension(path);
+ var ext = Path.GetExtension(path);
+ var index = 1;
+
+ while (File.Exists(Path.Combine(dir, $"{fileName} ({index}){ext}")))
+ index++;
+
+ File.WriteAllText(Path.Combine(dir, $"{fileName} ({index}){ext}"), data);
}
private static string LoadData(string path)
{
- var text = System.IO.File.ReadAllText(path);
+ var text = File.ReadAllText(path);
return text;
}
diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs
index d596a5e..33ec53a 100644
--- a/ViewModels/MainWindowViewModel.cs
+++ b/ViewModels/MainWindowViewModel.cs
@@ -82,12 +82,14 @@ public partial class MainWindowViewModel : ViewModelBase
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
});
+ if (files.Count < 1) return;
+
IsLoading = true;
foreach (var file in files)
{
var url = file.Path.AbsolutePath;
- var decoded = HttpUtility.HtmlDecode(url);
+ var decoded = HttpUtility.UrlDecode(url);
var point = DataSerialization.LoadPoint(decoded);
point?.SetPropertyParents();
@@ -113,11 +115,9 @@ public partial class MainWindowViewModel : ViewModelBase
await w.StorageProvider.TryGetFolderFromPathAsync(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
});
+ if (folder.Count != 1) return;
foreach (var point in Points)
- {
- DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.HtmlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
- }
-
+ DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.UrlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
}
// Visual and other properties
diff --git a/Views/EditEquipmentDialog.axaml b/Views/EditEquipmentDialog.axaml
index 7454a60..6077be6 100644
--- a/Views/EditEquipmentDialog.axaml
+++ b/Views/EditEquipmentDialog.axaml
@@ -49,7 +49,7 @@
-
@@ -137,7 +137,8 @@
+ Value="{Binding PeriodValue}"
+ Minimum="0"/>
(w));
});
- // new property dialog
-
- // edit property dialog
-
// complete editing equipment
WeakReferenceMessenger.Default.Register(this, static (w, m) =>
{
@@ -56,8 +52,6 @@ public partial class EditEquipmentDialog : Window
{
WeakReferenceMessenger.Default.Unregister(this);
WeakReferenceMessenger.Default.Unregister(this);
- //
- //
WeakReferenceMessenger.Default.Unregister(this);
}
}
\ No newline at end of file
diff --git a/Views/EditPointDialog.axaml b/Views/EditPointDialog.axaml
index a7cf584..5084c78 100644
--- a/Views/EditPointDialog.axaml
+++ b/Views/EditPointDialog.axaml
@@ -47,7 +47,7 @@
-