13 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:15:26.402494+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 90f6d98d170275b8 |
Documentation: Settings Controls Module
1. Purpose
This module provides UI controls for configuring various application settings within the DataPROWin7 application. Each control implements the ISettingsControl interface and integrates with the application’s page navigation and permission system via IPageContent. These controls expose settings through property grids or dedicated views, support permission-based UI enablement, and provide mechanisms for restoring default values, validating user input, and managing lifecycle events (activation/deactivation). The module serves as the presentation layer for persistent configuration data, bridging user interactions with underlying settings models and database-backed state.
2. Public Interface
All classes implement the following interfaces:
IPageContent(explicitly implemented)INotifyPropertyChangedISettingsControl
ISettingsControl
void RestoreOriginalSettings();
- Restores settings to their original/default values (e.g., from database or defaults). Must trigger UI refresh (e.g., via
OnPropertyChanged).
IPageContent (Explicit Implementations)
All controls implement these methods, though most are no-ops or minimal stubs:
void SetPermissions(UserPermissionLevels actualPermission, UserPermissionLevels requiredPermission);
bool KeyDown(object sender, KeyEventArgs arg);
void StartSearch(string term);
bool OnButtonPress(PageButton button);
object GetPageContent();
SetPermissions(...): Enables/disables the control UI based on permission level (actualPermission >= requiredPermission).GetPageContent(): Returnsthis(the control instance).- Others are typically no-ops or return
false.
INotifyPropertyChanged
All controls expose:
event PropertyChangedEventHandler PropertyChanged;
protected bool SetProperty<T>(ref T storage, T value, string propertyName = null);
protected void OnPropertyChanged(string propertyName = null);
- Standard MVVM property change infrastructure.
Concrete Controls
EditAdvancedSettings
public AdvancedSettings AdvancedSettings { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void Reset();
OnSetActive(): Refreshes_advancedSettings, then rebindspropertyGrid.SelectedObjectto force UI update (workaround forPropertyGridnot observingINotifyPropertyChanged).RestoreOriginalSettings(): Calls_advancedSettings.Restore()and raisesPropertyChanged("AdvancedSettings").
EditRealtimeSettings
public RealtimeSettings RealtimeSettings { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void Reset();
- Identical pattern to
EditAdvancedSettings, but operates onRealtimeSettings. RestoreOriginalSettings()calls_realtimeSettings.Restore()and raisesPropertyChanged("RealtimeSettings").
TestHistorySettings
public TestHistoryDefaults TestHistoryDefaults { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
OnSetActive(): Instantiates newTestHistoryDefaults.RestoreOriginalSettings(): CallsSettings.TestHistoryDefaults.RestoreOriginalSettings(), then creates newTestHistoryDefaultsinstance and raisesPropertyChanged("TestHistoryDefaults").
EditUISettings
public void OnSetActive();
public void Reset();
public void UnSet(Action OnComplete = null);
OnSetActive(): Instantiates newUIProperties, subscribes to itsPropertyChanged, binds togridUIProperties._uiProperties_PropertyChanged: Handles"ShowGroups"(callsMainWindow.SetGroupsVisible()) and"UICulture"(callsApp.SetCulture(true)).RestoreOriginalSettings(): InstantiatesUIProperties(true)(likely constructor overload for defaults), re-subscribes, rebinds.
ImportDB
public object DBImportView { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void RestoreOriginalSettings(); // no-op
- Delegates to Prism/IoC-resolved
IDBImportViewandIDBViewModel. OnSetActive(): Resolves and initializes viewmodel/view; setsDBImportViewandImportDBViewContainer.Content.RestoreOriginalSettings()is empty.
SoftwareFilters
public object SoftwareFiltersView { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void RestoreOriginalSettings(); // no-op
public bool CheckChangeStep(); // custom method
- Delegates to Prism/IoC-resolved
ISoftwareFiltersViewandISoftwareFiltersViewModel. UnSet(...): Sets_vm.CurrentUserand calls_vm.Unset().CheckChangeStep(): Sets_vm.CurrentUserand calls_vm.ValidateAndSave().RestoreOriginalSettings()is empty.
EditISOSettings
public object IsoSettingsView { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void Reset();
public void RestoreOriginalSettings();
UnSet(...): Saves_vm.ISODatavia_vm.Model.SaveData, updatesSerializedSettingsproperties (e.g.,ISOViewMode,ShowISOStringBuilder, etc.), and callsApp.ResetISOSupport().RestoreOriginalSettings(): ResetsSerializedSettings.*Defaultproperties to defaults, then reloads_vm.ISODatavia_vm.Model.LoadData().
DBImport
public object DBImportView { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void RestoreOriginalSettings(); // no-op
public void Import(); // public method
public void ImportXML(object o);
Import(): Validates import file exists; queuesImportXMLon thread pool.ImportXML(...): ConstructsDatabaseImport.DbImporterand callsImportXML(...).RestoreOriginalSettings()is empty.
DatabaseSettings
public bool DatabaseCopyEnabled { get; }
public bool DatabaseControlEnabled { get; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void RestoreOriginalSettings(); // no-op
DatabaseCopyEnabled/DatabaseControlEnabled: Returntrueonly ifDBType == 2(Hybrid) orDBType == 2respectively.OnSetActive(): Initializes viewmodels (IDatabaseCopyViewModel,IDatabaseSwitchViewModel) via IoC.RestoreOriginalSettings()is empty.
PowerAndBattery
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void RestoreOriginalSettings();
- Constructor populates
InputAndBatterySettingcontrols for allHardwareTypes. RestoreOriginalSettings(): CallsRestore()on eachInputAndBatterySettingper hardware type.Reset(): CallsReset()on eachInputAndBatterySetting.
EditTables
public TableHelper[] AllTables { get; set; }
public bool Validate(ref List<string> errors, ref List<string> warnings, bool displayWindow);
public void OnSetActive();
public void UnSet(Action OnComplete = null);
public void Reset();
TableHelper: WrapsGenericTableColumnOrderTable, exposes data viaDataTablebound toTableOptionsTable.RestoreOriginalSettings(): CallsGenericTableDictionary.Dictionary.ResetTable(...)for each table, then repopulates.
3. Invariants
ISettingsControl.RestoreOriginalSettings()must refresh UI: All implementations must ensure UI reflects restored state (e.g., viaOnPropertyChanged, reassignment of bound properties, or rebinding property grids).- Permission-based UI enablement:
IPageContent.SetPermissions(...)must setIsEnabled(or equivalent) based onactualPermission >= requiredPermission. OnSetActive()must initialize viewmodels: For controls using Prism/IoC (ImportDB,SoftwareFilters,EditISOSettings,DatabaseSettings,DBImport),OnSetActive()must resolve and initialize viewmodel/view if not already done.Validate(...)always returnstrue: All controls’Validate(...)methods currently returntrueunconditionally. No validation logic is present in the source.UnSet(...)andReset()are no-ops in most controls: OnlyEditUISettings,EditISOSettings,SoftwareFilters, andPowerAndBatteryhave non-trivial logic in these methods.
4. Dependencies
Internal Dependencies (from source):
- Core interfaces:
IPageContent(namespaceDataPROWin7.Controls.Settings)ISettingsControl(defined in same file)
- Settings models:
AdvancedSettings,RealtimeSettings,TestHistoryDefaults,UIProperties,SerializedSettings,TableHelper,TableOptionsTable
- User/Permission system:
DTS.Slice.Users.User.UserPermissionLevels
- UI frameworks:
System.ComponentModel(INotifyPropertyChanged)System.Windows.Controls,System.Windows.Input,Xceed.Wpf.Toolkit.PropertyGrid
- Prism/IoC:
Prism.Events.IEventAggregator,Prism.Regions.IRegionManager,Prism.Ioc.IContainerLocator,Unity.IUnityContainer
- Database/Import:
DTS.Common.Interface.IDBViewModel,DTS.Common.Interface.IDBImportView,DatabaseImport.DbImporter
- Hardware types:
DTS.Common.Enums.Hardware.HardwareTypes
External Dependencies (inferred):
DTS.*assemblies (e.g.,DTS.Slice,DTS.Common)Prism.*assemblies (Prism Framework)UnitycontainerXceed.Wpf.Toolkit(PropertyGrid)System.Windows.Forms(used inPowerAndBattery.xaml.cs)
Depended Upon:
- No other modules depend on this module directly in the source, but it is consumed by the broader settings UI system (e.g., via
IPageContentintegration inDataPROPage/HomePage).
5. Gotchas
- PropertyGrid INotifyPropertyChanged limitation:
EditAdvancedSettingsandEditRealtimeSettingsexplicitly rebindpropertyGrid.SelectedObjectinOnSetActive()to force UI updates, as noted in comments referencing a knownPropertyGridlimitation (StackOverflow link). RestoreOriginalSettings()semantics vary:EditAdvancedSettings/EditRealtimeSettings: Restore via_settings.Restore().TestHistorySettings: Calls staticSettings.TestHistoryDefaults.RestoreOriginalSettings().EditISOSettings: ResetsSerializedSettings.*Defaultfields and reloads viewmodel data.- Others (
ImportDB,SoftwareFilters,DatabaseSettings,DBImport): No-op.
EditTables.TableHelpermutates underlying data onDataTable.ColumnChanged: Changes toDisplayOrder,Visible, orWidthcolumns directly updateGenericTableColumnOrderColumnand persist viaGenericTableDictionary.Dictionary.SaveColumns(...).PowerAndBatteryconstructor hardcodes hardware types: The list ofHardwareTypesis hardcoded in the constructor; missing types will result inGetSettingCtrl(...)returningnull.EditISOSettings.UnSet(...)saves state even if not modified: It unconditionally updatesSerializedSettings.*fields and callsApp.ResetISOSupport()on deactivation, regardless of whether changes occurred.DatabaseSettings.OnDbError(...)does not handle allDbStatusArg.EventTypes: Theswitchstatement includes adefaultthat throwsArgumentOutOfRangeException, but some cases (e.g.,FailedToRestoreLocal,Complete,LegacyStatus) are silent.ImportDB.ImportXML(...)runs on thread pool without cancellation: No mechanism to cancel or track import progress beyondSetStatus(...)callback.SoftwareFilters.CheckChangeStep()is not part ofISettingsControl: It is a custom method used elsewhere (likely for step validation), but not exposed via interface.EditTables.UnSet(...)clearsAllTables: SetsAllTables = new TableHelper[0], which may cause UI issues if not handled by consuming code.