Exemple #1
0
        /// //////////////////////////////////////////////
        public virtual void Draw(CContextDessinObjetGraphique ctx)
        {
            if (!ctx.ShouldDrawElement(RectangleAbsolu))
            {
                return;
            }
            if (ctx.FonctionDessinSupplementaireAvantObjet != null)
            {
                if (!ctx.FonctionDessinSupplementaireAvantObjet(ctx, this))
                {
                    return;
                }
            }
            MyDraw(ctx);
            if (ctx.FonctionDessinSupplementaireApresObjet != null)
            {
                if (!ctx.FonctionDessinSupplementaireApresObjet(ctx, this))
                {
                    return;
                }
            }

            foreach (I2iObjetGraphique fils in GetChildsTriesPourDessin())
            {
                fils.Draw(ctx);
            }
        }
 public override void DrawInterieur(sc2i.drawing.CContextDessinObjetGraphique ctx)
 {
     if (m_nActivePage >= 0 && m_nActivePage < m_listePages.Count)
     {
         C2iWndTabPage page = m_listePages[m_nActivePage];
         page.Draw(ctx);
     }
 }
        protected override void MyDraw(sc2i.drawing.CContextDessinObjetGraphique ctx)
        {
            Rectangle rect = new Rectangle(Position, Size);
            Brush     br   = new SolidBrush(BackColor);

            ctx.Graphic.FillRectangle(br, rect);
            br.Dispose();
            base.MyDraw(ctx);
        }
Exemple #4
0
        //---------------------------------------------------
        public virtual Bitmap GetBitmapCopie(int nTailleImage, bool bChildsOnly)
        {
            //Calcule la taille de l'image
            Size sizeThis = Size;
            int  nMaxX = 0, nMaxY = 0, nMinX = Size.Width, nMinY = Size.Height;

            if (bChildsOnly)
            {
                foreach (I2iObjetGraphique objet in Childs)
                {
                    nMaxX = Math.Max(objet.Position.X + objet.Size.Width, nMaxX);
                    nMaxY = Math.Max(objet.Position.Y + objet.Size.Height, nMaxY);
                    nMinX = Math.Min(objet.Position.X, nMinX);
                    nMinY = Math.Min(objet.Position.Y, nMinY);
                }
                sizeThis = new Size(nMaxX - nMinX, nMaxY - nMinY);
            }
            if (sizeThis.Width == 0 || sizeThis.Height == 0)
            {
                return(new Bitmap(10, 10));
            }
            int nWidthImage, nHeightImage;

            if (sizeThis.Width > sizeThis.Height)
            {
                nWidthImage  = nTailleImage;
                nHeightImage = (int)((double)sizeThis.Height * (double)nWidthImage / (double)sizeThis.Width);
            }
            else
            {
                nHeightImage = nTailleImage;
                nWidthImage  = (int)((double)sizeThis.Width * (double)nHeightImage / (double)sizeThis.Height);
            }
            float    fEchelle = (float)nWidthImage / sizeThis.Width;
            Bitmap   bmp      = new Bitmap(nWidthImage, nHeightImage);
            Graphics g        = Graphics.FromImage(bmp);

            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.ScaleTransform(fEchelle, fEchelle);
            if (bChildsOnly)
            {
                g.TranslateTransform(-nMinX, -nMinY);
            }
            CContextDessinObjetGraphique ctx = new CContextDessinObjetGraphique(g);

            Draw(ctx);
            g.Dispose();
            return(bmp);
        }
        public override void Draw2D(sc2i.drawing.CContextDessinObjetGraphique contexte, EFaceVueDynamique faceVisible, System.Drawing.Size sizeReference)
        {
            I2iObjetGraphique rect = Get2D(faceVisible);
            Brush             br   = new HatchBrush(HatchStyle.Divot, ForeColor, Color.FromArgb(50, BackColor));
            Rectangle         rct  = CUtilRect.Normalise(rect.RectangleAbsolu);

            contexte.Graphic.FillRectangle(br, rct);
            br.Dispose();
            contexte.Graphic.DrawRectangle(Pens.Beige, rct);

            foreach (C2iComposant3D fils in SortChildsFor2D(faceVisible))
            {
                fils.Draw2D(contexte, faceVisible, sizeReference);
            }
        }
Exemple #6
0
        public override void Draw2D(
            sc2i.drawing.CContextDessinObjetGraphique ctx,
            EFaceVueDynamique faceVisible,
            Size sizeReference)
        {
            I2iObjetGraphique rect = Get2D(faceVisible);
            Brush             br   = new SolidBrush(BackColor);

            ctx.Graphic.FillRectangle(br, CUtilRect.Normalise(rect.RectangleAbsolu));
            br.Dispose();

            foreach (C2iComposant3D fils in SortChildsFor2D(faceVisible))
            {
                fils.Draw2D(ctx, faceVisible, sizeReference);
            }
        }
        //--------------------------------
        protected override void MyDraw(sc2i.drawing.CContextDessinObjetGraphique ctx)
        {
            Rectangle rect = new Rectangle(Position, Size);
            Brush     br   = new SolidBrush(BackColor);

            ctx.Graphic.FillRectangle(br, rect);
            br.Dispose();
            Pen pen = new Pen(ForeColor);

            ctx.Graphic.DrawRectangle(pen, rect);

            int nNumPage = 0;
            int nX       = rect.Left + 1;

            foreach (C2iWndTabPage page in m_listePages)
            {
                Rectangle rcTab = new Rectangle(nX, rect.Top, m_nLargeurOnglets, c_nHauteurTitres);
                nX += m_nLargeurOnglets;
                br  = null;
                if (nNumPage == m_nActivePage)
                {
                    br = new SolidBrush(Color.FromArgb((BackColor.R * 2) % 255,
                                                       (BackColor.G * 2) % 255,
                                                       (BackColor.B * 2) % 255));
                }
                else
                {
                    br = new SolidBrush(BackColor);
                }
                ctx.Graphic.FillRectangle(br, rcTab);
                br.Dispose();
                pen = new Pen(ForeColor);
                ctx.Graphic.DrawRectangle(pen, rcTab);
                pen.Dispose();
                rcTab.Offset(new Point(2, 2));
                rcTab.Width -= 4;
                br           = new SolidBrush(ForeColor);
                ctx.Graphic.DrawString(page.Text, Font, br, rcTab);
                br.Dispose();

                nNumPage++;
            }
            base.MyDraw(ctx);
        }
Exemple #8
0
        //dessine une flèche sur un segment en connaissant les extrémités du segment et la position de l'extrémité de la flèche
        //La flèche se dessine dans le sens pt1 ->pt2
        private void DrawFleche(sc2i.drawing.CContextDessinObjetGraphique ctx, Pen pen, Point pt1, Point pt2, Point extremite)
        {
            double fCosa = (double)Math.Abs(pt1.X - extremite.X) / (double)(Math.Sqrt((pt1.X - extremite.X) * (pt1.X - extremite.X) + (pt1.Y - extremite.Y) * (pt1.Y - extremite.Y)));
            double fSina = (double)Math.Abs(pt1.Y - extremite.Y) / (double)(Math.Sqrt((pt1.X - extremite.X) * (pt1.X - extremite.X) + (pt1.Y - extremite.Y) * (pt1.Y - extremite.Y)));
            Point  m     = new Point(0, 0);


            double fDim = 12.0;

            Point[] p = new Point[2];
            p[0] = new Point(0, 0);
            p[1] = new Point(0, 0);
            //flèche vers la gauche
            if (pt1.X > extremite.X)
            {
                m.X    = (int)(extremite.X + (long)(fDim * Math.Sqrt(3) * fCosa / 2.0));
                p[0].X = (int)(m.X + (long)(fDim * fSina / 2.0));
                p[1].X = (int)(m.X - (long)(fDim * fSina / 2.0));
            }
            //flèche vers la droite
            else if (pt1.X <= extremite.X)
            {
                m.X    = (int)(extremite.X - (long)(fDim * Math.Sqrt(3) * fCosa / 2.0));
                p[0].X = (int)(m.X - (long)(fDim * fSina / 2.0));
                p[1].X = (int)(m.X + (long)(fDim * fSina / 2.0));
            }
            //flèche vers le bas
            if (pt1.Y > extremite.Y)
            {
                m.Y    = (int)(extremite.Y + (long)(fDim * Math.Sqrt(3) * fSina / 2.0));
                p[0].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0));
                p[1].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0));
            }
            //flèche vers le haut
            else if (pt1.Y <= extremite.Y)
            {
                m.Y    = (int)(extremite.Y - (long)(fDim * Math.Sqrt(3) * fSina / 2.0));
                p[0].Y = (int)(m.Y + (long)(fDim * fCosa / 2.0));
                p[1].Y = (int)(m.Y - (long)(fDim * fCosa / 2.0));
            }

            ctx.Graphic.DrawLine(pen, extremite.X, extremite.Y, p[0].X, p[0].Y);
            ctx.Graphic.DrawLine(pen, extremite.X, extremite.Y, p[1].X, p[1].Y);
        }
        //-------------------------------------------
        public override void Draw2D(sc2i.drawing.CContextDessinObjetGraphique contexte, EFaceVueDynamique faceVisible, System.Drawing.Size sizeReference)
        {
            I2iObjetGraphique rect = Get2D(faceVisible);
            Brush             br   = new SolidBrush(BackColor);
            Rectangle         rct  = CUtilRect.Normalise(rect.RectangleAbsolu);

            contexte.Graphic.FillRectangle(br, rct);
            br.Dispose();


            contexte.Graphic.DrawRectangle(Pens.Beige, rct);


            Pen pen = new Pen(Color.Black);

            if (ConvertFaceToLocal(faceVisible) == AlignmentFace)
            {
                if (m_nEspaceGraduations > 0)
                {
                    switch (GraduationOrientation)
                    {
                    case EGraduationOrientation.HorizMinToMax:
                        for (int n = 0; n < rct.Width; n += m_nEspaceGraduations)
                        {
                            contexte.Graphic.DrawLine(pen, rct.Left + n, rct.Top, rct.Left + n, rct.Bottom);
                        }
                        break;

                    case EGraduationOrientation.HorizMaxToMin:
                        for (int n = rct.Width; n > 0; n -= m_nEspaceGraduations)
                        {
                            contexte.Graphic.DrawLine(pen, rct.Left + n, rct.Top, rct.Left + n, rct.Bottom);
                        }
                        break;

                    case EGraduationOrientation.VertMinToMax:
                        for (int n = 0; n < rct.Height; n += m_nEspaceGraduations)
                        {
                            contexte.Graphic.DrawLine(pen, rct.Left, rct.Top + n, rct.Right, rct.Top + n);
                        }
                        break;

                    case EGraduationOrientation.VertMaxToMin:
                        for (int n = Size.Height; n > 0; n -= m_nEspaceGraduations)
                        {
                            contexte.Graphic.DrawLine(pen, rct.Left, rct.Top + n, rct.Right, rct.Top + n);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            pen.Dispose();

            foreach (C2iComposant3D fils in SortChildsFor2D(faceVisible))
            {
                fils.Draw2D(contexte, faceVisible, sizeReference);
            }
        }
Exemple #10
0
 /// //////////////////////////////////////////////
 protected abstract void MyDraw(CContextDessinObjetGraphique ctx);
Exemple #11
0
        //---------------------------------------------------------------------------
        protected override void MyDraw(sc2i.drawing.CContextDessinObjetGraphique ctx)
        {
            if (ElementDeSchema == null || !ElementDeSchema.IsValide())
            {
                return;
            }
            bool             bNewObjet1 = true;
            bool             bNewObjet2 = true;
            C2iObjetDeSchema objet1     = GetObjetElement1(ref bNewObjet1);
            C2iObjetDeSchema objet2     = GetObjetElement2(ref bNewObjet2);

            if (objet1 == null || objet2 == null)
            {
                return;
            }
            if (bNewObjet1)
            {
                objet1.Position = Position;
            }
            if (bNewObjet2)
            {
                objet2.Position = new Point(Position.X + Size.Width, Position.Y + Size.Height);
            }

            //Vérifie que la position des objets 1 et 2 permet de voir le lien
            if (objet1.RectangleAbsolu.IntersectsWith(objet2.RectangleAbsolu))
            {
                //Il faut déplacer l'un des deux objets
                if (bNewObjet1)
                {
                    //On déplace l'objet 1
                    if (objet1.Position.X < objet2.Position.X)
                    {
                        objet1.Position = new Point(objet2.RectangleAbsolu.Left - objet1.Size.Width * 2, objet1.Position.Y);
                    }
                    if (objet1.Position.X > objet2.Position.X)
                    {
                        objet1.Position = new Point(objet2.RectangleAbsolu.Right + objet1.Size.Width, objet1.Position.Y);
                    }
                }
                else if (bNewObjet2)
                {
                    //On déplace l'objet 2
                    if (objet2.Position.X < objet1.Position.X)
                    {
                        objet2.Position = new Point(objet1.RectangleAbsolu.Left - objet2.Size.Width * 2, objet2.Position.Y);
                    }
                    if (objet2.Position.X > objet1.Position.X)
                    {
                        objet2.Position = new Point(objet1.RectangleAbsolu.Right + objet2.Size.Width, objet2.Position.Y);
                    }
                }
            }


            Point pt1 = new Point(objet1.Position.X + objet1.Size.Width / 2,
                                  objet1.Position.Y + objet1.Size.Height / 2);

            Point pt2 = new Point(objet2.Position.X + objet2.Size.Width / 2,
                                  objet2.Position.Y + objet2.Size.Height / 2);


            List <Point> pts = new List <Point>(Points);

            //Calcule la position de départ
            if (OffsetElement1.X >= 0)
            {
                pt1.X = objet1.Position.X + OffsetElement1.X;
            }
            if (OffsetElement1.Y >= 0)
            {
                pt1.Y = objet1.Position.Y + OffsetElement1.Y;
            }
            if (OffsetElement2.X >= 0)
            {
                pt2.X = objet2.Position.X + OffsetElement2.X;
            }
            if (OffsetElement2.Y >= 0)
            {
                pt2.Y = objet2.Position.Y + OffsetElement2.Y;
            }
            if (pts.Count < 1)
            {
                pts.Add(pt1);
            }
            else
            {
                pts[0] = pt1;
            }
            if (pts.Count < 2)
            {
                pts.Add(pt2);
            }
            else
            {
                pts[pts.Count - 1] = pt2;
            }
            Points = pts.ToArray();

            Pen pen = new Pen(ForeColor);

            pen.Width = LineWidth;
            switch (DonneeDessinLien.Forward_Backward)
            {
            case ESensAllerRetourLienReseau.Backward:
                pen.DashStyle   = System.Drawing.Drawing2D.DashStyle.Custom;
                pen.DashPattern = new float[] { 5.0f, 5.0f, 1.0f, 5.0f };
                break;
            }
            Pen penFleche = new Pen(ForeColor);

            penFleche.Width = LineWidth;
            if (pts.Count > 2 && DonneeDessinLien.Curve)
            {
                ctx.Graphic.DrawCurve(pen, pts.ToArray());
                for (int n = 1; n < pts.Count - 1; n++)
                {
                    DrawFleches(ctx, penFleche, pts[n], pts[n - 1], pts[n + 1], ElementDeSchema.LienReseau.Direction);
                }
            }
            else
            {
                for (int i = 0; i < pts.Count - 1; i++)
                {
                    ctx.Graphic.DrawLine(pen, (Point)pts[i], (Point)pts[i + 1]);

                    DrawFleches(ctx, penFleche, null, (Point)pts[i], (Point)pts[i + 1], ElementDeSchema.LienReseau.Direction);
                }
            }
            pen.Dispose();
            penFleche.Dispose();

            if (m_bModeSelection == false)
            {
                Brush bPoint = new SolidBrush(Color.FromArgb(128, ForeColor));

                for (int i = 0; i < pts.Count; i++)
                {
                    ctx.Graphic.FillRectangle(bPoint, pts[i].X - 2, pts[i].Y - 2, 5, 5);
                }


                bPoint.Dispose();
            }
        }
 //--------------------------------------------------------------------
 protected override void MyDraw(sc2i.drawing.CContextDessinObjetGraphique ctx)
 {
     throw new NotImplementedException();
 }