示例#1
0
        //-----------------------------------------------
        public CResultAErreur RefreshFormuleFinale()
        {
            m_formuleFinale = null;
            CResultAErreur     result  = CResultAErreur.True;
            C2iExpressionBegin formule = new C2iExpressionBegin();

            foreach (CDefinitionProprieteDynamiqueVariableFormule def in m_listeVariables)
            {
                C2iExpressionVariable var = new C2iExpressionVariable();
                C2iExpression         exp = new C2iExpressionChamp();
                ((C2iExpressionChamp)exp).DefinitionPropriete = def;
                var.Parametres.Add(exp);
                exp = new C2iExpressionConstante(def.TypeDonnee.TypeDotNetNatif.ToString());
                var.Parametres.Add(exp);
                if (def.TypeDonnee.IsArrayOfTypeNatif)
                {
                    exp = new C2iExpressionVrai();
                    var.Parametres.Add(exp);
                }
                formule.Parametres.Add(var);
            }
            CRepresentationExpressionGraphique graf = StartPoint;

            if (graf == null)
            {
                result.EmpileErreur(I.T("No start point|20103"));
                return(result);
            }

            while (graf != null)
            {
                result = graf.RefreshParametres();
                if (!result)
                {
                    return(result);
                }
                if (graf.Formule != null)
                {
                    formule.Parametres.Add(graf.Formule);
                }
                graf = graf.Next;
            }
            m_formuleFinale = formule;
            return(CResultAErreur.True);
        }
示例#2
0
        //--------------------------------------------------
        /// <summary>
        /// crée les éléments graphiques d'une formule
        /// </summary>
        /// <param name="formule"></param>
        public void InitFromFormule(C2iExpression formule)
        {
            m_listeRepresentations.Clear();
            m_listeVariables.Clear();
            if (formule == null)
            {
                return;
            }
            ArrayList lst = formule.ExtractExpressionsType(typeof(C2iExpressionVariable));

            foreach (C2iExpressionVariable variable in lst)
            {
                if (variable.Parametres.Count > 0)
                {
                    C2iExpressionChamp champ = variable.Parametres[0] as C2iExpressionChamp;
                    if (champ != null)
                    {
                        CDefinitionProprieteDynamiqueVariableFormule def = champ.DefinitionPropriete as CDefinitionProprieteDynamiqueVariableFormule;
                        if (def != null)
                        {
                            m_listeVariables.Add(def);
                        }
                    }
                }
            }
            C2iExpressionBegin begin = formule as C2iExpressionBegin;

            m_strIdStartPoint = "";
            int nX = 100;
            int nY = 20;

            if (begin != null)
            {
                CRepresentationExpressionGraphique previous = null;
                foreach (C2iExpression action in begin.Parametres)
                {
                    if (!(action is C2iExpressionVariable))
                    {
                        CRepresentationExpressionGraphique rep = new CRepresentationExpressionGraphique();
                        rep.Position = new Point(nX, nY);
                        AddChild(rep);
                        rep.Parent  = this;
                        rep.Formule = action;
                        nY          = rep.RectangleAbsolu.Bottom;
                        foreach (CRepresentationExpressionGraphique repTmp in m_listeRepresentations)
                        {
                            if (repTmp.RectangleAbsolu.Bottom > nY)
                            {
                                nY = rep.RectangleAbsolu.Bottom;
                            }
                        }
                        nY += 20;
                        if (previous == null)
                        {
                            StartPoint = rep;
                        }
                        else
                        {
                            previous.Next = rep;
                        }
                        previous = rep;
                    }
                }
            }
            else
            {
                CRepresentationExpressionGraphique rep = new CRepresentationExpressionGraphique();
                rep.Position = new Point(nX, nY);
                AddChild(rep);
                rep.Parent  = this;
                rep.Formule = formule;
                StartPoint  = rep;
            }
        }