コード例 #1
0
        private void ButtonSearch_Click(object sender, EventArgs e)
        {
            string text = textBoxSearch.Text;
            //filtruoti

            var matchedForumContent = forum.Where(
                fo => fo.description.Contains(text)
                );

            var forumContent = matchedForumContent.Join(subjects, //^query
                                                        fo => fo.subjectId,
                                                        su => su.id,
                                                        (fo, su) => new
            {
                fo.id,
                fo.name,
                subject = su.name,
                fo.description
            });

            problemsGridView.Rows.Clear();

            foreach (var forumRow in forumContent)
            {
                problemsGridView.Rows.Add(forumRow.name, forumRow.subject, forumRow.description);
                CommentsManager.AddNewFile(forumRow.name + ".txt");
            }
            filterSubjectsComboBox.SelectedIndex = -1;
        }
コード例 #2
0
        private void FilterSubjectsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (filterSubjectsComboBox.SelectedIndex < 0)
            {
                return;
            }
            int selectedInd = ((Subjects.Subject)filterSubjectsComboBox.SelectedItem).id;
            //filtruoti
            var matchedForumContent = forum.Where(
                fo => fo.subjectId == selectedInd
                );

            var forumContent = matchedForumContent.Join(subjects, //^query
                                                        fo => fo.subjectId,
                                                        su => su.id,
                                                        (fo, su) => new
            {
                fo.id,
                fo.name,
                subject = su.name,
                fo.description
            });

            problemsGridView.Rows.Clear();

            foreach (var forumRow in forumContent)
            {
                problemsGridView.Rows.Add(forumRow.name, forumRow.subject, forumRow.description);
                CommentsManager.AddNewFile(forumRow.name + ".txt");
            }
            textBoxSearch.Text = "";
        }
コード例 #3
0
        public ProblemDiscussion(ForumPost forumPost)
        {
            InitializeComponent();

            FormConfig.GetFormConfig(this);

            this.forumPost                    = forumPost;
            this.problemNameLabel.Text        = forumPost.name;
            this.problemDescriptionLabel.Text = forumPost.description;
            this.upvoteButton                 = new VoteButton(forumPost);
            this.upvoteButton.Name            = "upvoteButton";
            this.upvoteButton.Location        = new System.Drawing.Point(7, 39);
            this.upvoteButton.Click          += (o, e) => UpdateVotesLabel(); //^lambda
            this.votesGroupBox.Controls.Add(this.upvoteButton);               //^events standard
            comments = new CommentsManager(forumPost, commentsPanel);
            comments.SuccessfullyAddedCommentEvent += SuccessfullyAddedCommentEventHandler;
        }
コード例 #4
0
        private void ForumForm_Load(object sender, EventArgs e)
        {
            var forumContent = subjects.GroupJoin(forum, //^query //^groupjoin
                                                  su => su.id,
                                                  fo => fo.subjectId,
                                                  (su, fo) => new
            {
                su.name,
                forumPosts = fo
            });

            foreach (var subject in forumContent)
            {
                foreach (var forumRow in subject.forumPosts)
                {
                    problemsGridView.Rows.Add(0, forumRow.name, subject.name, forumRow.description, forumRow.id);
                    CommentsManager.AddNewFile(forumRow.name + ".txt");
                }
            }

            //problemsGridView.Rows.Add("Lietuviu", "Foreign language", "Kas tas yr, renesansas???");
            //CommentsManager.AddNewFile("Lietuviu.txt");

            foreach (var subject in subjects)
            {
                filterSubjectsComboBox.Items.Add(subject);
            }
            //var forumContent = forum.GroupJoin(this.subjects, //change to users
            //    forumRow => forumRow.subjectId,
            //    subj => subj.id,
            //    (forumRow, subj) => new
            //    {
            //        forumRow.name,
            //        subject = subj,
            //        forumRow.description
            //        //subj.name,
            //        //forumRow.description
            //    }) ;
        }