예제 #1
0
        void newWindow_RaiseCustomEvent(object sender, CustomEventArgs e)
        {
            String   classAbbr = e.classAbbrev;
            CourseDB courseDB  = CourseDB.Instance;
            Course   c         = courseDB.fetchCourseByName(classAbbr);

            c.Reviews.Add(e.userReview);
            c.Tags.Add(e.tag);
            CourseListItemControl clic = courseDB.getControl(c);

            ReviewPanel reviewPanel = new ReviewPanel();

            reviewPanel.RatingNumber.Text  = e.userReview.GetRating() + "";
            reviewPanel.ReviewSummary.Text = e.userReview.Summary;
            reviewPanel.Title.Text         = e.userReview.Title;
            clic.CommentsStackPanel.Children.Add(reviewPanel);

            clic.Star.RatingValue = c.GetRating();
            clic.TagLabel.Text    = c.CourseTagsToString();

            ReviewClass.Remove(classAbbr);

            if (ReviewClass.Count == 0)
            {
                this.ReviewButton.IsEnabled  = false;
                this.ReviewButton.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF747474"));
            }
        }
예제 #2
0
        /// <summary>
        /// Given a Course, generate a CourseListItemControl object for it.
        /// </summary>
        /// <param name="cCourse">Course to generate Control from</param>
        /// <returns>The Generated Control.</returns>
        private CourseListItemControl generateCLIC(Course cCourse)
        {
            // Generate new Control and populate.
            CourseListItemControl pReturnControl = new CourseListItemControl(cCourse);

            pReturnControl.CourseNameLabel.Content = cCourse.CourseAbbrev + "\t" + cCourse.CourseName;
            pReturnControl.CourseDayLabel.Text     = cCourse.SceduleDayToString();
            pReturnControl.CourseTime.Text         = cCourse.SceduleTimeToString();
            pReturnControl.CourseRoom.Text         = cCourse.Location;
            pReturnControl.ProfNameLabel.Text      = cCourse.ProfessorName;

            if (cCourse.StatusToString().Equals("Open"))
            {
                Uri uri = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + "../../green_dot.png");
                pReturnControl.StatusIcon.Source = new BitmapImage(uri);
            }
            else
            {
                Uri uri = new Uri(System.AppDomain.CurrentDomain.BaseDirectory + "../../red_dot.png");
                pReturnControl.StatusIcon.Source = new BitmapImage(uri);
            }
            pReturnControl.StatusLabel.Text            = cCourse.getStatusAbbrev();
            pReturnControl.CourseDescriptionLabel.Text = cCourse.Description;
            pReturnControl.TagLabel.Text    = cCourse.CourseTagsToString();
            pReturnControl.Height           = CourseListItemControl.ShortDescriptionHeight;
            pReturnControl.PreReqLabel.Text = cCourse.PreReqToString();
            pReturnControl.Star.RatingValue = cCourse.GetRating();

            foreach (Tutorial t in cCourse.Tutorials)
            {
                pReturnControl.TutorialTimeDropDown.Items.Add(t);
            }
            if (cCourse.Tutorials.Count == 0)
            {
                pReturnControl.TutorialTimeDropDown.Items.Add("No tutorials");
            }

            pReturnControl.TutorialTimeDropDown.SelectedIndex = 0;

            foreach (UserReview rev in cCourse.Reviews)
            {
                ReviewPanel reviewPanel = new ReviewPanel();
                reviewPanel.RatingNumber.Text  = rev.GetRating() + "";
                reviewPanel.ReviewSummary.Text = rev.Summary;
                reviewPanel.Title.Text         = rev.Title;
                pReturnControl.CommentsStackPanel.Children.Add(reviewPanel);
            }

            return(pReturnControl);
        }