/// <summary> /// Constructs the GapView. /// </summary> /// <param name="gap"> the Gap to view </param> public GapView(PigWorldView pigWorldView, Gap gap) { this.gap = gap; this.Dock = DockStyle.Fill; this.Margin = new Padding(0); // Fill the entire space available. gap.gapChangedEvent += GapChangedEvent; }
/// <summary> /// Creates all the GapsViews in this PigWorldView. /// </summary> private void CreateGapViews() { horizontalGapViews = new GapView[pigWorld.NumOfHorizontalGapsPerColumn, pigWorld.NumOfColumns]; for (int row = 0; row < pigWorld.NumOfHorizontalGapsPerColumn; row++) { for (int column = 0; column < pigWorld.NumOfColumns; column++) { Gap gap = pigWorld.GetGap(row, column, GapDirection.Horizontal); GapView gapView = new GapView(this, gap); horizontalGapViews[row, column] = gapView; } } verticalGapViews = new GapView[pigWorld.NumOfRows, pigWorld.NumOfVerticalGapsPerRow]; for (int row = 0; row < pigWorld.NumOfRows; row++) { for (int column = 0; column < pigWorld.NumOfVerticalGapsPerRow; column++) { Gap gap = pigWorld.GetGap(row, column, GapDirection.Vertical); GapView gapView = new GapView(this, gap); verticalGapViews[row, column] = gapView; } } }
/// <summary> /// Creates all the Gaps in this pigWorld, /// both the Horizontal ones and the Vertical ones. /// </summary> private void CreateGaps() { horizontalGaps = new Gap[numOfHorizontalGapsPerColumn, numOfColumns]; for (int row = 0; row < numOfHorizontalGapsPerColumn; row++) { for (int column = 0; column < numOfColumns; column++) { Position position = new Position(row, column); Gap gap = new Gap(position, GapDirection.Horizontal); horizontalGaps[row, column] = gap; } } verticalGaps = new Gap[numOfRows, numOfVerticalGapsPerRow]; for (int row = 0; row < numOfRows; row++) { for (int column = 0; column < numOfVerticalGapsPerRow; column++) { Position position = new Position(row, column); Gap gap = new Gap(position, GapDirection.Vertical); verticalGaps[row, column] = gap; } } }
/// <summary> /// Fills a vertical gap with a Wall. /// </summary> /// <param name="row"> the row position of the vertical gap to be filled. </param> /// <param name="column"> the column position of the vertical gap to be filled. </param> public void FillVerticalGap(int row, int column) { Gap gap = verticalGaps[row, column]; gap.HasWall = true; }
/// <summary> /// Fills a horizontal gap with a Wall. /// </summary> /// <param name="row"> the row position of the horizontal gap to be filled. </param> /// <param name="column"> the column position of the horizontal gap to be filled. </param> public void FillHorizontalGap(int row, int column) { Gap gap = horizontalGaps[row, column]; gap.HasWall = true; }