public void RestoreTo(GridLayoutModel layout) { int rows = Rows; int cols = Columns; layout.Rows = rows; layout.Columns = cols; int[,] cellChildMap = new int[rows, cols]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { cellChildMap[row, col] = CellChildMap[row, col]; } } layout.CellChildMap = cellChildMap; List <int> rowPercents = new List <int>(rows); for (int row = 0; row < rows; row++) { rowPercents.Add(RowPercents[row]); } layout.RowPercents = rowPercents; List <int> colPercents = new List <int>(cols); for (int col = 0; col < cols; col++) { colPercents.Add(ColumnPercents[col]); } layout.ColumnPercents = colPercents; layout.ShowSpacing = ShowSpacing; layout.Spacing = Spacing; layout.SensitivityRadius = SensitivityRadius; }
// Clone // Implements the LayoutModel.Clone abstract method // Clones the data from this GridLayoutModel to a new GridLayoutModel public override LayoutModel Clone() { GridLayoutModel layout = new GridLayoutModel(Name); int rows = Rows; int cols = Columns; layout.Rows = rows; layout.Columns = cols; int[,] cellChildMap = new int[rows, cols]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { cellChildMap[row, col] = CellChildMap[row, col]; } } layout.CellChildMap = cellChildMap; int[] rowPercents = new int[rows]; for (int row = 0; row < rows; row++) { rowPercents[row] = RowPercents[row]; } layout.RowPercents = rowPercents; int[] colPercents = new int[cols]; for (int col = 0; col < cols; col++) { colPercents[col] = ColumnPercents[col]; } layout.ColumnPercents = colPercents; return(layout); }
// Loads all the Layouts persisted under the Layouts key in the registry public static ObservableCollection <LayoutModel> LoadCustomModels() { _customModels = new ObservableCollection <LayoutModel>(); RegistryKey key = Registry.CurrentUser.OpenSubKey(_registryPath); if (key != null) { foreach (string name in key.GetValueNames()) { LayoutModel model = null; byte[] data = (byte[])Registry.GetValue(_fullRegistryPath, name, null); ushort version = (ushort)((data[0] * 256) + data[1]); byte type = data[2]; ushort id = (ushort)((data[3] * 256) + data[4]); switch (type) { case 0: model = new GridLayoutModel(version, name, id, data); break; case 1: model = new CanvasLayoutModel(version, name, id, data); break; } if (model != null) { if (_maxId < id) { _maxId = id; } _customModels.Add(model); } } } return(_customModels); }