1.5 KiB
1.5 KiB
MVVM layering inside a single WPF UserControl:
MacroBrowserControl.xaml/.xaml.csis the view; it wires AvalonEdit syntax highlighting (Python.Dark.xshd) and opens hyperlinks viaProcess.Start.MacroBrowserViewModel : BaseViewModelowns all UI state (ObservableCollection<string>for Authors/Eras/Shards/Macros,Categoryfilter), exposesRelayCommand/RelayCommandAsyncactions, and drives data loading on construction by invoking a_datadictionary ofFunc<Task<string[]>>entries backed by the singletonDatabase.Data/Databaseis a thread-safe singleton wrapping an in-process LiteDB file (macros.db) with three collections —repository,manifest,macros— plus anHttpClientandGitHubClient. It fetchesmetadata.jsonfrom the repo's raw URL, caches it for 15 minutes (or until the master branch SHA changes), and lazily downloads macro source text keyed by name+SHA1.Models/holds LiteDB-persisted entities (Macro,Manifest,Metadata,Repository) plus aCategoryused as a hierarchical filter value.Data/Filter+FilterTypemodel the shard/era/author/category predicate applied against the manifest before returning macro names.Controls/ClearableComboBoxis a reusable ComboBox extension exposing aClearCommandDP bound to the ViewModel'sClearCommand. Dependency direction: View → ViewModel → Data/Models; Models are pure POCOs decorated with[BsonId]; no cross-dependencies between sibling subfolders except ViewModel depending on both Data and Models.