private bool SetTemplateLayouts(List <TemplateLayoutWrapper> templateLayouts) { if (templateLayouts == null) { return(false); } foreach (var wrapper in templateLayouts) { LayoutType type = JsonTagToLayoutType(wrapper.Type); LayoutModel layout = MainWindowSettingsModel.DefaultModels[(int)type]; layout.SensitivityRadius = wrapper.SensitivityRadius; layout.TemplateZoneCount = wrapper.ZoneCount; if (layout is GridLayoutModel grid) { grid.ShowSpacing = wrapper.ShowSpacing; grid.Spacing = wrapper.Spacing; } layout.InitTemplateZones(); } return(true); }
public LayoutModel UpdateSelectedLayoutModel() { LayoutModel foundModel = null; LayoutSettings currentApplied = App.Overlay.CurrentLayoutSettings; // set new layout if (currentApplied.Type == LayoutType.Custom) { foreach (LayoutModel model in CustomModels) { if (model.Uuid == currentApplied.ZonesetUuid.ToUpperInvariant()) { // found match foundModel = model; break; } } } else { foreach (LayoutModel model in DefaultModels) { if (model.Type == currentApplied.Type) { // found match foundModel = model; foundModel.TemplateZoneCount = currentApplied.ZoneCount; foundModel.SensitivityRadius = currentApplied.SensitivityRadius; if (foundModel is GridLayoutModel grid) { grid.ShowSpacing = currentApplied.ShowSpacing; grid.Spacing = currentApplied.Spacing; } foundModel.InitTemplateZones(); break; } } } if (foundModel == null) { foundModel = DefaultModels[(int)LayoutType.PriorityGrid]; } SetSelectedModel(foundModel); SetAppliedModel(foundModel); FirePropertyChanged(nameof(IsCustomLayoutActive)); return(foundModel); }