From bd5ffd8362be9fcfb5822b1a8abe23249546567a Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 5 Feb 2012 12:19:05 +0000 Subject: [PATCH] Show used colors from other sessions in color picker as favorite colors. Fixes issue #2704. --- source/main.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/main.pas b/source/main.pas index 3d6b99a9..67a75b32 100644 --- a/source/main.pas +++ b/source/main.pas @@ -3882,10 +3882,28 @@ end; procedure TMainForm.actSelectTreeBackgroundExecute(Sender: TObject); var cs: TColorSelect; + SessionNames: TStringList; + i: Integer; + Col: Integer; + CharPostfix: Char; begin // Select database tree background color cs := TColorSelect.Create(Self); cs.Dialog.Color := DBtree.Color; + // Add custom colors from all sessions + SessionNames := TStringList.Create; + MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True); + MainReg.GetKeyNames(SessionNames); + CharPostfix := 'A'; + for i:=0 to SessionNames.Count-1 do begin + Col := GetRegValue(REGNAME_TREEBACKGROUND, clWhite, SessionNames[i]); + if Col <> clWhite then begin + cs.Dialog.CustomColors.Add('Color'+CharPostfix+'='+Copy(ColorToString(Col),4,8)); + if CharPostFix = 'P' then + break; + CharPostfix := Chr(Ord(CharPostfix)+1); + end; + end; if cs.Execute then begin DBtree.Color := cs.Dialog.Color; OpenRegistry(ActiveConnection.Parameters.SessionName);