protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is Qusition)
     {
         qusition = (Qusition)e.Parameter;
     }
     else if (e.Parameter is AnswerDraft)
     {
         answerDraft   = (AnswerDraft)e.Parameter;
         MyAnswer.Text = answerDraft.Content;
     }
 }
Пример #2
0
        private async Task Get()
        {
            Draft         draft;
            List <string> File = new List <string>(await FileIO.ReadLinesAsync(storageFile));

            if (File.Count > 0)
            {
                foreach (var item in File)
                {
                    string[] a = item.Split("---");
                    if (a[0] == "A")
                    {
                        draft = new Draft
                        {
                            dateTime = Convert.ToDateTime(a[1]),
                            Title    = a[2],
                            Content  = a[3],
                        };
                        drafts.Add(draft);
                    }
                    else if (a[0] == "Q")
                    {
                        AnswerDraft answerDraft = new AnswerDraft
                        {
                            dateTime = Convert.ToDateTime(a[1]),
                            QName    = a[1],
                            Qid      = Convert.ToInt32(a[2]),
                            Content  = a[3],
                        };
                        answerDrafts.Add(answerDraft);
                    }
                }
                Draftlist.ItemsSource  = drafts;
                AnswerList.ItemsSource = answerDrafts;
            }
        }
Пример #3
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            await storageFolder.CreateFileAsync("Draft.txt", CreationCollisionOption.OpenIfExists);

            storageFile = await storageFolder.GetFileAsync("Draft.txt");

            Draft          draft;
            AnswerDraft    answerDraft;
            IList <string> File = Task.Run(async() => { return(await FileIO.ReadLinesAsync(storageFile)); }).Result;

            File = File.Where(p => p.Split("---").Last() == myStruct.id.ToString()).ToList();
            foreach (var item in File)
            {
                string[] a = item.Split("---");
                if (a[0] == "A")
                {
                    draft = new Draft
                    {
                        dateTime = Convert.ToDateTime(a[1]),
                        Title    = a[2],
                        Content  = a[3],
                    };
                    drafts.Add(draft);
                }
                else if (a[0] == "Q")
                {
                    answerDraft = new AnswerDraft
                    {
                        dateTime = Convert.ToDateTime(a[1]),
                        QName    = a[2],
                        Qid      = Convert.ToInt32(a[3]),
                        Content  = a[4]
                    };
                    answerDrafts.Add(answerDraft);
                }
            }

            if (e.Parameter is string str)
            {
                string[] a = str.Split("---");
                if (a[0] == "A")
                {
                    draft = new Draft
                    {
                        dateTime = Convert.ToDateTime(a[1]),
                        Title    = a[2],
                        Content  = a[3],
                    };
                    drafts.Add(draft);
                    RootPivot.SelectedIndex = 0;
                }
                else if (a[0] == "Q")
                {
                    answerDraft = new AnswerDraft
                    {
                        dateTime = Convert.ToDateTime(a[1]),
                        QName    = a[2],
                        Qid      = Convert.ToInt32(a[3]),
                        Content  = a[4],
                    };
                    answerDrafts.Add(answerDraft);
                    RootPivot.SelectedIndex = 1;
                }
            }
            Draftlist.ItemsSource  = drafts;
            AnswerList.ItemsSource = answerDrafts;
            this.Bindings.Update();
        }