forked from files-community/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
AppSettings
0x5BFA edited this page Jan 18, 2025
·
14 revisions
Current settings manager is separated into multiple services that share the same json context object is configured in DI container. We rather should have a static class that can be initialized whenever we want and get/set settings values from/to a centralized static manager
public sealed partial class AppSettings {}
// Sets up the watcher to the json file and gets a handle of it with shareable access, etc.
AppSettings.Initialize("The full path to the json");
// Free the watcher and the handle for the json file at the main process termination, etc.
AppSettings.Dispose();
if (AppSettings.SaveLastOpenedSessions)
AppSettings.SaveLastOpenedSessions = false;
// AppSettings.Layout.cs
public sealed partial class AppSettings
{
[GeneratedAppSettingsProperty(DefaultValue = false)]
public partial bool SyncFolderPreferencesAcrossDirectories { get; set; }
[GeneratedAppSettingsProperty(DefaultValue = FolderLayoutModes.Adaptive)]
public partial FolderLayoutModes DefaultLayoutMode { get; set; }
}
// AppSettings.Appearance.cs
public sealed partial class AppSettings
{
[GeneratedAppSettingsProperty(DefaultValue = Math.Min(Math.Max(Get(255d), Constants.UI.MinimumSidebarWidth), 500d))]
public partial double SidebarWidth { get; set; }
[GeneratedAppSettingsProperty(DefaultValue = true)]
public partial bool IsSidebarOpen { get; set; }
}
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class GeneratedAppSettingsPropertyAttribute : Attribute {}
// AppSettings.General.g.cs
public partial bool SaveLastOpenedSessions
{
get => Get(true);
set => Set(value);
}
We would use this event when we try to get a setting for the first time after the cold launch and it'd possibly be before the UI is fully initialized; therefore, we have to wait until the all UI elements in MainPage then display an error dialog that tells user that the settings json file has been reset.
public event EventHandler<JsonSerializationException> JsonDeserializationFailed;
This documentation is not open for everyone. Do not copy.
Controls
- FolderBrowser
- DetailsFolderView
- GridFolderView
- ListFolderView
- TilesFolderView
- ContentFolderView
- ColumnsFolderView
- TreeFolderView
- GalleryFolderView
- HomeFolderView
- RectanglurSelectionVisual
- DataGrid
- SidebarView
- Omnibar
- Toolbar
- FilePreviewPresenter
- ColorTags
- RichTokens
- TerminalView
API
- WindowsStorable
- ArchiveStorable
- HomeStorable
- FtpStorable
- SftpStorable
- WebDAVStorable
Infrastructure
- CommandManager
- MultitaskingManager
- DialogManager
- AppSettings
- OperationServer
Copyright © 2025 0x5BFA. All rights reserved. Do not copy or redistribute modified versions.