//跳转到成功签到这个activity,并且将objective传到数据库中 private async void ensure_Click(object sender, RoutedEventArgs e) { if (QuickDiaryObject.getEmoji().Length == 0) { MessageDialog saves = new MessageDialog("Please choose your mood", "Message"); saves.Commands.Add(new UICommand("ok")); await saves.ShowAsync(); return; } DateTime currentTime = DateTime.Now; int[] createTime = new int[3]; createTime[0] = currentTime.Year; createTime[1] = currentTime.Month; createTime[2] = currentTime.Day; QuicDiary newQuickDiary = new QuicDiary(QuickDiaryObject.getEmoji(), createTime, QuickDiaryObject.getQuickDiary()); DiaryManage.addQuickDiary(newQuickDiary); MessageDialog save = new MessageDialog("Save successfully", "Message"); save.Commands.Add(new UICommand("ok", uicommand => { Frame.Navigate(typeof(UserWelcome)); }) ); await save.ShowAsync(); }
public static void addQuickDiary(QuicDiary newQuickDiary) { Boolean cover = false; if (qcount > 0 && quickDiarys[qcount - 1].getYear() == newQuickDiary.getYear() && quickDiarys[qcount - 1].getMonth() == newQuickDiary.getMonth() && quickDiarys[qcount - 1].getDay() == newQuickDiary.getDay()) { quickDiarys[qcount - 1] = newQuickDiary; cover = true; } else { quickDiarys[qcount++] = newQuickDiary; } writeQuickData(qcount - 1, cover); }
public async static void readQuickData() { folder = ApplicationData.Current.LocalFolder; Chart = await folder.CreateFileAsync("QuickDiaryCharts.ltr", CreationCollisionOption.OpenIfExists); using (Stream file = await Chart.OpenStreamForReadAsync()) { if (file.Length == 0) { return; } using (StreamReader chartsReader = new StreamReader(file)) { while (!chartsReader.EndOfStream) { int i, j; createTime = new int[3]; string temp = chartsReader.ReadLine(); for (i = 0; temp[i] != ' '; ++i) { ; } emotion = temp.Substring(0, i); while (temp[++i] == ' ') { ; } for (j = 0; temp[i + j] >= '0' && temp[i + j] <= '9'; ++j) { ; } createTime[0] = Int32.Parse(temp.Substring(i, j)); i = i + j; while (temp[++i] == ' ') { ; } for (j = 0; temp[i + j] >= '0' && temp[i + j] <= '9'; ++j) { ; } createTime[1] = Int32.Parse(temp.Substring(i, j)); i = i + j; while (temp[++i] == ' ') { ; } for (j = 0; temp[i + j] >= '0' && temp[i + j] <= '9'; ++j) { ; } createTime[2] = Int32.Parse(temp.Substring(i, j)); i = i + j; while (temp[++i] == ' ') { ; } for (j = 0; i + j < temp.Length; ++j) { ; } content = temp.Substring(i, j); quickDiarys[qcount++] = new QuicDiary(emotion, createTime, content); } } } }