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


C# Corner.AddWall方法代码示例

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


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

示例1: Clone

        /**
         * This method returns a copy of the blueprint.
         * This is a Deep Copy, meaning that all the Rooms, Corners in those rooms and Walls connected to those corners will be copied.
         * The purpose of this is to make a new copy to work in when editing a blueprint, while preserving the original.
         */
        public Blueprint Clone()
        {
            Blueprint newBp = new Blueprint(this.Name);

            List<Wall> newWalls = new List<Wall>();
            List<Corner> newCorners = new List<Corner>();

            foreach(Room room in this.Rooms) {
                Room newRoom = new Room(room.Name, room.GetID(), room.GetFloorID(), room.FunctionID);
                newBp.Rooms.Add(newRoom);

                foreach(Corner corner in room.GetCorners()) {
                    Corner newCorner = newCorners.Find( (c) => (c.GetID() == corner.GetID()) );
                    if(newCorner != null) {
                        newRoom.AddCorner(newCorner);
                        continue;
                    }

                    newCorner = new Corner(corner.GetID(), corner.GetPoint());
                    newRoom.AddCorner(newCorner);
                    newCorners.Add(newCorner);

                    foreach(Wall wall in corner.GetWalls()) {
                        Wall newWall = newWalls.Find( (w) => (w.GetID() == wall.GetID()) );
                        if(newWall != null) {
                            if(newWall.Left.GetID() == corner.GetID()) {
                                newWall.Left = newCorner;
                            } else if(newWall.Right.GetID() == corner.GetID()) {
                                newWall.Right = newCorner;
                            }
                            if(newWall.GetType() == typeof(Door)) {
                                ((Door)newWall).Hinge = (((Door)newWall).Hinge.Equals(newWall.Left) ? newWall.Left : newWall.Right);
                            }
                            newCorner.AddWall(newWall);
                            continue;
                        }

                        Corner left = (wall.Left.Equals(newCorner) ? newCorner : wall.Left);
                        Corner right = (wall.Right.Equals(newCorner) ? newCorner : wall.Right);

                        if(wall.GetType() == typeof(Door)) {
                            newWall = new Door(wall.GetID(), left, right, (((Door)wall).Hinge.GetID() == left.GetID() ? left : right), ((Door)wall).Direction);
                        } else {
                            newWall = new Wall(wall.GetID(), left, right);
                        }

                        newWalls.Add(newWall);
                        newCorner.AddWall(newWall);
                    }
                }
                newRoom.IsChanged = room.IsChanged;
            }

            return newBp;
        }
开发者ID:Railec,项目名称:SE1cKBS2,代码行数:60,代码来源:Blueprint.cs

示例2: DoorAddWall

        public void DoorAddWall()
        {
            //Arrange
            Corner left = new Corner(new PointF(0, 0));
            Corner right = new Corner(new PointF(10, 0));
            Door door = new Door(left, right);

            //Act
            left.AddWall(door);
            right.AddWall(door);

            //Assert
            IList lWalls = left.GetWalls();
            Assert.AreEqual(1, lWalls.Count);
            Assert.IsInstanceOf<Door>(lWalls[0]);
            Assert.AreEqual(door, lWalls[0]);
        }
开发者ID:Railec,项目名称:SE1cKBS2,代码行数:17,代码来源:CornerTest.cs

示例3: OnMouseDown

        /**
         * This event is called when the user begins to hold down a mouse button while on this control.
         */
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if(this.ActiveBlueprint == null) return;

            if(e.Button.HasFlag(MouseButtons.Right)) {
                this.LoadContextMenu();
            } else if(e.Button.HasFlag(MouseButtons.Middle)) {
                //Panning
                if(Control.ModifierKeys.HasFlag(Keys.Control)) {
                    this.Size = new Size(this.Parent.ClientSize.Width - 10, this.Parent.ClientSize.Height - 35);
                    this._center = new PointF(this.Size.Width/2, this.Size.Height/2);
                    this.Invalidate();
                } else {
                    this._panOrigin = e.Location;
                }
                return;
            } else if(this._editMode && e.Button.HasFlag(MouseButtons.Left)) {
                if(this._status == Status.CreateCorner) {
                    //New corner
                    PointF mouseLoc = this.PointToClient(Cursor.Position);
                    PointF mouseOffset = new PointF(mouseLoc.X-this._center.X, mouseLoc.Y-this._center.Y);
                    Corner newCorner = new Corner(mouseOffset);
                    if(this._currentRoom != null) {
                        this._currentRoom.AddCorner(newCorner);
                        this._status = Status.CreateRoom;
                        if(this.SelectedCorner != null) {
                            Wall newWall = new Wall(newCorner, this.SelectedCorner);
                            newCorner.AddWall(newWall);
                            this.SelectedCorner.AddWall(newWall);
                        }
                    }
                    this.Cursor = Cursors.Default;
                    this.SelectedCorner = newCorner;
                    this.Invalidate();
                } else if(this._status == Status.ConnectCorners) {
                    //Connect 2 corners
                    PointF mouseLoc = this.PointToClient(Cursor.Position);
                    PointF mouseOffset = new PointF(mouseLoc.X-this._center.X, mouseLoc.Y-this._center.Y);
                    Corner otherCorner = this.ActiveBlueprint.GetCornerAtPoint(mouseOffset, this.Renderer.CornerSizeEdit);
                    if(this.SelectedCorner != null && otherCorner != null && !this.SelectedCorner.Equals(otherCorner)) {
                        Wall newWall = new Wall(otherCorner, this.SelectedCorner);
                        otherCorner.AddWall(newWall);
                        this.SelectedCorner.AddWall(newWall);
                        this._status = (this._currentRoom != null ? Status.CreateRoom : Status.None);
                        if(this._currentRoom != null){
                            if(this._currentRoom.GetCorners().Contains(this.SelectedCorner)
                            && !this._currentRoom.GetCorners().Contains(otherCorner)) {
                                this._currentRoom.AddCorner(otherCorner);
                            } else if(this._currentRoom.GetCorners().Contains(otherCorner)
                            && !this._currentRoom.GetCorners().Contains(this.SelectedCorner)) {
                                this._currentRoom.AddCorner(this.SelectedCorner);
                            }
                        }
                        this.Cursor = Cursors.Default;
                    }
                } else {
                    //Selects
                    if(this.SelectedCorner != null) this.SelectedCorner.SaveChanges = true;
                    if(this.SelectedWall != null) this.SelectedWall.SaveChanges = true;

                    int? state = ((int?)this.SelectedRoom?.GetID() ?? -1) + ((int?)this.SelectedCorner?.GetID() ?? -1) + ((int?)this.SelectedWall?.GetID() ?? -1);
                    this.SelectedRoom = this.HoveredRoom;
                    this.SelectedCorner = this.HoveredCorner;
                    this.SelectedWall = this.HoveredWall;
                    int? newState = ((int?)this.SelectedRoom?.GetID() ?? -1) + ((int?)this.SelectedCorner?.GetID() ?? -1) + ((int?)this.SelectedWall?.GetID() ?? -1);

                    if(this.SelectedCorner != null) {
                        if(this._status == Status.CreateRoomSelect) {
                            this._currentRoom.GetCorners().Add(this.SelectedCorner);
                            this._status = Status.CreateRoom;
                        } else {
                            this.SelectedCorner.SaveChanges = false;
                            this._movingCorner = true;
                        }
                    }
                    if(this.SelectedWall != null) this.SelectedWall.SaveChanges = false;

                    if(state != newState) this.Invalidate();
                }
            }
        }
开发者ID:Railec,项目名称:SE1cKBS2,代码行数:85,代码来源:BlueprintPanel.cs

示例4: NullAddWall

        public void NullAddWall()
        {
            //Arrange
            Corner left = new Corner(new PointF(0, 0));
            Corner right = new Corner(new PointF(10, 0));
            Wall wall = null;

            //Act
            left.AddWall(wall);
            right.AddWall(wall);

            //Assert
            IList lWalls = left.GetWalls();
            Assert.AreEqual(0, lWalls.Count);
        }
开发者ID:Railec,项目名称:SE1cKBS2,代码行数:15,代码来源:CornerTest.cs


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