private void InitializeObjects()
        {
            for (int currentRow = 0; currentRow < 9; currentRow++)
            {
                for (int currentColumn = 0; currentColumn < 9; currentColumn++)
                {
                    Models.Cell newCell = new Models.Cell();
                    newCell.CellRow     = currentRow;
                    newCell.CellColumn  = currentColumn;
                    newCell.CellSquare  = Convert.ToInt32((currentRow / 3)) * 3 + Convert.ToInt32((currentColumn / 3));
                    newCell.CellContent = 0;
                    Cells.Add(newCell);

                    for (int currentDigit = 1; currentDigit < 10; currentDigit++)
                    {
                        Models.CellValue newCellValue = new Models.CellValue();
                        newCellValue.CellValueRow     = currentRow;
                        newCellValue.CellValueColumn  = currentColumn;
                        newCellValue.CellValueDigit   = currentDigit;
                        newCellValue.CellIsFixedState = false;
                        newCellValue.CellValueState   = 1;
                        CellValues.Add(newCellValue);
                    }
                }
            }
        }
Пример #2
0
        public Models.Cell CreateCell(ICell cell, ISheet sheet)
        {
            Models.Cell result     = null;
            bool        valid      = true;
            int         rowSpan    = 1;
            int         columnSpan = 1;

            if (cell.IsMergedCell)
            {
                valid = false;
                for (var i = 0; i < sheet.NumMergedRegions; i++)
                {
                    var region = sheet.GetMergedRegion(i);
                    if (region.FirstRow == cell.RowIndex && region.FirstColumn == cell.ColumnIndex)
                    {
                        valid      = true;
                        rowSpan    = region.LastRow - region.FirstRow + 1;
                        columnSpan = region.LastColumn - region.FirstColumn + 1;
                        break;
                    }
                }
            }

            if (valid)
            {
                result             = new Models.Cell();
                result.Value       = GetValue(cell);
                result.ColumnIndex = cell.ColumnIndex;
                result.RowIndex    = cell.RowIndex;
                result.ColumnSpan  = columnSpan;
                result.RowSpan     = rowSpan;
            }
            return(result);
        }
Пример #3
0
 public void Execute(object parameter)
 {
     if (parameter is Models.Cell)
     {
         Models.Cell cell = parameter as Models.Cell;
         cell.live = !cell.live;
     }
 }
 private void UpdateNewSetOfCells(List <Cell> cells, List <Cell> newSetOfCells)
 {
     foreach (Cell oldCell in cells)
     {
         Models.Cell newCell = new Models.Cell();
         newCell.CellColumn  = oldCell.CellColumn;
         newCell.CellContent = oldCell.CellContent;
         newCell.CellRow     = oldCell.CellRow;
         newCell.CellSquare  = oldCell.CellSquare;
         newSetOfCells.Add(newCell);
     }
 }
Пример #5
0
        public void UpdateCell(Models.Cell modelCell)
        {
            int index = modelCell.Index;

            Cell temp = TempStore;

            TempStore = this[index];

            temp.CopyFrom(modelCell, index);

            this[index] = temp;
        }
Пример #6
0
 public static Models.Cell[,] ToCellArray(this int[,] table)
 {
     Models.Cell[,] tableArray = new Models.Cell[table.GetLength(0), table.GetLength(1)];
     for (int i = 0; i < table.GetLength(0); i++)
     {
         for (int j = 0; j < table.GetLength(1); j++)
         {
             tableArray[i, j]      = new Models.Cell();
             tableArray[i, j].live = table[i, j] == 1 ? true : false;
         }
     }
     return(tableArray);
 }
 private void UpdateOldSetOfCells(List <Cell> newSetOfCells, List <Cell> cells)
 {
     cells.Clear();
     foreach (Cell newCell in newSetOfCells)
     {
         Models.Cell oldCell = new Models.Cell();
         oldCell.CellColumn  = newCell.CellColumn;
         oldCell.CellContent = newCell.CellContent;
         oldCell.CellRow     = newCell.CellRow;
         oldCell.CellSquare  = newCell.CellSquare;
         cells.Add(newCell);
     }
 }
Пример #8
0
        public void MakeBorderTest1()
        {
            Bitmap bmp = new Bitmap(100, 100);

            Models.Cell resultCell = _IImageWorker.MakeBorderOnCell(new Models.Cell {
                CellImage = bmp, X = 0, Y = 1
            });
            Assert.True(resultCell.X == 0 && resultCell.Y == 1);
            Bitmap result = ((Bitmap)resultCell.CellImage);

            Assert.True(result.Width == 100 && result.Height == 100);

            Assert.True(result.GetPixel(10, 0).ToArgb().Equals(Color.Black.ToArgb()));
            Assert.True(result.GetPixel(0, 10).ToArgb().Equals(Color.Black.ToArgb()));
            Assert.True(result.GetPixel(99, 10).ToArgb().Equals(Color.Black.ToArgb()));
            Assert.True(result.GetPixel(10, 99).ToArgb().Equals(Color.Black.ToArgb()));
        }
Пример #9
0
 public BorderCell(Models.Cell cell)
 {
     model = cell;
     this.InitializeComponent();
     DataContext = model;
 }
Пример #10
0
 /// <summary>
 /// Constructeur complet
 /// </summary>
 /// <param name="model">Modèle de la cellule</param>
 public Cell(Models.Cell model)
 {
     this.model = model;
 }