예제 #1
0
 private void OnLoad(object sender, RoutedEventArgs e)
 {
     try
     {
         selectedExam = GlobalVars.UserExams[index];
         PageTitle.DataContext = selectedExam.Ename;
         ExamDateHolder.DataContext = selectedExam.Edate.Date.ToLongDateString();
         ExamTimeHolder.DataContext = String.Concat(selectedExam.Etime.Hour.ToString(), ":", selectedExam.Etime.Minute.ToString(), " hrs");
         if (selectedExam.Priority == "High Priority")
         {
             DispImg.Source = new BitmapImage(new Uri("/Images/high.png", UriKind.Relative));
             TimeSpan span = selectedExam.Edate.Subtract(DateTime.Today);
             CommentTbl.Text = "This exam seems to be very important. Lets gear up ourselves and GET THIS DONE. Only " + span.Days.ToString() + " days remaining.";
         }
         else if (selectedExam.Priority == "Medium Priority")
         {
             DispImg.Source = new BitmapImage(new Uri("/Images/attention.png", UriKind.Relative));
             TimeSpan span = selectedExam.Edate.Subtract(DateTime.Today);
             CommentTbl.Text = "Exam seems easy but important. Leave no loophole and crack this exam. Only " + span.Days.ToString() + " days remaining.";
         }
         else if (selectedExam.Priority == "Low Priority")
         {
             DispImg.Source = new BitmapImage(new Uri("/Images/everythingok.png", UriKind.Relative));
             TimeSpan span = selectedExam.Edate.Subtract(DateTime.Today);
             CommentTbl.Text = "Seems like this exam is a piece of cake for you. Go ahead and score high. Only " + span.Days.ToString() + " days remaining.";
         }
     }
     catch
     {
         MessageBox.Show("Sorry the page u are trying to visit no longer exists. Maybe you had deleted this exam.");
         NavigationService.GoBack();
     }
 }
예제 #2
0
 private void OnLoad(object sender, RoutedEventArgs e)
 {
     try
     {
         if (index != -1)
         {
             PageTitle.DataContext = "edit details";
             using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
             {
                 List<Exam> temp = new List<Exam>();
                 if (myIsolatedStorage.FileExists("Exams.xml"))
                 {
                     using (IsolatedStorageFileStream stream1 = new IsolatedStorageFileStream("Exams.xml", FileMode.Open, FileAccess.Read, myIsolatedStorage))
                     {
                         XmlSerializer serializer = new XmlSerializer(typeof(List<Exam>));
                         temp = (List<Exam>)serializer.Deserialize(stream1);
                     }
                     ToEdit = temp[index];
                     if (firstload)
                     {
                         examNameTbx.DataContext = ToEdit.Ename;
                         examDate.Value = ToEdit.Edate;
                         examTime.Value = ToEdit.Etime;
                         priorityPicker.SelectedIndex = GlobalVars.Priorities.IndexOf(ToEdit.Priority);
                         firstload = false;
                     }
                 }
             }
         }
         else
             PageTitle.DataContext = "add new exam";
     }
     catch
     {
         MessageBox.Show("Oops! Something went wrong. You might have deleted the item that was on this page.");
         NavigationService.GoBack();
     }
 }