You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.8 KiB

3 years ago
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ECMonitor.PlayerDraw.Code
{
/// <summary>
/// 数据模型基类
/// </summary>
[Serializable]
public abstract class DataBase : BindableBase, INotifyPropertyChanged
{
public DataBase(string fileName)
{
string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Computer Madman");
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
DataPath = Path.Combine(directory, fileName);
}
[NonSerialized]
string dataPath;
/// <summary>
/// 保存文件的路径
/// </summary>
public string DataPath
{
get
{
return dataPath;
}
set
{
dataPath = value;
}
}
/// <summary>
/// 在更改属性值时发生。
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 用于触发INotifyPropertyChanged的PropertyChanged事件
/// </summary>
/// <param name="propertyName">属性名</param>
protected void DataChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
private string _title = "";
public string Title
{
get { return _title; }
set { SetProperty(ref _title, value); }
}
}
}