JSON import added

This commit is contained in:
retr0volkov
2025-07-10 11:29:19 +03:00 Unverified
parent fe8bfe7ef0
commit 7a34fc2dbb
7 changed files with 60 additions and 9 deletions
+19 -4
View File
@@ -45,15 +45,29 @@ public partial class MainWindowViewModel : ViewModelBase
}
[RelayCommand]
private void ImportPoint(Window w)
private async Task ImportPoint(Window w)
{
var files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = true,
SuggestedStartLocation =
await w.StorageProvider.TryGetFolderFromPathAsync(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
});
foreach (var file in files)
{
var url = file.Path.AbsolutePath;
var decoded = HttpUtility.HtmlDecode(url);
var point = DataSerialization.LoadPoint(decoded);
point?.SetPropertyParents();
Points.Add(new PointViewModel(point ?? new Point()));
}
}
[RelayCommand]
private async Task ExportPoint(Window w)
{
var folder = await w.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
var folder = await w.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
AllowMultiple = false,
SuggestedStartLocation =
@@ -64,9 +78,10 @@ public partial class MainWindowViewModel : ViewModelBase
{
DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.HtmlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
}
}
// Visual properties
// Visual and other properties
[ObservableProperty]
private bool _isLineVisible;