JSON export added

This commit is contained in:
retr0volkov
2025-07-10 10:57:42 +03:00 Unverified
parent 915c7a7c5e
commit fe8bfe7ef0
13 changed files with 112 additions and 8 deletions
+29 -2
View File
@@ -1,17 +1,22 @@
using System.Collections.ObjectModel;
using System;
using System.IO;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Web;
using Avalonia.Controls;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using GazpromApp.Messages;
using GazpromApp.Models;
using GazpromApp.Utils;
namespace GazpromApp.ViewModels;
public partial class MainWindowViewModel : ViewModelBase
{
public ObservableCollection<PointViewModel> Points { get; } = [];
public ObservableCollection<PointViewModel> Points { get; }
[RelayCommand]
private async Task AddPoint()
@@ -38,6 +43,28 @@ public partial class MainWindowViewModel : ViewModelBase
IsLineVisible = Points.Count > 0;
}
[RelayCommand]
private void ImportPoint(Window w)
{
}
[RelayCommand]
private async Task ExportPoint(Window w)
{
var folder = await w.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{
AllowMultiple = false,
SuggestedStartLocation =
await w.StorageProvider.TryGetFolderFromPathAsync(
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
});
foreach (var point in Points)
{
DataSerialization.SavePoint(point.GetPoint(), Path.Combine(HttpUtility.HtmlDecode(folder[0].Path.AbsolutePath), point.Name + ".json") );
}
}
// Visual properties