예제 #1
0
        public void TestDefault()
        {
            PBDQConfig pC = conf.pBDQ;

            Assert.IsFalse(pC.markAsBlack);
            Assert.AreEqual(ColConfWinTest.cf5, pC.GetCfForPBDQLetter('p'));
            Assert.AreEqual(ColConfWinTest.cfu, pC.GetCfForPBDQLetter('b'));
            Assert.AreEqual(ColConfWinTest.cfBLEU, pC.GetCfForPBDQLetter('d'));
            Assert.AreEqual(ColConfWinTest.cfON, pC.GetCfForPBDQLetter('q'));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7));
        }
예제 #2
0
        private void CheckConsistency(PBDQConfig pC)
        {
            List <char> letters = new List <char>();

            for (char ci = 'A'; ci <= 'Z'; ci++)
            {
                letters.Add(ci);
            }
            for (char ci = 'a'; ci <= 'z'; ci++)
            {
                letters.Add(ci);
            }
            Assert.AreEqual(52, letters.Count);
            CharFormatting cfOthers = pC.GetCfForPBDQLetter('#');

            Assert.AreEqual(cfOthers, pC.GetCfForPBDQLetter(PBDQConfig.inactiveLetter));

            for (int i = 0; i < PBDQConfig.nrButtons; i++)
            {
                char           c;
                CharFormatting cf = pC.GetCfForPBDQButton(i, out c);
                if (c == PBDQConfig.inactiveLetter)
                {
                    Assert.AreEqual(cfOthers, cf);
                }
                else
                {
                    Assert.AreNotEqual(PBDQConfig.inactiveLetter, c);
                    Assert.AreEqual(cf, pC.GetCfForPBDQLetter(c));
                    Assert.AreEqual(c, pC.GetLetterForButtonNr(i));
                    if (letters.Contains(c))
                    {
                        letters.Remove(c);
                    }
                }
            }


            foreach (char c2 in letters)
            {
                Assert.AreEqual(cfOthers, pC.GetCfForPBDQLetter(c2));
            }
        }
예제 #3
0
        public void TestPBDQConfig()
        {
            PBDQConfig pc = new PBDQConfig();

            pc.UpdateLetter(3, 'e', TestTheText.fixCFs[1]);
            Assert.AreEqual(TestTheText.fixCFs[1], pc.GetCfForPBDQLetter('e'));
            Assert.AreEqual('e', pc.GetLetterForButtonNr(3));
            pc.UpdateLetter(4, 'f', TestTheText.fixCFs[2]);
            Assert.AreEqual(TestTheText.fixCFs[2], pc.GetCfForPBDQLetter('f'));
            pc.UpdateLetter(4, 'k', TestTheText.fixCFs[3]);
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQLetter('k'));
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQButton(4, out _));
            UndoFactory.UndoLastAction();
            Assert.AreEqual(TestTheText.fixCFs[2], pc.GetCfForPBDQButton(4, out _));
            UndoFactory.UndoLastAction();
            UndoFactory.UndoLastAction();
            Assert.AreEqual('q', pc.GetLetterForButtonNr(3));
            Assert.IsFalse(pc.markAsBlack);
            pc.SetMarkAsBlackTo(true);
            Assert.IsTrue(pc.markAsBlack);
            UndoFactory.UndoLastAction();
            Assert.IsFalse(pc.markAsBlack);
            UndoFactory.RedoLastCanceledAction();
            Assert.IsTrue(pc.markAsBlack);
            pc.UpdateLetter(4, 'k', TestTheText.fixCFs[3]);
            pc.Reset();
            Assert.IsFalse(pc.markAsBlack);
            Assert.AreEqual(' ', pc.GetLetterForButtonNr(4));
            UndoFactory.UndoLastAction();
            Assert.IsTrue(pc.markAsBlack);
            Assert.AreEqual(TestTheText.fixCFs[3], pc.GetCfForPBDQButton(4, out _));
            Assert.AreEqual('k', pc.GetLetterForButtonNr(4));
            UndoFactory.RedoLastCanceledAction();
            Assert.IsFalse(pc.markAsBlack);
            Assert.AreEqual(' ', pc.GetLetterForButtonNr(4));
        }
예제 #4
0
        public LetterFormatForm(char letter, int buttonNr, PBDQConfig inPbdqConf)
        {
            logger.ConditionalDebug("CTOR LetterFormatForm");

            InitializeComponent();
            pbdqConf = inPbdqConf;
            CharFormatting cf = pbdqConf.GetCfForPBDQLetter(letter);

            if (!HilightForm.CanOperate())
            {
                // We are not in Word
                btnCouleur.Width = btnCouleur.Width * 2;
                btnSurl.Visible  = false;
                btnSurl.Enabled  = false;
            }
            mcd = new MyColorDialog();
            mcd.CustomColors = StaticColorizControls.customColors;
            mcd.AnyColor     = true;
            mcd.FullOpen     = true;
            colorSet         = true; // Si le bouton "valider" est cliqué, la couleur doit être la couleur mise.
            inCF             = cf;
            theColor         = cf.color;
            mcd.Color        = theColor;
            hilightSet       = cf.changeHilight;
            theHilightColor  = cf.hilightColor;
            bold             = cf.bold;
            italic           = cf.italic;
            underscore       = cf.underline;
            theButtonNr      = buttonNr;

            bHandler = new FormatButtonHandler2(pbxBold, Properties.Resources.Bold, Properties.Resources.BoldSet,
                                                Properties.Resources.BoldPressed, Properties.Resources.BoldSetMouseOn1, SetBold, UnsetBold, bold);
            iHandler = new FormatButtonHandler2(pbxItalic, Properties.Resources.Italic, Properties.Resources.ItalicSet,
                                                Properties.Resources.ItalicPressed, Properties.Resources.ItalicSetOver, SetItalic, UnsetItalic, italic);
            uHandler = new FormatButtonHandler2(pbxUnderscore, Properties.Resources.Underscore, Properties.Resources.UnderscoreSet,
                                                Properties.Resources.UnderscorePressed, Properties.Resources.UnderscoreSetOver, SetUnderscore, UnsetUnderscore, underscore);

            btnCouleur.BackColor = theColor;
            btnSurl.BackColor    = theHilightColor;
            StringBuilder sb = new StringBuilder();
            char          c  = pbdqConf.GetLetterForButtonNr(theButtonNr);

            if (c != ' ')
            {
                sb.Append(pbdqConf.GetLetterForButtonNr(theButtonNr));
            }
            txbLetter.Text = sb.ToString();
        }
예제 #5
0
        public void TestMethod4()
        {
            // Il faut vérifier que le flag markAsBlack a bien l'effet voulu.
            PBDQConfig  pC  = conf.pBDQ;
            TestTheText ttt = new TestTheText(text1);

            ttt.AssertColor(12, TestTheText.black);

            // Tout marquer avec un seul CF
            SylConfig sC = conf.sylConf;

            for (int i = SylConfig.NrButtons - 1; i >= 0; i--)
            {
                if (sC.ButtonIsLastActive(i))
                {
                    sC.ClearButton(i);
                }
            }
            conf.sylConf.SetSylButtonCF(0, TestTheText.fixCFs[7]);
            ttt.MarkWords(conf);

            ttt.AssertNotColor(12, TestTheText.black);
            ttt.AssertBold(12, true);
            CharFormatting cf12 = ttt.GetCF(12);

            pC.SetMarkAsBlackTo(false);

            Assert.IsTrue(pC.UpdateLetter(0, 'M', TestTheText.fixCFs[0]));
            Assert.IsTrue(pC.UpdateLetter(1, 'P', TestTheText.fixCFs[1]));
            Assert.IsTrue(pC.UpdateLetter(2, 'e', TestTheText.fixCFs[2]));
            Assert.IsTrue(pC.UpdateLetter(3, 'h', TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(4, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(5, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(6, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));
            Assert.IsTrue(pC.UpdateLetter(7, PBDQConfig.inactiveLetter, TestTheText.fixCFs[3]));

            Assert.IsFalse(pC.UpdateLetter(3, 'M', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(4, 'M', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(5, 'P', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(6, 'e', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(7, 'h', TestTheText.fixCFs[0]));
            Assert.IsFalse(pC.UpdateLetter(1, 'M', TestTheText.fixCFs[0]));
            Assert.AreEqual('M', pC.GetLetterForButtonNr(0));
            Assert.AreEqual('P', pC.GetLetterForButtonNr(1));
            Assert.AreEqual('e', pC.GetLetterForButtonNr(2));
            Assert.AreEqual('h', pC.GetLetterForButtonNr(3));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7));

            pC.SetMarkAsBlackTo(false);
            Assert.AreEqual(pC.GetCfForPBDQLetter(
                                PBDQConfig.inactiveLetter), CharFormatting.NeutralCF);
            pC.SetMarkAsBlackTo(true);
            Assert.AreEqual(pC.GetCfForPBDQLetter(
                                PBDQConfig.inactiveLetter), TestTheText.blackCF);

            Assert.IsTrue(pC.UpdateLetter(4, 'x', TestTheText.fixCFs[4]));
            Assert.IsTrue(pC.UpdateLetter(5, 'y', TestTheText.fixCFs[5]));
            Assert.IsTrue(pC.UpdateLetter(6, 'z', TestTheText.fixCFs[6]));
            Assert.IsTrue(pC.UpdateLetter(7, '§', TestTheText.fixCFs[7]));
            CheckConsistency(pC);

            pC.SetMarkAsBlackTo(false);
            ttt.MarkLetters(conf);
            int index = ttt.S.IndexOf("Monsieur");

            ttt.AssertColor(index, TestTheText.fixCols[0]);
            ttt.AssertColor(index + 5, TestTheText.fixCols[2]);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertColor(index, TestTheText.fixCols[1]);
            index = ttt.S.IndexOf("cachait");
            ttt.AssertColor(index + 3, TestTheText.fixCols[3]);
            ttt.AssertNotColor(12, TestTheText.black);
            ttt.AssertCF(12, cf12);
            ttt.AssertBold(12, true);
            CheckConsistency(pC);

            pC.SetMarkAsBlackTo(true);
            ttt.MarkLetters(conf);
            index = ttt.S.IndexOf("Monsieur");
            ttt.AssertColor(index, TestTheText.fixCols[0]);
            ttt.AssertColor(index + 5, TestTheText.fixCols[2]);
            index = ttt.S.IndexOf("Poiret");
            ttt.AssertColor(index, TestTheText.fixCols[1]);
            index = ttt.S.IndexOf("cachait");
            ttt.AssertColor(index + 3, TestTheText.fixCols[3]);
            ttt.AssertColor(12, TestTheText.black);
            ttt.AssertBold(12, true);

            pC.Reset();
            Assert.IsFalse(pC.markAsBlack);
            Assert.AreEqual(ColConfWinTest.cf5, pC.GetCfForPBDQLetter('p'));
            Assert.AreEqual(ColConfWinTest.cfu, pC.GetCfForPBDQLetter('b'));
            Assert.AreEqual(ColConfWinTest.cfBLEU, pC.GetCfForPBDQLetter('d'));
            Assert.AreEqual(ColConfWinTest.cfON, pC.GetCfForPBDQLetter('q'));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(4));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(5));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(6));
            Assert.AreEqual(PBDQConfig.inactiveLetter, pC.GetLetterForButtonNr(7));
        }