protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            this.target = e.Parameter as TargetDiary;
            if (target.qExist)
            {
                QuickDiary.Text        = DiaryManage.getQuickDiary(target.qIndex).getContent();
                EmojiBrush.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/emotion/" + DiaryManage.getQuickDiary(target.qIndex).getEmotion() + ".png"));
                Emoji.Background       = EmojiBrush;
            }
            else
            {
                QuickDiary.Text = "No QuickDiary record";
            }

            if (target.dExist)
            {
                //DiaryManage.getDiary(target.dIndex).readContent();
                while (!DiaryManage.getDiary(target.dIndex).getHaveRead())
                {
                    ;
                }
                DailyDiary.Text = DiaryManage.getDiary(target.dIndex).getContent();
            }
            else
            {
                DailyDiary.Text = "No diary record";
            }
        }
Пример #2
0
        //跳转到成功签到这个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 UserWelcome()
        {
            this.InitializeComponent();
            DateTime currentTime = DateTime.Now;
            int      year        = (int)DataUnit.GetData("7");
            int      month       = (int)DataUnit.GetData("8");
            int      day         = (int)DataUnit.GetData("9");
            DateTime StartTime   = new DateTime((int)DataUnit.GetData("7"), (int)DataUnit.GetData("8"), (int)DataUnit.GetData("9"));
            int      totalDiarys = DiaryManage.getCount();

            int totalDays = (int)currentTime.Subtract(StartTime).TotalDays;

            if (totalDays == 0)
            {
                cal.Text = "欢迎使用Life Tracer~愿与你共度未来的长久时光~";
            }
            else
            {
                cal.Text = "Life Tracer已经陪你走过了" + totalDays + "天,这些天里你一共写过" + totalDiarys +
                           "篇日记";
                float ratio = (float)totalDiarys / (float)totalDays;
                if (ratio >= 0.7)
                {
                    tips.Text = "当前写日记习惯非常良好,请继续保持~";
                }
                else if (ratio >= 0.4)
                {
                    tips.Text = "写日记是个好习惯,再接再厉~";
                }
                else
                {
                    tips.Text = "最近工作繁忙吗?最好不要放弃写日记的习惯~";
                }
            }
        }
Пример #4
0
 public MainPage()
 {
     this.InitializeComponent();
     DiaryManage.readData();
     DiaryManage.readQuickData();
     MainView.Navigate(typeof(Welcome));
     Back.Visibility = Visibility.Collapsed;
 }
Пример #5
0
        private async void next_Click(object sender, RoutedEventArgs e)
        {
            if (emoji.Length == 0)
            {
                MessageDialog saves = new MessageDialog("Please choose your mood", "Message");
                saves.Commands.Add(new UICommand("ok"));
                await saves.ShowAsync();

                return;
            }
            if (background == 0)
            {
                MessageDialog saves = new MessageDialog("Please choose your background", "Message");
                saves.Commands.Add(new UICommand("ok"));
                await saves.ShowAsync();

                return;
            }


            //从diarycontent移植过来的代码
            string   fileName;
            DateTime currentTime = DateTime.Now;

            fileName = currentTime.Year.ToString() + "-" + currentTime.Month.ToString() + "-" + currentTime.Day.ToString();
            folder   = ApplicationData.Current.LocalFolder;
            diary    = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

            using (Stream file = await diary.OpenStreamForWriteAsync())
            {
                using (StreamWriter diaryWriter = new StreamWriter(file))
                {
                    diaryWriter.Write(DiaryText);
                    int[] createTime = new int[3];
                    createTime[0] = currentTime.Year;
                    createTime[1] = currentTime.Month;
                    createTime[2] = currentTime.Day;
                    DailyDiary newDialyDiary = new DailyDiary(emoji, createTime, background, tagContent, fileName);
                    DiaryManage.addDiary(newDialyDiary);
                }
            }

            MessageDialog save = new MessageDialog("Save successfully", "Message");

            save.Commands.Add(new UICommand("ok", uicommand =>
            {
                Frame.Navigate(typeof(UserWelcome));
            })
                              );
            await save.ShowAsync();
        }
Пример #6
0
 private void showResults()
 {
     if (results.Count != 0)
     {
         noResult.Visibility = Visibility.Collapsed;
         foreach (int i in results)
         {
             DailyDiary   temp      = DiaryManage.getDiary(i);
             string       diaryDate = temp.getYear().ToString() + "年" + temp.getMonth().ToString() + '月' + temp.getDay().ToString() + "日";
             ListViewItem diaryItem = new ListViewItem();
             diaryItem.Content  = diaryDate;
             diaryItem.FontSize = 48;
             diaryItem.Name     = i.ToString();
             resultsList.Items.Add(diaryItem);
         }
     }
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            this.index = (int)e.Parameter;
            folder     = ApplicationData.Current.LocalFolder;
            file       = await StorageFile.GetFileFromPathAsync(ApplicationData.Current.LocalFolder.Path + "\\" + DiaryManage.getDiary(index).getFileName());

            Emotion.ImageSource        = new BitmapImage(new Uri("ms-appx:/Assets/emotion/" + DiaryManage.getDiary(index).getEmotion() + ".png"));
            GridBackground.ImageSource = new BitmapImage(new Uri("ms-appx:/Assets/background/bg" + DiaryManage.getDiary(index).getBackground().ToString() + ".jpg"));
            Emoji.Background           = Emotion;
            background.Background      = GridBackground;
            switch (DiaryManage.getDiary(index).getEmotion())
            {
            default:
                Describtion.Text = "";
                break;

            case "smiling":
                Describtion.Text = "今天过的不错!~";
                break;

            case "angry": Describtion.Text = "烦死了烦死了烦死了!!!"; break;

            case "boring": Describtion.Text = "=_= 今天好无聊啊"; break;

            case "depressed": Describtion.Text = "有些小失落……"; break;

            case "happy": Describtion.Text = "Oh~Year!太开心了!~>_<!!"; break;

            case "jealous": Describtion.Text = "哼,那些家伙肯定作弊了!"; break;

            case "sad": Describtion.Text = "T_T 欲语泪先流……"; break;

            case "upsetting": Describtion.Text = "唉……"; break;
            }
            //下面一句写QuickDiary的text内容
            using (Stream diary = await file.OpenStreamForReadAsync())
            {
                using (StreamReader read = new StreamReader(diary))
                {
                    DailyDiary.Text = read.ReadToEnd();
                }
            }
        }
Пример #8
0
        private void beginSearch_Click(object sender, RoutedEventArgs e)
        {
            getKeyWords();
            startYear    = (filterYear1.SelectedIndex == 0) ? 2016 : Int32.Parse(filterYear1.SelectedItem.ToString());
            endYear      = (filterYear2.SelectedIndex == 0) ? 2050 : Int32.Parse(filterYear2.SelectedItem.ToString());
            startMonth   = Int32.Parse(filterMonth1.SelectedItem.ToString());
            endMonth     = Int32.Parse(filterMonth2.SelectedItem.ToString());
            startDay     = Int32.Parse(filterDay1.SelectedItem.ToString());
            endDay       = Int32.Parse(filterDay2.SelectedItem.ToString());
            restrictMood = (filterMood.SelectedIndex == 0) ? false : true;
            mood         = filterMood.SelectedItem.ToString();
            results      = new ArrayList();
            int i;

            for (i = 0; i < DiaryManage.getCount(); ++i)
            {
                DailyDiary temp = DiaryManage.getDiary(i);
                if (temp.getYear() >= startYear && temp.getMonth() >= startMonth && temp.getDay() >= startDay)
                {
                    break;
                }
            }
            for (; i < DiaryManage.getCount(); ++i)
            {
                DailyDiary temp = DiaryManage.getDiary(i);
                if (temp.getYear() > endYear ||
                    temp.getYear() == endYear && temp.getMonth() > endMonth ||
                    temp.getYear() == endYear && temp.getMonth() == endMonth && temp.getDay() > endDay)
                {
                    break;
                }
                if (restrictMood && !mood.Equals(temp.getEmotion()))
                {
                    continue;
                }
                ArrayList tempTags = temp.getTags();
                Boolean   flag1    = true;
                for (int n = 0; n < kwCount; ++n)
                {
                    Boolean flag2 = false;
                    for (int j = 0; j < tempTags.Count; ++j)
                    {
                        if (keyWords[n].Equals(tempTags[j]))
                        {
                            flag2 = true;
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        flag1 = false;
                        break;
                    }
                }
                if (flag1 || kwCount == 0)
                {
                    results.Add(i);
                }
            }
            Frame.Navigate(typeof(SearchResults), results);
        }