コード例 #1
0
        public void Apply()
        {
            ActiveZoneSetWrapper activeZoneSet = new ActiveZoneSetWrapper
            {
                Uuid = "{" + Guid.ToString().ToUpper() + "}",
            };

            switch (Type)
            {
            case LayoutType.Focus:
                activeZoneSet.Type = FocusJsonTag;
                break;

            case LayoutType.Rows:
                activeZoneSet.Type = RowsJsonTag;
                break;

            case LayoutType.Columns:
                activeZoneSet.Type = ColumnsJsonTag;
                break;

            case LayoutType.Grid:
                activeZoneSet.Type = GridJsonTag;
                break;

            case LayoutType.PriorityGrid:
                activeZoneSet.Type = PriorityGridJsonTag;
                break;

            case LayoutType.Custom:
                activeZoneSet.Type = CustomJsonTag;
                break;
            }

            Settings settings = ((App)Application.Current).ZoneSettings;

            AppliedZoneSet zoneSet = new AppliedZoneSet
            {
                DeviceId          = Settings.UniqueKey,
                ActiveZoneset     = activeZoneSet,
                EditorShowSpacing = settings.ShowSpacing,
                EditorSpacing     = settings.Spacing,
                EditorZoneCount   = settings.ZoneCount,
            };

            JsonSerializerOptions options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = new DashCaseNamingPolicy(),
            };

            try
            {
                string jsonString = JsonSerializer.Serialize(zoneSet, options);
                File.WriteAllText(Settings.ActiveZoneSetTmpFile, jsonString);
            }
            catch (Exception ex)
            {
                ShowExceptionMessageBox(ErrorApplyingLayout, ex);
            }
        }
コード例 #2
0
        public void SerializeAppliedLayouts()
        {
            AppliedZonesetsToDesktops applied = new AppliedZonesetsToDesktops {
            };

            applied.AppliedZonesets = new List <AppliedZoneSet>();

            foreach (var monitor in App.Overlay.Monitors)
            {
                LayoutSettings zoneset = monitor.Settings;
                if (zoneset.ZonesetUuid.Length == 0)
                {
                    continue;
                }

                ActiveZoneSetWrapper activeZoneSet = new ActiveZoneSetWrapper
                {
                    Uuid = zoneset.ZonesetUuid,
                };

                activeZoneSet.Type = LayoutTypeToJsonTag(zoneset.Type);

                applied.AppliedZonesets.Add(new AppliedZoneSet
                {
                    DeviceId                = zoneset.DeviceId,
                    ActiveZoneset           = activeZoneSet,
                    EditorShowSpacing       = zoneset.ShowSpacing,
                    EditorSpacing           = zoneset.Spacing,
                    EditorZoneCount         = zoneset.ZoneCount,
                    EditorSensitivityRadius = zoneset.SensitivityRadius,
                });
            }

            try
            {
                string jsonString = JsonSerializer.Serialize(applied, _options);
                _fileSystem.File.WriteAllText(ActiveZoneSetTmpFile, jsonString);
            }
            catch (Exception ex)
            {
                App.ShowExceptionMessageBox(Properties.Resources.Error_Applying_Layout, ex);
            }
        }