コード例 #1
0
ファイル: CPoignee.cs プロジェクト: ykebaili/sc2idlls
        ///////////////////////////////////
        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();
        }
コード例 #2
0
        // /////////////////////////////////////////////////
        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();
        }
コード例 #3
0
        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
            {
            }
        }