📄 eerdm.pas
字号:
procedure TDMEER.LoadWorkToolLabelTextsFromIniFile;
var theIni: TMemIniFile;
i: integer;
begin
//Read IniFile
theIni:=TMemIniFile.Create(DMMain.SettingsPath+DMMain.ProgName+'_Translations.ini');
try
theIni.ReadSectionValues('Worktool_Infos', WorkToolLabelTexts);
i:=0;
while(i<WorkToolLabelTexts.Count)do
begin
//Filter all strings in the wrong language
if(Copy(WorkToolLabelTexts[i], 1, 2)<>DMMain.GetLanguageCode)then
WorkToolLabelTexts.Delete(i)
else
begin
//keep only translation
WorkToolLabelTexts[i]:=WorkToolLabelTexts.ValueFromIndex[i];
inc(i);
end;
end;
finally
theIni.Free;
end;
end;
procedure TDMEER.LoadCursors;
var thepath: string;
begin
thepath:=ExtractFilePath(Application.ExeName)+'Gfx'+PathDelim+'Cursor'+PathDelim;
try
DMMain.LoadACursor(crMoveCursor, thepath+'Move.bmp',
thepath+'MoveMask.bmp', 0, 0);
DMMain.LoadACursor(crNewTableCursor, thepath+'newTable.bmp',
thepath+'newTableMask.bmp', 6, 3);
DMMain.LoadACursor(crRel1nCursor, thepath+'Rel1n.bmp',
thepath+'Rel1nMask.bmp', 0, 0);
DMMain.LoadACursor(crRel1nSubCursor, thepath+'Rel1nSub.bmp',
thepath+'Rel1nMask.bmp', 0, 0);
DMMain.LoadACursor(crRel11Cursor, thepath+'Rel11.bmp',
thepath+'Rel1nMask.bmp', 0, 0);
DMMain.LoadACursor(crRelnmCursor, thepath+'Relnm.bmp',
thepath+'Rel1nMask.bmp', 0, 0);
DMMain.LoadACursor(crRel11SubCursor, thepath+'Rel11Sub.bmp',
thepath+'Rel11SubMask.bmp', 0, 0);
DMMain.LoadACursor(crRel11NonIdCursor, thepath+'Rel11NonId.bmp',
thepath+'Rel11NonIdMask.bmp', 0, 0);
DMMain.LoadACursor(crNewRegionCursor, thepath+'newRegion.bmp',
thepath+'newRegionMask.bmp', 6, 3);
DMMain.LoadACursor(crNewNoteCursor, thepath+'newNote.bmp',
thepath+'newNoteMask.bmp', 6, 3);
DMMain.LoadACursor(crHandCursor, thepath+'Hand.bmp',
thepath+'HandMask.bmp', 8, 9);
DMMain.LoadACursor(crZoomInCursor, thepath+'ZoomIn.bmp',
thepath+'ZoomMask.bmp', 5, 5);
DMMain.LoadACursor(crZoomOutCursor, thepath+'ZoomOut.bmp',
thepath+'ZoomMask.bmp', 5, 5);
DMMain.LoadACursor(crSizeCursor, thepath+'Size.bmp',
thepath+'SizeMask.bmp', 0, 0);
DMMain.LoadACursor(crDeleteCursor, thepath+'Delete.bmp',
thepath+'DeleteMask.bmp', 0, 10);
DMMain.LoadACursor(crNewImageCursor, thepath+'newImage.bmp',
thepath+'newImageMask.bmp', 6, 3);
//SQL Cursors
DMMain.LoadACursor(crSQLSelectCursor, thepath+'SQLQuerySelect.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLFromCursor, thepath+'SQLQueryFrom.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLOnCursor, thepath+'SQLQueryOn.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLWhereCursor, thepath+'SQLQueryWhere.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLGroupCursor, thepath+'SQLQueryGroup.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLHavingCursor, thepath+'SQLQueryHaving.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLOrderCursor, thepath+'SQLQueryOrder.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crSQLSetCursor, thepath+'SQLQuerySet.bmp',
thepath+'SQLQueryMask.bmp', 0, 0);
DMMain.LoadACursor(crPlacementCursor, thepath+'newPlacement.bmp',
thepath+'newPlacementMask.bmp', 6, 3);
except
on x: Exception do
MessageDlg(DMMain.GetTranslatedMessage('ERROR: One of the Cursors could not be loaded. '#13#10+
'Please check the Gfx/Cursor directory.'#13#10'%s', 29, x.Message),
mtError, [mbOK], 0);
end;
end;
procedure TDMEER.LoadSettingsFromIniFile;
var theIni: TMemIniFile;
DefRegionColorsList: TStringList;
begin
DefRegionColorsList:=TStringList.Create;
try
//Read IniFile
theIni:=TMemIniFile.Create(DMMain.SettingsPath+DMMain.ProgName+'_Settings.ini');
try
//Read several Params
DisplayMode:=StrToInt(theIni.ReadString('GeneralSettings', 'DisplayMode',
'3'));
DisplayPhysicalSchema:=(StrToInt(theIni.ReadString('GeneralSettings', 'DisplayPhysicalSchema',
'1'))=1);
Notation:=StrToInt(theIni.ReadString('GeneralSettings', 'Notation',
'1'));
DisplayRelationNames:=(StrToInt(theIni.ReadString('GeneralSettings', 'DisplayRelationNames',
'0'))=1);
DisplayTableIndices:=(StrToInt(theIni.ReadString('GeneralSettings', 'DisplayTableIndices',
'0'))=1);
LimitUndoActions:=(StrToInt(theIni.ReadString('GeneralSettings', 'LimitUndoActions',
'0'))=1);
UndoActionLimit:=StrToInt(theIni.ReadString('GeneralSettings', 'UndoActionLimit',
'10'));
theIni.ReadSectionValues('RegionColors', DefRegionColorsList);
DefaultRegionColors:=DefRegionColorsList.Text;
if(theIni.ReadString('GeneralSettings', 'RunFirstTime', '0')='0')then
InitWorkMode:=StrToInt(theIni.ReadString('GeneralSettings', 'WorkMode', '0'));
TblHeaderBGImgs:=theIni.ReadString('GeneralSettings', 'TblHeaderBGImgs',
'XP1');
//TableNameInRefs Default
TableNameInRefs:=(StrToInt(theIni.ReadString('EditingSettings', 'TableNameInRefs',
'0'))=1);
//Position Grid Default
UsePositionGrid:=(StrToInt(theIni.ReadString('EditingSettings', 'UsePositionGrid',
'0'))=1);
PositionGrid.X:=StrToInt(theIni.ReadString('EditingSettings', 'PositionGridX',
'20'));
PositionGrid.Y:=StrToInt(theIni.ReadString('EditingSettings', 'PositionGridY',
'20'));
DefaultTableType:=StrToInt(theIni.ReadString('EditingSettings', 'DefaultTableType',
'0'));
ActivateRefDefForNewRelations:=(StrToInt(theIni.ReadString('EditingSettings', 'ActivateRefDefForNewRelations',
'0'))=1);
FKPrefix:=theIni.ReadString('EditingSettings', 'FKPrefix', '');
FKPostfix:=theIni.ReadString('EditingSettings', 'FKPostfix', '');
CreateFKRefDefIndex:=(StrToInt(theIni.ReadString('EditingSettings', 'CreateFKRefDefIndex', '0'))=1);
EncloseNames:=(StrToInt(theIni.ReadString('EditingSettings', 'EncloseNames',
'0'))=1);
RenameReservedWords:=(StrToInt(theIni.ReadString('EditingSettings', 'RenameReservedWords',
'1'))=1);
TableSplitterPos:=StrToInt(theIni.ReadString('EditingSettings', 'TableSplitterPos',
'172'));
DoNotUseRelNameInRefDef:=(StrToInt(theIni.ReadString('GeneralSettings', 'DoNotUseRelNameInRefDef',
'1'))=1);
UseNewXMLParser:=(StrToInt(theIni.ReadString('GeneralSettings', 'UseNewXMLParser',
'1'))=1);
SyncDatatypesOfForeignKeys:=(StrToInt(theIni.ReadString('GeneralSettings', 'SyncDatatypesOfForeignKeys', '1'))=1);
{$IFDEF LINUX}
OutputLinuxStyleLineBreaks:=(StrToInt(theIni.ReadString('GeneralSettings', 'OutputLinuxStyleLineBreaks', '1'))=1);
{$ELSE}
OutputLinuxStyleLineBreaks:=(StrToInt(theIni.ReadString('GeneralSettings', 'OutputLinuxStyleLineBreaks', '0'))=1);
{$ENDIF}
AddQuotesToDefVals:=(StrToInt(theIni.ReadString('GeneralSettings', 'AddQuotesToDefVals', '0'))=1);
finally
theIni.Free;
end;
finally
DefRegionColorsList.Free;
end;
end;
procedure TDMEER.SaveSettingsToIniFile;
var theIni: TMemIniFile;
DefRegionColorsList: TStringList;
i: integer;
begin
DefRegionColorsList:=TStringList.Create;
try
//Open IniFile
theIni:=TMemIniFile.Create(DMMain.SettingsPath+DMMain.ProgName+'_Settings.ini');
try
theIni.WriteString('GeneralSettings', 'DisplayMode', IntToStr(DisplayMode));
theIni.WriteString('GeneralSettings', 'DisplayPhysicalSchema', IntToStr(Ord(DisplayPhysicalSchema)));
theIni.WriteString('GeneralSettings', 'Notation', IntToStr(Notation));
theIni.WriteString('GeneralSettings', 'DisplayRelationNames', IntToStr(Ord(DisplayRelationNames)));
theIni.WriteString('GeneralSettings', 'DisplayTableIndices', IntToStr(Ord(DisplayTableIndices)));
theIni.WriteString('GeneralSettings', 'LimitUndoActions',
IntToStr(Ord(LimitUndoActions)));
theIni.WriteString('GeneralSettings', 'UndoActionLimit',
IntToStr(UndoActionLimit));
theIni.WriteString('GeneralSettings', 'WorkMode',
IntToStr(WorkMode));
theIni.WriteString('GeneralSettings', 'TblHeaderBGImgs',
TblHeaderBGImgs);
DefRegionColorsList.Text:=DefaultRegionColors;
theIni.EraseSection('RegionColors');
for i:=0 to DefRegionColorsList.Count-1 do
theIni.WriteString('RegionColors', DefRegionColorsList.Names[i],
Trim(DefRegionColorsList.ValueFromIndex[i]));
//TableNameInRefs Default
theIni.WriteString('EditingSettings', 'TableNameInRefs',
IntToStr(Ord(TableNameInRefs)));
//Position Grid Default
theIni.WriteString('EditingSettings', 'UsePositionGrid',
IntToStr(Ord(UsePositionGrid)));
theIni.WriteString('EditingSettings', 'PositionGridX',
IntToStr(PositionGrid.X));
theIni.WriteString('EditingSettings', 'PositionGridY',
IntToStr(PositionGrid.Y));
theIni.WriteString('EditingSettings', 'DefaultTableType',
IntToStr(DefaultTableType));
theIni.WriteString('EditingSettings', 'ActivateRefDefForNewRelations',
IntToStr(Ord(ActivateRefDefForNewRelations)));
theIni.WriteString('EditingSettings', 'FKPrefix',
FKPrefix);
theIni.WriteString('EditingSettings', 'FKPostfix',
FKPostfix);
theIni.WriteString('EditingSettings', 'CreateFKRefDefIndex',
IntToStr(Ord(CreateFKRefDefIndex)));
theIni.WriteString('EditingSettings', 'EncloseNames',
IntToStr(Ord(EncloseNames)));
theIni.WriteString('EditingSettings', 'RenameReservedWords',
IntToStr(Ord(RenameReservedWords)));
theIni.WriteString('EditingSettings', 'TableSplitterPos',
IntToStr(Ord(TableSplitterPos)));
theIni.WriteString('GeneralSettings', 'DoNotUseRelNameInRefDef',
IntToStr(Ord(DoNotUseRelNameInRefDef)));
theIni.WriteString('GeneralSettings', 'UseNewXMLParser',
IntToStr(Ord(UseNewXMLParser)));
theIni.WriteString('GeneralSettings', 'SyncDatatypesOfForeignKeys', IntToStr(Ord(SyncDatatypesOfForeignKeys)));
theIni.WriteString('GeneralSettings', 'OutputLinuxStyleLineBreaks', IntToStr(Ord(OutputLinuxStyleLineBreaks)));
theIni.WriteString('GeneralSettings', 'AddQuotesToDefVals', IntToStr(Ord(AddQuotesToDefVals)));
theIni.UpdateFile;
finally
theIni.Free;
end;
finally
DefRegionColorsList.Free;
end;
end;
procedure TDMEER.RefreshSavedImg;
begin
QApplication_postEvent(Application.MainForm.Handle, QCustomEvent_create(QEventType_SetSaveImgs, nil));
end;
function TDMEER.GetNextNonameNumber: String;
begin
inc(NonameCounter);
GetNextNonameNumber:=IntToStr(NonameCounter);
end;
function TDMEER.AssignNewIDsToEERObjects(themodel: string; shiftObjectPositions: Boolean): string;
var s, id, newid, SearchStr, OldPos, NewPos: string;
i: integer;
begin
//Assign new ids
s:=themodel;
while(Pos('ID="', s)>0)do
begin
//Get id
id:=Copy(s, Pos('ID="', s)+4, 25);
id:=Copy(id, 1, Pos('"', id)-1);
s:=DMMain.ReplaceText(s, 'ID="'+id+'"', 'XX="XX"');
//Replace with new id
newid:=IntToStr(DMMain.GetNextGlobalID);
themodel:=DMMain.ReplaceText(themodel, 'ID="'+id+'"', 'ID="'+newid+'"');
//for indices
themodel:=DMMain.ReplaceText(themodel, 'idColumn="'+id+'"', 'idColumn="'+newid+'"');
//for relations
themodel:=DMMain.ReplaceText(themodel, 'SrcTable="'+id+'"', 'SrcTable="'+newid+'"');
themodel:=DMMain.ReplaceText(themodel, 'DestTable="'+id+'"', 'DestTable="'+newid+'"');
end;
if(shiftObjectPositions)then
begin
//Translate X+40, Y+40
s:=themodel;
for i:=0 to 1 do
begin
if(i=0)then
SearchStr:='XPos'
else
SearchStr:='YPos';
while(Pos(SearchStr+'="', s)>0)do
begin
//Get id
OldPos:=Copy(s, Pos(SearchStr+'="', s)+6, 25);
OldPos:=Copy(OldPos, 1, Pos('"', OldPos)-1);
s:=DMMain.ReplaceText(s, SearchStr+'="'+OldPos+'"', 'XX="XX"');
//Replace with new Pos
NewPos:=IntToStr(StrToIntDef(OldPos, 0)+30);
themodel:=DMMain.ReplaceText(themodel, SearchStr+'="'+OldPos+'"', SearchStr+'="'+NewPos+'"');
end;
end;
end;
AssignNewIDsToEERObjects:=themodel;
end;
procedure TDMEER.CenterModel(theModel: TEERModel);
var i: integer;
m_left, m_top, m_right, m_bottom, move_x, move_y: integer;
begin
m_left:=theModel.EERModel_Width;
m_top:=theModel.EERModel_Height;
m_right:=0;
m_bottom:=0;
for i:=0 to theModel.ComponentCount-1 do
if(theModel.Components[i].ClassParent=TEERObj)then
begin
//Get model left/top/right/bottom
if(TEERObj(theModel.Components[i]).Obj_X<m_left)then
m_left:=TEERObj(theModel.Components[i]).Obj_X;
if(TEERObj(theModel.Components[i]).Obj_Y<m_top)then
m_top:=TEERObj(theModel.Components[i]).Obj_Y;
if(TEERObj(theModel.Components[i]).Obj_X+
TEERObj(theModel.Components[i]).Obj_W>m_right)then
m_right:=TEERObj(theModel.Components[i]).Obj_X+
TEERObj(theModel.Components[i]).Obj_W;
if(TEERObj(theModel.Components[i]).Obj_Y+
TEERObj(theModel.Components[i]).Obj_H>m_bottom)then
m_bottom:=TEERObj(theModel.Components[i]).Obj_Y+
TEERObj(theModel.Components[i]).Obj_H;
end;
//If there is at least one object
if(m_right>0)then
begin
move_x:=(theModel.EERModel_Width-
(m_right-m_left)) div 2;
move_y:=(theModel.EERModel_Height-
(m_bottom-m_top)) div 2;
//Log move action
theModel.StartSubActionLog(at_MoveObj);
for i:=0 to theModel.ComponentCount-1 do
if(theModel.Components[i].ClassParent=TEERObj)then
begin
with TEERObj(theModel.Components[i]) do
begin
ParentEERModel.LogSubAction(sa_MoveFrom, Obj_id,
'Obj_X='+IntToStr(Obj_X)+#13#10+'Obj_Y='+IntToStr(Obj_Y));
Obj_X:=Obj_X+move_x;
Obj_Y:=Obj_Y+move_y;
//Log Move
ParentEERModel.LogSubAction(sa_MoveTo, Obj_id,
'Obj_X='+IntToStr(Obj_X)+#13#10+'Obj_Y='+IntToStr(Obj_Y));
RefreshObj;
end;
end;
//Close Log
theModel.EndSubAction;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -