コード例 #1
0
        //show right-click menu
        //set Tag of RCM_group or RCM_answer to the clicked node
        private void treeView1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right &&
                treeView1.GetNodeAt(e.Location) != null &&
                treeView1.GetNodeAt(e.Location).Tag != null)

            {
                TreeNode clicked_node = treeView1.GetNodeAt(e.Location);

                treeView1.SelectedNode = clicked_node;

                if (clicked_node.Tag.GetType() == typeof(ShGroup))
                {
                    ShGroup grp = (ShGroup)clicked_node.Tag;
                    RCM_group.Tag          = clicked_node;
                    RCM_group_correct.Text = "Mark " +
                                             ShGame.GetCorrectText(curScoreMethod, !grp.Correct);

                    RCM_group.Show(treeView1, e.Location);
                }
                else if (clicked_node.Tag.GetType() == typeof(ShAnswer))
                {
                    RCM_answer.Tag = clicked_node;
                    RCM_answer.Show(treeView1, e.Location);
                }
            }
        }
コード例 #2
0
        //returns text that should be displayed on this treenode
        private string TextForTreeNode(ShGroup grp)
        {
            if (grp.Answers.Count == 0)
            {
                return(grp.Text);
            }

            string scoreString = "";

            try
            {
                if (curScoreMethod == ShScoringMethod.Manual)
                {
                    scoreString = "[" + grp.GroupBonus + "]";
                }
                else
                {
                    string bonus_text = "";
                    if (grp.GroupBonus > 0)
                    {
                        bonus_text = " + " + grp.GroupBonus.ToString();
                    }
                    if (grp.GroupBonus < 0)
                    {
                        bonus_text = " - " + (-grp.GroupBonus).ToString();
                    }

                    scoreString = "[" + grp.Question.Scores(false)
                                  [grp.Answers[0].Player].ToString()
                                  + bonus_text + "]";
                }
            }
            catch
            {
                scoreString = "ERROR";
            }
            return(grp.Text + " - " + (grp.Correct ? "" :
                                       ShGame.GetCorrectText(curScoreMethod, grp.Correct).ToUpper() + " - ") + scoreString);
        }
コード例 #3
0
        //generate post for answers
        private void copyAnswersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (sg == null || sg.Players.Count == 0 || sg.Questions.Count == 0)
            {
                Clipboard.SetText("Either no questions or no players loaded.");
                return;
            }

            string txt = "[b]Question " + (cur_q_index + 1).ToString() + ": " +
                         sg.Questions[cur_q_index].Text + "[/b]" + Environment.NewLine + Environment.NewLine;

            #region sheepscoreoutput
            List <ShGroup> validGroups   = new List <ShGroup>(); //valid/correct groups
            List <ShGroup> validAces     = new List <ShGroup>(); //valid/correct aces
            List <ShGroup> invalidGroups = new List <ShGroup>(); //invalid/incorrect groups

            if (curScoreMethod == ShScoringMethod.Sheep || curScoreMethod == ShScoringMethod.Heep ||
                curScoreMethod == ShScoringMethod.Peehs1 || curScoreMethod == ShScoringMethod.Peehs2)
            {
                validGroups = (from g in sg.Questions[cur_q_index].Groups
                               where (g.Answers.Count > 1) && (g.Correct)
                               orderby - g.Answers.Count select g).ToList();

                validAces = (from g in sg.Questions[cur_q_index].Groups
                             where (g.Answers.Count == 1) && (g.Correct)
                             select g).ToList();

                invalidGroups = (from g in sg.Questions[cur_q_index].Groups
                                 where !g.Correct
                                 select g).ToList();
            }
            else if (curScoreMethod == ShScoringMethod.Kangaroo)
            {
                validGroups = (from g in sg.Questions[cur_q_index].Groups
                               where (g.Answers.Count > 1) && (!g.Correct)
                               orderby - g.Answers.Count select g).ToList();

                validAces = (from g in sg.Questions[cur_q_index].Groups
                             where (g.Answers.Count == 1) && (!g.Correct)
                             select g).ToList();

                invalidGroups = (from g in sg.Questions[cur_q_index].Groups
                                 where g.Correct
                                 select g).ToList();
            }
            else if (curScoreMethod == ShScoringMethod.Manual)
            {
                validGroups = (from g in sg.Questions[cur_q_index].Groups
                               where g.Correct
                               orderby - g.Answers.Count
                               select g).ToList();

                invalidGroups = (from g in sg.Questions[cur_q_index].Groups
                                 where !g.Correct
                                 select g).ToList();
            }

            foreach (ShGroup grp in validGroups)
            {
                txt += "[b]" + grp.Text + " - " +
                       GetScoreOutputText(grp.GetScore(false), grp.GroupBonus, curScoreMethod) +
                       "[/b]" + Environment.NewLine;

                foreach (ShAnswer ans in grp.Answers)
                {
                    txt += ans.Player.Name + " " +
                           GetBonusOutputText(ans.AnswerBonus, curScoreMethod)
                           + Environment.NewLine;
                }
                txt += Environment.NewLine;
            }

            if (validAces.Count > 0)
            {
                txt += "[b]ACES:[/b]" + Environment.NewLine + Environment.NewLine;
            }

            foreach (ShGroup grp in validAces)
            {
                txt += "[b]" + grp.Text + "[/b] - " + grp.Answers[0].Player.Name + " " +
                       GetBonusOutputText(grp.GroupBonus + grp.Answers[0].AnswerBonus, curScoreMethod)
                       + Environment.NewLine;
            }

            if (invalidGroups.Count > 0)
            {
                txt += Environment.NewLine + "[b]" + ShGame.GetCorrectText(curScoreMethod,
                                                                           (curScoreMethod == ShScoringMethod.Kangaroo ? true : false)).ToUpper() + "S[/b] - "
                       + invalidGroups[0].GetScore(false).ToString() + ":" + Environment.NewLine + Environment.NewLine;
            }
            foreach (ShGroup grp in invalidGroups)
            {
                foreach (ShAnswer ans in grp.Answers)
                {
                    txt += "[b]" + ans.Text + "[/b] - " + ans.Player.Name + " " +
                           GetBonusOutputText(grp.GroupBonus + grp.Answers[0].AnswerBonus, curScoreMethod)
                           + Environment.NewLine;
                }
            }

            #endregion

            Clipboard.SetText(txt);
        }