@@ -30,77 +30,122 @@ Install the package for your preferred UI framework:
3030
3131## Quick Start
3232
33- ### 1. Define Your Settings Class
33+ This section shows a minimal end-to-end setup using the current demos as reference. It covers Avalonia, Ursa, and WPF, plus AOT support.
34+
35+ ### 1. Add Packages / References
36+
37+ ``` xml
38+ <!-- Avalonia -->
39+ <PackageReference Include =" AutoSettingUI.Avalonia" Version =" 1.0.0" />
40+
41+ <!-- Ursa (Avalonia with Ursa theme) -->
42+ <PackageReference Include =" AutoSettingUI.Ursa" Version =" 1.0.0" />
43+
44+ <!-- WPF -->
45+ <PackageReference Include =" AutoSettingUI.WPF" Version =" 1.0.0" />
46+ ```
47+
48+ If you want AOT support, also reference the generator in your ** app** project:
49+
50+ ``` xml
51+ <ProjectReference Include =" ..\..\src\AutoSettingUI.Generator\AutoSettingUI.Generator.csproj"
52+ OutputItemType =" Analyzer"
53+ ReferenceOutputAssembly =" false" />
54+ ```
55+
56+ ### 2. Define a Settings Model
3457
3558``` csharp
3659using AutoSettingUI .Core .Attributes ;
60+ using AutoSettingUI .Avalonia .Attributes ; // or AutoSettingUI.Ursa.Attributes
3761
38- [SettingUI (Category = " General" , Order = 0 )]
39- [MainHeader (" Application Settings" )]
40- public class AppSettings
62+ [SettingUI ]
63+ public sealed class AppSettings
4164{
42- [Title (" App Name" )]
43- public string Name { get ; set ; } = " My App" ;
65+ [Title (" Volume" )]
66+ [ControlBinding (typeof (Avalonia .Controls .Slider ), " Value" , nameof (CreateVolume ))]
67+ public double Volume { get ; set ; } = 50 ;
4468
45- [ Title ( " Enable Dark Mode " )]
46- public bool DarkMode { get ; set ; }
69+ public Avalonia.Controls. Slider CreateVolume ()
70+ => new Avalonia . Controls . Slider { Minimum = 0 , Maximum = 100 , Value = 50 };
4771
48- [Title (" Volume" ), Range (0 , 100 )]
49- public int Volume { get ; set ; } = 50 ;
72+ [Title (" Enable Feature" )]
73+ [CheckBox ]
74+ public bool EnableFeature { get ; set ; } = true ;
5075
51- [Title (" Language " )]
52- [ItemsSource ( typeof ( AppSettings ), nameof ( AvailableLanguages ) )]
53- public string Language { get ; set ; } = " en-US " ;
76+ [Title (" Font Size " )]
77+ [NumericUpDown ( Minimum = 8 , Maximum = 32 , Increment = 1 )]
78+ public int FontSize { get ; set ; } = 14 ;
5479
55- public static string [] AvailableLanguages => [" en-US" , " zh-CN" , " ja-JP" ];
80+ [Title (" Tags" )]
81+ public System.Collections.ObjectModel.ObservableCollection <string > Tags { get ; set ; }
82+ = new () { " Important" , " Work" };
5683}
5784```
5885
59- ### 2. Add the Panel to Your UI
86+ ### 3. Bind the Panel
6087
61- #### Avalonia
88+ Avalonia:
6289
6390``` xml
6491<Window xmlns : auto =" clr-namespace:AutoSettingUI.Avalonia.Controls;assembly=AutoSettingUI.Avalonia" >
65- <auto : AvaloniaAutoSettingPanel
66- Title =" Settings"
67- Targets =" {Binding SettingsList}"
68- ShowNavigation =" True" />
92+ <auto : AvaloniaAutoSettingPanel Targets =" {Binding Targets}" />
6993</Window >
7094```
7195
72- #### Ursa
96+ Ursa:
7397
7498``` xml
7599<Window xmlns : ursa =" clr-namespace:AutoSettingUI.Ursa.Controls;assembly=AutoSettingUI.Ursa" >
76- <ursa : UrsaAutoSettingPanel
77- Title =" Settings"
78- Targets =" {Binding SettingsList}"
79- UseCardBorderTheme =" True" />
100+ <ursa : UrsaAutoSettingPanel Targets =" {Binding Targets}" />
80101</Window >
81102```
82103
83- #### WPF
104+ WPF:
84105
85106``` xml
86107<Window xmlns : auto =" clr-namespace:AutoSettingUI.WPF.Controls;assembly=AutoSettingUI.WPF" >
87- <auto : WpfAutoSettingPanel
88- Title =" Settings"
89- Targets =" {Binding SettingsList}"
90- ShowNavigation =" True" />
108+ <auto : WpfAutoSettingPanel Targets =" {Binding Targets}" />
91109</Window >
92110```
93111
94- ### 3. AOT Support (Optional)
112+ ViewModel:
113+
114+ ``` csharp
115+ public class MainViewModel
116+ {
117+ public IEnumerable <object > Targets { get ; } = new object []
118+ {
119+ new AppSettings ()
120+ };
121+ }
122+ ```
123+
124+ ### 4. AOT Support (Optional)
95125
96- For Native AOT or trimming support, use the generated provider:
126+ For Native AOT or trimming, make sure the generator is referenced by the ** app ** project. In most cases the generated provider is picked up automatically. If you want to force it (or you see fallback-to-TextBox in AOT), do :
97127
98128``` csharp
99- // The source generator creates this class automatically
100- panel .DescriptorProvider = new AutoSettingUI .Generated .GeneratedSettingProvider ();
101- panel .PropertyAccessor = new AutoSettingUI .Generated .GeneratedSettingProvider ();
129+ using AutoSettingUI .Core .Registry ;
130+ using AutoSettingUI .Generated ;
131+
132+ var provider = new GeneratedSettingProvider ();
133+ AotSettingRegistry .Provider = provider ;
134+ AotSettingRegistry .Accessor = provider ;
135+ ```
136+
137+ ### 5. Publish AOT (Example)
138+
139+ ``` bash
140+ # Ursa demo
141+ pwsh ./publish-demo.ps1 -Framework Avalonia -Mode AOT
102142```
103143
144+ ### Notes
145+
146+ - Use ` EmitCompilerGeneratedFiles=true ` if you want to inspect generated code.
147+ - ` CollectionEditor(AllowEditItems = false) ` can make collection rows read-only.
148+
104149## Extended Controls
105150
106151AutoSettingUI provides extended control attributes for specialized inputs:
0 commit comments