Introduce TConnectionParameters.SessionColor property to hold the tree background color, and use that to paint the background of relevant nodes only, instead of the whole tree. See http://www.heidisql.com/forum.php?t=10133

This commit is contained in:
Ansgar Becker
2012-04-22 08:40:30 +00:00
parent af747da0b6
commit 1b5285bb0e
2 changed files with 10 additions and 6 deletions

View File

@ -4,7 +4,7 @@ interface
uses
Classes, SysUtils, windows, mysql_structures, SynRegExpr, Contnrs, Generics.Collections, Generics.Defaults,
DateUtils, Types, ShellApi, Math, Dialogs, ADODB, DB, DBCommon, ComObj;
DateUtils, Types, ShellApi, Math, Dialogs, ADODB, DB, DBCommon, ComObj, Graphics;
type
@ -157,6 +157,7 @@ type
FSSHHost, FSSHUser, FSSHPassword, FSSHPlinkExe, FSSHPrivateKey: String;
FPort, FSSHPort, FSSHLocalPort, FSSHTimeout: Integer;
FLoginPrompt, FCompressed, FWindowsAuth, FWantSSL: Boolean;
FSessionColor: TColor;
function GetImageIndex: Integer;
public
constructor Create;
@ -176,6 +177,7 @@ type
property NetTypeGroup: TNetTypeGroup read GetNetTypeGroup;
property ServerVersion: String read FServerVersion write FServerVersion;
property SessionName: String read FSessionName write FSessionName;
property SessionColor: TColor read FSessionColor write FSessionColor;
property Hostname: String read FHostname write FHostname;
property Port: Integer read FPort write FPort;
property Username: String read FUsername write FUsername;
@ -744,6 +746,7 @@ begin
else begin
Result := TConnectionParameters.Create;
Result.SessionName := Session;
Result.SessionColor := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, Session);
Result.NetType := TNetType(GetRegValue(REGNAME_NETTYPE, Integer(ntMySQL_TCPIP), Session));
Result.Hostname := GetRegValue(REGNAME_HOST, '', Session);
Result.Username := GetRegValue(REGNAME_USER, '', Session);

View File

@ -4132,7 +4132,7 @@ var
begin
// Select database tree background color
cs := TColorSelect.Create(Self);
cs.Dialog.Color := DBtree.Color;
cs.Dialog.Color := ActiveConnection.Parameters.SessionColor;
// Add custom colors from all sessions
SessionNames := TStringList.Create;
MainReg.OpenKey(RegPath + REGKEY_SESSIONS, True);
@ -4151,7 +4151,7 @@ begin
end;
end;
if cs.Execute then begin
DBtree.Color := cs.Dialog.Color;
ActiveConnection.Parameters.SessionColor := cs.Dialog.Color;
OpenRegistry(ActiveConnection.Parameters.SessionName);
MainReg.WriteInteger(REGNAME_TREEBACKGROUND, cs.Dialog.Color);
end;
@ -7206,7 +7206,6 @@ begin
// When clicked node is from a different connection than before, do session specific stuff here:
if (PrevDBObj = nil) or (PrevDBObj.Connection <> FActiveDbObj.Connection) then begin
LogSQL('Entering session "'+FActiveDbObj.Connection.Parameters.SessionName+'"', lcInfo);
DBTree.Color := GetRegValue(REGNAME_TREEBACKGROUND, clWindow, FActiveDbObj.Connection.Parameters.SessionName);
RefreshHelperNode(HELPERNODE_HISTORY);
case FActiveDbObj.Connection.Parameters.NetTypeGroup of
ngMySQL:
@ -9837,9 +9836,11 @@ var
DBObj: PDBObject;
AllObjects: TDBObjectList;
begin
if (CellPaintMode=cpmPaint) and (Column=1) then begin
if CellPaintMode=cpmPaint then begin
DBObj := Sender.GetNodeData(Node);
if DBObj.Connection.DbObjectsCached(DBObj.Database) then begin
TargetCanvas.Brush.Color := DbObj.Connection.Parameters.SessionColor;
TargetCanvas.FillRect(CellRect);
if (Column=1) and DBObj.Connection.DbObjectsCached(DBObj.Database) then begin
AllObjects := DBObj.Connection.GetDBObjects(DBObj.Database);
PaintColorBar(DBObj.Size, AllObjects.LargestObjectSize, TargetCanvas, CellRect);
end;