Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public AppSettings()
        {
            string appSettingsPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                "OpenTracker", "OpenTracker.json");

            if (File.Exists(appSettingsPath))
            {
                string jsonContent           = File.ReadAllText(appSettingsPath);
                AppSettingsSaveData saveData =
                    JsonConvert.DeserializeObject <AppSettingsSaveData>(jsonContent);
                Load(saveData);
            }
            else
            {
                Colors.AccessibilityColors.Add(AccessibilityLevel.None, "#ffff3030");
                Colors.AccessibilityColors.Add(AccessibilityLevel.Partial, "#ffff8c00");
                Colors.AccessibilityColors.Add(AccessibilityLevel.Inspect, "#ff6495ed");
                Colors.AccessibilityColors.Add(AccessibilityLevel.SequenceBreak, "#ffffff00");
                Colors.AccessibilityColors.Add(AccessibilityLevel.Normal, "#ff00ff00");
                Colors.AccessibilityColors.Add(AccessibilityLevel.Cleared, "#ff333333");
            }
        }
Exemple #2
0
        /// <summary>
        /// Loads app settings save data.
        /// </summary>
        public void Load(AppSettingsSaveData saveData)
        {
            if (saveData == null)
            {
                throw new ArgumentNullException(nameof(saveData));
            }

            Bounds.Maximized            = saveData.Maximized;
            Bounds.X                    = saveData.X;
            Bounds.Y                    = saveData.Y;
            Bounds.Width                = saveData.Width;
            Bounds.Height               = saveData.Height;
            Tracker.DisplayAllLocations = saveData.DisplayAllLocations;
            Tracker.ShowItemCountsOnMap = saveData.ShowItemCountsOnMap;

            if (saveData.DisplayMapsCompasses.HasValue)
            {
                Layout.DisplayMapsCompasses = saveData.DisplayMapsCompasses.Value;
            }

            if (saveData.AlwaysDisplayDungeonItems.HasValue)
            {
                Layout.AlwaysDisplayDungeonItems = saveData.AlwaysDisplayDungeonItems.Value;
            }

            Layout.LayoutOrientation = saveData.LayoutOrientation;
            Layout.MapOrientation    = saveData.MapOrientation;

            // Code to handle change of type from 1.3.2 to later versions.
            if (saveData.Version == null)
            {
                Layout.HorizontalUIPanelPlacement = saveData.HorizontalUIPanelPlacement switch
                {
                    Dock.Bottom => Dock.Top,
                    _ => Dock.Bottom
                };

                Layout.VerticalUIPanelPlacement = saveData.VerticalUIPanelPlacement switch
                {
                    Dock.Bottom => Dock.Left,
                    _ => Dock.Right
                };

                Layout.HorizontalItemsPlacement = saveData.HorizontalItemsPlacement switch
                {
                    Dock.Bottom => Dock.Left,
                    _ => Dock.Right
                };

                Layout.VerticalItemsPlacement = saveData.VerticalItemsPlacement switch
                {
                    Dock.Bottom => Dock.Top,
                    _ => Dock.Bottom
                };
            }
            else
            {
                Layout.HorizontalUIPanelPlacement = saveData.HorizontalUIPanelPlacement;
                Layout.VerticalUIPanelPlacement   = saveData.VerticalUIPanelPlacement;
                Layout.HorizontalItemsPlacement   = saveData.HorizontalItemsPlacement;
                Layout.VerticalItemsPlacement     = saveData.VerticalItemsPlacement;
            }

            Layout.UIScale           = saveData.UIScale == 0.0 ? 1.0 : saveData.UIScale;
            Colors.EmphasisFontColor = saveData.EmphasisFontColor;
            Colors.ConnectorColor    = saveData.ConnectorColor;

            foreach (var color in saveData.AccessibilityColors)
            {
                if (Colors.AccessibilityColors.ContainsKey(color.Key))
                {
                    Colors.AccessibilityColors[color.Key] = color.Value;
                }
                else
                {
                    Colors.AccessibilityColors.Add(color);
                }
            }
        }