Ejemplo n.º 1
0
        // ****************************************************************************************
        // *                                     public methods                                   *
        // ****************************************************************************************

        public RTBText(RichTextBox theRTB)
            : base(theRTB.Text)
        {
            logger.ConditionalDebug("RTBText");
            rtb = theRTB;
            logger.ConditionalTrace(rtb.Text);
            finDeLignes = new List <int>();
            if (theRTB.Multiline)
            {
                int      lineStart = 0;
                string[] theLines  = theRTB.Lines;
                for (int i = 0; i < theLines.Length; i++)
                {
                    int eol = lineStart + theLines[i].Length - 1;
                    finDeLignes.Add(eol);
                    lineStart = eol + 2;
                }
            }
#if DEBUG
            for (int i = 0; i < finDeLignes.Count; i++)
            {
                logger.ConditionalTrace("finDeLignes[{0}] == {1}", i, finDeLignes[i]);
            }
#endif
        }
Ejemplo n.º 2
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case "ponctCF":
                ponctConf.SetCFwoState(p, prevCF);
                break;

            case "ponctCB":
                ponctConf.SetCBwoState(p, prevCB);
                break;

            case "masterCF":
                ponctConf.SetMasterCFWithoutPropagation(prevCF);
                // les familles de ponctuation sont restaurées individuellement.
                break;

            case "masterState":
                ponctConf.MasterState = prevMasterState;
                break;

            case "majDebCF":
                ponctConf.MajDebCF = prevCF;
                break;

            case "majDebCB":
                ponctConf.MajDebCB = prevCB;
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 3
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case "sonCF":
                if (prevCF != null)
                {
                    ccw.SetCFSon(son, prevCF);
                }
                break;

            case "sonCB":
                ccw.SetChkSon(son, prevCB);
                break;

            case "ill":
                ccw.IllRuleToUse = prevIllRule;
                break;

            case "defBeh":
                ccw.SetDefaultBehaviourTo(prevDefBeh);
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Réinitialise tous les flags à <c>false</c>.
 /// </summary>
 public override void Reset()
 {
     logger.ConditionalDebug("Reset");
     for (int i = 0; i < (int)Ucbx.last; i++)
     {
         SetCbuFlag((Ucbx)i, false);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Démarrage de la tâche.
 /// </summary>
 public void Start()
 {
     logger.ConditionalDebug("Start");
     stopwatch.Restart();
     invSpeed         = 10; // ça nous met la tâche standard à une seconde...
     previousProgress = 0;
     previousTime     = 0;
     OnStartEvent();
 }
Ejemplo n.º 6
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case SylActionType.sylBut:
                if (butNr == prevNrSetButtons)
                {
                    sylConf.ClearButton(butNr);
                }
                else
                {
                    sylConf.SetSylButtonCF(butNr, prevCF);
                }
                break;

            case SylActionType.clearBut:
                sylConf.SetSylButtonCF(butNr, prevCF);
                break;

            case SylActionType.doubleCons:
                sylConf.DoubleConsStd = prevBoolVal;
                break;

            case SylActionType.mode:
                sylConf.mode = prevMode;
                break;

            case SylActionType.marquerMuettes:
                sylConf.marquerMuettes = prevBoolVal;
                break;

            case SylActionType.dierese:
                sylConf.chercherDierese = prevBoolVal;
                break;

            case SylActionType.nbrePieds:
                sylConf.nbrPieds = prevNrPieds;
                break;

            case SylActionType.exceptMots:
                sylConf.ExcMots = prevExcMots;
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 7
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            InitNLog.StartNLog();

            logger.ConditionalDebug("ThisAddIn_Startup");
            MSWText.Initialize();
            WordRibbon.Init();

            thisAddIn = this;

            foreach (WordRibbon wr in wRibbonL)
            {
                wr.InitHandlers(this.Application);
            }
        }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Retourne la liste des positions des derniers caractères de chaque ligne (dans S).
 /// </summary>
 /// <remarks>Utilise <c>finDeLignes</c> comme cache.</remarks>
 /// <returns>La liste des positions des derniers caractères de chaque ligne (dans S)</returns>
 protected override List <int> GetLastLinesPos()
 {
     logger.ConditionalDebug("GetLastLinesPos");
     if (finsDeLigne == null)
     {
         logger.ConditionalTrace("txtRange.Start: {0}, txtRange.Length: {1}", txtRange.Start, txtRange.Length);
         finsDeLigne = new List <int>(7);
         int       i = 1;
         int       startColoredLine = 0;
         TextRange theLine          = txtRange.Lines(i);
         while ((theLine.Start > startColoredLine) && (theLine.Start + theLine.Length) <= (txtRange.Start + txtRange.Length))
         {
             logger.ConditionalTrace("i: {0}, theLine - Start: {1}, Length: {2}", i, theLine.Start, theLine.Length);
             if (theLine.Length > 0)
             {
                 int endFormattedLine = theLine.Start + theLine.Length - 1;
                 finsDeLigne.Add(endFormattedLine - txtRange.Start);
             }
             startColoredLine = theLine.Start;
             i++;
             theLine = txtRange.Lines(i);
         }
     }
     logger.ConditionalTrace("EXIT GetLastLinesPos");
     return(finsDeLigne);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Exécute l'annulation de la dernière action enregistrée. Ne fait rien s'il n'y a pas de
        /// dernière action à annuler.
        /// </summary>
        public static void UndoLastAction()
        {
            logger.ConditionalDebug("UndoLastAction");
            logger.ConditionalTrace(undoStack.ToString());
            CLAction act = undoStack.Pop();

            if (act != null)
            {
                undoing = true;
                act.Undo();
                OnUndoCountModified();
                redoStack.Push(act);
                OnRedoCountModified();
                undoing = false;
            }
        }
Ejemplo n.º 11
0
        public static bool BulkInsertDataTable(System.Data.DataTable dt, string tableName, string _connectionString)
        {
            bool IsSuccess = false;

            try
            {
                using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(_connectionString))
                {
                    con.Open();
                    //TODO: See if using TableLock is good, bad, or does not matter.
                    using (System.Data.SqlClient.SqlBulkCopy bc = new System.Data.SqlClient.SqlBulkCopy(con, System.Data.SqlClient.SqlBulkCopyOptions.TableLock, null))
                    {
                        bc.DestinationTableName = tableName;
                        bc.BatchSize            = dt.Rows.Count;
                        bc.BulkCopyTimeout      = 0;
                        bc.WriteToServer(dt);
                    }
                    IsSuccess = true;
                    logger.ConditionalDebug(string.Format("Batch Complete"));
                }
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("BulkInsertDataTable DataTable : {0}", dt.Rows.Count.ToString()));
                logger.Error(string.Format("BulkInsertDataTable Error : {0}", ex.Message));
                if (ex.InnerException != null)
                {
                    logger.Error(string.Format("BulkInsertDataTable Inner : {0}", ex.InnerException.Message));
                }
                throw ex;
            }
            return(IsSuccess);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// <see cref="CharFormatting"/> pour la lettre <paramref name="c"/>.
        /// </summary>
        /// <param name="c">La lettre pour laquelle on cherche le <see cref="CharFormatting"/></param>
        /// <returns>Le <see cref="CharFormatting"/> recherché. Si aucun <c>CharFormatting</c>
        /// n'est géré pour <c>c</c>, retourne le <c>CharFormatting</c> à appliquer pour
        /// les autres lettres. Celui-ci dépend du flag <see cref="markAsBlack"/>; ls sera soit
        /// neutre ou impliquera un formattage noir.</returns>
        public CharFormatting GetCfForPBDQLetter(char c)
        {
            logger.ConditionalDebug("GetCfForPBDQLetter bouton with letter {0}", c);
            CharFormatting toReturn = null;

            if (!bpdqCF.TryGetValue(c, out toReturn))
            {
                toReturn = defaultCF;
            }
            return(toReturn);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Opens the ConfigPane for the given Window.
        /// </summary>
        /// <param name="theWin">The window the ConfigPane is attached to</param>
        /// <param name="theDoc">The document (or presentation in PPT) that is opened in <c>theWin</c></param>
        /// <param name="inCustomTaskPanes">The <c>CustomTaskPaneCOllection the ConfigPane should be added to.</c></param>
        /// <param name="version">The version of the software as should be displayed in the pannel </param>
        /// <remarks>We assume that there can be several windows for the same document</remarks>
        public static void MakePaneVisibleInWin(Object theWin, Object theDoc, CustomTaskPaneCollection inCustomTaskPanes,
                                                string version)
        {
            logger.ConditionalDebug("MakePaneVisibleInWin");
            ConfigPane theCP;

            if (!confTaskPanes.TryGetValue(theWin, out theCP))
            {
                theCP = new ConfigPane(theWin, theDoc, inCustomTaskPanes, version);
                confTaskPanes.Add(theWin, theCP);
            }
            else
            {
                theCP.confContr.UpdateAll();
                // formellement, ceci n'est pas nécessaire. Néanmoins, ça donne un peu de robustesse. Si l'utilisateur constate
                // qqch de bizarre, il peut fermer et réouvrir le panneau qui se remettra à jour.
            }

            theCP.configTaskPane.Visible = true;
        }
Ejemplo n.º 14
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case ArcActType.arcButton:
                if (butNr == prevNrSetArcButtons)
                {
                    arcConf.ClearButton(butNr);
                }
                else
                {
                    arcConf.SetArcButtonCol(butNr, prevCol);
                }
                break;

            case ArcActType.clearArcBut:
                arcConf.SetArcButtonCol(butNr, prevCol);
                break;

            case ArcActType.decalage:
                arcConf.Decalage = prevFloat;
                break;

            case ArcActType.ecartement:
                arcConf.Ecartement = prevInt;
                break;

            case ArcActType.epaisseur:
                arcConf.Epaisseur = prevFloat;
                break;

            case ArcActType.hauteur:
                arcConf.Hauteur = prevInt;
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Ajoute un espace entre chaque mot.
        /// </summary>
        /// <remarks>
        /// A priori, la config n'est pas utilisée, mais ça permet de réutiliser le même "pattern"
        /// </remarks>
        /// <param name="conf">La <see cref="Config"/> à utiliser.</param>
        public void AddSpace(Config conf)
        {
            logger.ConditionalDebug("AddSpace");
            bool previousIsSpace = false;

            for (int i = txtRange.Length - 1; i >= 0; i--)
            {
                if (txtRange.Text[i] == ' ')
                {
                    if (!previousIsSpace)
                    {
                        TextRange space = txtRange.Characters(i + 1, 1);
                        space.InsertAfter(" ");
                    }
                    previousIsSpace = true;
                }
                else
                {
                    previousIsSpace = false;
                }
            }
        }
Ejemplo n.º 16
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case "cfOnly":
                pbdqConf.UpdateLetter(buttonNr, prevCF);
                break;

            case "leterAndCF":
                pbdqConf.UpdateLetter(buttonNr, prevLetter, prevCF);
                break;

            case "markAsBlack":
                pbdqConf.SetMarkAsBlackTo(prevMarkAsBlack);
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 17
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case ConfigActionType.confName:
                conf.SetConfigName(prevConfName);
                break;

            case ConfigActionType.duoConf:
                conf.duoConf = prevDuoConf;
                break;

            case ConfigActionType.newConfig:
                newConf.OnConfigReplaced(conf);
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 18
0
        public override void Undo()
        {
            logger.ConditionalDebug("Undo");
            switch (type)
            {
            case DuoActionType.alternance:
                duoConf.alternance = prevAlternance;
                break;

            case DuoActionType.colorisFunction:
                duoConf.colorisFunction = prevColFunction;
                break;

            case DuoActionType.nbreAlt:
                duoConf.nbreAlt = prevNbrAlt;
                break;

            default:
                logger.Error("Type de commande non traitée: {0}", type);
                throw new InvalidOperationException(String.Format("Type de commande non traitée: {0}", type));
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Initialise les éléments statiques de la classe. Crée le répertoire pour le fichiers
 /// de Coloriƨation.
 /// </summary>
 /// <param name="errMsgs">Si une erreur se produit, un message est ajouté à la liste.
 /// La liste n'est pas touchée si tout se passe bien. <c>null</c> indique que le message
 /// n'est pas souhaité par l'appelant.</param>
 public static void Init(List <string> errMsgs = null)
 {
     logger.ConditionalDebug("Init");
     // Ensure that colorizationDirPath folder does exist
     if (!System.IO.Directory.Exists(colorizationDirPath))
     {
         try
         {
             System.IO.Directory.CreateDirectory(colorizationDirPath);
             logger.Info("Dossier {0} créé.", colorizationDirPath);
         }
         catch (System.IO.IOException e)
         {
             errMsgs?.Add("Impossible de créer le répertoire" + colorizationDirPath);
             logger.Error("Impossible de créer le répertoire {0}. Erreur {1}", colorizationDirPath, e.Message);
         }
     }
 }
Ejemplo n.º 20
0
 public static void Init()
 {
     logger.ConditionalDebug("Init");
     ConfigControl.markSelLetters      = WordRibbon.ColorSelectedLetters;
     ConfigControl.colorizeAllSelPhons = WordRibbon.ColorSelectedPhons;
     ConfigControl.colSylSelLetters    = WordRibbon.ColorSelectedSyls;
     ConfigControl.colMotsSelLetters   = WordRibbon.ColorSelectedWords;
     ConfigControl.colLignesSelText    = WordRibbon.ColorSelectedLignes;
     ConfigControl.colVoyConsSelText   = WordRibbon.ColorSelectedVoyCons;
     ConfigControl.colNoirSelText      = WordRibbon.ColorSelectedNoir;
     ConfigControl.colMuettesSelText   = WordRibbon.ColorSelectedMuettes;
     ConfigControl.colDuoSelText       = WordRibbon.ColorSelectedDuo;
     ConfigControl.drawArcs            = WordRibbon.ColorSelectedArcs;
     ConfigControl.removeArcs          = WordRibbon.RemoveSelectedArcs;
     ConfigControl.colPonctuation      = WordRibbon.ColorPonctuation;
     ConfigControl.ecarter             = WordRibbon.Ecarter;
     ConfigControl.resserrer           = WordRibbon.Resserrer;
 }
 public static void Init()
 {
     logger.ConditionalDebug("Init");
     ConfigControl.markSelLetters      = Ribbon1.ColorSelectedLetters;
     ConfigControl.colorizeAllSelPhons = Ribbon1.ColorizeSelectedPhons;
     ConfigControl.colSylSelLetters    = Ribbon1.ColorSelectedSyls;
     ConfigControl.colMotsSelLetters   = Ribbon1.ColorSelectedWords;
     ConfigControl.colVoyConsSelText   = Ribbon1.ColorSelectedVoyCons;
     ConfigControl.colLignesSelText    = Ribbon1.ColorSelectedLignes;
     ConfigControl.colNoirSelText      = Ribbon1.ColorSelectedNoir;
     ConfigControl.colMuettesSelText   = Ribbon1.ColorSelectedMuettes;
     ConfigControl.colDuoSelText       = Ribbon1.ColorSelectedDuo;
 }
Ejemplo n.º 22
0
 public static void InitAutomat()
 {
     logger.ConditionalDebug("InitAutomat");
     AutomRuleFilter.InitAutomat();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Réinitialise à la configuration par défaut
 /// </summary>
 public override void Reset()
 {
     logger.ConditionalDebug("Reset");
     UndoFactory.StartRecording("Réinitialiser ponctuation");
     MasterCF = new CharFormatting(ColConfWin.coloredCF[(int)PredefCol.pinky], true, false, false);
     MajDebCF = MasterCF;
     MajDebCB = false;
     UndoFactory.EndRecording();
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Ouvre une fenêtre pour le choix des paramètres de formatage des caractères.
 /// </summary>
 /// <param name="cf">La configuration de départ à afficher.</param>
 /// <param name="theSon">Le nom du son à formater. Ne doit pas obligatoirement être un son.
 /// Est utilisé lors de l'appel de la méthode pour stocker le résultat.</param>
 /// <param name="displayText">Le texte à afficher comme titre de la fenêtre.</param>
 /// <param name="inCharFormResult">La méthode à appeler pour communiquer le nouveau
 /// <see cref="CharFormatting"/>. <paramref name="theSon"/> est passé également lors de cet
 /// appel.</param>
 public CharFormatForm(CharFormatting cf, string theSon,
                       string displayText, SetCharFormResult inCharFormResult)
 {
     logger.ConditionalDebug("CTOR CharFormatForm");
     InitCtor(cf, theSon, displayText, inCharFormResult);
 }
Ejemplo n.º 25
0
 static public void InitAutomat()
 {
     logger.ConditionalDebug("InitAutomat");
     AutomLetter.InitAutomat();
     autom = new AutomAutomat(theAutomat);
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Cherche une ou plusieurs diérèses dans le vers, transforme les mots correspondants
        /// jusqu'à ce que le nombre de pieds voulu soit atteint ou qu'il n'y ait plus de diérèse
        /// détectable.
        /// </summary>
        /// <param name="conf">La <c>Config</c> à utiliser pour l'identification des pieds.</param>
        /// <param name="nbrPiedsVoulu">Le nombre de pieds souhaité après la mise en évidence des
        /// diérèses. </param>
        /// <exception cref="ArgumentOutOfRangeException">Si <c>nbrPiedsVoulu</c> n'est pas
        /// plus grand que zéro.</exception>
        public void ChercheDierese(int nbrPiedsVoulu)
        {
            logger.ConditionalDebug("ChercheDierese, nrPiedsVoulu: {0}, vers; {1}", nbrPiedsVoulu, ToString());
            if (nbrPiedsVoulu > MaxNrPieds)
            {
                logger.Info(
                    "Chercher diérèse pour vers de plus de [0] pieds. Non exécuté. nrPiedsVoulu: {1}",
                    MaxNrPieds, nbrPiedsVoulu);
                return;
            }
            if (nbrPiedsVoulu <= 0)
            {
                logger.Fatal("nbrPiedsVoulu == {0}", nbrPiedsVoulu);
                throw new ArgumentOutOfRangeException(nameof(nbrPiedsVoulu), "doit être plus grand que 0");
            }
            // traitement spécial pour les nombres de pieds pairs, parcequ'ils le valent bien!
            if (nbrPiedsVoulu % 2 == 0)
            {
                // nombre pair de pieds
                // Y a-t-il un hémistiche à la moitié du vers ou juste avant?
                int             demiVers = nbrPiedsVoulu / 2;
                List <PhonWord> moitie1  = new List <PhonWord>(5);
                int             i        = 0;
                int             piedsM1  = 0;
                while (i < pWordList.Count && piedsM1 < demiVers - 1)
                {
                    moitie1.Add(pWordList[i]);
                    piedsM1 = ComptePieds(moitie1);
                    i++;
                }

                // En prenant les cas dans cet ordre, on favorise légèrement la recherche de la
                // diérèse dans la première partie du vers. Il y a au moins un exemple dans le
                // poème de référence où cette approche est justifiée:
                // "D'affreux bohémiens, des vainqueurs de charnier"
                // Faut-il rallonger "bohémines" ou "charnier"? Il y a certainement des cas
                // qui demanderaient l'approche opposée. Je ne vois pas comment les distinguer
                // sans tenir compte du sens ou d'éléments que j'ignore jusqu'ici comme la
                // virgule dans le vers de V. Hugo.

                if (piedsM1 == demiVers - 1)
                {
                    List <PhonWord> moitie2 = new List <PhonWord>(5);
                    while (i < pWordList.Count)
                    {
                        moitie2.Add(pWordList[i]);
                        i++;
                    }
                    ChercherDierese(moitie1, demiVers);
                    if (ComptePieds(pWordList) < nbrPiedsVoulu)
                    {
                        ChercherDierese(moitie2, demiVers);
                    }
                    if (ComptePieds(pWordList) < nbrPiedsVoulu)
                    {
                        ChercherDierese(pWordList, nbrPiedsVoulu);
                    }
                }
                else if (piedsM1 == demiVers)
                {
                    // hypothèse: on a trouvé l'hémistiche
                    List <PhonWord> moitie2 = new List <PhonWord>(5);
                    while (i < pWordList.Count)
                    {
                        moitie2.Add(pWordList[i]);
                        i++;
                    }
                    ChercherDierese(moitie2, demiVers);
                    if (ComptePieds(pWordList) < nbrPiedsVoulu)
                    {
                        ChercherDierese(moitie1, demiVers);
                    }
                    if (ComptePieds(pWordList) < nbrPiedsVoulu)
                    {
                        ChercherDierese(pWordList, nbrPiedsVoulu);
                    }
                }
                else if (piedsM1 > demiVers)
                {
                    // On est allés trop loin.
                    // on n'a pas réussi à trouver d'hémistiche.
                    ChercherDierese(pWordList, nbrPiedsVoulu);
                }
                else
                {
                    // Bizarre: le vers entier semble faire moins de la moitié des pieds voulus...
                    logger.Info("On demande {0} pieds pour le vers {1}.", nbrPiedsVoulu, ToString());
                    ChercherDierese(pWordList, nbrPiedsVoulu); // ça ne devrait pas marcher...
                }
            }
            else
            {
                // nombre impair de pieds voulu.
                logger.ConditionalDebug("Nombre impair ({0}) de pieds voulus pour {1}",
                                        nbrPiedsVoulu, ToString());
                ChercherDierese(pWordList, nbrPiedsVoulu);
            }
            nrPieds = ComptePieds(pWordList);
            if (nrPieds != nbrPiedsVoulu)
            {
                logger.ConditionalTrace(
                    "!! Diérèse pas trouvée. nbrPiedsVoulu: {0}, nrPieds: {1}, vers: \'{2}\'," +
                    "syls: \'{3}\'", nbrPiedsVoulu, nrPieds, ToString(), Syllabes());
            }
        }
Ejemplo n.º 27
0
        private int _nbreAlt = 1; // pour mettre une base aux séries d'annulation

        // ------------------------------------------ Methods -------------------------------------------------

        /// <summary>
        /// Construit un DuoConfig avec une configuration par défaut.
        /// </summary>
        public DuoConfig()
        {
            logger.ConditionalDebug("DuoConfig");
            UndoFactory.DisableUndoRegistration();
            subConfig1 = new Config(1);
            subConfig1.ConfigReplacedEvent += SubConfig1Replaced;

            subConfig2 = new Config(2);
            subConfig2.ConfigReplacedEvent += SubConfig2Replaced;

            InitFields();
            UndoFactory.EnableUndoRegistration();
        }
Ejemplo n.º 28
0
        private static Dictionary <Object, List <Object> > doc2Win; // key is document, value is list of windows

        // -------------------------------------- Public Static Methods -------------------------------------------------------

        /// <summary>
        /// Initialise la partie statique de la classe (la gestion du  mapping entre documents, fenêtres et configurations).
        /// Appelle les <c>Init()</c> statiques des autres classes de configuration.
        /// </summary>
        /// <remarks> Est responsable de la création du répertoire où seront sauvegardées les configs.</remarks>
        /// <param name="errMsgs">Si une erreur se produit, un message est ajouté à la liste.
        /// La liste n'est pas touchée si tout se passe bien. <c>null</c> indique que le message
        /// n'est pas souhaité par l'appelant.</param>
        public static new void Init(List <string> errMsgs = null)
        {
            logger.ConditionalDebug("Init");
            ColConfWin.Init();
            // Ensure that ConfigDirPath folder does exist
            if (!System.IO.Directory.Exists(ConfigDirPath))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(ConfigDirPath);
                    logger.Info("Dossier \'{0}\' créé.", ConfigDirPath);
                }
                catch (Exception e) when(e is IOException || e is UnauthorizedAccessException)
                {
                    errMsgs?.Add("Impossible de créer le répertoire" + ConfigDirPath);
                    logger.Error("Impossible de créer le répertoire {0}. Erreur {1}", ConfigDirPath, e.Message);
                }
            }
            theConfs = new Dictionary <object, Config>();
            doc2Win  = new Dictionary <object, List <object> >();
        }
Ejemplo n.º 29
0
 private void UpdateAlternance(object sender, EventArgs e)
 {
     logger.ConditionalDebug("UpdateAlternance val: ´\'{0}\'", duoConfCopy.alternance);
     if (duoConfCopy.alternance == DuoConfig.Alternance.lignes)
     {
         rbtnLignes.Checked = true;
         rbtnMots.Checked   = false;
     }
     else if (duoConfCopy.alternance == DuoConfig.Alternance.mots)
     {
         rbtnLignes.Checked = false;
         rbtnMots.Checked   = true;
     }
     else
     {
         logger.Error("Valeur d'alternance inattendue: {0}", duoConfCopy.alternance);
         // Essayons de sauver les meubles et mettons-nous dans une situation claire.
         // Même si on a un peu de récusion dans cette affaire.
         duoConfCopy.alternance = DuoConfig.Alternance.mots;
     }
 }