Example #1
0
 //-----------------------------------------------
 public void SetExterne(int nNumParametre, CRepresentationExpressionGraphique exp)
 {
     if (exp != null)
     {
         while (exp.Prev != null)
         {
             exp = exp.Prev;
         }
         m_dicParametresGraphiques[nNumParametre] = exp.Id;
         if (m_formule != null)
         {
             m_formule.SetParametre(nNumParametre, exp.FormuleFinale);
         }
     }
     else
     {
         C2iExpressionGraphique             rep    = RepresentationRacine;
         CRepresentationExpressionGraphique oldExt = GetExterne(nNumParametre);
         if (m_dicParametresGraphiques.ContainsKey(nNumParametre))
         {
             m_dicParametresGraphiques.Remove(nNumParametre);
         }
         if (oldExt != null && oldExt.Next == null && oldExt.Prev == null)
         {
             if (rep != null && rep.GetUtilisateurs(oldExt.Id).Count() == 0)
             {
                 rep.RemoveChild(oldExt);
                 oldExt.ClearExternes();
             }
         }
     }
 }
        //------------------------------------------------------------------------
        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 #3
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);
        }
Example #4
0
        public override void DrawExpression(CContextDessinObjetGraphique ctx, CRepresentationExpressionGraphique expressionGraphique)
        {
            Rectangle rct = expressionGraphique.RectangleAbsolu;

            List<Point> pts = new List<Point>();
            pts.Add(new Point(rct.Left, rct.Top + rct.Height / 2));
            pts.Add(new Point(rct.Left + rct.Width / 2, rct.Top));
            pts.Add(new Point(rct.Right, rct.Top + rct.Height / 2));
            pts.Add(new Point(rct.Left + rct.Width / 2, rct.Bottom));
            ctx.Graphic.FillPolygon(Brushes.White, pts.ToArray());
            ctx.Graphic.DrawPolygon(Pens.Black, pts.ToArray());

            C2iExpressionAnalysable expAn = expressionGraphique.Formule as C2iExpressionAnalysable;
            
            string strText = "";
            if (expAn.Parametres.Count >0 && expAn.Parametres[0] != null)
            {
                strText = expAn.Parametres2i[0].GetString();
            }
            else
            {

                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);


            C2iExpressionGraphique rep = expressionGraphique.RepresentationRacine;
            AdjustableArrowCap cap = new AdjustableArrowCap(4, 4, true);
            if (rep != null)
            {
                
                Pen pen = new Pen ( Color.Black, 2 );
                pen.CustomEndCap = cap;
                for ( int n = 0; n< 3; n++ )
                {
                    
                    CRepresentationExpressionGraphique ext = expressionGraphique.GetExterne ( n );
                    if ( ext != null )
                    {
                        if ( n == 0 )
                        {
                            pen.Color = Color.Black;
                            pen.Width = 1;
                            pen.DashStyle = DashStyle.Dot;
                            DrawLien ( ctx, pen, ft, ext, expressionGraphique, "?" );
                        }
                        else if (n == 1)
                        {
                            pen.Width = 3;
                            pen.DashStyle = DashStyle.Solid;
                            pen.Color = Color.Green;
                            DrawLien(ctx, pen, ft, expressionGraphique, ext, I.T("Yes|20082"));
                        }
                        else if (n == 2)
                        {
                            pen.Width = 3;
                            pen.DashStyle = DashStyle.Solid;
                            pen.Color = Color.Red;
                            DrawLien(ctx, pen, ft, expressionGraphique, ext, I.T("no|20083"));
                        }
                    }
                }
                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, I.T("End if|20084"));
                pen.Dispose();
            }
            cap.Dispose();
            ft.Dispose();
        }
        //------------------------------------------------------------------------
        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();
        }