Interface IMainService

Unit

Declaration

type IMainService = interface(IInterface)

Description

Interface

Attributes
GUID['{F60F6353-A3B1-46A1-82AF-54F1BE568E4C}']

Hierarchy

Overview

Methods

Public function Console: TConsoleReaderThread;
Public function ContractDB: TContractDB;
Public procedure UpdateMainFormPosition(AForm: TForm);
Public procedure ValidateMonitorSettings;
Public procedure IniPropStorageRestore;
Public procedure IniPropStorageSetAllOptionsToDefault;
Public procedure IniPropStorageSetAllOptions;
Public function GetPathLoadExecuteDir: String;
Public procedure SetPathLoadExecuteDir(Path: String);
Public procedure SavePathLoadExecuteDir;
Public function GetPathSaveExecuteDir: String;
Public procedure SetPathSaveExecuteDir(Path: String);
Public procedure SavePathSaveExecuteDir;
Public function GetFileNameCommoditiesList: String;
Public procedure SetFileNameCommoditiesList(Path: String);
Public procedure SaveFileNameCommoditiesList;
Public function GetFileNameStationsList: String;
Public procedure SetFileNameStationsList(Path: String);
Public procedure SaveFileNameStationsList;
Public procedure ShowConsoleSettings(Sender: TObject);
Public procedure ShowHideConsole;
Public procedure FormKeyDownPressConsole;

Description

Methods

Public function Console: TConsoleReaderThread;

Console Server

Public function ContractDB: TContractDB;

Contract Database

Public procedure UpdateMainFormPosition(AForm: TForm);

Updates the position of the main form based on the current positioning mode.

The method calculates the new coordinates (X, Y) to center the form within the work area of the target monitor, excluding taskbars and docked toolbars.

Positioning Modes:

  • fpmDefault: No action is taken; the form remains at its current position.

  • fpmFollowActiveMonitor: The form is centered on the monitor where it is currently located.

  • fpmSpecificMonitor: The form is moved to the monitor specified by the global index _SelectedFormMainMonitorIndex.

Parameters
AForm
The form instance to be repositioned. Currently, the method internal logic is tied to the main form, but is designed for future generalization.
Public procedure ValidateMonitorSettings;

Validates and corrects monitor-related settings to prevent errors after hardware changes.

This procedure acts as a safety check (fail-safe). If a previously selected monitor is no longer available (e.g., unplugged), it resets the positioning mode and index to their default values.

Technical Notes: This method is typically called during application startup or in response to a WM_DISPLAYCHANGE message.

Public procedure IniPropStorageRestore;

Resets all application settings to their predefined default values in the INI storage.

This method bypasses the current session variables and writes the ValueDefault constants directly to the storage.

Note: A call to IniPropStorage.Save is performed at the end to ensure changes are flushed to the physical disk.

Public procedure IniPropStorageSetAllOptionsToDefault;

Persists the current session variables into the INI storage.

This method takes the values currently held in the private fields and writes them to the IniPropStorage component.

Note: Enumerated types are stored as integers using the Ord() function to ensure compatibility with the INI format.

Public procedure IniPropStorageSetAllOptions;

Restores session variables from the INI storage into memory.

This procedure reads the values from the storage and populates the application's internal state. It includes fallback logic to handle missing keys or corrupted data.

Technical Notes: The range checking on integers is critical to prevent Access Violations or undefined behavior when an INI file is manually edited with invalid values.

Public function GetPathLoadExecuteDir: String;
 
Returns

The path to the load execute directory.

Public procedure SetPathLoadExecuteDir(Path: String);

Sets the path to the load execute directory.

Public procedure SavePathLoadExecuteDir;

Saves the path to the load execute directory.

Public function GetPathSaveExecuteDir: String;
 
Returns

The path to the save execute directory.

Public procedure SetPathSaveExecuteDir(Path: String);

Sets the path to the save execute directory.

Public procedure SavePathSaveExecuteDir;

Saves the path to the save execute directory.

Public function GetFileNameCommoditiesList: String;
 
Returns

The name of the commodities list file.

Public procedure SetFileNameCommoditiesList(Path: String);

Sets the name of the commodities list file.

Public procedure SaveFileNameCommoditiesList;

Saves the name of the commodities list file.

Public function GetFileNameStationsList: String;
 
Returns

The name of the stations list file.

Public procedure SetFileNameStationsList(Path: String);

Sets the name of the stations list file.

Public procedure SaveFileNameStationsList;

Saves the name of the stations list file.

Public procedure ShowConsoleSettings(Sender: TObject);

Shows the console settings form.

Public procedure ShowHideConsole;

Shows or hides the console.

Public procedure FormKeyDownPressConsole;

Helper method to manage the visibility and focus of the external console.

If the console is currently visible, it forces it to the foreground. Otherwise, it triggers the console display logic (simulating a click on the console tool button).