Reverted trunk back to revision 38 (base for 1.0.6 release branch)
This commit is contained in:
parent
6aca2ebe1b
commit
77cf10ddf6
@ -1,45 +0,0 @@
|
|||||||
object ButtonAssignmentFrame: TButtonAssignmentFrame
|
|
||||||
Left = 0
|
|
||||||
Top = 0
|
|
||||||
Width = 261
|
|
||||||
Height = 41
|
|
||||||
TabOrder = 0
|
|
||||||
DesignSize = (
|
|
||||||
261
|
|
||||||
41)
|
|
||||||
object lblFunction: TLabel
|
|
||||||
Left = 53
|
|
||||||
Top = 6
|
|
||||||
Width = 208
|
|
||||||
Height = 13
|
|
||||||
Anchors = [akLeft, akTop, akRight]
|
|
||||||
AutoSize = False
|
|
||||||
Caption = '[runtime: function]'
|
|
||||||
EllipsisPosition = epEndEllipsis
|
|
||||||
Font.Charset = DEFAULT_CHARSET
|
|
||||||
Font.Color = clWindowText
|
|
||||||
Font.Height = -11
|
|
||||||
Font.Name = 'Tahoma'
|
|
||||||
Font.Style = [fsBold]
|
|
||||||
ParentFont = False
|
|
||||||
end
|
|
||||||
object lblCategory: TLabel
|
|
||||||
Left = 53
|
|
||||||
Top = 22
|
|
||||||
Width = 208
|
|
||||||
Height = 13
|
|
||||||
Anchors = [akLeft, akTop, akRight]
|
|
||||||
AutoSize = False
|
|
||||||
Caption = '[runtime: category]'
|
|
||||||
EllipsisPosition = epEndEllipsis
|
|
||||||
end
|
|
||||||
object btnConfiguration: TButton
|
|
||||||
Left = 0
|
|
||||||
Top = 0
|
|
||||||
Width = 41
|
|
||||||
Height = 41
|
|
||||||
Caption = 'P&?'
|
|
||||||
TabOrder = 0
|
|
||||||
OnClick = btnConfigurationClick
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,87 +0,0 @@
|
|||||||
unit ButtonAssignmentFrm;
|
|
||||||
|
|
||||||
interface
|
|
||||||
uses
|
|
||||||
System.Classes,
|
|
||||||
Vcl.Controls,
|
|
||||||
Vcl.Forms,
|
|
||||||
Vcl.StdCtrls;
|
|
||||||
|
|
||||||
|
|
||||||
type
|
|
||||||
TButtonAssignmentFrame = class(TFrame)
|
|
||||||
btnConfiguration: TButton;
|
|
||||||
lblFunction: TLabel;
|
|
||||||
lblCategory: TLabel;
|
|
||||||
|
|
||||||
procedure btnConfigurationClick(Sender: TObject);
|
|
||||||
private
|
|
||||||
FLEDIndex: Integer;
|
|
||||||
FOnConfigurationClick: TNotifyEvent;
|
|
||||||
|
|
||||||
function GetCategoryName: string;
|
|
||||||
function GetFunctionName: string;
|
|
||||||
procedure SetCategoryName(const Value: string);
|
|
||||||
procedure SetFunctionName(const Value: string);
|
|
||||||
public
|
|
||||||
constructor Create(AOwner: TComponent); override;
|
|
||||||
|
|
||||||
property LEDIndex: Integer read FLEDIndex write FLEDIndex;
|
|
||||||
property CategoryName: string read GetCategoryName write SetCategoryName;
|
|
||||||
property FunctionName: string read GetFunctionName write SetFunctionName;
|
|
||||||
|
|
||||||
property OnConfigurationClick: TNotifyEvent read FOnConfigurationClick write FOnConfigurationClick;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
|
||||||
uses
|
|
||||||
Graphics;
|
|
||||||
|
|
||||||
|
|
||||||
{$R *.dfm}
|
|
||||||
|
|
||||||
|
|
||||||
{ TButtonAssignmentFrame }
|
|
||||||
constructor TButtonAssignmentFrame.Create(AOwner: TComponent);
|
|
||||||
begin
|
|
||||||
inherited Create(AOwner);
|
|
||||||
|
|
||||||
lblCategory.Font.Color := clGrayText;
|
|
||||||
|
|
||||||
SetCategoryName('');
|
|
||||||
SetFunctionName('');
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TButtonAssignmentFrame.GetCategoryName: string;
|
|
||||||
begin
|
|
||||||
Result := lblCategory.Caption;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TButtonAssignmentFrame.GetFunctionName: string;
|
|
||||||
begin
|
|
||||||
Result := lblFunction.Caption;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TButtonAssignmentFrame.SetCategoryName(const Value: string);
|
|
||||||
begin
|
|
||||||
lblCategory.Caption := Value;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TButtonAssignmentFrame.SetFunctionName(const Value: string);
|
|
||||||
begin
|
|
||||||
lblFunction.Caption := Value;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TButtonAssignmentFrame.btnConfigurationClick(Sender: TObject);
|
|
||||||
begin
|
|
||||||
if Assigned(FOnConfigurationClick) then
|
|
||||||
FOnConfigurationClick(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
|||||||
unit MainFrm;
|
unit MainFrm;
|
||||||
|
|
||||||
|
// #ToDo1 -oMvR: 3-3-2013: trigger profile update when Save As only changes the name
|
||||||
|
|
||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
System.Classes,
|
System.Classes,
|
||||||
@ -19,12 +21,11 @@ uses
|
|||||||
pngimage,
|
pngimage,
|
||||||
X2UtPersistIntf,
|
X2UtPersistIntf,
|
||||||
|
|
||||||
ButtonAssignmentFrm,
|
|
||||||
FSXSimConnectIntf,
|
FSXSimConnectIntf,
|
||||||
LEDStateConsumer,
|
LEDStateConsumer,
|
||||||
Profile,
|
Profile,
|
||||||
ProfileManager,
|
ProfileManager,
|
||||||
Settings, VirtualTrees, Vcl.ImgList, Vcl.ActnList, Vcl.ToolWin, Vcl.Menus;
|
Settings;
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -44,6 +45,13 @@ const
|
|||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TLEDControls = record
|
||||||
|
ConfigureButton: TButton;
|
||||||
|
CategoryLabel: TLabel;
|
||||||
|
FunctionLabel: TLabel;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
TMainForm = class(TForm, IProfileObserver)
|
TMainForm = class(TForm, IProfileObserver)
|
||||||
imgStateNotFound: TImage;
|
imgStateNotFound: TImage;
|
||||||
lblG940Throttle: TLabel;
|
lblG940Throttle: TLabel;
|
||||||
@ -64,6 +72,35 @@ type
|
|||||||
btnCheckUpdates: TButton;
|
btnCheckUpdates: TButton;
|
||||||
lblProxy: TLabel;
|
lblProxy: TLabel;
|
||||||
tsButtons: TTabSheet;
|
tsButtons: TTabSheet;
|
||||||
|
btnP1: TButton;
|
||||||
|
lblP1Function: TLabel;
|
||||||
|
lblP1Category: TLabel;
|
||||||
|
btnP2: TButton;
|
||||||
|
lblP2Function: TLabel;
|
||||||
|
lblP2Category: TLabel;
|
||||||
|
btnP3: TButton;
|
||||||
|
lblP3Function: TLabel;
|
||||||
|
lblP3Category: TLabel;
|
||||||
|
btnP4: TButton;
|
||||||
|
lblP4Function: TLabel;
|
||||||
|
lblP4Category: TLabel;
|
||||||
|
btnP5: TButton;
|
||||||
|
lblP5Function: TLabel;
|
||||||
|
lblP5Category: TLabel;
|
||||||
|
btnP6: TButton;
|
||||||
|
lblP6Function: TLabel;
|
||||||
|
lblP6Category: TLabel;
|
||||||
|
btnP7: TButton;
|
||||||
|
lblP7Function: TLabel;
|
||||||
|
lblP7Category: TLabel;
|
||||||
|
btnP8: TButton;
|
||||||
|
lblP8Function: TLabel;
|
||||||
|
lblP8Category: TLabel;
|
||||||
|
lblProfile: TLabel;
|
||||||
|
cmbProfiles: TComboBox;
|
||||||
|
btnSaveProfile: TButton;
|
||||||
|
btnDeleteProfile: TButton;
|
||||||
|
bvlProfiles: TBevel;
|
||||||
pnlFSX: TPanel;
|
pnlFSX: TPanel;
|
||||||
imgFSXStateNotConnected: TImage;
|
imgFSXStateNotConnected: TImage;
|
||||||
imgFSXStateConnected: TImage;
|
imgFSXStateConnected: TImage;
|
||||||
@ -75,44 +112,11 @@ type
|
|||||||
cbProfileMenuCascaded: TCheckBox;
|
cbProfileMenuCascaded: TCheckBox;
|
||||||
lblProfileSwitching: TLabel;
|
lblProfileSwitching: TLabel;
|
||||||
bvlProfileSwitching: TBevel;
|
bvlProfileSwitching: TBevel;
|
||||||
TrayIcon: TTrayIcon;
|
|
||||||
bafP1: TButtonAssignmentFrame;
|
|
||||||
bafP2: TButtonAssignmentFrame;
|
|
||||||
bafP3: TButtonAssignmentFrame;
|
|
||||||
bafP4: TButtonAssignmentFrame;
|
|
||||||
bafP5: TButtonAssignmentFrame;
|
|
||||||
bafP6: TButtonAssignmentFrame;
|
|
||||||
bafP7: TButtonAssignmentFrame;
|
|
||||||
bafP8: TButtonAssignmentFrame;
|
|
||||||
vstProfile: TVirtualStringTree;
|
|
||||||
pnlProfiles: TPanel;
|
|
||||||
tbProfiles: TToolBar;
|
|
||||||
tbNewProfile: TToolButton;
|
|
||||||
tbSaveProfile: TToolButton;
|
|
||||||
ActionList: TActionList;
|
|
||||||
actNewProfile: TAction;
|
|
||||||
actSaveProfile: TAction;
|
|
||||||
actRevertProfile: TAction;
|
|
||||||
tbRevertProfile: TToolButton;
|
|
||||||
ImageList: TImageList;
|
|
||||||
tbDeleteProfile: TToolButton;
|
|
||||||
actDeleteProfile: TAction;
|
|
||||||
ToolButton1: TToolButton;
|
|
||||||
tbSetActiveProfile: TToolButton;
|
|
||||||
actSetActiveProfile: TAction;
|
|
||||||
pmnProfiles: TPopupMenu;
|
|
||||||
pmnProfilesNew: TMenuItem;
|
|
||||||
pmnProfilesSave: TMenuItem;
|
|
||||||
pmnProfilesRevert: TMenuItem;
|
|
||||||
pmnProfilesDelete: TMenuItem;
|
|
||||||
pmnProfilesSetActive: TMenuItem;
|
|
||||||
pmnProfilesSep1: TMenuItem;
|
|
||||||
tbRenameProfile: TToolButton;
|
|
||||||
actRenameProfile: TAction;
|
|
||||||
|
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure lblLinkLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType);
|
procedure lblLinkLinkClick(Sender: TObject; const Link: string; LinkType: TSysLinkType);
|
||||||
procedure btnCheckUpdatesClick(Sender: TObject);
|
procedure btnCheckUpdatesClick(Sender: TObject);
|
||||||
|
procedure LEDButtonClick(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure cmbProfilesClick(Sender: TObject);
|
procedure cmbProfilesClick(Sender: TObject);
|
||||||
procedure cbCheckUpdatesClick(Sender: TObject);
|
procedure cbCheckUpdatesClick(Sender: TObject);
|
||||||
@ -120,14 +124,8 @@ type
|
|||||||
procedure btnDeleteProfileClick(Sender: TObject);
|
procedure btnDeleteProfileClick(Sender: TObject);
|
||||||
procedure cbProfileMenuClick(Sender: TObject);
|
procedure cbProfileMenuClick(Sender: TObject);
|
||||||
procedure cbProfileMenuCascadedClick(Sender: TObject);
|
procedure cbProfileMenuCascadedClick(Sender: TObject);
|
||||||
procedure actNewProfileExecute(Sender: TObject);
|
|
||||||
procedure actSaveProfileExecute(Sender: TObject);
|
|
||||||
procedure actRevertProfileExecute(Sender: TObject);
|
|
||||||
procedure actSetActiveProfileExecute(Sender: TObject);
|
|
||||||
procedure actDeleteProfileExecute(Sender: TObject);
|
|
||||||
procedure actRenameProfileExecute(Sender: TObject);
|
|
||||||
private
|
private
|
||||||
FLEDControls: array[0..LED_COUNT - 1] of TButtonAssignmentFrame;
|
FLEDControls: array[0..LED_COUNT - 1] of TLEDControls;
|
||||||
FEventMonitor: TOmniEventMonitor;
|
FEventMonitor: TOmniEventMonitor;
|
||||||
|
|
||||||
FProfilesFilename: string;
|
FProfilesFilename: string;
|
||||||
@ -182,8 +180,6 @@ type
|
|||||||
procedure HandleDeviceStateMessage(AMessage: TOmniMessage);
|
procedure HandleDeviceStateMessage(AMessage: TOmniMessage);
|
||||||
procedure HandleFSXStateMessage(AMessage: TOmniMessage);
|
procedure HandleFSXStateMessage(AMessage: TOmniMessage);
|
||||||
|
|
||||||
procedure LEDConfigurationClick(Sender: TObject);
|
|
||||||
|
|
||||||
procedure CMAskAutoUpdate(var Msg: TMessage); message CM_ASKAUTOUPDATE;
|
procedure CMAskAutoUpdate(var Msg: TMessage); message CM_ASKAUTOUPDATE;
|
||||||
|
|
||||||
property EventMonitor: TOmniEventMonitor read FEventMonitor;
|
property EventMonitor: TOmniEventMonitor read FEventMonitor;
|
||||||
@ -291,7 +287,7 @@ begin
|
|||||||
worker := TFSXStateMonitorWorker.Create;
|
worker := TFSXStateMonitorWorker.Create;
|
||||||
EventMonitor.Monitor(CreateTask(worker)).Run;
|
EventMonitor.Monitor(CreateTask(worker)).Run;
|
||||||
|
|
||||||
Profiles.Attach(Self);
|
TProfileManager.Attach(Self);
|
||||||
|
|
||||||
FindLEDControls;
|
FindLEDControls;
|
||||||
|
|
||||||
@ -310,7 +306,7 @@ begin
|
|||||||
FinalizeProfileMenu;
|
FinalizeProfileMenu;
|
||||||
|
|
||||||
UnregisterDeviceArrival;
|
UnregisterDeviceArrival;
|
||||||
Profiles.Detach(Self);
|
TProfileManager.Detach(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -382,7 +378,7 @@ var
|
|||||||
profile: TProfile;
|
profile: TProfile;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
profile := Profiles.ActiveProfile;
|
profile := TProfileManager.Instance.ActiveProfile;
|
||||||
|
|
||||||
if Settings.ActiveProfile <> profile.Name then
|
if Settings.ActiveProfile <> profile.Name then
|
||||||
begin
|
begin
|
||||||
@ -390,13 +386,12 @@ begin
|
|||||||
SaveSettings;
|
SaveSettings;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// #ToDo1 -oMvR: 21-4-2013: invalidate profile node
|
FLockChangeProfile := True;
|
||||||
// FLockChangeProfile := True;
|
try
|
||||||
// try
|
cmbProfiles.ItemIndex := cmbProfiles.Items.IndexOfObject(profile);
|
||||||
// cmbProfiles.ItemIndex := cmbProfiles.Items.IndexOfObject(profile);
|
finally
|
||||||
// finally
|
FLockChangeProfile := False;
|
||||||
// FLockChangeProfile := False;
|
end;
|
||||||
// end;
|
|
||||||
|
|
||||||
LoadActiveProfile;
|
LoadActiveProfile;
|
||||||
end;
|
end;
|
||||||
@ -416,17 +411,20 @@ procedure TMainForm.FindLEDControls;
|
|||||||
var
|
var
|
||||||
ledIndex: Integer;
|
ledIndex: Integer;
|
||||||
ledNumber: string;
|
ledNumber: string;
|
||||||
buttonFrame: TButtonAssignmentFrame;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for ledIndex := 0 to Pred(LED_COUNT) do
|
for ledIndex := 0 to Pred(LED_COUNT) do
|
||||||
begin
|
begin
|
||||||
ledNumber := IntToStr(Succ(ledIndex));
|
ledNumber := IntToStr(Succ(ledIndex));
|
||||||
|
|
||||||
buttonFrame := (ComponentByName('bafP' + ledNumber, ledIndex) as TButtonAssignmentFrame);
|
FLEDControls[ledIndex].ConfigureButton := (ComponentByName('btnP' + ledNumber, ledIndex) as TButton);
|
||||||
buttonFrame.OnConfigurationClick := LEDConfigurationClick;
|
FLEDControls[ledIndex].CategoryLabel := (ComponentByName('lblP' + ledNumber + 'Category', ledIndex) as TLabel);
|
||||||
|
FLEDControls[ledIndex].FunctionLabel := (ComponentByName('lblP' + ledNumber + 'Function', ledIndex) as TLabel);
|
||||||
|
|
||||||
FLEDControls[ledIndex] := buttonFrame;
|
FLEDControls[ledIndex].ConfigureButton.OnClick := LEDButtonClick;
|
||||||
|
FLEDControls[ledIndex].CategoryLabel.Caption := '';
|
||||||
|
FLEDControls[ledIndex].CategoryLabel.Font.Color := clGrayText;
|
||||||
|
FLEDControls[ledIndex].FunctionLabel.Caption := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -456,43 +454,43 @@ begin
|
|||||||
begin
|
begin
|
||||||
Debug.Log('UI: Succesfully converted 0.x profile');
|
Debug.Log('UI: Succesfully converted 0.x profile');
|
||||||
defaultProfile.Name := DefaultProfileName;
|
defaultProfile.Name := DefaultProfileName;
|
||||||
|
defaultProfile.IsTemporary := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(defaultProfile) then
|
if Assigned(defaultProfile) then
|
||||||
Profiles.Add(defaultProfile);
|
TProfileManager.Add(defaultProfile);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
persistXML := TX2UtPersistXML.Create;
|
persistXML := TX2UtPersistXML.Create;
|
||||||
try
|
try
|
||||||
persistXML.FileName := FProfilesFilename;
|
persistXML.FileName := FProfilesFilename;
|
||||||
Profiles.Load(persistXML.CreateReader);
|
TProfileManager.Load(persistXML.CreateReader);
|
||||||
finally
|
finally
|
||||||
FreeAndNil(persistXML);
|
FreeAndNil(persistXML);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ Make sure we always have a profile }
|
{ Make sure we always have a profile }
|
||||||
if Profiles.Count = 0 then
|
if TProfileManager.Instance.Count = 0 then
|
||||||
begin
|
begin
|
||||||
Debug.Log('UI: No profiles found, creating default profile');
|
Debug.Log('UI: No profiles found, creating default profile');
|
||||||
Profiles.Add(CreateDefaultProfile);
|
TProfileManager.Add(CreateDefaultProfile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// #ToDo1 -oMvR: 21-4-2013: load tree
|
FLockChangeProfile := True;
|
||||||
// FLockChangeProfile := True;
|
try
|
||||||
// try
|
cmbProfiles.Items.BeginUpdate;
|
||||||
// cmbProfiles.Items.BeginUpdate;
|
try
|
||||||
// try
|
cmbProfiles.Items.Clear;
|
||||||
// cmbProfiles.Items.Clear;
|
|
||||||
//
|
for profile in TProfileManager.Instance do
|
||||||
// for profile in TProfileManager.Instance do
|
cmbProfiles.Items.AddObject(profile.Name, profile);
|
||||||
// cmbProfiles.Items.AddObject(profile.Name, profile);
|
finally
|
||||||
// finally
|
cmbProfiles.Items.EndUpdate;
|
||||||
// cmbProfiles.Items.EndUpdate;
|
end;
|
||||||
// end;
|
finally
|
||||||
// finally
|
FLockChangeProfile := False;
|
||||||
// FLockChangeProfile := False;
|
end;
|
||||||
// end;
|
|
||||||
finally
|
finally
|
||||||
Debug.UnIndent;
|
Debug.UnIndent;
|
||||||
end;
|
end;
|
||||||
@ -509,7 +507,7 @@ begin
|
|||||||
persistXML := TX2UtPersistXML.Create;
|
persistXML := TX2UtPersistXML.Create;
|
||||||
try
|
try
|
||||||
persistXML.FileName := FProfilesFilename;
|
persistXML.FileName := FProfilesFilename;
|
||||||
Profiles.Save(persistXML.CreateWriter);
|
TProfileManager.Instance.Save(persistXML.CreateWriter);
|
||||||
finally
|
finally
|
||||||
FreeAndNil(persistXML);
|
FreeAndNil(persistXML);
|
||||||
end;
|
end;
|
||||||
@ -554,22 +552,13 @@ begin
|
|||||||
{ Default profile }
|
{ Default profile }
|
||||||
profile := nil;
|
profile := nil;
|
||||||
if Length(Settings.ActiveProfile) > 0 then
|
if Length(Settings.ActiveProfile) > 0 then
|
||||||
begin
|
profile := TProfileManager.Instance.Find(Settings.ActiveProfile);
|
||||||
{ Version 0.2 used the profile name, not a UID }
|
|
||||||
if Settings.ActiveProfile[1] <> '{' then
|
|
||||||
begin
|
|
||||||
profile := Profiles.FindByName(Settings.ActiveProfile);
|
|
||||||
if Assigned(profile) then
|
|
||||||
Settings.ActiveProfile := profile.UID;
|
|
||||||
end else
|
|
||||||
profile := Profiles.FindByUID(Settings.ActiveProfile);
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ LoadProfiles ensures there's always at least 1 profile }
|
{ LoadProfiles ensures there's always at least 1 profile }
|
||||||
if (not Assigned(profile)) and (Profiles.Count > 0) then
|
if (not Assigned(profile)) and (TProfileManager.Instance.Count > 0) then
|
||||||
profile := Profiles[0];
|
profile := TProfileManager.Instance[0];
|
||||||
|
|
||||||
Profiles.ActiveProfile := profile;
|
TProfileManager.Instance.ActiveProfile := profile;
|
||||||
|
|
||||||
{ Auto-update }
|
{ Auto-update }
|
||||||
cbCheckUpdates.Checked := Settings.CheckUpdates;
|
cbCheckUpdates.Checked := Settings.CheckUpdates;
|
||||||
@ -612,7 +601,7 @@ begin
|
|||||||
{ Default button functions are assigned during UpdateButton }
|
{ Default button functions are assigned during UpdateButton }
|
||||||
Result := TProfile.Create;
|
Result := TProfile.Create;
|
||||||
Result.Name := DefaultProfileName;
|
Result.Name := DefaultProfileName;
|
||||||
// Result.IsTemporary := True;
|
Result.IsTemporary := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -622,8 +611,7 @@ var
|
|||||||
buttonIndex: Integer;
|
buttonIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// #ToDo1 -oMvR: 21-4-2013: change to LoadSelectedProfile
|
activeProfile := TProfileManager.Instance.ActiveProfile;
|
||||||
activeProfile := Profiles.ActiveProfile;
|
|
||||||
if not Assigned(activeProfile) then
|
if not Assigned(activeProfile) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
@ -664,52 +652,16 @@ begin
|
|||||||
|
|
||||||
if Assigned(buttonFunction) then
|
if Assigned(buttonFunction) then
|
||||||
begin
|
begin
|
||||||
FLEDControls[AButtonIndex].CategoryName := buttonFunction.GetCategoryName;
|
FLEDControls[AButtonIndex].CategoryLabel.Caption := buttonFunction.GetCategoryName;
|
||||||
FLEDControls[AButtonIndex].FunctionName := buttonFunction.GetDisplayName;
|
FLEDControls[AButtonIndex].FunctionLabel.Caption := buttonFunction.GetDisplayName;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actDeleteProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actNewProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actRenameProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actRevertProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actSaveProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.actSetActiveProfileExecute(Sender: TObject);
|
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.AddProfile(AProfile: TProfile);
|
procedure TMainForm.AddProfile(AProfile: TProfile);
|
||||||
begin
|
begin
|
||||||
// cmbProfiles.Items.AddObject(AProfile.Name, AProfile);
|
cmbProfiles.Items.AddObject(AProfile.Name, AProfile);
|
||||||
Profiles.Add(AProfile, True);
|
TProfileManager.Instance.Add(AProfile, True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -719,18 +671,18 @@ var
|
|||||||
oldItemIndex: Integer;
|
oldItemIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// itemIndex := cmbProfiles.Items.IndexOfObject(AProfile);
|
itemIndex := cmbProfiles.Items.IndexOfObject(AProfile);
|
||||||
// if itemIndex > -1 then
|
if itemIndex > -1 then
|
||||||
// begin
|
begin
|
||||||
// oldItemIndex := cmbProfiles.ItemIndex;
|
oldItemIndex := cmbProfiles.ItemIndex;
|
||||||
// FLockChangeProfile := True;
|
FLockChangeProfile := True;
|
||||||
// try
|
try
|
||||||
// cmbProfiles.Items[itemIndex] := AProfile.Name;
|
cmbProfiles.Items[itemIndex] := AProfile.Name;
|
||||||
// cmbProfiles.ItemIndex := oldItemIndex;
|
cmbProfiles.ItemIndex := oldItemIndex;
|
||||||
// finally
|
finally
|
||||||
// FLockChangeProfile := False;
|
FLockChangeProfile := False;
|
||||||
// end;
|
end;
|
||||||
// end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -739,39 +691,39 @@ var
|
|||||||
itemIndex: Integer;
|
itemIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// itemIndex := cmbProfiles.Items.IndexOfObject(AProfile);
|
itemIndex := cmbProfiles.Items.IndexOfObject(AProfile);
|
||||||
// if itemIndex > -1 then
|
if itemIndex > -1 then
|
||||||
// begin
|
begin
|
||||||
// TProfileManager.Remove(AProfile);
|
TProfileManager.Remove(AProfile);
|
||||||
// cmbProfiles.Items.Delete(itemIndex);
|
cmbProfiles.Items.Delete(itemIndex);
|
||||||
//
|
|
||||||
// if TProfileManager.Instance.Count = 0 then
|
if TProfileManager.Instance.Count = 0 then
|
||||||
// AddProfile(CreateDefaultProfile);
|
AddProfile(CreateDefaultProfile);
|
||||||
//
|
|
||||||
// if ASetActiveProfile then
|
if ASetActiveProfile then
|
||||||
// begin
|
begin
|
||||||
// if itemIndex >= TProfileManager.Instance.Count then
|
if itemIndex >= TProfileManager.Instance.Count then
|
||||||
// itemIndex := Pred(TProfileManager.Instance.Count);
|
itemIndex := Pred(TProfileManager.Instance.Count);
|
||||||
//
|
|
||||||
// FLockChangeProfile := True;
|
FLockChangeProfile := True;
|
||||||
// try
|
try
|
||||||
// cmbProfiles.ItemIndex := itemIndex;
|
cmbProfiles.ItemIndex := itemIndex;
|
||||||
// TProfileManager.Instance.ActiveProfile := TProfile(cmbProfiles.Items.Objects[itemIndex]);
|
TProfileManager.Instance.ActiveProfile := TProfile(cmbProfiles.Items.Objects[itemIndex]);
|
||||||
// finally
|
finally
|
||||||
// FLockChangeProfile := False;
|
FLockChangeProfile := False;
|
||||||
// end;
|
end;
|
||||||
// end;
|
end;
|
||||||
// end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.cmbProfilesClick(Sender: TObject);
|
procedure TMainForm.cmbProfilesClick(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// if not FLockChangeProfile then
|
if not FLockChangeProfile then
|
||||||
// begin
|
begin
|
||||||
// if cmbProfiles.ItemIndex > -1 then
|
if cmbProfiles.ItemIndex > -1 then
|
||||||
// TProfileManager.Instance.ActiveProfile := TProfile(cmbProfiles.Items.Objects[cmbProfiles.ItemIndex]);
|
TProfileManager.Instance.ActiveProfile := TProfile(cmbProfiles.Items.Objects[cmbProfiles.ItemIndex]);
|
||||||
// end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -834,7 +786,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TMainForm.LEDConfigurationClick(Sender: TObject);
|
procedure TMainForm.LEDButtonClick(Sender: TObject);
|
||||||
|
|
||||||
function GetUniqueProfileName(const AName: string): string;
|
function GetUniqueProfileName(const AName: string): string;
|
||||||
var
|
var
|
||||||
@ -844,15 +796,14 @@ procedure TMainForm.LEDConfigurationClick(Sender: TObject);
|
|||||||
Result := AName;
|
Result := AName;
|
||||||
counter := 0;
|
counter := 0;
|
||||||
|
|
||||||
// while Assigned(Profiles.Find(Result)) do
|
while Assigned(TProfileManager.Find(Result)) do
|
||||||
// begin
|
begin
|
||||||
// Inc(counter);
|
Inc(counter);
|
||||||
// Result := Format('%s (%d)', [AName, counter]);
|
Result := Format('%s (%d)', [AName, counter]);
|
||||||
// end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
// #ToDo1 -oMvR: 6-5-2013: new style!
|
|
||||||
var
|
var
|
||||||
activeProfile: TProfile;
|
activeProfile: TProfile;
|
||||||
buttonIndex: NativeInt;
|
buttonIndex: NativeInt;
|
||||||
@ -860,25 +811,25 @@ var
|
|||||||
newProfile: Boolean;
|
newProfile: Boolean;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
activeProfile := Profiles.ActiveProfile;
|
activeProfile := TProfileManager.Instance.ActiveProfile;
|
||||||
if not Assigned(activeProfile) then
|
if not Assigned(activeProfile) then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
{ Behaviour similar to the Windows System Sounds control panel;
|
{ Behaviour similar to the Windows System Sounds control panel;
|
||||||
when a change occurs, create a temporary profile "(modified)"
|
when a change occurs, create a temporary profile "(modified)"
|
||||||
so the original profile can still be selected }
|
so the original profile can still be selected }
|
||||||
// if not activeProfile.IsTemporary then
|
if not activeProfile.IsTemporary then
|
||||||
// begin
|
begin
|
||||||
// profile := TProfile.Create;
|
profile := TProfile.Create;
|
||||||
// profile.Assign(activeProfile);
|
profile.Assign(activeProfile);
|
||||||
// profile.Name := GetUniqueProfileName(profile.Name + ProfilePostfixModified);
|
profile.Name := GetUniqueProfileName(profile.Name + ProfilePostfixModified);
|
||||||
// profile.IsTemporary := True;
|
profile.IsTemporary := True;
|
||||||
// newProfile := True;
|
newProfile := True;
|
||||||
// end else
|
end else
|
||||||
// begin
|
begin
|
||||||
profile := activeProfile;
|
profile := activeProfile;
|
||||||
newProfile := False;
|
newProfile := False;
|
||||||
// end;
|
end;
|
||||||
|
|
||||||
buttonIndex := (Sender as TComponent).Tag;
|
buttonIndex := (Sender as TComponent).Tag;
|
||||||
if TButtonFunctionForm.Execute(profile, buttonIndex) then
|
if TButtonFunctionForm.Execute(profile, buttonIndex) then
|
||||||
@ -1004,13 +955,13 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
name := '';
|
name := '';
|
||||||
profile := Profiles.ActiveProfile;
|
profile := TProfileManager.Instance.ActiveProfile;
|
||||||
existingProfile := nil;
|
existingProfile := nil;
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
if InputQuery('Save profile as', 'Save this profile as:', name) then
|
if InputQuery('Save profile as', 'Save this profile as:', name) then
|
||||||
begin
|
begin
|
||||||
existingProfile := Profiles.FindByName(name);
|
existingProfile := TProfileManager.Find(name);
|
||||||
if existingProfile = profile then
|
if existingProfile = profile then
|
||||||
existingProfile := nil;
|
existingProfile := nil;
|
||||||
|
|
||||||
@ -1035,24 +986,24 @@ begin
|
|||||||
existingProfile.Assign(profile);
|
existingProfile.Assign(profile);
|
||||||
existingProfile.Name := name;
|
existingProfile.Name := name;
|
||||||
UpdateProfile(existingProfile);
|
UpdateProfile(existingProfile);
|
||||||
Profiles.ActiveProfile := existingProfile;
|
TProfileManager.Instance.ActiveProfile := existingProfile;
|
||||||
|
|
||||||
// if profile.IsTemporary then
|
if profile.IsTemporary then
|
||||||
// DeleteProfile(profile, False);
|
DeleteProfile(profile, False);
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// if profile.IsTemporary then
|
if profile.IsTemporary then
|
||||||
// begin
|
begin
|
||||||
// profile.Name := name;
|
profile.Name := name;
|
||||||
// profile.IsTemporary := False;
|
profile.IsTemporary := False;
|
||||||
// UpdateProfile(profile);
|
UpdateProfile(profile);
|
||||||
// end else
|
end else
|
||||||
// begin
|
begin
|
||||||
newProfile := TProfile.Create;
|
newProfile := TProfile.Create;
|
||||||
newProfile.Assign(profile);
|
newProfile.Assign(profile);
|
||||||
newProfile.Name := name;
|
newProfile.Name := name;
|
||||||
AddProfile(newProfile);
|
AddProfile(newProfile);
|
||||||
// end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SaveProfiles;
|
SaveProfiles;
|
||||||
@ -1064,7 +1015,7 @@ var
|
|||||||
activeProfile: TProfile;
|
activeProfile: TProfile;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
activeProfile := Profiles.ActiveProfile;
|
activeProfile := TProfileManager.Instance.ActiveProfile;
|
||||||
if Assigned(activeProfile) then
|
if Assigned(activeProfile) then
|
||||||
begin
|
begin
|
||||||
if MessageBox(Self.Handle, PChar(Format('Do you want to remove the profile named "%s"?', [activeProfile.Name])),
|
if MessageBox(Self.Handle, PChar(Format('Do you want to remove the profile named "%s"?', [activeProfile.Name])),
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
program G940LEDControl;
|
program G940LEDControl;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
System.SysUtils,
|
Forms,
|
||||||
Vcl.Forms,
|
SysUtils,
|
||||||
MainFrm in 'Forms\MainFrm.pas' {MainForm},
|
MainFrm in 'Forms\MainFrm.pas' {MainForm},
|
||||||
LogiJoystickDLL in '..\Shared\LogiJoystickDLL.pas',
|
LogiJoystickDLL in '..\Shared\LogiJoystickDLL.pas',
|
||||||
SimConnect in '..\Shared\SimConnect.pas',
|
SimConnect in '..\Shared\SimConnect.pas',
|
||||||
@ -36,8 +36,7 @@ uses
|
|||||||
FSXLEDFunctionProviderIntf in 'Units\FSXLEDFunctionProviderIntf.pas',
|
FSXLEDFunctionProviderIntf in 'Units\FSXLEDFunctionProviderIntf.pas',
|
||||||
GxDbugIntf in 'Units\GxDbugIntf.pas',
|
GxDbugIntf in 'Units\GxDbugIntf.pas',
|
||||||
DebugLog in 'Units\DebugLog.pas',
|
DebugLog in 'Units\DebugLog.pas',
|
||||||
DebugLogGExperts in 'Units\DebugLogGExperts.pas',
|
DebugLogGExperts in 'Units\DebugLogGExperts.pas';
|
||||||
ButtonAssignmentFrm in 'Forms\ButtonAssignmentFrm.pas' {ButtonAssignmentFrame: TFrame};
|
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<FrameworkType>VCL</FrameworkType>
|
<FrameworkType>VCL</FrameworkType>
|
||||||
<ProjectVersion>13.4</ProjectVersion>
|
<ProjectVersion>13.4</ProjectVersion>
|
||||||
<Base>True</Base>
|
<Base>True</Base>
|
||||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
<Config Condition="'$(Config)'==''">Release</Config>
|
||||||
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
<Platform Condition="'$(Platform)'==''">Win32</Platform>
|
||||||
<TargetedPlatforms>1</TargetedPlatforms>
|
<TargetedPlatforms>1</TargetedPlatforms>
|
||||||
<AppType>Application</AppType>
|
<AppType>Application</AppType>
|
||||||
@ -148,11 +148,6 @@
|
|||||||
<DCCReference Include="Units\GxDbugIntf.pas"/>
|
<DCCReference Include="Units\GxDbugIntf.pas"/>
|
||||||
<DCCReference Include="Units\DebugLog.pas"/>
|
<DCCReference Include="Units\DebugLog.pas"/>
|
||||||
<DCCReference Include="Units\DebugLogGExperts.pas"/>
|
<DCCReference Include="Units\DebugLogGExperts.pas"/>
|
||||||
<DCCReference Include="Forms\ButtonAssignmentFrm.pas">
|
|
||||||
<Form>ButtonAssignmentFrame</Form>
|
|
||||||
<FormType>dfm</FormType>
|
|
||||||
<DesignClass>TFrame</DesignClass>
|
|
||||||
</DCCReference>
|
|
||||||
<BuildConfiguration Include="Debug">
|
<BuildConfiguration Include="Debug">
|
||||||
<Key>Cfg_2</Key>
|
<Key>Cfg_2</Key>
|
||||||
<CfgParent>Base</CfgParent>
|
<CfgParent>Base</CfgParent>
|
||||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
@ -118,7 +118,6 @@ type
|
|||||||
FProfileMenu: Boolean;
|
FProfileMenu: Boolean;
|
||||||
FProfileMenuCascaded: Boolean;
|
FProfileMenuCascaded: Boolean;
|
||||||
|
|
||||||
// #ToDo1 -oMvR: 6-5-2013: change to object list
|
|
||||||
FMenuProfiles: TStringList;
|
FMenuProfiles: TStringList;
|
||||||
FMenuWasCascaded: Boolean;
|
FMenuWasCascaded: Boolean;
|
||||||
protected
|
protected
|
||||||
@ -312,9 +311,9 @@ begin
|
|||||||
if AEnabled <> FObservingProfileManager then
|
if AEnabled <> FObservingProfileManager then
|
||||||
begin
|
begin
|
||||||
if AEnabled then
|
if AEnabled then
|
||||||
Profiles.Attach(Self)
|
TProfileManager.Attach(Self)
|
||||||
else
|
else
|
||||||
Profiles.Detach(Self);
|
TProfileManager.Detach(Self);
|
||||||
|
|
||||||
FObservingProfileManager := AEnabled;
|
FObservingProfileManager := AEnabled;
|
||||||
end;
|
end;
|
||||||
@ -553,9 +552,9 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
profileName := FMenuProfiles[Pred(AEventID)];
|
profileName := FMenuProfiles[Pred(AEventID)];
|
||||||
profile := Profiles.FindByUID(profileName);
|
profile := TProfileManager.Find(profileName);
|
||||||
if Assigned(profile) then
|
if Assigned(profile) then
|
||||||
Profiles.ActiveProfile := profile;
|
TProfileManager.Instance.ActiveProfile := profile;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -686,12 +685,8 @@ begin
|
|||||||
|
|
||||||
if ProfileMenu then
|
if ProfileMenu then
|
||||||
begin
|
begin
|
||||||
try
|
for profile in TProfileManager.Instance do
|
||||||
for profile in Profiles.LockList do
|
FMenuProfiles.Add(profile.Name);
|
||||||
FMenuProfiles.Add(profile.Name);
|
|
||||||
finally
|
|
||||||
Profiles.UnlockList;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FMenuProfiles.Sort;
|
FMenuProfiles.Sort;
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ type
|
|||||||
|
|
||||||
TProfile = class(TPersistent)
|
TProfile = class(TPersistent)
|
||||||
private
|
private
|
||||||
FUID: string;
|
|
||||||
FName: string;
|
FName: string;
|
||||||
|
FIsTemporary: Boolean;
|
||||||
FButtons: TProfileButtonList;
|
FButtons: TProfileButtonList;
|
||||||
|
|
||||||
function GetButton(Index: Integer): TProfileButton;
|
function GetButton(Index: Integer): TProfileButton;
|
||||||
@ -61,8 +61,8 @@ type
|
|||||||
|
|
||||||
function HasButton(AIndex: Integer): Boolean;
|
function HasButton(AIndex: Integer): Boolean;
|
||||||
|
|
||||||
property UID: string read FUID write FUID;
|
|
||||||
property Name: string read FName write FName;
|
property Name: string read FName write FName;
|
||||||
|
property IsTemporary: Boolean read FIsTemporary write FIsTemporary;
|
||||||
|
|
||||||
property ButtonCount: Integer read GetButtonCount;
|
property ButtonCount: Integer read GetButtonCount;
|
||||||
property Buttons[Index: Integer]: TProfileButton read GetButton;
|
property Buttons[Index: Integer]: TProfileButton read GetButton;
|
||||||
@ -71,7 +71,7 @@ type
|
|||||||
|
|
||||||
TProfileList = class(TObjectList<TProfile>)
|
TProfileList = class(TObjectList<TProfile>)
|
||||||
public
|
public
|
||||||
// function Find(const AName: string): TProfile;
|
function Find(const AName: string): TProfile;
|
||||||
|
|
||||||
procedure Load(AReader: IX2PersistReader);
|
procedure Load(AReader: IX2PersistReader);
|
||||||
procedure Save(AWriter: IX2PersistWriter);
|
procedure Save(AWriter: IX2PersistWriter);
|
||||||
@ -92,6 +92,7 @@ const
|
|||||||
|
|
||||||
KeyProviderUID = 'ProviderUID';
|
KeyProviderUID = 'ProviderUID';
|
||||||
KeyFunctionUID = 'FunctionUID';
|
KeyFunctionUID = 'FunctionUID';
|
||||||
|
KeyIsTemporary = 'IsTemporary';
|
||||||
|
|
||||||
|
|
||||||
{ TProfileButton }
|
{ TProfileButton }
|
||||||
@ -231,8 +232,8 @@ begin
|
|||||||
begin
|
begin
|
||||||
sourceProfile := TProfile(Source);
|
sourceProfile := TProfile(Source);
|
||||||
|
|
||||||
FUID := sourceProfile.UID;
|
|
||||||
FName := sourceProfile.Name;
|
FName := sourceProfile.Name;
|
||||||
|
FIsTemporary := sourceProfile.IsTemporary;
|
||||||
|
|
||||||
FButtons.Clear;
|
FButtons.Clear;
|
||||||
for buttonIndex := 0 to Pred(sourceProfile.ButtonCount) do
|
for buttonIndex := 0 to Pred(sourceProfile.ButtonCount) do
|
||||||
@ -250,8 +251,8 @@ var
|
|||||||
begin
|
begin
|
||||||
buttonIndex := 0;
|
buttonIndex := 0;
|
||||||
|
|
||||||
// if not AReader.ReadBoolean(KeyIsTemporary, FIsTemporary) then
|
if not AReader.ReadBoolean(KeyIsTemporary, FIsTemporary) then
|
||||||
// FIsTemporary := False;
|
FIsTemporary := False;
|
||||||
|
|
||||||
while AReader.BeginSection(SectionButton + IntToStr(buttonIndex)) do
|
while AReader.BeginSection(SectionButton + IntToStr(buttonIndex)) do
|
||||||
try
|
try
|
||||||
@ -276,7 +277,7 @@ var
|
|||||||
buttonIndex: Integer;
|
buttonIndex: Integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// AWriter.WriteBoolean(KeyIsTemporary, IsTemporary);
|
AWriter.WriteBoolean(KeyIsTemporary, IsTemporary);
|
||||||
|
|
||||||
for buttonIndex := 0 to Pred(FButtons.Count) do
|
for buttonIndex := 0 to Pred(FButtons.Count) do
|
||||||
begin
|
begin
|
||||||
@ -329,7 +330,6 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{ TProfileList }
|
{ TProfileList }
|
||||||
{
|
|
||||||
function TProfileList.Find(const AName: string): TProfile;
|
function TProfileList.Find(const AName: string): TProfile;
|
||||||
var
|
var
|
||||||
profile: TProfile;
|
profile: TProfile;
|
||||||
@ -344,7 +344,6 @@ begin
|
|||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileList.Load(AReader: IX2PersistReader);
|
procedure TProfileList.Load(AReader: IX2PersistReader);
|
||||||
|
@ -3,6 +3,7 @@ unit ProfileManager;
|
|||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
System.Classes,
|
System.Classes,
|
||||||
|
System.SyncObjs,
|
||||||
|
|
||||||
Profile,
|
Profile,
|
||||||
X2UtPersistIntf;
|
X2UtPersistIntf;
|
||||||
@ -20,53 +21,57 @@ type
|
|||||||
TProfileManager = class;
|
TProfileManager = class;
|
||||||
|
|
||||||
|
|
||||||
ILockedProfileList = interface
|
TProfileManagerEnumerator = class(TProfileList.TEnumerator)
|
||||||
['{4F647762-AA70-4315-BB1C-E85E320F4E82}']
|
private
|
||||||
function GetEnumerator: TProfileList.TEnumerator;
|
FManager: TProfileManager;
|
||||||
|
public
|
||||||
|
constructor Create(AManager: TProfileManager);
|
||||||
|
destructor Destroy; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TProfileManager = class(TObject)
|
TProfileManager = class(TObject)
|
||||||
private
|
private
|
||||||
|
FLock: TCriticalSection;
|
||||||
|
FProfiles: TProfileList;
|
||||||
FObservers: TInterfaceList;
|
FObservers: TInterfaceList;
|
||||||
FProfileList: TProfileList;
|
|
||||||
FActiveProfile: TProfile;
|
FActiveProfile: TProfile;
|
||||||
|
|
||||||
|
function GetActiveProfile: TProfile;
|
||||||
function GetCount: Integer;
|
function GetCount: Integer;
|
||||||
function GetItem(Index: Integer): TProfile;
|
function GetItem(Index: Integer): TProfile;
|
||||||
procedure SetActiveProfile(const Value: TProfile);
|
procedure SetActiveProfile(const Value: TProfile);
|
||||||
procedure SetItem(Index: Integer; const Value: TProfile);
|
procedure SetItem(Index: Integer; const Value: TProfile);
|
||||||
protected
|
protected
|
||||||
property Observers: TInterfaceList read FObservers;
|
property Observers: TInterfaceList read FObservers;
|
||||||
property ProfileList: TProfileList read FProfileList;
|
property Profiles: TProfileList read FProfiles;
|
||||||
public
|
public
|
||||||
|
class function Instance(): TProfileManager;
|
||||||
|
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
procedure Add(AProfile: TProfile; ASetActive: Boolean = False);
|
procedure Lock;
|
||||||
function FindByName(const AName: string): TProfile;
|
procedure Unlock;
|
||||||
function FindByUID(const AName: string): TProfile;
|
|
||||||
function Remove(const AProfile: TProfile): Integer;
|
|
||||||
|
|
||||||
procedure Load(AReader: IX2PersistReader);
|
class procedure Add(AProfile: TProfile; ASetActive: Boolean = False);
|
||||||
procedure Save(AWriter: IX2PersistWriter);
|
class function Find(const AName: string): TProfile;
|
||||||
|
class function Remove(const AProfile: TProfile): Integer;
|
||||||
|
|
||||||
procedure Attach(AObserver: IProfileObserver);
|
class procedure Load(AReader: IX2PersistReader);
|
||||||
procedure Detach(AObserver: IProfileObserver);
|
class procedure Save(AWriter: IX2PersistWriter);
|
||||||
|
|
||||||
function LockList: ILockedProfileList;
|
class procedure Attach(AObserver: IProfileObserver);
|
||||||
procedure UnlockList;
|
class procedure Detach(AObserver: IProfileObserver);
|
||||||
|
|
||||||
property ActiveProfile: TProfile read FActiveProfile write SetActiveProfile;
|
function GetEnumerator: TProfileManagerEnumerator;
|
||||||
|
|
||||||
|
property ActiveProfile: TProfile read GetActiveProfile write SetActiveProfile;
|
||||||
property Count: Integer read GetCount;
|
property Count: Integer read GetCount;
|
||||||
property Items[Index: Integer]: TProfile read GetItem write SetItem; default;
|
property Items[Index: Integer]: TProfile read GetItem write SetItem; default;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Singleton }
|
|
||||||
function Profiles: TProfileManager;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -78,20 +83,8 @@ var
|
|||||||
ProfileManagerInstance: TProfileManager;
|
ProfileManagerInstance: TProfileManager;
|
||||||
|
|
||||||
|
|
||||||
|
{ TProfileManager }
|
||||||
type
|
class function TProfileManager.Instance: TProfileManager;
|
||||||
TLockedProfileList = class(TInterfacedObject, ILockedProfileList)
|
|
||||||
private
|
|
||||||
FList: TProfileList;
|
|
||||||
public
|
|
||||||
constructor Create(AList: TProfileList);
|
|
||||||
|
|
||||||
function GetEnumerator: TProfileList.TEnumerator;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Profiles: TProfileManager;
|
|
||||||
begin
|
begin
|
||||||
if not Assigned(ProfileManagerInstance) then
|
if not Assigned(ProfileManagerInstance) then
|
||||||
ProfileManagerInstance := TProfileManager.Create;
|
ProfileManagerInstance := TProfileManager.Create;
|
||||||
@ -100,130 +93,136 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TProfileManager }
|
|
||||||
constructor TProfileManager.Create;
|
constructor TProfileManager.Create;
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
|
|
||||||
FObservers := TInterfaceList.Create;
|
FObservers := TInterfaceList.Create;
|
||||||
FProfileList := TProfileList.Create(True);
|
FProfiles := TProfileList.Create(True);
|
||||||
|
FLock := TCriticalSection.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
destructor TProfileManager.Destroy;
|
destructor TProfileManager.Destroy;
|
||||||
begin
|
begin
|
||||||
FreeAndNil(FProfileList);
|
FreeAndNil(FLock);
|
||||||
|
FreeAndNil(FProfiles);
|
||||||
FreeAndNil(FObservers);
|
FreeAndNil(FObservers);
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.Add(AProfile: TProfile; ASetActive: Boolean);
|
procedure TProfileManager.Lock;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TProfileManager.Unlock;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
class procedure TProfileManager.Add(AProfile: TProfile; ASetActive: Boolean);
|
||||||
var
|
var
|
||||||
observer: IInterface;
|
observer: IInterface;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
TMonitor.Enter(ProfileList);
|
Instance.Lock;
|
||||||
try
|
try
|
||||||
ProfileList.Add(AProfile);
|
Instance.Profiles.Add(AProfile);
|
||||||
finally
|
finally
|
||||||
TMonitor.Exit(ProfileList);
|
Instance.Unlock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for observer in Observers do
|
for observer in Instance.Observers do
|
||||||
(observer as IProfileObserver).ObserveAdd(AProfile);
|
(observer as IProfileObserver).ObserveAdd(AProfile);
|
||||||
|
|
||||||
if ASetActive then
|
if ASetActive then
|
||||||
SetActiveProfile(AProfile);
|
Instance.SetActiveProfile(AProfile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.FindByName(const AName: string): TProfile;
|
class function TProfileManager.Find(const AName: string): TProfile;
|
||||||
begin
|
begin
|
||||||
// Result := Instance.ProfileList.Find(AName);
|
Result := Instance.Profiles.Find(AName);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.FindByUID(const AName: string): TProfile;
|
class function TProfileManager.Remove(const AProfile: TProfile): Integer;
|
||||||
begin
|
|
||||||
//
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.Remove(const AProfile: TProfile): Integer;
|
|
||||||
var
|
var
|
||||||
observer: IInterface;
|
observer: IInterface;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
TMonitor.Enter(ProfileList);
|
Instance.Lock;
|
||||||
try
|
try
|
||||||
Result := ProfileList.Remove(AProfile);
|
Result := Instance.Profiles.Remove(AProfile);
|
||||||
finally
|
finally
|
||||||
TMonitor.Exit(ProfileList);
|
Instance.Unlock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for observer in Observers do
|
for observer in Instance.Observers do
|
||||||
(observer as IProfileObserver).ObserveRemove(AProfile);
|
(observer as IProfileObserver).ObserveRemove(AProfile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.Load(AReader: IX2PersistReader);
|
class procedure TProfileManager.Load(AReader: IX2PersistReader);
|
||||||
begin
|
begin
|
||||||
TMonitor.Enter(ProfileList);
|
Instance.Lock;
|
||||||
try
|
try
|
||||||
ProfileList.Load(AReader);
|
Instance.Profiles.Load(AReader);
|
||||||
finally
|
finally
|
||||||
TMonitor.Exit(ProfileList);
|
Instance.Unlock;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.Save(AWriter: IX2PersistWriter);
|
class procedure TProfileManager.Save(AWriter: IX2PersistWriter);
|
||||||
begin
|
begin
|
||||||
TMonitor.Enter(ProfileList);
|
Instance.Lock;
|
||||||
try
|
try
|
||||||
ProfileList.Save(AWriter);
|
Instance.Profiles.Save(AWriter);
|
||||||
finally
|
finally
|
||||||
TMonitor.Exit(ProfileList);
|
Instance.Unlock;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.Attach(AObserver: IProfileObserver);
|
class procedure TProfileManager.Attach(AObserver: IProfileObserver);
|
||||||
begin
|
begin
|
||||||
Observers.Add(AObserver as IProfileObserver);
|
Instance.Observers.Add(AObserver as IProfileObserver);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.Detach(AObserver: IProfileObserver);
|
class procedure TProfileManager.Detach(AObserver: IProfileObserver);
|
||||||
begin
|
begin
|
||||||
Observers.Remove(AObserver as IProfileObserver);
|
Instance.Observers.Remove(AObserver as IProfileObserver);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.LockList: ILockedProfileList;
|
function TProfileManager.GetActiveProfile: TProfile;
|
||||||
begin
|
begin
|
||||||
TMonitor.Enter(ProfileList);
|
Result := Instance.FActiveProfile;
|
||||||
Result := TLockedProfileList.Create(ProfileList);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure TProfileManager.UnlockList;
|
|
||||||
begin
|
|
||||||
TMonitor.Exit(ProfileList);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.GetCount: Integer;
|
function TProfileManager.GetCount: Integer;
|
||||||
begin
|
begin
|
||||||
Result := ProfileList.Count;
|
Result := Instance.Profiles.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TProfileManager.GetEnumerator: TProfileManagerEnumerator;
|
||||||
|
begin
|
||||||
|
Result := TProfileManagerEnumerator.Create(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TProfileManager.GetItem(Index: Integer): TProfile;
|
function TProfileManager.GetItem(Index: Integer): TProfile;
|
||||||
begin
|
begin
|
||||||
Result := ProfileList[Index];
|
Result := Profiles[Index];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -243,24 +242,26 @@ end;
|
|||||||
|
|
||||||
procedure TProfileManager.SetItem(Index: Integer; const Value: TProfile);
|
procedure TProfileManager.SetItem(Index: Integer; const Value: TProfile);
|
||||||
begin
|
begin
|
||||||
ProfileList[Index] := Value;
|
Profiles[Index] := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TLockedProfileList }
|
{ TProfileManagerEnumerator }
|
||||||
constructor TLockedProfileList.Create(AList: TProfileList);
|
constructor TProfileManagerEnumerator.Create(AManager: TProfileManager);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create(AManager.Profiles);
|
||||||
|
|
||||||
FList := AList;
|
FManager := AManager;
|
||||||
|
FManager.Lock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TLockedProfileList.GetEnumerator: TProfileList.TEnumerator;
|
destructor TProfileManagerEnumerator.Destroy;
|
||||||
begin
|
begin
|
||||||
Result := FList.GetEnumerator;
|
FManager.Unlock;
|
||||||
end;
|
|
||||||
|
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
finalization
|
finalization
|
||||||
|
Loading…
Reference in New Issue
Block a user