Ejemplo n.º 1
0
        public void UpdateApps(GridSizeData newGridSize)
        {
            if (SelectedApps.Count == _gridSize.CellCount)
            {
                if (newGridSize.Rows != _gridSize.Rows || newGridSize.Cols != _gridSize.Cols)
                {
                    //init
                    List <AppInfo> list = new List <AppInfo>();
                    for (int i = 0; i < newGridSize.CellCount; i++)
                    {
                        list.Add(AppInfo.GetEmptyAppInfo());
                    }

                    //smart copy
                    for (int row = 0; row < _gridSize.Rows; row++) //copy maximum possible settings
                    {
                        for (int col = 0; col < _gridSize.Cols; col++)
                        {
                            if (row < newGridSize.Rows && col < newGridSize.Cols)
                            {
                                int index = newGridSize.Pos(row, col);
                                list[index] = this[row, col];
                            }
                        }
                    }
                    SelectedApps = list;
                }
            }
            else if (SelectedApps.Count > 0)
            {
                List <AppInfo> list = new List <AppInfo>();
                for (int i = 0; i < newGridSize.CellCount; i++)
                {
                    list.Add(AppInfo.GetEmptyAppInfo());
                }

                //smart copy
                for (int row = 0; row < _gridSize.Rows; row++) //copy maximum possible settings
                {
                    for (int col = 0; col < _gridSize.Cols; col++)
                    {
                        if (row < newGridSize.Rows && col < newGridSize.Cols)
                        {
                            int index = newGridSize.Pos(row, col);
                            if (index < SelectedApps.Count)
                            {
                                list[index] = SelectedApps[index];
                            }
                        }
                    }
                }
                SelectedApps = list;
            }

            _gridSize = newGridSize;
        }
        private void RebuildAppsGrid(GridSizeData newGridSize)
        {
            if (!_isInitialized)
            {
                return;
            }

            AppContext.Sync = true;
            {
                //AppContext.ViewModel.ReloadApps();

                this.LayoutConfiguration.UpdateApps(newGridSize);

                int rows = this.LayoutConfiguration.GridSize.Rows;
                int cols = this.LayoutConfiguration.GridSize.Cols;

                gridSizeSelector.SelectedSize = new GridSizeData(rows, cols);

                RebuildAppsGrid(gridApps, rows, cols, this.LayoutConfiguration, AppContext.ViewModel);

                DrawGridLines();
            }
            AppContext.Sync = false;
        }
Ejemplo n.º 3
0
 public void SetSelectedgridSizeText(string txtGridSize)
 {
     UpdateApps(GridSizeData.Parse(txtGridSize));
 }