Class TFormMain

Unit

Declaration

type TFormMain = class(TForm, IConsoleInputHandler, IMainService)

Description

Hierarchy

Overview

Fields

Public ActionClearCache: TAction;
Public ActionAbout: TAction;
Public ActionShowConsoleSettings: TAction;
Public ActionList: TActionList;
Public ApplicationProperties: TApplicationProperties;
Public Bevel16: TBevel;
Public BitBtnSCUxSize: TBitBtn;
Public CoolBarTopLeftMenu: TCoolBar;
Public ImageAvatarWeb: TImage;
Public ImageOrganization: TImage;
Public ImageAvatar: TImage;
Public ImageAGPL: TImage;
Public ImageBanner: TImage;
Public ImageInfoTime_1: TImage;
Public ImageInfoTime_2: TImage;
Public ImageListMenu: TImageList;
Public ImageOrganizationWeb: TImage;
Public ImageStarCitizenLogoLeft: TImage;
Public ImageStarCitizenLogoRight: TImage;
Public ImageStarCitizenLogoGreyLeft: TImage;
Public ImageStarCitizenLogoGreyRight: TImage;
Public ImageWarning_1: TImage;
Public ImageWarning_2: TImage;
Public IniPropStorage: TIniPropStorage;
Public LabelStarCitizenActivity: TLabel;
Public LabelTime: TLabel;
Public MainMenuItemShowConsoleSettings: TMenuItem;
Public MenuItemClearCache: TMenuItem;
Public MenuItemTools: TMenuItem;
Public MenuItemAbout: TMenuItem;
Public MenuItemAiuto: TMenuItem;
Public MenuMain: TMainMenu;
Public PanelOrganization: TPanel;
Public PanelTop: TPanel;
Public PanelAvatar: TPanel;
Public PanelTopMenu: TPanel;
Public PanelBanner: TPanel;
Public PanelTime: TPanel;
Public PanelStarCitizenActivity: TPanel;
Public PopupMenuItemShowConsoleSettings: TMenuItem;
Public MainMenuItemSettings: TMenuItem;
Public PopupMenuItemSettings: TMenuItem;
Public PanelMainHeader: TPanel;
Public PanelMainTools: TPanel;
Public PopupMenuMain: TPopupMenu;
Public SaveDialog1: TSaveDialog;
Public StaticTextTime: TStaticText;
Public StaticTextTimeStamp: TStaticText;
Public TimerStarCitizenActivity: TTimer;
Public TimerTimeActivity: TTimer;
Public ToolBarTopMenuWin: TToolBar;
Public ToolBarTopMenuDev: TToolBar;
Public ToolButtonProfile: TToolButton;
Public ToolButtonTest: TToolButton;
Public ToolButtonAlwaysShowOnTop: TToolButton;
Public ToolButton3: TToolButton;
Public ToolButtonConsole: TToolButton;

Methods

Public procedure ActionAboutExecute(Sender: TObject);
Public procedure ActionClearCacheExecute(Sender: TObject);
Public procedure ActionShowConsoleSettingsExecute(Sender: TObject);
Public procedure ApplicationPropertiesActivate(Sender: TObject);
Public procedure ApplicationPropertiesDeactivate(Sender: TObject);
Public procedure BitBtnSCUxSizeClick(Sender: TObject);
Public procedure BitBtnShowConsoleSettingsApplyClick(Sender: TObject);
Public procedure FormActivate(Sender: TObject);
Public procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
Public procedure FormCreate(Sender: TObject);
Public procedure FormDestroy(Sender: TObject);
Public procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
Public procedure FormKeyPress(Sender: TObject; var Key: char);
Public procedure ImageAvatarClick(Sender: TObject);
Public procedure ImageOrganizationClick(Sender: TObject);
Public procedure TimerStarCitizenActivityTimer(Sender: TObject);
Public procedure ToolButtonProfileClick(Sender: TObject);
Public procedure ToolButtonAlwaysShowOnTopClick(Sender: TObject);
Public procedure ToolButtonConsoleClick(Sender: TObject);
Public procedure TimerTimeActivityTimer(Sender: TObject);
Public procedure ToolButtonTestClick(Sender: TObject);
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;
Public procedure ConsoleInputExecute(const S: string);
Public constructor Create(TheOwner: TComponent); override;
Public destructor Destroy; override;

Description

Fields

Public ActionClearCache: TAction;
 
Public ActionAbout: TAction;
 
Public ActionShowConsoleSettings: TAction;
 
Public ActionList: TActionList;
 
Public ApplicationProperties: TApplicationProperties;
 
Public Bevel16: TBevel;
 
Public BitBtnSCUxSize: TBitBtn;
 
Public CoolBarTopLeftMenu: TCoolBar;
 
Public ImageAvatarWeb: TImage;
 
Public ImageOrganization: TImage;
 
Public ImageAvatar: TImage;
 
Public ImageAGPL: TImage;
 
Public ImageBanner: TImage;
 
Public ImageInfoTime_1: TImage;
 
Public ImageInfoTime_2: TImage;
 
Public ImageListMenu: TImageList;
 
Public ImageOrganizationWeb: TImage;
 
Public ImageStarCitizenLogoLeft: TImage;
 
Public ImageStarCitizenLogoRight: TImage;
 
Public ImageStarCitizenLogoGreyLeft: TImage;
 
Public ImageStarCitizenLogoGreyRight: TImage;
 
Public ImageWarning_1: TImage;
 
Public ImageWarning_2: TImage;
 
Public IniPropStorage: TIniPropStorage;
 
Public LabelStarCitizenActivity: TLabel;
 
Public LabelTime: TLabel;
 
Public MainMenuItemShowConsoleSettings: TMenuItem;
 
Public MenuItemClearCache: TMenuItem;
 
Public MenuItemTools: TMenuItem;
 
Public MenuItemAbout: TMenuItem;
 
Public MenuItemAiuto: TMenuItem;
 
Public MenuMain: TMainMenu;
 
Public PanelOrganization: TPanel;
 
Public PanelTop: TPanel;
 
Public PanelAvatar: TPanel;
 
Public PanelTopMenu: TPanel;
 
Public PanelBanner: TPanel;
 
Public PanelTime: TPanel;
 
Public PanelStarCitizenActivity: TPanel;
 
Public PopupMenuItemShowConsoleSettings: TMenuItem;
 
Public MainMenuItemSettings: TMenuItem;
 
Public PopupMenuItemSettings: TMenuItem;
 
Public PanelMainHeader: TPanel;
 
Public PanelMainTools: TPanel;
 
Public PopupMenuMain: TPopupMenu;
 
Public SaveDialog1: TSaveDialog;
 
Public StaticTextTime: TStaticText;
 
Public StaticTextTimeStamp: TStaticText;
 
Public TimerStarCitizenActivity: TTimer;
 
Public TimerTimeActivity: TTimer;
 
Public ToolBarTopMenuWin: TToolBar;
 
Public ToolBarTopMenuDev: TToolBar;
 
Public ToolButtonProfile: TToolButton;
 
Public ToolButtonTest: TToolButton;
 
Public ToolButtonAlwaysShowOnTop: TToolButton;
 
Public ToolButton3: TToolButton;
 
Public ToolButtonConsole: TToolButton;
 

Methods

Public procedure ActionAboutExecute(Sender: TObject);
 
Public procedure ActionClearCacheExecute(Sender: TObject);
 
Public procedure ActionShowConsoleSettingsExecute(Sender: TObject);
 
Public procedure ApplicationPropertiesActivate(Sender: TObject);
 
Public procedure ApplicationPropertiesDeactivate(Sender: TObject);
 
Public procedure BitBtnSCUxSizeClick(Sender: TObject);
 
Public procedure BitBtnShowConsoleSettingsApplyClick(Sender: TObject);
 
Public procedure FormActivate(Sender: TObject);
 
Public procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
 
Public procedure FormCreate(Sender: TObject);
 
Public procedure FormDestroy(Sender: TObject);
 
Public procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
 
Public procedure FormKeyPress(Sender: TObject; var Key: char);
 
Public procedure ImageAvatarClick(Sender: TObject);
 
Public procedure ImageOrganizationClick(Sender: TObject);
 
Public procedure TimerStarCitizenActivityTimer(Sender: TObject);
 
Public procedure ToolButtonProfileClick(Sender: TObject);
 
Public procedure ToolButtonAlwaysShowOnTopClick(Sender: TObject);
 
Public procedure ToolButtonConsoleClick(Sender: TObject);
 
Public procedure TimerTimeActivityTimer(Sender: TObject);
 
Public procedure ToolButtonTestClick(Sender: TObject);
 
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).

Public procedure ConsoleInputExecute(const S: string);

Executes commands received from an external shell.

Since the main application is a GUI and does not directly handle standard input (stdin) or standard output (stdout), this procedure acts as a bridge. It processes commands forwarded from an external shell process.

Parameters
S
The command string sent by the user through the external shell.
Public constructor Create(TheOwner: TComponent); override;

Constructor.

Parameters
TheOwner
The component that owns this form.
Public destructor Destroy; override;

Destructor.