JSON export added
This commit is contained in:
@@ -37,7 +37,6 @@ public partial class PointViewModel : ViewModelBase
|
||||
Properties = point.Properties;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global
|
||||
public Point GetPoint()
|
||||
{
|
||||
return new Point
|
||||
@@ -45,6 +44,7 @@ public partial class PointViewModel : ViewModelBase
|
||||
Name = Name,
|
||||
Description = Description,
|
||||
Equipment = Equipment ?? [],
|
||||
Images = Images ?? [],
|
||||
Properties = Properties ?? []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user