Files
Beyhan Oğur d5f52cc3d3 first commit
2026-09-03 04:45:36 +03:00

1.5 KiB

MVVM layering inside a single WPF UserControl:

  • MacroBrowserControl.xaml/.xaml.cs is the view; it wires AvalonEdit syntax highlighting (Python.Dark.xshd) and opens hyperlinks via Process.Start.
  • MacroBrowserViewModel : BaseViewModel owns all UI state (ObservableCollection<string> for Authors/Eras/Shards/Macros, Category filter), exposes RelayCommand/RelayCommandAsync actions, and drives data loading on construction by invoking a _data dictionary of Func<Task<string[]>> entries backed by the singleton Database.
  • Data/Database is a thread-safe singleton wrapping an in-process LiteDB file (macros.db) with three collections — repository, manifest, macros — plus an HttpClient and GitHubClient. It fetches metadata.json from 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 a Category used as a hierarchical filter value.
  • Data/Filter + FilterType model the shard/era/author/category predicate applied against the manifest before returning macro names.
  • Controls/ClearableComboBox is a reusable ComboBox extension exposing a ClearCommand DP bound to the ViewModel's ClearCommand. 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.