FindMyFiles
FindMyFiles.ViewModels
MainViewModel Class
Provides a mechanism for releasing unmanaged resources.
public sealed class MainViewModel : CommunityToolkit.Mvvm.ComponentModel.ObservableObject, System.IDisposable
Inheritance System.Object → CommunityToolkit.Mvvm.ComponentModel.ObservableObject → MainViewModel
Implements System.IDisposable
Constructors
MainViewModel(IEngineClient, IDispatcher, AppSettings, Func<Task<string>>, Action, Func<bool>, ServiceProvisioner) Constructor
Builds the focused components, restores focused-search settings, and subscribes the engine events (volume updates, errors, connection changes). Call StartAsync() afterwards to begin indexing.
public MainViewModel(FindMyFiles.Engine.IEngineClient engine, FindMyFiles.Services.IDispatcher dispatcher, FindMyFiles.Services.AppSettings? settings=null, System.Func<System.Threading.Tasks.Task<string?>>? folderPicker=null, System.Action? relaunch=null, System.Func<bool>? isScopeMode=null, FindMyFiles.Services.ServiceProvisioner? provisioner=null);
Parameters
engine IEngineClient
The engine client (Fake / Ffi / Pipe) this page drives.
dispatcher IDispatcher
UI dispatcher used to marshal engine callbacks and back timers.
settings AppSettings
App settings to read/persist; loaded from disk when null.
folderPicker System.Func<System.Threading.Tasks.Task<System.String>>
Scope-folder picker; defaults to the real PickAsync() (tests inject a fake).
relaunch System.Action
Unelevated relaunch action; defaults to the real Relaunch() (tests inject a no-op).
isScopeMode System.Func<System.Boolean>
Reports whether the engine is a scope-mode walk; defaults to inspecting the real FfiEngineClient (tests inject a constant to drive the mode-dependent UI).
provisioner ServiceProvisioner
The register→wait→relaunch steps behind the setup screen's one-click button; defaults to Real (tests inject fakes so EnableSearchAsync() runs without UAC).
Properties
MainViewModel.CanStartScope Property
The "start scope search" button is enabled only once at least one folder has been chosen.
public bool CanStartScope { get; }
Property Value
MainViewModel.DataLocationText Property
The portable-data-root footnote (only shown when IsPortable).
public string DataLocationText { get; }
Property Value
MainViewModel.IsDisconnected Property
True when the engine is the empty fake (unelevated, no service) — the page shows the setup screen instead of a search box that can only return zero rows. Fixed for this instance's lifetime (the transport is chosen once; registering relaunches), so x:Bind OneTime is enough.
public bool IsDisconnected { get; }
Property Value
MainViewModel.IsPortable Property
True when app state lives next to the exe rather than the user profile (AppPaths) — drives the setup screen's "nothing leaves this folder" footnote. Fixed at startup, so x:Bind OneTime.
public bool IsPortable { get; }
Property Value
MainViewModel.IsPrivilegedMode Property
True once indexing in the elevated whole-volume mode (service or in-proc). Gates the gear menu's "manage service" item — the complement of IsScopeMode while ready, both false while disconnected. Fixed at startup, so x:Bind OneTime.
public bool IsPrivilegedMode { get; }
Property Value
MainViewModel.IsReady Property
Inverse of IsDisconnected — true when the search UI (box + result list) should be shown instead of the setup screen.
public bool IsReady { get; }
Property Value
MainViewModel.IsScopeMode Property
True once indexing in **scope mode** (ADR-0024: a user-chosen set of folders, not all drives). Gates the gear menu's "change search folders" item. Fixed at startup (the transport is chosen once), so x:Bind OneTime is enough.
public bool IsScopeMode { get; }
Property Value
MainViewModel.ModeText Property
The current index mode for the status submenu's info row (selected folders vs all drives). Fixed at startup, so x:Bind OneTime.
public string ModeText { get; }
Property Value
MainViewModel.Notifications Property
The InfoBar stack — failures and transient notices are pushed here.
public FindMyFiles.ViewModels.NotificationCenter Notifications { get; }
Property Value
MainViewModel.Perf Property
State behind the F12 performance panel (last trace, stats, latency history).
public FindMyFiles.ViewModels.PerfPanelViewModel Perf { get; }
Property Value
MainViewModel.Results Property
How results land in the virtualized list (publish / refresh in place / empty) — the seam the orchestrator hands outcomes to.
public FindMyFiles.ViewModels.ResultsPresenter Results { get; }
Property Value
MainViewModel.ScopeCoverageNote Property
A note naming the folders already inside a larger selected one, so the user sees the bigger set subsumes them (they merge on apply). Empty when the selection has no nesting. Recomputed on every ScopeFolders change.
public string ScopeCoverageNote { get; }
Property Value
MainViewModel.ScopeExcludes Property
Subfolders to prune from the walk (ADR-0025), shown in the scope manager dialog. Each must sit under a ScopeFolders root; seeded from settings, persisted by ApplyScopeChange().
public System.Collections.ObjectModel.ObservableCollection<string> ScopeExcludes { get; }
Property Value
System.Collections.ObjectModel.ObservableCollection<System.String>
MainViewModel.ScopeFolders Property
Folders the user has chosen to fold-walk in scope mode, edited in the scope dialog. Seeded from settings; ApplyScopeChange() persists them as ScopeRoots and relaunches.
public System.Collections.ObjectModel.ObservableCollection<string> ScopeFolders { get; }
Property Value
System.Collections.ObjectModel.ObservableCollection<System.String>
MainViewModel.Search Property
Decides when and what to search (debounce, generation, requery triggers); the page forwards box edits and toggles to it.
public FindMyFiles.ViewModels.SearchOrchestrator Search { get; }
Property Value
MainViewModel.SearchPlaceholder Property
The search box hint — regex/scope-aware, so the box itself signals that regex mode is on (the toggle lives in the gear menu).
public string SearchPlaceholder { get; }
Property Value
MainViewModel.SetupNotBusy Property
Inverse of FindMyFiles.ViewModels.MainViewModel.SetupBusy — gates the setup button's enabled state.
public bool SetupNotBusy { get; }
Property Value
Methods
MainViewModel.ApplyScopeChange() Method
Apply the current ScopeFolders as the scope: drop
roots nested under another (Normalize(IEnumerable<string>)), and if the
set actually changed, persist it as ScopeRoots
and relaunch (unelevated) into a fresh WalkInProc that folder-walks
the new set (ADR-0024). The engine has no live root-swap
(index_start_scope no-ops on an existing scope slot), so a relaunch
is the only way to re-walk. No-op when empty or unchanged, so re-opening
the manager and closing it without edits never restarts.
public void ApplyScopeChange();
MainViewModel.Dispose() Method
Unsubscribe the engine-event marshaler — the one owned disposable — so its handlers stop holding this view model rooted.
public void Dispose();
Implements Dispose()
MainViewModel.EnableSearchAsync() Method
Setup screen's one-click action: register the service elevated, then (on success) wait for its pipe and relaunch — so a first-time user goes from the setup screen to a working search box in one click. The app stays unelevated; only fmf-service is elevated (per-action UAC).
public System.Threading.Tasks.Task EnableSearchAsync();
Returns
System.Threading.Tasks.Task
A task that completes when registration finishes, or before relaunch on success.
MainViewModel.PickScopeExcludeAsync() Method
Manager dialog (scope mode): pick a subfolder to prune from the walk (ADR-0025). Rejected with a notice when it is not inside one of the chosen ScopeFolders roots (an exclude outside the indexed set prunes nothing). Case-insensitive dedupe.
public System.Threading.Tasks.Task PickScopeExcludeAsync();
Returns
System.Threading.Tasks.Task
A task that completes once the picked folder (if valid) is added.
MainViewModel.PickScopeFoldersAsync() Method
Setup screen (no-admin path): open the folder picker and add the chosen folder to ScopeFolders (case-insensitive dedupe). The picker is single-select, so this adds one folder per click.
public System.Threading.Tasks.Task PickScopeFoldersAsync();
Returns
System.Threading.Tasks.Task
A task that completes once the picked folder (if any) has been added.
MainViewModel.RemoveScopeExclude(string) Method
Drop one excluded subfolder (the per-row × button).
public void RemoveScopeExclude(string path);
Parameters
path System.String
The exclude path to remove.
MainViewModel.RemoveScopeFolder(string) Method
Drop one folder from the scope list (the per-row × button).
public void RemoveScopeFolder(string path);
Parameters
path System.String
The folder path to remove.
MainViewModel.SetSort(FmfSort) Method
Column-header click: re-clicking the active FindMyFiles.ViewModels.MainViewModel.Sort column toggles FindMyFiles.ViewModels.MainViewModel.SortDescending, a new column switches to it ascending. Either way requeries with Sort.
public void SetSort(FindMyFiles.Engine.FmfSort key);
Parameters
key FmfSort
The sort column the clicked header maps to.
MainViewModel.StartAsync() Method
Startup sequence, in order: status text → StartIndexing → initial requery. Runs on the UI thread; the engine calls are awaited so a pipe transport never blocks it.
public System.Threading.Tasks.Task StartAsync();
Returns
System.Threading.Tasks.Task
A task that completes once startup indexing and the initial requery are kicked off.