示例#1
0
文件: Model.cs 项目: ruly-rudel/ruly
        public Model()
        {
            // prepare model state/data
            m_data = new PersistentModelData ();

            // prepare DB
            //			Log.Debug ("Ruly", "ext sd: " + Android.OS.Environment.ExternalStorageDirectory);
            //			string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            string folder = Android.OS.Environment.ExternalStorageDirectory + "/ruly/ruly.db";
            Util.EnsureDirectory (System.IO.Path.GetDirectoryName (folder));
            m_db = new SQLiteConnection (folder);
            m_db.CreateTable<TaskData>();
            m_db.CreateTable<TaskHistory>();
            m_db.CreateTable<TaskAlarm> ();

            m_unknown_task = new TaskData () {
                Id = -1,
                Title = "休憩"
            };

            // create ViewModel I/F datasets
            Tasks = new ObservableCollection<TaskData>();
            TaskHistories = new ObservableCollection<CombinedTaskHistory> ();
            RawTaskHistories = new ObservableCollection<CombinedTaskHistory> ();
            UpdateTaskList ();

            // show today task at default
            // this result in call UpdateTaskHistoryList();
            ShowDate = DateTime.Today;
        }
示例#2
0
        public Model()
        {
            // prepare model state/data
            m_data = new PersistentModelData();

            // prepare DB
//			Log.Debug ("Ruly", "ext sd: " + Android.OS.Environment.ExternalStorageDirectory);
//			string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            string folder = Android.OS.Environment.ExternalStorageDirectory + "/ruly/ruly.db";

            Util.EnsureDirectory(System.IO.Path.GetDirectoryName(folder));
            m_db = new SQLiteConnection(folder);
            m_db.CreateTable <TaskData>();
            m_db.CreateTable <TaskHistory>();
            m_db.CreateTable <TaskAlarm> ();

            m_unknown_task = new TaskData()
            {
                Id    = -1,
                Title = "休憩"
            };

            // create ViewModel I/F datasets
            Tasks            = new ObservableCollection <TaskData>();
            TaskHistories    = new ObservableCollection <CombinedTaskHistory> ();
            RawTaskHistories = new ObservableCollection <CombinedTaskHistory> ();
            UpdateTaskList();

            // show today task at default
            // this result in call UpdateTaskHistoryList();
            ShowDate = DateTime.Today;
        }
示例#3
0
        public void LoadState()
        {
            string folder = Android.OS.Environment.ExternalStorageDirectory + "/ruly/";
//			string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var path = System.IO.Path.Combine(folder, "model_data.json");

            try {
                var sw = new StreamReader(path, Encoding.Unicode);
                if (sw != null)
                {
                    m_data = Newtonsoft.Json.JsonConvert.DeserializeObject <PersistentModelData>(sw.ReadToEnd());
                    sw.Close();
                }
            } catch (Exception e) {
                Log.Debug("RULY", e.Message);
            }
        }
示例#4
0
文件: Model.cs 项目: ruly-rudel/ruly
        public void LoadState()
        {
            string folder = Android.OS.Environment.ExternalStorageDirectory + "/ruly/";
            //			string folder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var path = System.IO.Path.Combine (folder, "model_data.json");

            try {
                var sw = new StreamReader(path, Encoding.Unicode);
                if(sw != null) {
                    m_data = Newtonsoft.Json.JsonConvert.DeserializeObject<PersistentModelData>(sw.ReadToEnd());
                    sw.Close();
                }
            } catch (Exception e) {
                Log.Debug ("RULY", e.Message);
            }
        }