Пример #1
0
        /// <summary>
        /// Draws the line shape across all of the cells. Will not draw the effect. Must be done outside of this method.
        /// </summary>
        /// <param name="cells">The cells to draw on.</param>
        public void Draw(IEnumerable <Cell> cells)
        {
            List <Cell> newCells = new List <Cell>(cells);

            if (newCells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(newCells[0]);
                }
                else
                {
                    CellAppearance.Copy(newCells[0]);
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(newCells[newCells.Count - 1]);
                }
                else
                {
                    CellAppearance.Copy(newCells[newCells.Count - 1]);
                }

                for (int i = 1; i < newCells.Count - 1; i++)
                {
                    CellAppearance.Copy(newCells[i]);
                }
            }
            else if (newCells.Count == 1)
            {
                CellAppearance.Copy(newCells[0]);
            }
        }
Пример #2
0
        /// <summary>
        /// Draws the line shape.
        /// </summary>
        /// <param name="surface">The cell surface to draw on.</param>
        public void Draw(SurfaceEditor surface)
        {
            List <Cell> cells = new List <Cell>();

            Algorithms.Line(StartingLocation.X, StartingLocation.Y, EndingLocation.X, EndingLocation.Y, (x, y) => { cells.Add(surface[x, y]); return(true); });

            if (cells.Count > 1)
            {
                if (UseStartingCell)
                {
                    StartingCellAppearance.Copy(cells[0]);
                    cells[0].Effect = StartingCellAppearance.Effect;
                }
                else
                {
                    CellAppearance.Copy(cells[0]);
                    cells[0].Effect = StartingCellAppearance.Effect;
                }

                if (UseEndingCell)
                {
                    EndingCellAppearance.Copy(cells[cells.Count - 1]);
                    cells[cells.Count - 1].Effect = EndingCellAppearance.Effect;
                }
                else
                {
                    CellAppearance.Copy(cells[cells.Count - 1]);
                    cells[cells.Count - 1].Effect = CellAppearance.Effect;
                }

                for (int i = 1; i < cells.Count - 1; i++)
                {
                    CellAppearance.Copy(cells[i]);
                    cells[i].Effect = CellAppearance.Effect;
                }
            }
            else if (cells.Count == 1)
            {
                CellAppearance.Copy(cells[0]);
                cells[0].Effect = CellAppearance.Effect;
            }
        }