13 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T04:06:41.007079+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | ff478277c20f6904 |
DataPROWin7.Common Module Documentation
1. Purpose
This module (DataPROWin7.Common) provides foundational infrastructure components for the DataPRO Windows 7 application. It defines shared interfaces, data models, UI helpers, converters, and database initialization utilities used across the application’s UI and data layers. Its role is to decouple cross-cutting concerns—such as navigation state management, UI state transitions, cursor handling, and hardware/database metadata caching—from domain-specific logic, enabling consistent behavior and reuse across modules like Data Recorders, Sensor Database, and Test Setup pages.
2. Public Interface
Interfaces
-
IPageGridvoid OnSetActive();Called when a page becomes active (e.g., during navigation). Intended for page-specific initialization or UI updates.
-
IFullScreenCapablevoid GoFullScreen(); void GoSmallScreen();Enables toggling between full-screen and normal windowed display modes. Note: Interface is internal (
interfacewithoutpublicmodifier). -
INavStepContentvoid UnSet(Action OnComplete = null);Invoked when the current test setup changes, allowing UI cleanup (e.g., clearing fields). Optional completion callback.
Classes
-
UsedInGrouppublic class UsedInGroup { public string Name { get; set; } }Represents a group context where an item is used (e.g., in group-based configurations).
-
UsedInTestSetuppublic class UsedInTestSetup { public string Name { get; set; } }Represents a test setup context where an item is used.
-
UsedInpublic class UsedIn { public string Type { get; set; } public string Name { get; set; } }Generic metadata for tracking where an item is used (e.g., in groups or test setups).
Typeindicates context (e.g.,"Group"or"TestSetup"). -
WindowWrapperpublic class WindowWrapper : System.Windows.Forms.IWin32WindowWraps a Win32
HWND(IntPtr) for interop with WinForms APIs (e.g., dialog hosting). Constructor:WindowWrapper(IntPtr handle). -
UsageReportpublic class UsageReport { public List<DeviceSelected> SelectedDevices { get; set; } }Container for usage report data, populated from Data Recorders/Sensor Database tabs (FB 12774).
-
DeviceSelectedpublic class DeviceSelected { public string Type { get; set; } public string SerialNumber { get; set; } public DateTime CalDueDate { get; set; } public List<UsedIn> Groups { get; set; } public List<UsedIn> TestSetups { get; set; } }Represents a selected device for usage reporting, including calibration due date and usage contexts (FB 12774).
-
TimeUnitspublic class TimeUnits : BasePropertyChanged { public enum Units { MilliSeconds, Seconds } public Units MyUnits { get; set; } public string ToShortString() { ... } }Encapsulates time unit selection (
msors).ToShortString()returns"ms"or"s". InheritsBasePropertyChangedfor property change notifications. -
Negativepublic class Negative : IValueConverter { public static Negative Instance { get; } public object Convert(object value, ...) { ... } public object ConvertBack(...) { throw ...; } }XAML value converter that negates
doublevalues.ConvertBackis unimplemented. -
BoolToVisibilityConverterpublic sealed class BoolToVisibilityConverter : IValueConverter { public Visibility TrueValue { get; set; } // default: Visible public Visibility FalseValue { get; set; } // default: Collapsed public object Convert(...) { ... } public object ConvertBack(...) { ... } }Converts
booltoVisibility(and vice versa). ConfigurableTrueValue/FalseValue(defaults:Visible/Collapsed). -
InvertVisibilityConverterpublic sealed class InvertVisibilityConverter : IValueConverter { public object Convert(...) { ... } // Visible ↔ Collapsed public object ConvertBack(...) { ... } }Inverts
Visibilityvalues (Visible↔Collapsed). ReturnsVisiblefor non-Visibilityinputs. -
PageHelperinternal static class PageHelper { public static int GetTabAndButtonFontSize() }Retrieves tab/page button font size from app settings, clamped to
[Min, Max]range (FB 44523). ReturnsMinif out of bounds. -
SQLConversionpublic static class SQLConversion { public static string ConvertInternalVersionToYear(int sqlVersion) }Maps SQL Server internal version numbers to release years (e.g.,
12→"2014",16→"2022"). Returns"{version} (Internal)"for unknown versions. -
WaitCursorpublic class WaitCursor : IDisposable { public WaitCursor(); public void Dispose(); }Temporarily sets the mouse cursor to
Cursors.Waitduring disposal. Ensures cursor restoration viaIDisposable. -
HardwareIPRangespublic class HardwareIPRanges { public IPRange[] IPRanges { get; set; } public void AddIPRange(IPRange r); public void AddRange(IPRange[] ranges); public HardwareIPRanges(); // Loads from "HWIPRanges.txt" }Loads IP ranges from
HWIPRanges.txt(comma-separated start/end IPs) for hardware discovery/ping sweeps. Logs exceptions viaAPILogger. -
Transitionpublic class Transition : FrameworkElement { public enum TransitionState { A, B } public object Source { get; set; } public object DisplayA { get; set; } public object DisplayB { get; set; } public TransitionState State { get; set; } }A WPF
FrameworkElementthat swapsSourcebetweenDisplayAandDisplayBbased onState. Initialized toState.A. -
ToastWindowpublic partial class ToastWindow : Window { public ToastWindow(string screenShotFilename); }Displays a non-modal notification in the lower-right corner. Auto-closes after 2 seconds. Clicking opens the screenshot file. Used for screenshot notifications (FB 15332).
-
ModalDialogpublic partial class ModalDialog : UserControl { public string Message { get; set; } public void SetParent(UIElement parent); public bool ShowHandlerDialog(string message); public void OkButton_Click(...); public void CancelButton_Click(...); public UserControl MyContent { set { ... } } } public interface IModalDialogContent { void SetCancelEvent(ModalDialog.ButtonEvent ev); void SetOKEvent(ModalDialog.ButtonEvent ev); }A reusable modal dialog overlay.
ShowHandlerDialogblocks until user clicks OK/Cancel.MyContentsetter wires events for content implementingIModalDialogContent. -
GroupedItemControlpublic class GroupedItemControl : Control { public static RoutedCommand ClickCommand { get; } public ImageSource Image { get; set; } public int ResourceId { get; set; } public string Title { get; set; } public DataModel.TabPageItem TabItem { get; set; } }A custom control for tab/page tiles. Triggers
ClickCommand(handled byMainWindow.GroupedItemControlClicked). Note:Subtitleproperty is commented out. -
DataPROTabItempublic class DataPROTabItem : TabItem { public void SetReferringTab(DataPROTabItem tab); public void GoToNewPage(UserControl o); public void ClearPreviousPages(); public void GoToPreviousPage(bool setActive); public TabPageItem Item { get; } public DataPROTabItem(TabPageItem item); }Extends
TabItemto manage navigation history. Supports forward/back navigation, caching of test setup names (FB 15748), and special handling forRunTestBase/EditTestSetupPage. -
DbAccesspublic abstract class DbAccess { public static void InitializeGroupHardwareIds(); public static void InitializeTestSetupHardwareIds(); public static void InitializeDASIdChannelIndexGroupIdList(); public static void InitializeBaseModuleChannelIndexList(); public static void InitializeDASIds(); public static void InitializeGroupChannelIds(); public static void InitializeStaticGroupNames(); public static void InitializeEmbeddedGroupIdList(); public static void InitializeTestSetupGroupIds(); public static void InitializeTestSetupNames(); }Static methods to populate
GroupHelper/TestSetupHelpercaches from the database. Used during application startup to avoid repeated DB queries.
Helpers
CommonStyles.ToolTipEventHandlerPublishespublic void ToolTipEventHandler(object sender, ToolTipEventArgs e)HelpTextEventvia Prism’sIEventAggregatorfor context-sensitive help.
3. Invariants
IPageGrid.OnSetActive(): Must be called exactly once per page activation (e.g., duringDataPROTabItem.GoToNewPage).IFullScreenCapable:GoFullScreen/GoSmallScreenmust be symmetric (no partial states).INavStepContent.UnSet: Must be idempotent and safe to call multiple times.WaitCursor: Must restore the original cursor onDispose, even if exceptions occur.HardwareIPRanges: RequiresHWIPRanges.txtin the application directory; malformed lines are silently skipped (exceptions logged).Transition:Sourceproperty changes trigger an immediate swap to the opposite display (A/B).SQLConversion.ConvertInternalVersionToYear: Only supports known SQL Server versions (12–16); others return(Internal).DbAccessmethods: All assume database connectivity; failures are silently ignored (no exceptions thrown).
4. Dependencies
- Imports/References:
System.Windows.Forms(IWin32WindowforWindowWrapper).Prism.Ioc,Prism.Events(IEventAggregator,ContainerLocator).DTS.Common.*(e.g.,DTS.Common.Events,DTS.Common.Base,DTS.Common.Storage,DTS.Common.Classes.*).System.Data,System.Data.SqlClient(ADO.NET forDbAccess).System.Windows,System.Windows.Data(WPF converters).
- Consumers:
DataPROWin7.DataModel(TabPageItem,DataPROPage).DataPROWin7.TSRAIRGo.ViewModel(NavigationViewModel).DataPROWin7.App(App.Current,CurrentUser).MainWindow(handlesGroupedItemControl.ClickCommand).
5. Gotchas
Negative.ConvertBack: ThrowsNotImplementedException; not suitable for two-way binding.InvertVisibilityConverter.ConvertBack: ReturnsVisibility.Visiblefor non-Visibilityinputs (notnull).HardwareIPRangesconstructor: ReadsHWIPRanges.txtsynchronously on instantiation; may block startup if file is large or network-mounted.ModalDialog.ShowHandlerDialog: Uses a blocking loop withDispatcher.Invoke/Thread.Sleep(a "DoEvents" hack); may cause reentrancy issues.DataPROTabItemcaching:_currentTestNameis static; may cause incorrect navigation if multiple tabs are used concurrently.DbAccessmethods: All are static and mutate global state (GroupHelper,TestSetupHelper); not thread-safe or testable in isolation.TimeUnits.ToShortString: ThrowsNotSupportedExceptionfor unknown units (should beArgumentExceptionper .NET conventions).PageHelper.GetTabAndButtonFontSize: Relies onProperties.Settings.DefaultandDTS.Common.Constants; external dependency not visible in source.IFullScreenCapable: Interface is internal (nopublicmodifier), limiting its use outside the assembly.GroupedItemControl:Subtitleproperty is commented out; developers may assume it exists.WindowWrapper: Does not validateIntPtr(e.g.,IntPtr.Zerois accepted).