Commit 819010c
Migrate ViewModels to CommunityToolkit.MVVM and wire UnitConverter to native engine
## CommunityToolkit.MVVM Migration
- Add CommunityToolkit.Mvvm 8.4.2, set LangVersion 13.0
- All 18 ViewModel classes inherit ObservableObject
- Simple properties use [ObservableProperty] field-based source generator
- Complex properties (side-effect setters) use SetProperty/OnPropertyChanged
- Custom RelayCommand.cs removed, toolkit RelayCommand<object> used
- DelegateCommand.cs preserved (used by Calculator UI project)
- 3 VMs with OnPropertyChanged hooks use HandlePropertySideEffects + override
- All MVVMTK0034/CS0169/CS0219/CS0414 warnings fixed
## UnitConverter Wired to Native CalcManager Engine
- UnitConverterDataLoader extends ConverterDataLoaderBase with all 12
categories, 168 unit IDs, and conversion ratios matching C++ main
- CurrencyDataLoader fully ported: JSON parsing, cache/web loading,
pairwise ratio computation, currency symbols, timestamps
- IDL methods marked overridable for C# subclassing
- ConverterDataLoaderBridge updated to use IOverrides interface pattern
- Full OnPropertyChanged side-effect chain: CurrentCategory, Unit1/2,
Value1/2, Value1Active/2Active, SupplementaryResults, CurrencySymbols
- PopulateData, ResetCategory, SetSelectedUnits, BuildUnitList
- SaveUserPreferences/RestoreUserPreferences via LocalSettings
- Proper OnPaste with negate tracking and DisplayPasteError
- OnCopyCommand copies unlocalized value (matches C++ behavior)
- AnnounceConversionResult uses correct unit order based on active field
- RefreshSupplementaryResults includes first whimsical unit
- ResetView calls model Reset + OnCategoryChanged
- Callbacks marshaled to UI thread via CoreDispatcher
- ButtonPressed alias for CalculatorButton {Binding} compatibility
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent a82a3d8 commit 819010c
File tree
6 files changed
+1943
-266
lines changed- src
- CalcManager.Interop
- Calculator.ViewModels
- DataLoaders
6 files changed
+1943
-266
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
0 commit comments