// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { AddCustomLayout(this); var canvasRect = CanvasRect; if (canvasRect.Width == 0 || canvasRect.Height == 0) { canvasRect = App.Overlay.WorkArea; } CanvasLayoutInfo layoutInfo = new CanvasLayoutInfo { RefWidth = (int)canvasRect.Width, RefHeight = (int)canvasRect.Height, Zones = new Zone[Zones.Count], }; for (int i = 0; i < Zones.Count; ++i) { Zone zone = new Zone { X = Zones[i].X, Y = Zones[i].Y, Width = Zones[i].Width, Height = Zones[i].Height, }; layoutInfo.Zones[i] = zone; } CanvasLayoutJson jsonObj = new CanvasLayoutJson { 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(); }
// PersistData // Implements the LayoutModel.PersistData abstract method protected override void PersistData() { CanvasLayoutInfo layoutInfo = new CanvasLayoutInfo { RefWidth = lastWorkAreaWidth, RefHeight = lastWorkAreaHeight, Zones = new Zone[Zones.Count], }; for (int i = 0; i < Zones.Count; ++i) { Zone zone = new Zone { X = Zones[i].X, Y = Zones[i].Y, Width = Zones[i].Width, Height = Zones[i].Height, }; layoutInfo.Zones[i] = zone; } CanvasLayoutJson jsonObj = new CanvasLayoutJson { Uuid = "{" + Guid.ToString().ToUpper() + "}", Name = Name, Type = "canvas", Info = layoutInfo, }; JsonSerializerOptions options = new JsonSerializerOptions { PropertyNamingPolicy = new DashCaseNamingPolicy(), }; try { string jsonString = JsonSerializer.Serialize(jsonObj, options); File.WriteAllText(Settings.AppliedZoneSetTmpFile, jsonString); } catch (Exception ex) { ShowExceptionMessageBox("Error persisting canvas layout", ex); } }