using AddInPlugin;
|
using OpenTap.Addin;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using System.IO;
|
using UtilLib;
|
|
namespace OpenTapEditor
|
{
|
public class UIStationGlobalsManager : DefaultStationGlobalsManager, INotifyPropertyChanged
|
{
|
public static UIStationGlobalsManager Instance { get; } = new UIStationGlobalsManager();
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
private ObservableCollection<TestVariable> datasource;
|
public ObservableCollection<TestVariable> Datasource
|
{
|
get
|
{
|
return datasource;
|
}
|
set
|
{
|
datasource = value;
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Datasource)));
|
}
|
}
|
|
private UIStationGlobalsManager()
|
{
|
ReadFromLocal();
|
}
|
|
public IEnumerable<TestVariable> ReadFromLocal()
|
{
|
if (Datasource == null)
|
{
|
string path = Path.Combine(GetRegister(), "Config", "StationGlobals.data");
|
if (!File.Exists(path))
|
{
|
Datasource = new ObservableCollection<TestVariable>();
|
}
|
else
|
{
|
Datasource = XmlHelper.DeserializeFromXml<ObservableCollection<TestVariable>>(path);
|
}
|
}
|
return Datasource;
|
}
|
}
|
}
|