Beispiel #1
0
        /// <summary>
        /// Selected a class.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            SectionButton button = (SectionButton)sender;

            ClassNameBox.Text = (String)button.Content;
            StudentSelectPanel.Children.Clear();
            CurrentSection = button.Info;

            foreach (var item in ClassSelectPanel.Children)
            {
                if (item is SectionButton)
                {
                    ((SectionButton)item).IsEnabled = true;
                }
            }

            foreach (StudentInfo info in button.Info.Students.OrderBy(inf => inf.LastName).ThenBy(inf => inf.FirstName).ToList())
            {
                StudentButton studentButton = new StudentButton(info);
                studentButton.Click += StudentButton_Click;
                StudentSelectPanel.Children.Add(studentButton);
            }

            try
            {
                CommentSettings.CurrentHeaderParagraph = await button.Info.CurrentCommentHeaderAsync();
            }
            // If something goes wrong alert the user.
            catch (WebException ex)
            {
                String responseBody;
                using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream()))
                {
                    responseBody = sr.ReadToEnd();
                }

                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(responseBody);
                await dialog.ShowAsync();
            }

            using (MemoryStream ms = new MemoryStream())
            {
                StreamWriter writer = new StreamWriter(ms);
                writer.Write(CommentSettings.CurrentHeaderParagraph.Html);
                writer.Flush();
                ms.Position = 0;

                EditorBox.Load(ms, FormatType.Html);
            }


            button.IsEnabled = false;
            CurrentState     = State.LoadedHeader;
            StateChanged(this, new EventArgs());
        }
Beispiel #2
0
        private async void StudentButton_Click(object sender, RoutedEventArgs e)
        {
            StudentButton btn = (StudentButton)sender;

            StudentNameBox.Text = (String)btn.Content;
            CurrentStudent      = btn.Info;

            foreach (var item in StudentSelectPanel.Children)
            {
                if (item is StudentButton)
                {
                    ((StudentButton)item).IsEnabled = true;
                }
            }

            try
            {
                CommentSettings.CurrentStudentComment = await CurrentStudent.CurrentCommentAsync();
            }
            // If something goes wrong alert the user.
            catch (WebException ex)
            {
                String responseBody;
                using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream()))
                {
                    responseBody = sr.ReadToEnd();
                }

                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(responseBody);
                await dialog.ShowAsync();
            }

            using (MemoryStream ms = new MemoryStream())
            {
                StreamWriter writer = new StreamWriter(ms);
                writer.Write(CommentSettings.CurrentStudentComment.HtmlContent);
                writer.Flush();
                ms.Position = 0;

                EditorBox.Load(ms, FormatType.Html);
            }

            btn.IsEnabled = false;
            CurrentState  = State.LoadedStudent;
            StateChanged(this, new EventArgs());
        }