using GeekDesk.Constant;
using GeekDesk.Util;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
/// 
/// 程序数据
/// 
namespace GeekDesk.ViewModel
{
    [Serializable]
    public class AppData : INotifyPropertyChanged
    {
        private ObservableCollection menuList; //菜单信息及菜单对应icon信息
        private AppConfig appConfig = new AppConfig(); //程序设置信息
        private ObservableCollection hiToDoList; //历史待办
        private ObservableCollection toDoList; //未处理待办 为了提高任务效率 分开处理
        public ObservableCollection HiToDoList
        {
            get
            {
                if (hiToDoList == null)
                {
                    hiToDoList = new ObservableCollection();
                }
                return hiToDoList;
            }
            set
            {
                hiToDoList = value;
                OnPropertyChanged("HiToDoList");
            }
        }
        public ObservableCollection ToDoList
        {
            get
            {
                if (toDoList == null)
                {
                    toDoList = new ObservableCollection();
                }
                return toDoList;
            }
            set
            {
                toDoList = value;
                OnPropertyChanged("ToDoList");
            }
        }
        public ObservableCollection MenuList
        {
            get
            {
                if (menuList == null)
                {
                    menuList = new ObservableCollection();
                }
                return menuList;
            }
            set
            {
                menuList = value;
                OnPropertyChanged("MenuList");
            }
        }
        public AppConfig AppConfig
        {
            get
            {
                return appConfig;
            }
            set
            {
                appConfig = value;
                OnPropertyChanged("AppConfig");
            }
        }
        [field: NonSerializedAttribute()]
        public event PropertyChangedEventHandler PropertyChanged;
        private void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
            CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
        }
    }
}