Пример #1
0
        public void MethodeDeplacer(Point pt)
        {
            Rectangle rct     = RectangleOrigine;
            int       nWidth  = rct.Width;
            int       nHeight = rct.Height;
            int       nX      = rct.X;
            int       nY      = rct.Y;
            int       nXMax   = nX + nWidth;
            int       nYMax   = nY + nHeight;

            if (Editeur.ModeAlignement)
            {
                Point ptInParent = pt;
                switch (Alignement)
                {
                case ContentAlignment.BottomCenter:
                    nYMax = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    pt    = new Point(ptInParent.X, nYMax);
                    break;

                case ContentAlignment.BottomLeft:
                    nX    = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    nYMax = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    pt    = new Point(nX, nYMax);
                    break;

                case ContentAlignment.BottomRight:
                    nXMax = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    nYMax = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    pt    = new Point(nXMax, nYMax);
                    break;

                case ContentAlignment.MiddleLeft:
                    nX = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    pt = new Point(nX, ptInParent.Y);
                    break;

                case ContentAlignment.MiddleRight:
                    nXMax = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    pt    = new Point(nXMax, ptInParent.Y);
                    break;

                case ContentAlignment.TopCenter:
                    nY = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    pt = new Point(ptInParent.X, nY);
                    break;

                case ContentAlignment.TopLeft:
                    nX = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    nY = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    pt = new Point(nX, nY);
                    break;

                case ContentAlignment.TopRight:
                    nY    = Editeur.GetThePlusProche(ptInParent.Y, EDimentionDessin.Y);
                    nXMax = Editeur.GetThePlusProche(ptInParent.X, EDimentionDessin.X);
                    pt    = new Point(nXMax, nY);
                    break;

                default:
                case ContentAlignment.MiddleCenter:
                    break;
                }
            }


            int nHMin = Editeur.HauteurMinimaleDesObjets;
            int nLMin = Editeur.LargeurMinimaleDesObjets;

            /*bool bCompressionBasVersHaut = nY + nHMin <= pt.Y;
             * bool bCompressionHautVersBas = nYMax - nHMin >= pt.Y;
             * bool bCompressionDroiteVersGauche = nX + nLMin <= pt.X;
             * bool bCompressionGaucheVersDroite = nXMax - nLMin >= pt.X;
             * switch (Alignement)
             * {
             *      case ContentAlignment.BottomCenter:
             *              if (!bCompressionBasVersHaut)
             *              {
             *                      nX = m_lastPtDraggPoignee.X;
             *                      pt = new Point(nX, nY + nHMin);
             *              }
             *              break;
             *
             *      case ContentAlignment.BottomLeft:
             *              if (!bCompressionBasVersHaut && !bCompressionGaucheVersDroite)
             *                      pt = new Point(nXMax - nLMin, nY + nHMin);
             *              else if (!bCompressionBasVersHaut)
             *                      pt = new Point(pt.X, nY + nHMin);
             *              else if (!bCompressionGaucheVersDroite)
             *                      pt = new Point(nXMax - nLMin, pt.Y);
             *              break;
             *
             *      case ContentAlignment.BottomRight:
             *              if (!bCompressionBasVersHaut && !bCompressionDroiteVersGauche)
             *                      pt = new Point(nX + nLMin, nY + nHMin);
             *              else if (!bCompressionBasVersHaut)
             *                      pt = new Point(pt.X, nY + nHMin);
             *              else if (!bCompressionDroiteVersGauche)
             *                      pt = new Point(nX + nLMin, pt.Y);
             *              break;
             *
             *      case ContentAlignment.MiddleLeft:
             *              if (!bCompressionGaucheVersDroite)
             *              {
             *                      nY = m_lastPtDraggPoignee.Y;
             *                      pt = new Point(nXMax - nLMin, nY);
             *              }
             *              break;
             *
             *      case ContentAlignment.MiddleRight:
             *              if (!bCompressionDroiteVersGauche)
             *              {
             *                      nY = m_lastPtDraggPoignee.Y;
             *                      pt = new Point(nX + nLMin, nY);
             *              }
             *              break;
             *
             *      case ContentAlignment.TopCenter:
             *              if (!bCompressionHautVersBas)
             *              {
             *                      nX = m_lastPtDraggPoignee.X;
             *                      pt = new Point(nX, nYMax - nHMin);
             *              }
             *              break;
             *
             *      case ContentAlignment.TopLeft:
             *              if (!bCompressionHautVersBas && !bCompressionGaucheVersDroite)
             *                      pt = new Point(nXMax - nLMin, nYMax - nHMin);
             *              else if (!bCompressionHautVersBas)
             *                      pt = new Point(pt.X, nYMax - nHMin);
             *              else if (!bCompressionGaucheVersDroite)
             *                      pt = new Point(nXMax - nLMin, pt.Y);
             *              break;
             *
             *      case ContentAlignment.TopRight:
             *              if (!bCompressionHautVersBas && !bCompressionDroiteVersGauche)
             *                      pt = new Point(nX + nLMin, nYMax - nHMin);
             *              else if (!bCompressionHautVersBas)
             *                      pt = new Point(pt.X, nYMax - nHMin);
             *              else if (!bCompressionDroiteVersGauche)
             *                      pt = new Point(nX + nLMin, pt.Y);
             *              break;
             *
             *      case ContentAlignment.MiddleCenter:
             *      default:
             *              break;
             * }*/
            m_bNewSizeCalculated = m_lastPtDraggPoignee != pt;
            if (m_bNewSizeCalculated)
            {
                m_rectResize = CalcRectDragDrop(pt);
                RecalcPosition(m_rectResize);
                Cursor.Current = Cursor;
            }

            m_lastPtDraggPoignee = pt;
        }