Exemple #1
0
 //------------------------------------------
 public void Draw(
     CContextDessinObjetGraphique ctx,
     IElementDeSchemaReseau element,
     C2iObjetGraphique objetGraphique)
 {
     ApplyOnSymbole(element);
     if (m_symbole != null)
     {
         m_symbole.Transparency = 100;
         Matrix oldMat = ctx.Graphic.Transform;
         C2iLienDeSchemaReseau lien = objetGraphique as C2iLienDeSchemaReseau;
         if (lien != null)
         {
             //Se place au centre du lien
             Point pt = lien.GetPointCentral();
             pt.Offset(-m_symbole.Width / 2, -m_symbole.Height / 2);
             ctx.Graphic.TranslateTransform(pt.X, pt.Y);
         }
         else
         {
             float fEchelleX = (float)objetGraphique.Size.Width / (float)m_symbole.Size.Width;
             float fEchelleY = (float)objetGraphique.Size.Height / (float)m_symbole.Size.Height;
             ctx.Graphic.InterpolationMode = InterpolationMode.HighQualityBilinear;
             ctx.Graphic.TranslateTransform(objetGraphique.Position.X, objetGraphique.Position.Y);
             ctx.Graphic.ScaleTransform(fEchelleX, fEchelleY);
         }
         m_symbole.Draw(ctx);
         ctx.Graphic.Transform = oldMat;
     }
 }
Exemple #2
0
        private void CControlDessinSymbole_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            if (m_symbole != null)
            {
                //   float fScale = (float)(((double)Math.Min(this.Size.Height,this.Size.Width)) /((double)Math.Min(m_symbole.Size.Height,m_symbole.Size.Width)));


                float fScale;

                if (this.Size.Height > this.Size.Width)
                {
                    fScale = (float)((double)this.Size.Width / (double)m_symbole.Size.Width);
                }
                else
                {
                    fScale = (float)((double)this.Size.Height / (double)m_symbole.Size.Height);
                }


                if (fScale < 1)
                {
                    Matrix mat = new Matrix(fScale, 0, 0, fScale, 0, 0);
                    g.Transform = mat;
                }
                else
                {
                    float depX = (float)(((double)this.Size.Width - (double)m_symbole.Size.Width) / 2.0);
                    float depY = (float)(((double)this.Size.Height - (double)m_symbole.Size.Height) / 2.0);

                    Matrix mat = new Matrix(1, 0, 0, 1, depX, depY);
                    g.Transform = mat;
                }
                CContextDessinObjetGraphique ctg = new CContextDessinObjetGraphique(g);

                m_symbole.Draw(ctg);
            }
        }