Esempio n. 1
0
        //------------------------------------------------------------
        public C2iObjetDeSchema GetObjetElement2(ref bool bCreate)
        {
            if (ElementDeSchema == null || !ElementDeSchema.IsValide())
            {
                return(null);
            }
            CLienReseau lien = ElementDeSchema.LienReseau;

            if (lien == null)
            {
                return(null);
            }
            IElementDeSchemaReseau extremite = null;
            CCheminLienReseau      racine    = ElementDeSchema.RacineChemin2;

            if (racine != null)
            {
                extremite = racine.Etape as IElementDeSchemaReseau;
            }
            if (extremite == null)
            {
                extremite = lien.Element2 as IElementDeSchemaReseau;
            }

            return(GetObjetElement(extremite, ref bCreate));
        }
Esempio n. 2
0
 /// ////////////////////////////////////////////////////////
 public override void CancelClone()
 {
     if (ElementDeSchema != null && ElementDeSchema.IsNew())
     {
         ElementDeSchema.CancelCreate();
         ElementDeSchema = null;
     }
 }
Esempio n. 3
0
        //----------------------------------------------------
        public CResultAErreur DeleteObjetLie(bool bDansContexteCourant)
        {
            CResultAErreur result = CResultAErreur.True;

            if (ElementDeSchema != null && ElementDeSchema.IsValide())
            {
                result = ElementDeSchema.Delete(bDansContexteCourant);
                return(result);
            }
            else
            {
                return(CResultAErreur.False);
            }
        }
Esempio n. 4
0
        //---------------------------------------------------
        protected override void MyDraw(CContextDessinObjetGraphique ctx)
        {
            if (ElementDeSchema != null && ElementDeSchema.IsValide())
            {
                C2iSymbole symbole = ElementDeSchema.SymboleADessiner;
                if (symbole != null)
                {
                    if (m_imageCache != null)
                    {
                        if (m_imageCache.Size == Size)
                        {
                            ctx.Graphic.DrawImageUnscaled(m_imageCache, new Point(Position.X, Position.Y));
                            return;
                        }
                    }
                    if (m_imageCache != null)
                    {
                        m_imageCache.Dispose();
                    }
                    m_imageCache = new Bitmap(Size.Width, Size.Height);

                    Graphics g = Graphics.FromImage(m_imageCache);
                    g.SmoothingMode     = SmoothingMode.AntiAlias;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode   = PixelOffsetMode.HighQuality;
                    g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    //Ajuste la matrice pour que le symbole prenne toute la place
                    //dans le rectangle
                    float fEchelleX = (float)ClientSize.Width / (float)symbole.Size.Width;
                    float fEchelleY = (float)ClientSize.Height / (float)symbole.Size.Height;
                    g.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    g.ScaleTransform(fEchelleX, fEchelleY);
                    Graphics oldG      = ctx.Graphic;
                    bool     bOldLimit = ctx.WorkWithLimits;
                    ctx.WorkWithLimits = false;
                    ctx.Graphic        = g;
                    symbole.Draw(ctx);
                    g.ResetTransform();
                    if (ElementDeSchema.IsCableALinterieur)
                    {
                        Icon icon = (System.Drawing.Icon)Resource.ResourceManager.GetObject("Connection");
                        ctx.Graphic.DrawIcon(icon, new Rectangle(ClientSize.Width - icon.Width,
                                                                 ClientSize.Height - icon.Height, icon.Width, icon.Height));
                    }
                    g.Dispose();
                    ctx.Graphic        = oldG;
                    ctx.WorkWithLimits = bOldLimit;
                    ctx.Graphic.DrawImage(m_imageCache, PositionAbsolue.X, PositionAbsolue.Y, ClientSize.Width, ClientSize.Height);


                    /*
                     * //Ajuste la matrice pour que le symbole prenne toute la place
                     * //dans le rectangle
                     * Matrix oldMat = ctx.Graphic.Transform;
                     * float fEchelleX = (float)ClientSize.Width / (float)symbole.Size.Width;
                     * float fEchelleY = (float)ClientSize.Height / (float)symbole.Size.Height;
                     * ctx.Graphic.InterpolationMode = InterpolationMode.HighQualityBilinear;
                     * ctx.Graphic.TranslateTransform(Position.X, Position.Y);
                     * ctx.Graphic.ScaleTransform(fEchelleX, fEchelleY);
                     *
                     * symbole.Draw(ctx);
                     * ctx.Graphic.Transform = oldMat;
                     *
                     * if ( ElementDeSchema.IsCableALinterieur )
                     * {
                     *  Icon icon = (System.Drawing.Icon)Resource.ResourceManager.GetObject("Connection");
                     *  ctx.Graphic.DrawIconUnstretched ( icon, new Rectangle ( Position.X+ClientSize.Width - icon.Width,
                     *      Position.Y+ClientSize.Height -icon.Height, icon.Width, icon.Height ));
                     * }*/
                }
            }
        }
Esempio n. 5
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();
            }
        }