当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.Move方法代码示例

本文整理汇总了C#中System.Drawing.Rectangle.Move方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Move方法的具体用法?C# Rectangle.Move怎么用?C# Rectangle.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Rectangle的用法示例。


在下文中一共展示了Rectangle.Move方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SimpleMend

        /// <summary>
        /// Próbuje pierwsze puste pole z listy u¿ywaj¹c najmniejszych pokrywaj¹cych prostok¹tów
        /// </summary>
        /// <param name="container"></param>
        /// <param name="r"></param>
        private bool SimpleMend(RectangleContainer container, Rectangle r)
        {
            if (container == null || r == null)
                throw new ArgumentNullException();

            Rectangle empty = container.EmptyFields[0];
            if (empty == null)
                return false;

            if (empty.LongerSide > r.LongerSide || empty.ShorterSide > r.ShorterSide)
                return false;

            if (!empty.RectangleOrientation.Equals(r.RectangleOrientation))
                r.Rotate();
            Point nLT = new Point(empty.RightDown.X - r.SideA, empty.RightDown.Y - r.SideB);
            if (nLT.X >= 0 && nLT.Y >= 0)
            {
                r.Move(nLT);
                rects.RemoveRectangle(r);
            }
            container.InsertRectangle(r);
            return true;
        }
开发者ID:BackupTheBerlios,项目名称:warcom,代码行数:28,代码来源:Algorithm2.cs

示例2: FirstRectanglePreparation

 /// <summary>
 /// Przygotowuje pierwszy prostokat do wstawienia do kontenera
 /// </summary>
 /// <param name="r">Prostok�t do wstawienia jako pierwszy</param>
 private void FirstRectanglePreparation(Rectangle r)
 {
     r.Move(new Point(0, 0));
     this.maxCorrectRect = new Rectangle(r.LeftTop, r.RightDown);
     this.maxCorrectRect.ContainedRectangles.Add(r);
     this.maxPossibleRect = new Rectangle(r.LeftTop, r.RightDown);
     this.isCorrectRectangle = true;
 }
开发者ID:BackupTheBerlios,项目名称:warcom,代码行数:12,代码来源:RectangleContainer.cs

示例3: stickRectangleRight

        /// <summary>
        /// Prostok�t do��czany do boku budowanego prostak�ta z prawej strony.
        /// </summary>
        /// <param name="outsRight">lista prostok�t�w na brzegu z prawej strony</param>
        /// <param name="outsDown">lista prostok�t�w na brzegu z do�u</param>
        /// <param name="holesRight">lista dziur z prawej strony</param>
        /// <param name="holesDown">lista dziur z do�u</param>
        /// <param name="rect">do��czany prostok�t</param>        
        private void stickRectangleRight(List<OutRect> outsRight, List<OutRect> outsDown, 
                            List<Hole> holesRight, List<Hole> holesDown, Rectangle rect)
        {
            OutRect outRect;
            Hole hole;

            rect.Move(new Point(Min_X, 0));
            updateMaxValues(rect);

            if (rect.SideB < Min_Y)
            {
                outRect = new OutRect(rect.SideA, rect.SideB, new Point(rect.LeftTop.X,
                                                rect.LeftTop.Y));
                outsRight.Add(outRect);

                hole = new Hole(rect.SideA, Max_Y - rect.SideB, new Point(Min_X,
                                    rect.RightDown.Y));
                hole.NeighbourOne = outRect;
                hole.OrientDown = true;
                hole.OrientRight = true;

                if (isCornerHole(holesDown))
                    hole.saveResize(rect.SideA, Min_Y - rect.SideB);
                else
                {
                    hole.Corner = true;
                    if (outsDown.Count > 0)
                        hole.NeighbourSecond = outsDown[outsDown.Count - 1];
                }

                holesRight.Add(hole);
            }
            else
            {
                if (Max_Y > Min_Y && !isCornerHole(holesDown) && outsDown.Count > 0)
                {
                    hole = new Hole(Max_X - Min_X, Max_Y - Min_Y, new Point(Min_X, Min_Y));
                    hole.NeighbourOne = outsDown[outsDown.Count - 1];
                    hole.OrientDown = true;
                    hole.OrientRight = true;
                    hole.Corner = true;
                    holesDown.Add(hole);
                }

                Min_X = rect.RightDown.X;
            }
        }
开发者ID:BackupTheBerlios,项目名称:warcom,代码行数:55,代码来源:Algorithm3.cs

示例4: InsertRectangle

        /// <summary>
        /// Wstawia prostok�t do kontenera
        /// </summary>
        /// <param name="r">Prostok�t do wstawienia</param>
        /// <param name="rLeftTop">Lewy g�rny wierzcho�ek prostok�ta</param>
        /// <param name="o">Orientacja prostok�ta</param>
        public void InsertRectangle(Rectangle r, Point rLeftTop, Rectangle.Orientation o)
        {
            Console.WriteLine("insert rect[(" + r.LeftTop.X + ", " + r.LeftTop.Y + "), (" +
                r.RightDown.X + ", " + r.RightDown.Y + ")]" + " -> (" + rLeftTop.X + ", " +
                rLeftTop.Y + ")");

            InsertRectangleCheckParameters(r, rLeftTop);

            if (o.Equals(Rectangle.Orientation.Horizontal) && r.SideA < r.SideB)
                r.Rotate();
            else if (o.Equals(Rectangle.Orientation.Vertical) && r.SideA > r.SideB)
                r.Rotate();

            if (rectangles.Count == 0)
                FirstRectanglePreparation(r);
            else
                r.Move(rLeftTop);

            rectangles.Add(r);

            //jesli to byl pierwszy prostakat wszystko jest dobrze - nie trzeba tego robic
            if (rectangles.Count > 1)
            {
                // spr. czy po dodaniu wciaz prawidlowy prostokat
                if (isCorrectRectangle)
                {
                    // doklejamy od dolu prostokata
                    if (r.LeftTop.X == maxCorrectRect.LeftTop.X &&
                        r.RightDown.X == maxCorrectRect.RightDown.X &&
                        r.LeftTop.Y <= maxCorrectRect.RightDown.Y)
                        UpdateMaxRectangles(r);

                        // doklejamy z prawej strony prostokata
                    else if (r.LeftTop.Y == maxCorrectRect.LeftTop.Y &&
                        r.RightDown.Y == maxCorrectRect.RightDown.Y &&
                        r.LeftTop.X <= maxCorrectRect.RightDown.X)
                        UpdateMaxRectangles(r);

                        // naklejamy na prostokat
                    else if (maxCorrectRect.Covers(r))
                        r.SetParentRectangle(maxCorrectRect);

                        // zaklejamy ca�y prostok�t - to r�wnie g�upi przypadek jak poprzedni, ale skoro kto� tak chce...
                    else if (r.Covers(maxCorrectRect))
                        UpdateMaxRectangles(r);

                        // calosc przestaje byc poprawnym prostokatem
                    else
                    {
                        isCorrectRectangle = false;
                        AddNewEmptyFields(r);
                        UpdateMaxPossibleRectangle(r);
                    }
                }// gdy calosc nie jest prawidlowym prostokatem
                else
                {
                    //sprawdzenie czy dodanie prostokata nie pokrylo calkowicie jakichs emptyFields
                    //spr. czy przeciecia dodanego z empty sa niepuste (jesli tak - usuwamy odpow. empty z listy i wstawiamy zamiast niego empty-dodany)
                    //spr. czy nie zmienil sie maxPossibleRect

                    UpdateEmptyFields(r);
                    if (emptyFields.Count == 0)
                        UpdateMaxCorrectAfterFillingAllEmpties();
                    UpdateMaxPossibleRectangle(r);
                }
            }
        }
开发者ID:BackupTheBerlios,项目名称:warcom,代码行数:73,代码来源:RectangleContainer.cs

示例5: filled

            /// <summary>
            /// Prostok�t wype�nia na dan� dziur�. Ewentualnie mo�e powsta� nowa dziura.
            /// </summary>
            /// <param name="rect">dany prostok�t</param>
            /// <param name="newHole">powsta�a nowa dziura</param>
            /// <returns>
            /// 0 - prostok�t w ca�o�ci wype�ni� dan� dziur� - dziura do usuni�cia
            /// 1 - prostok�t wype�ni� cze�ciowo dan� dziur� - mo�liwa aktualizacja Min_X lub Min_Y
            /// -1 - prostok�t wype�ni� cz�ciowo dan� dziur�
            /// </returns>
            public int filled(Rectangle rect, out Hole newHole)
            {
                Point leftTop = new Point(_rect.LeftTop.X, _rect.LeftTop.Y);
                //Point rightTop = new Point(_rect.RightDown.X, _rect.RightDown.Y);
                int sideA = rect.SideA - _rect.SideA;
                int sideB = rect.SideB - _rect.SideB;
                int result = 0;

                rect.Move(leftTop);
                newHole = null;

                if (sideA >=0 && sideB >= 0)
                    return 0;

                if (_orientRight && _orientDown)
                {
                    result = 1;

                    if (sideA < 0 && sideB < 0)
                    {
                        int holeSideA = _rect.SideA;

                        _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y));
                        saveResize(-sideA, rect.SideB);
                        newHole = new Hole(holeSideA, -sideB, new Point(rect.LeftTop.X, rect.RightDown.Y));

                        if (_corner)
                        {
                            _corner = false;
                            newHole.OrientRight = true;
                            newHole.OrientDown = true;
                            newHole.Corner = true;
                        }
                    }
                    else if (sideA >= 0)
                    {
                        _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y));
                        saveResize(rect.SideA, -sideB);
                    }
                    else if (sideB >= 0)
                    {
                        _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y));
                        saveResize(-sideA, rect.SideB);
                    }
                }
                else if (_orientRight)
                {
                    if (sideB >= 0)
                    {
                        _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y));
                        saveResize(-sideA, _rect.SideB);
                        result = 1;
                    }
                    else
                    {
                        _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y));
                        if(_neighbourSecond != null)
                            saveResize(Math.Min(rect.SideA, _neighbourSecond.SideA), -sideB);
                        result = -1;
                    }
                }
                else if (_orientDown)
                {
                    if (sideA >= 0)
                    {
                        _rect.Move(new Point(rect.LeftTop.X, rect.RightDown.Y));
                        saveResize(_rect.SideA, -sideB);
                        result = 1;
                    }
                    else
                    {
                        _rect.Move(new Point(rect.RightDown.X, rect.LeftTop.Y));
                        if (_neighbourSecond != null)
                            saveResize(-sideA, Math.Min(rect.SideB, _neighbourSecond.SideB));
                        result = -1;
                    }
                }

                return result;
            }
开发者ID:BackupTheBerlios,项目名称:warcom,代码行数:90,代码来源:Algorithm3.cs


注:本文中的System.Drawing.Rectangle.Move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。