示例#1
0
        /// //////////////////////////////////////////
        public override CResultAErreur VerifieParametres()
        {
            CResultAErreur result = base.VerifieParametres();

            if (!result)
            {
                return(result);
            }
            C2iExpressionChamp expressionChamp = Parametres2i[0] as C2iExpressionChamp;

            if (expressionChamp == null)
            {
                C2iExpressionObjet expressionObjet = Parametres2i[0] as C2iExpressionObjet;
                while (expressionObjet != null && expressionChamp == null)
                {
                    expressionChamp = expressionObjet.Parametres2i[1] as C2iExpressionChamp;
                    expressionObjet = expressionObjet.Parametres2i[1] as C2iExpressionObjet;
                }
            }
            if (!(expressionChamp is C2iExpressionChamp))
            {
                result.EmpileErreur(I.T("The 'Set' first parameter must be a variable|134"));
                return(result);
            }
            return(result);
        }
示例#2
0
        /// //////////////////////////////////////////
        private CResultAErreur GetSourceEtChampFinal(C2iExpression expression, CContexteEvaluationExpression ctx, ref object source, ref C2iExpressionChamp expressionChamp)
        {
            CResultAErreur result = CResultAErreur.True;

            expressionChamp = expression as C2iExpressionChamp;
            if (expressionChamp != null)
            {
                return(result);
            }
            C2iExpressionObjet expObjet = expression as C2iExpressionObjet;

            if (expObjet == null)
            {
                result.EmpileErreur(I.T("Impossible to affect a value to @1|133", expression.GetString()));
            }
            result = expObjet.Parametres2i[0].Eval(ctx);
            if (!result || result == null)
            {
                return(result);
            }
            ctx.PushObjetSource(result.Data, false);
            source = result.Data;
            result = GetSourceEtChampFinal(expObjet.Parametres2i[1], ctx, ref source, ref expressionChamp);
            ctx.PopObjetSource(false);
            return(result);
        }
        //------------------------------------------------------------------------
        public override void DrawExpression(CContextDessinObjetGraphique ctx, CRepresentationExpressionGraphique expressionGraphique)
        {
            C2iExpressionObjet expObjet = expressionGraphique.Formule as C2iExpressionObjet;

            if (expObjet == null)
            {
                return;
            }

            Rectangle rct = expressionGraphique.RectangleAbsolu;

            Rectangle[] rcts = new Rectangle[] {
                new Rectangle(rct.Left, rct.Top, rct.Width, rct.Height / 2),
                new Rectangle(rct.Left, rct.Top + rct.Height / 2, rct.Width, rct.Height / 2)
            };
            //Dessin des deux paramètres
            for (int n = 0; n < 2; n++)
            {
                CRepresentationExpressionGraphique exp = new CRepresentationExpressionGraphique();
                exp.Position = new Point(rcts[n].Left, rcts[n].Top);
                exp.Size     = new Size(rcts[n].Width, rcts[n].Height);
                if (expObjet.Parametres.Count > n)
                {
                    exp.Formule = expObjet.Parametres2i[n];
                }
                CDessineurExpressionGraphique dessineur = CDessineurExpressionGraphique.GetDessineur(exp);
                if (dessineur != null)
                {
                    dessineur.DrawExpression(ctx, exp);
                }
            }



            StringFormat f = new StringFormat();

            f.Alignment     = StringAlignment.Center;
            f.LineAlignment = StringAlignment.Center;

            Font ft = new Font(FontFamily.GenericSansSerif, 8);

            AdjustableArrowCap     cap = new AdjustableArrowCap(4, 4, true);
            C2iExpressionGraphique rep = expressionGraphique.RepresentationRacine;

            if (rep != null)
            {
                Pen pen = new Pen(Brushes.DarkGreen, 1);
                pen.DashStyle = DashStyle.DashDotDot;
                pen.EndCap    = LineCap.Custom;

                pen.CustomEndCap = cap;
                foreach (string strLien in expressionGraphique.IdElementsUtilises)
                {
                    CRepresentationExpressionGraphique exp = rep.GetFormule(strLien);
                    if (exp != null)
                    {
                        DrawLien(ctx, pen, ft, exp, expressionGraphique, "");
                    }
                }
                pen.Dispose();
            }

            CRepresentationExpressionGraphique next = expressionGraphique.Next;

            if (next != null)
            {
                Pen pen = new Pen(Brushes.Black, 3);
                pen.CustomEndCap = cap;
                DrawLien(ctx, pen, ft, expressionGraphique, next, "");
                pen.Dispose();
            }
            cap.Dispose();
            ft.Dispose();
        }