예제 #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
        private void ShowLoadSheepDialog()
        {
            openFileDialog1.Title           = "Load Sheep Scoring File";
            openFileDialog1.Filter          = "Sheep Score 2012 File|*.sheep12";
            openFileDialog1.CheckFileExists = true;

            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //temp game object - don't overwrite game in memory until we know load worked
            ShGame sg2 = new ShGame();

            try
            {
                XmlReaderSettings xrs = new XmlReaderSettings();
                using (XmlReader xr = XmlReader.Create(openFileDialog1.FileName))
                {
                    sg2.ReadFromXML(xr);
                }
            }
            catch
            {
                MessageBox.Show("Error reading from " + openFileDialog1.FileName);
                return;
            }

            sg             = sg2;
            sheep_modified = false;
        }
예제 #3
0
            public List <ShAnswer> Answers; //references

            //constructor. answers start blank
            public ShPlayer(ShGame ref_game, string player_name, decimal start_score = 0)
            {
                _Game      = ref_game;
                Name       = player_name;
                Answers    = new List <ShAnswer>(ref_game.Questions.Count);
                StartScore = start_score;
            }
예제 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = Application.ProductName;
            SetScoringMethod(ShScoringMethod.Sheep);
            sg = new ShGame();

            redrawTreeView();
            SetTextForAllTreenodes();
            sheep_modified = false;
        }
예제 #5
0
        //start new reveal
        private void newSheepToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult d = CheckToSave();

            if (d == DialogResult.Cancel)
            {
                return;
            }

            sg = new ShGame();
            redrawTreeView();
            sheep_modified = false;
        }
예제 #6
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);
        }
예제 #7
0
        //cgenerate post for score totals up to and including this question
        private void copyScoresUpToThisQuestionToolStripMenuItem_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;
            }

            Dictionary <ShPlayer, int> curScores =
                sg.Questions[cur_q_index].ScoreUpTo(true);

            foreach (ShPlayer plr in sg.Players)
            {
                if (!curScores.ContainsKey(plr))
                {
                    Clipboard.SetText("ERROR");
                    return;
                }
            }

            string txt = "[b]Scores after question " + (cur_q_index + 1).ToString() + ":[/b]"
                         + Environment.NewLine + Environment.NewLine;

            if (ShGame.IsScoreDescending(curScoreMethod))
            {
                txt += string.Join(Environment.NewLine, (from p in sg.Players
                                                         orderby curScores[p] descending
                                                         select p.Name + " - " + curScores[p]).ToArray());
            }
            else
            {
                txt += string.Join(Environment.NewLine, (from p in sg.Players
                                                         orderby curScores[p] ascending
                                                         select p.Name + " - " + curScores[p]).ToArray());
            }

            Clipboard.SetText(txt);
        }
예제 #8
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);
        }
예제 #9
0
            private ShGame _Game; //reference to Player in SheepGame.Players

            //constructor

            public ShQuestion(ShGame ref_game, string new_text)
            {
                _Game  = ref_game;
                Text   = new_text;
                Groups = new List <ShGroup>(ref_game.Players.Count);
            }
예제 #10
0
            public List <ShAnswer> Answers; //references

            //constructor. answers start blank
            public ShPlayer(ShGame ref_game, string player_name)
            {
                _Game   = ref_game;
                Name    = player_name;
                Answers = new List <ShAnswer>(ref_game.Questions.Count);
            }