@@ -27,8 +27,11 @@ namespace KitopiaAvalonia.Pages;
27
27
28
28
public partial class SettingPage : UserControl
29
29
{
30
- private CompositeDisposable disposables = new CompositeDisposable ( ) ;
31
30
private ConfigBase ? _configBase ;
31
+ private CompositeDisposable disposables = new CompositeDisposable ( ) ;
32
+
33
+ private StackPanel nowControl ;
34
+
32
35
public SettingPage ( )
33
36
{
34
37
InitializeComponent ( ) ;
@@ -42,13 +45,13 @@ public void ChangeConfig(ConfigBase configBase)
42
45
StackPanel . Children . Clear ( ) ;
43
46
LoadConfig ( ) ;
44
47
}
48
+
45
49
~ SettingPage ( )
46
50
{
47
51
disposables . Dispose ( ) ;
48
52
49
53
}
50
54
51
- private StackPanel nowControl ;
52
55
protected override void OnUnloaded ( RoutedEventArgs e )
53
56
{
54
57
base . OnUnloaded ( e ) ;
@@ -57,7 +60,7 @@ protected override void OnUnloaded(RoutedEventArgs e)
57
60
nowControl = null ;
58
61
StackPanel . Children . Clear ( ) ;
59
62
}
60
-
63
+
61
64
62
65
private void LoadConfig ( )
63
66
{
@@ -116,6 +119,7 @@ private void LoadConfig()
116
119
Value = ( double ) selectedValue ,
117
120
Maximum = configField . MaxValue ,
118
121
Minimum = configField . MinValue ,
122
+ SimpleNumberFormat = "F0"
119
123
} ;
120
124
121
125
disposables . Add (
@@ -196,6 +200,25 @@ private void LoadConfig()
196
200
}
197
201
198
202
case ConfigFieldType . 浮点数 :
203
+ var textBox1 = new NumberBox ( )
204
+ {
205
+
206
+ Value = ( double ) selectedValue ,
207
+ Maximum = configField . MaxValue ,
208
+ Minimum = configField . MinValue ,
209
+ SimpleNumberFormat = "F2"
210
+ } ;
211
+
212
+ disposables . Add (
213
+ textBox1 . GetObservable ( NumberBox . ValueProperty ) . Subscribe ( ( d ) =>
214
+ {
215
+ _configBase . OnConfigChanged ( this , fieldInfo . Name , d ) ;
216
+ fieldInfo . SetValue ( _configBase , d ) ;
217
+ ConfigManger . Save ( _configBase . Name ) ;
218
+
219
+ } ) ) ;
220
+
221
+ SettingsExpander . Footer = textBox1 ;
199
222
break ;
200
223
case ConfigFieldType . 布尔 :
201
224
{
@@ -314,10 +337,12 @@ private void ObservableCollectionChange(object? sender, NotifyCollectionChangedE
314
337
public class AnonymousDisposable : IDisposable
315
338
{
316
339
private readonly Action _onDispose ;
340
+
317
341
public AnonymousDisposable ( Action onDispose )
318
342
{
319
343
_onDispose = onDispose ;
320
344
}
345
+
321
346
public void Dispose ( )
322
347
{
323
348
_onDispose . Invoke ( ) ;
0 commit comments