/// <summary> /// Reads a config from the default config file, creating it if it doesn't exist. /// </summary> public static DiaryConfig ReadConfig() { if (!ConfigExists()) { DiaryConfig newConfig = new DiaryConfig(); newConfig.StartDate = DateTime.Now; newConfig.Weeks = DEFAULT_WEEKS; newConfig.Name = "User"; newConfig.MorningTime = new TimeSpan(8, 0, 0); newConfig.AfternoonTime = new TimeSpan(12, 0, 0); newConfig.EveningTime = new TimeSpan(18, 0, 0); newConfig.SpecialTime = new TimeSpan(21, 0, 0); WriteConfig(newConfig); } List<String> lines = FileManager.ReadLines(DIARY_CONFIG_FILE); DiaryConfig config = new DiaryConfig(); config.StartDate = DateTime.Parse(lines[0]); config.Weeks = int.Parse(lines[1]); config.Name = lines[2]; config.MorningTime = TimeSpan.Parse(lines[3]); config.AfternoonTime = TimeSpan.Parse(lines[4]); config.EveningTime = TimeSpan.Parse(lines[5]); config.SpecialTime = TimeSpan.Parse(lines[6]); return config; }
/// <summary> /// Reads a config from the default config file, creating it if it doesn't exist. /// </summary> public static DiaryConfig ReadConfig() { if (!ConfigExists()) { DiaryConfig newConfig = new DiaryConfig(); newConfig.StartDate = DateTime.Now; newConfig.Weeks = DEFAULT_WEEKS; newConfig.Name = "User"; newConfig.MorningTime = new TimeSpan(8, 0, 0); newConfig.AfternoonTime = new TimeSpan(12, 0, 0); newConfig.EveningTime = new TimeSpan(18, 0, 0); newConfig.SpecialTime = new TimeSpan(21, 0, 0); WriteConfig(newConfig); } List <String> lines = FileManager.ReadLines(DIARY_CONFIG_FILE); DiaryConfig config = new DiaryConfig(); config.StartDate = DateTime.Parse(lines[0]); config.Weeks = int.Parse(lines[1]); config.Name = lines[2]; config.MorningTime = TimeSpan.Parse(lines[3]); config.AfternoonTime = TimeSpan.Parse(lines[4]); config.EveningTime = TimeSpan.Parse(lines[5]); config.SpecialTime = TimeSpan.Parse(lines[6]); return(config); }
private void InitDiary() { diaryConfig = DiaryManager.ReadConfig(); diaryEntryCollection = DiaryEntryCollection.Load(); log.Write("Initialised Diary."); DateTime now = DateTime.Now; DateTime start = diaryConfig.StartDate; bool configured = DiaryManager.ConfigExists(); if (configured) { welcomeText(true); } if (now.DayOfYear - start.DayOfYear > 7) { // We're in week 2 now //button_nextWeek.Background = (SolidColorBrush)Resources["Colour6"]; selectedWeek = 2; } else { // Still in week 1 //button_prevWeek.Background = (SolidColorBrush)Resources["Colour6"]; selectedWeek = 1; } // Update diary UI UpdateDiaryUI(); //editingNote = false; }
private void InitDiary() { diaryConfig = DiaryManager.ReadConfig(); diaryEntryCollection = DiaryEntryCollection.Load(); log.Write("Initialised Diary."); DateTime now = DateTime.Now; DateTime start = diaryConfig.StartDate; bool configured = DiaryManager.ConfigExists(); if (configured) welcomeText(true); if (now.DayOfYear - start.DayOfYear > 7) { // We're in week 2 now //button_nextWeek.Background = (SolidColorBrush)Resources["Colour6"]; selectedWeek = 2; } else { // Still in week 1 //button_prevWeek.Background = (SolidColorBrush)Resources["Colour6"]; selectedWeek = 1; } // Update diary UI UpdateDiaryUI(); //editingNote = false; }
/// <summary> /// Writes a reminder config to the default config file. /// </summary> public static void WriteConfig(DiaryConfig config) { String s = String.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}", config.StartDate.ToString(), config.Weeks, config.Name, config.MorningTime, config.AfternoonTime, config.EveningTime, config.SpecialTime); FileManager.Write(DIARY_CONFIG_FILE, s); }