// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { GridLayoutInfo layoutInfo = new GridLayoutInfo { Rows = Rows, Columns = Columns, RowsPercentage = RowPercents, ColumnsPercentage = ColumnPercents, CellChildMap = new int[Rows][], }; for (int row = 0; row < Rows; row++) { layoutInfo.CellChildMap[row] = new int[Columns]; for (int col = 0; col < Columns; col++) { layoutInfo.CellChildMap[row][col] = CellChildMap[row, col]; } } GridLayoutJson jsonObj = new GridLayoutJson { Uuid = "{" + Guid.ToString().ToUpper() + "}", Name = Name, Type = ModelTypeID, Info = layoutInfo, }; JsonSerializerOptions options = new JsonSerializerOptions { PropertyNamingPolicy = new DashCaseNamingPolicy(), }; try { string jsonString = JsonSerializer.Serialize(jsonObj, options); FileSystem.File.WriteAllText(Settings.AppliedZoneSetTmpFile, jsonString); } catch (Exception ex) { ShowExceptionMessageBox(ErrorPersistingGridLayout, ex); } }
// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { AddCustomLayout(this); GridLayoutInfo layoutInfo = new GridLayoutInfo { Rows = Rows, Columns = Columns, RowsPercentage = RowPercents, ColumnsPercentage = ColumnPercents, CellChildMap = new int[Rows][], }; for (int row = 0; row < Rows; row++) { layoutInfo.CellChildMap[row] = new int[Columns]; for (int col = 0; col < Columns; col++) { layoutInfo.CellChildMap[row][col] = CellChildMap[row, col]; } } GridLayoutJson jsonObj = new GridLayoutJson { Uuid = Uuid, Name = Name, Type = ModelTypeID, Info = layoutInfo, }; JsonSerializerOptions options = new JsonSerializerOptions { PropertyNamingPolicy = new DashCaseNamingPolicy(), }; string jsonString = JsonSerializer.Serialize(jsonObj, options); AddCustomLayoutJson(JsonSerializer.Deserialize <JsonElement>(jsonString)); SerializeCreatedCustomZonesets(); }