public bool PointIsInSelection(Point pt)
 {
     foreach (I2iObjetGraphique obj in this)
     {
         if (CUtilRect.Normalise(obj.RectangleAbsolu).Contains(pt))
         {
             return(true);
         }
     }
     return(false);
 }
        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);
            }
        }
Beispiel #3
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);
            }
        }
        private void InitPoignees(I2iObjetGraphique obj)
        {
            if (!obj.NoPoignees)
            {
                for (int n = 0; n < 8; n++)
                {
                    CPoignee p = new CPoignee(this, obj, Editeur);
                    switch (n)
                    {
                    case 0:
                        p.Alignement = ContentAlignment.TopLeft;
                        break;

                    case 1:
                        p.Alignement = ContentAlignment.TopCenter;
                        break;

                    case 2:
                        p.Alignement = ContentAlignment.TopRight;
                        break;

                    case 3:
                        p.Alignement = ContentAlignment.MiddleLeft;
                        break;

                    case 4:
                        p.Alignement = ContentAlignment.MiddleRight;
                        break;

                    case 5:
                        p.Alignement = ContentAlignment.BottomLeft;
                        break;

                    case 6:
                        p.Alignement = ContentAlignment.BottomCenter;
                        break;

                    case 7:
                        p.Alignement = ContentAlignment.BottomRight;
                        break;
                    }

                    p.RecalcPosition(CUtilRect.Normalise(obj.RectangleAbsolu));
                    m_poignees.Add(p);
                }
            }
        }
Beispiel #5
0
        ///////////////////////////////////
        public void Draw(Graphics g)
        {
            if (m_bIsDragging)
            {
                Pen pen = new Pen(Brushes.Black, 1);
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

                Rectangle rectDisplay = CUtilRect.Normalise(new Rectangle(Editeur.GetDisplayPointFromLogical(m_rectResize.Location),
                                                                          Editeur.GetDisplaySizeFromLogical(m_rectResize.Size)));


                g.DrawRectangle(pen, rectDisplay);


                pen.Dispose();
                m_bNewSizeCalculated = false;
            }

            Rectangle rect = new Rectangle(PositionDisplay, new Size(c_nTaille, c_nTaille));

            Brush bb;

            if (m_bIsDragging)
            {
                bb = new SolidBrush(CouleurPoigneeSelectionnee);
            }
            else
            {
                bb = new SolidBrush(CouleurPoignee);
            }


            g.FillRectangle(bb, rect);
            g.DrawRectangle(CrayonBordure, rect);

            bb.Dispose();
        }
        //-------------------------------------------
        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);
            }
        }
        // /////////////////////////////////////////////////
        public virtual void Draw(Graphics g, Rectangle zone, bool bAvecPoignees)
        {
            if (Count == 0)
            {
                return;
            }
            RecalcPositionPoignees();
            Pen penNotLock = new Pen(Color.Red, 2);

            penNotLock.DashStyle = DashStyle.Dot;
            Pen penLock = new Pen(Color.Brown, 2);

            Pen pBordureWhite = new Pen(Color.White);
            Pen pBordureBlack = new Pen(Color.Black);

            foreach (I2iObjetGraphique obj in this)
            {
                if (!obj.NoRectangleSelection)
                {
                    Rectangle rect = CUtilRect.Normalise(new Rectangle(
                                                             Editeur.GetDisplayPointFromLogical(obj.PositionAbsolue),
                                                             Editeur.GetDisplaySizeFromLogical(obj.Size)));
                    if (obj.IsLock)
                    {
                        penLock.DashStyle = obj == ControlReference ? DashStyle.Solid : DashStyle.Dot;
                        g.DrawRectangle(penLock, rect);
                        Bitmap bmpLock = Properties.Resources._lock;
                        if (obj.RectangleAbsolu.Width > bmpLock.Width && obj.RectangleAbsolu.Height > bmpLock.Height)
                        {
                            Rectangle rctIco = new Rectangle(
                                Editeur.GetDisplayPointFromLogical(new Point(obj.RectangleAbsolu.Right, obj.RectangleAbsolu.Top)),
                                bmpLock.Size);
                            rctIco.Offset(-bmpLock.Width, 0);
                            g.DrawImageUnscaled(bmpLock, rctIco.Location);
                            g.DrawRectangle(Pens.Black, rctIco);
                        }
                    }
                    else
                    {
                        if (Editeur.LockEdition && obj == ControlReference)
                        {
                            penNotLock.DashStyle = DashStyle.Solid;
                        }
                        else
                        {
                            penNotLock.DashStyle = DashStyle.Dot;
                        }

                        g.DrawRectangle(penNotLock, rect);
                        if (!Editeur.LockEdition)
                        {
                            List <CPoignee> poignees = GetPoignees(obj);
                            foreach (CPoignee p in poignees)
                            {
                                p.CouleurPoignee = obj == ControlReference ? Color.Black : Color.FromArgb(80, Color.White);
                                p.CrayonBordure  = obj == ControlReference ? pBordureWhite : pBordureBlack;
                                p.Draw(g);
                            }
                        }
                    }
                }
            }
            penNotLock.Dispose();
            penLock.Dispose();
        }
        public virtual void MouseMove(Point ptLogique)
        {
            try
            {
                if (EnRedimentionnement)
                {
                    DateTime dtStart    = DateTime.Now;
                    Graphics g          = Editeur.CreateGraphics();
                    Bitmap   bmp        = CacheScreenShot;
                    CPoignee poigneeRef = m_poigneesEnCour[0];
                    foreach (CPoignee p in m_poigneesEnCour)
                    {
                        //Redessine le fond
                        Rectangle rctPoignee = p.DerniereZoneDisplayPourResize;
                        g.DrawImage(bmp, rctPoignee, rctPoignee, GraphicsUnit.Pixel);

                        //Déplace la poignée
                        int   nDecalX = p.PointDebutDrag.X - poigneeRef.PointDebutDrag.X;
                        int   nDecalY = p.PointDebutDrag.Y - poigneeRef.PointDebutDrag.Y;
                        Point ptMove  = new Point(ptLogique.X + nDecalX, ptLogique.Y + nDecalY);
                        p.MouseMove(ptMove);

                        //Dessine la poignée (et la zone de redimensionnement)
                        p.Draw(g);
                    }
                    g.Dispose();
                }
                else if (EnSelection)
                {
                    //Redessine la sélection dans une image
                    //Redessiner fond

                    Bitmap   bmp = CacheScreenShot;
                    Graphics g   = Editeur.CreateGraphics();
                    g.DrawImage(bmp, m_lastZoneDisplayDessinee, m_lastZoneDisplayDessinee, GraphicsUnit.Pixel);

                    Rectangle rct = GetRectangleSelection(ptLogique);
                    rct = CUtilRect.Normalise(new Rectangle(Editeur.GetDisplayPointFromLogical(rct.Location),
                                                            Editeur.GetDisplaySizeFromLogical(rct.Size)));
                    m_lastZoneDisplayDessinee = new Rectangle(rct.Location, new Size(rct.Width + 1, rct.Height + 1));
                    g.DrawRectangle(Pens.Blue, rct);

                    Brush bb = new SolidBrush(Color.FromArgb(50, Color.YellowGreen));
                    g.FillRectangle(bb, rct);
                    g.Dispose();
                    bb.Dispose();
                }
                //DEPLACEMENT
                else if (Control.MouseButtons == MouseButtons.Left &&
                         m_bMouseDownDansCetteFenetre && !m_bBlocageMove &&
                         (Math.Abs(m_ptStartDrag.X - ptLogique.X) > 3 ||
                          Math.Abs(m_ptStartDrag.Y - ptLogique.Y) > 3))
                {
                    m_bIsStartDragging = true;

                    if (m_waitSelection != null && m_waitSelection.Count > 0 && this.Contains(m_waitSelection[0]))
                    {
                        ControlReference = m_waitSelection[0];
                    }

                    m_waitSelection = null;

                    try
                    {
                        List <CDonneeDragDropObjetGraphique> datasDrag = new List <CDonneeDragDropObjetGraphique>();
                        bool bDrag = false;
                        foreach (I2iObjetGraphique obj in this)
                        {
                            if (obj.IsLock)
                            {
                                continue;
                            }
                            Point ptOffset = new Point(m_ptStartDrag.X - obj.RectangleAbsolu.Left, m_ptStartDrag.Y - obj.RectangleAbsolu.Top);
                            datasDrag.Add(new CDonneeDragDropObjetGraphique(Editeur.OrigineDragDropId, obj, ptOffset));
                            bDrag = true;
                        }
                        DataObject dataObj = new DataObject(datasDrag);
                        Editeur.CompleteDragDropData(dataObj, ToArray());
                        if (bDrag)
                        {
                            Editeur.DoDragDrop(dataObj, System.Windows.Forms.DragDropEffects.Move | System.Windows.Forms.DragDropEffects.Copy | DragDropEffects.Link);
                        }
                        m_bMouseDownDansCetteFenetre = false;
                    }
                    catch
                    {
                    }
                    m_bIsStartDragging = false;
                }
                else if (Control.MouseButtons != MouseButtons.Left)
                {
                    if (!Editeur.LockEdition)
                    {
                        bool bOnElementSelectione = false;
                        foreach (I2iObjetGraphique ele in this)
                        {
                            if (!ele.IsLock && CUtilRect.Normalise(ele.RectangleAbsolu).Contains(ptLogique))
                            {
                                bOnElementSelectione = true;
                                break;
                            }
                        }
                        if (bOnElementSelectione)
                        {
                            Cursor.Current = Cursors.SizeAll;
                        }
                        foreach (CPoignee poignee in ToutesLesPoignees)
                        {
                            if (!poignee.ObjetLie.IsLock && poignee.IsPointIn(ptLogique))
                            {
                                Cursor.Current = poignee.Cursor;
                                break;
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #9
0
 //-----------------------------------------------
 public bool IsPointIn(System.Drawing.Point pt)
 {
     return(CUtilRect.Normalise(RectangleAbsolu).Contains(pt));
 }