Пример #1
0
        public void DifferenceBetweenGrid(GridModel newGridModel)
        {
            int temp = gridModel.Grid.Count;

            if (newGridModel != null)
            {
                if (newGridModel.Grid.Count > gridModel.Grid.Count)
                {
                    for (int i = newGridModel.Grid.Count - (newGridModel.Grid.Count - temp); i < newGridModel.Grid.Count; i++)
                    {
                        gridModel.AddCell(newGridModel.Grid[i]);
                        gridModel.Grid[i].SetView(_gridGenerator.CreateCellViewWithCustomParametrs(newGridModel.Grid[i], newGridModel.Grid[i].Weight, newGridModel.Grid[i].CurrentIndex));
                    }
                }
                else if (newGridModel.Grid.Count < gridModel.Grid.Count)
                {
                    for (int i = gridModel.Grid.Count - 1; i > temp - (temp - newGridModel.Grid.Count + 1); i--)
                    {
                        gridModel.Grid[i].DestroyCell();
                        gridModel.Grid.RemoveAt(i);
                    }
                    gridModel.CalculateRowsCount();
                }

                for (int i = 0; i < gridModel.Grid.Count; i++)
                {
                    gridModel.Grid[i].Value  = newGridModel.Grid[i].Value;
                    gridModel.Grid[i].Weight = newGridModel.Grid[i].Weight;

                    if (gridModel.Grid[i].Value != -1)
                    {
                        gridModel.Grid[i].GetView().Enable();
                    }
                    else
                    {
                        gridModel.Grid[i].GetView().Disable();
                    }
                }

                gridModel.CalculateRowsCount();
            }
        }