Files
DP44/enriched-qwen3-coder-next/DataPRO/DataPRO/Controls/Settings.md
2026-04-17 14:55:32 -04:00

13 KiB
Raw Blame History

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
DataPRO/DataPRO/Controls/Settings/ISettingsControl.cs
DataPRO/DataPRO/Controls/Settings/EditAdvancedSettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/EditRealtimeSettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/TestHistorySettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/EditUISettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/ImportDB.xaml.cs
DataPRO/DataPRO/Controls/Settings/SoftwareFilters.xaml.cs
DataPRO/DataPRO/Controls/Settings/EditISOSettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/DBImport.xaml.cs
DataPRO/DataPRO/Controls/Settings/DatabaseSettings.xaml.cs
DataPRO/DataPRO/Controls/Settings/PowerAndBattery.xaml.cs
DataPRO/DataPRO/Controls/Settings/EditTables.xaml.cs
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 applications 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)
  • INotifyPropertyChanged
  • ISettingsControl

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(): Returns this (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 rebinds propertyGrid.SelectedObject to force UI update (workaround for PropertyGrid not observing INotifyPropertyChanged).
  • RestoreOriginalSettings(): Calls _advancedSettings.Restore() and raises PropertyChanged("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 on RealtimeSettings.
  • RestoreOriginalSettings() calls _realtimeSettings.Restore() and raises PropertyChanged("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 new TestHistoryDefaults.
  • RestoreOriginalSettings(): Calls Settings.TestHistoryDefaults.RestoreOriginalSettings(), then creates new TestHistoryDefaults instance and raises PropertyChanged("TestHistoryDefaults").

EditUISettings

public void OnSetActive();
public void Reset();
public void UnSet(Action OnComplete = null);
  • OnSetActive(): Instantiates new UIProperties, subscribes to its PropertyChanged, binds to gridUIProperties.
  • _uiProperties_PropertyChanged: Handles "ShowGroups" (calls MainWindow.SetGroupsVisible()) and "UICulture" (calls App.SetCulture(true)).
  • RestoreOriginalSettings(): Instantiates UIProperties(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 IDBImportView and IDBViewModel.
  • OnSetActive(): Resolves and initializes viewmodel/view; sets DBImportView and ImportDBViewContainer.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 ISoftwareFiltersView and ISoftwareFiltersViewModel.
  • UnSet(...): Sets _vm.CurrentUser and calls _vm.Unset().
  • CheckChangeStep(): Sets _vm.CurrentUser and 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.ISOData via _vm.Model.SaveData, updates SerializedSettings properties (e.g., ISOViewMode, ShowISOStringBuilder, etc.), and calls App.ResetISOSupport().
  • RestoreOriginalSettings(): Resets SerializedSettings.*Default properties to defaults, then reloads _vm.ISOData via _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; queues ImportXML on thread pool.
  • ImportXML(...): Constructs DatabaseImport.DbImporter and calls ImportXML(...).
  • 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: Return true only if DBType == 2 (Hybrid) or DBType == 2 respectively.
  • 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 InputAndBatterySetting controls for all HardwareTypes.
  • RestoreOriginalSettings(): Calls Restore() on each InputAndBatterySetting per hardware type.
  • Reset(): Calls Reset() on each InputAndBatterySetting.

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: Wraps GenericTableColumnOrderTable, exposes data via DataTable bound to TableOptionsTable.
  • RestoreOriginalSettings(): Calls GenericTableDictionary.Dictionary.ResetTable(...) for each table, then repopulates.

3. Invariants

  • ISettingsControl.RestoreOriginalSettings() must refresh UI: All implementations must ensure UI reflects restored state (e.g., via OnPropertyChanged, reassignment of bound properties, or rebinding property grids).
  • Permission-based UI enablement: IPageContent.SetPermissions(...) must set IsEnabled (or equivalent) based on actualPermission >= 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 returns true: All controls Validate(...) methods currently return true unconditionally. No validation logic is present in the source.
  • UnSet(...) and Reset() are no-ops in most controls: Only EditUISettings, EditISOSettings, SoftwareFilters, and PowerAndBattery have non-trivial logic in these methods.

4. Dependencies

Internal Dependencies (from source):

  • Core interfaces:
    • IPageContent (namespace DataPROWin7.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)
  • Unity container
  • Xceed.Wpf.Toolkit (PropertyGrid)
  • System.Windows.Forms (used in PowerAndBattery.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 IPageContent integration in DataPROPage/HomePage).

5. Gotchas

  • PropertyGrid INotifyPropertyChanged limitation: EditAdvancedSettings and EditRealtimeSettings explicitly rebind propertyGrid.SelectedObject in OnSetActive() to force UI updates, as noted in comments referencing a known PropertyGrid limitation (StackOverflow link).
  • RestoreOriginalSettings() semantics vary:
    • EditAdvancedSettings/EditRealtimeSettings: Restore via _settings.Restore().
    • TestHistorySettings: Calls static Settings.TestHistoryDefaults.RestoreOriginalSettings().
    • EditISOSettings: Resets SerializedSettings.*Default fields and reloads viewmodel data.
    • Others (ImportDB, SoftwareFilters, DatabaseSettings, DBImport): No-op.
  • EditTables.TableHelper mutates underlying data on DataTable.ColumnChanged: Changes to DisplayOrder, Visible, or Width columns directly update GenericTableColumnOrderColumn and persist via GenericTableDictionary.Dictionary.SaveColumns(...).
  • PowerAndBattery constructor hardcodes hardware types: The list of HardwareTypes is hardcoded in the constructor; missing types will result in GetSettingCtrl(...) returning null.
  • EditISOSettings.UnSet(...) saves state even if not modified: It unconditionally updates SerializedSettings.* fields and calls App.ResetISOSupport() on deactivation, regardless of whether changes occurred.
  • DatabaseSettings.OnDbError(...) does not handle all DbStatusArg.EventTypes: The switch statement includes a default that throws ArgumentOutOfRangeException, 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 beyond SetStatus(...) callback.
  • SoftwareFilters.CheckChangeStep() is not part of ISettingsControl: It is a custom method used elsewhere (likely for step validation), but not exposed via interface.
  • EditTables.UnSet(...) clears AllTables: Sets AllTables = new TableHelper[0], which may cause UI issues if not handled by consuming code.