private RegionsPreset InitializeNewPreset(string name) { var preset = Settings.Instance.Regions.GetPresetByName(name); if (preset != null) { Settings.Instance.Regions.Presets.Remove(preset); } preset = new RegionsPreset(name, Screen.GetScreens().Select(s => new ScreenRegion(s.WorkspaceRect, s.Rect, s.IsPrimary)).ToArray()); Settings.Instance.Regions.Presets.Add(preset); return(preset); }
private bool IsPresetCorrespondsToScreens(RegionsPreset preset, Screen[] screens) { if (preset.ScreenRegions.Length != screens.Length) { return(false); } var sortedRegions = preset.ScreenRegions.OrderBy(r => r.PhysicalBounds.Top).ThenBy(r => r.PhysicalBounds.Left).ToArray(); var sortedScreens = screens.OrderBy(s => s.Rect.Top).ThenBy(s => s.Rect.Left).ToArray(); for (var i = 0; i < sortedRegions.Length; i++) { var region = sortedRegions[i]; var screen = sortedScreens[i]; if (region.PhysicalBounds != screen.Rect) { return(false); } region.IsPrimary = screen.IsPrimary; } return(true); }