//------------------------------------------------------------------------
        public virtual void DrawExpression(CContextDessinObjetGraphique ctx, CRepresentationExpressionGraphique expressionGraphique)
        {
            Rectangle rct = expressionGraphique.RectangleAbsolu;
            if ( expressionGraphique.LastErreur != null && expressionGraphique.LastErreur != "" )
                ctx.Graphic.FillRectangle(Brushes.Red, rct);
            else
                ctx.Graphic.FillRectangle(Brushes.White, rct);
            ctx.Graphic.DrawRectangle(Pens.Black, rct);

            C2iExpressionAnalysable expAn = expressionGraphique.Formule as C2iExpressionAnalysable;
            string strText = "";
            /*if (expAn != null)
                strText = expAn.GetInfos().Texte;
            else */if ( expressionGraphique.Formule != null )
                strText = expressionGraphique.Formule.GetString();
            StringFormat f = new StringFormat();
            f.Alignment = StringAlignment.Center;
            f.LineAlignment = StringAlignment.Center;

            Font ft = new Font(FontFamily.GenericSansSerif, 8);
            ctx.Graphic.DrawString(strText, ft, Brushes.Black, expressionGraphique.RectangleAbsolu, f);

            AdjustableArrowCap cap = new AdjustableArrowCap(4, 4, true);
            C2iExpressionGraphique rep = expressionGraphique.RepresentationRacine;
            if (rep != null)
            {
                Pen pen = new Pen(Brushes.Black, 1);
                pen.DashStyle = DashStyle.Dot;
                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();
        }
Example #2
0
        //-----------------------------------------------
        public CRepresentationExpressionGraphique GetExterne(int nNumParametre)
        {
            string strId = null;

            if (m_dicParametresGraphiques.TryGetValue(nNumParametre, out strId))
            {
                C2iExpressionGraphique rep = RepresentationRacine;
                if (rep != null)
                {
                    return(rep.GetFormule(strId));
                }
            }
            return(null);
        }
        //------------------------------------------------------------------------
        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();
        }