1 Star 0 Fork 39

hypcfan/ezdml

forked from huzgd/ezdml 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
wSettings.pas 33.50 KB
一键复制 编辑 原始数据 按行查看 历史
huzgd 提交于 2022-08-01 21:16 . v3.42 hive support
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
unit wSettings;
{$mode delphi}
{
Settings
--------------------------------------
AutoSaveMinutes Integer
SaveTempFileOnExit Bool
HugeModeTableCount Integer
MaxRowCountForTableData Integer
LogicNamesForTableData Bool
CreateSeqForOracle Bool
OCILIB String
NLSLang String
MYSQLLIB String
POSTGRESLIB String
SQLSERVERLIB String
UseOdbcDriverForMsSql Bool
SQLITELIB String
QuotReservedNames Bool
QuotAllNames Bool
BackupBeforeAlterColumn Bool
WriteConstraintToDescribeStr Bool
FieldGridShowLines Bool
AddColCommentToCreateTbSql Bool
CreateForeignkeys Bool
CreateIndexForForeignkey Bool
HiveVersion Integer
EnableCustomPropUI Bool
CustomPropUICaption String
EnableAdvTbProp Bool
EnableTbPropGenerate Bool
EnableTbPropData Bool
EnableTbPropUIDesign Bool
LANG String
AppDefFontName String
AppDefFontSize Integer
AppFixWidthFontName String
AppFixWidthFontSize Integer
DmlGraphFontName String
FieldNameMaxDrawSize Integer
FieldTypeMaxDrawSize Integer
TableFieldMaxDrawCount Integer
TableDialogViewModeByDefault Bool
}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
ComCtrls, uFrameCustPhyFieldTypes;
type
{ TfrmSettings }
TfrmSettings = class(TForm)
Bevel1: TBevel;
Bevel10: TBevel;
Bevel11: TBevel;
Bevel12: TBevel;
Bevel13: TBevel;
Bevel14: TBevel;
Bevel15: TBevel;
Bevel16: TBevel;
Bevel17: TBevel;
Bevel18: TBevel;
Bevel19: TBevel;
Bevel6: TBevel;
Bevel7: TBevel;
BevelGen1: TBevel;
Bevel3: TBevel;
Bevel4: TBevel;
Bevel5: TBevel;
Bevel8: TBevel;
Bevel9: TBevel;
BevelGen2: TBevel;
btnCancel: TButton;
btnOk: TButton;
btnOracleLibBrs: TButton;
btnMysqlLibBrs: TButton;
btnPostgreLibBrs: TButton;
btnSqlServerLibBrs: TButton;
btnSqliteLibBrs: TButton;
btnCustFldtpNew: TButton;
btnCustFldtpRemove: TButton;
btnTpnRepNew: TButton;
btnFDGenNew: TButton;
btnTpnRepRemove: TButton;
btnFDGenRemove: TButton;
ckbBigIntForIntKeys: TCheckBox;
ckbCheckForUpdates: TCheckBox;
ckbCreateForeignkeys: TCheckBox;
ckbEnableAdvTbProp: TCheckBox;
ckbEnableTbPropRelations: TCheckBox;
ckbEnableCustomPropUI: TCheckBox;
ckbEnableTbPropData: TCheckBox;
ckbEnableTbPropGenerate: TCheckBox;
ckbEnableTbPropUIDesign: TCheckBox;
ckbUseOdbcDriverForMsSql: TCheckBox;
ckbAddColCommentToCreateTbSql: TCheckBox;
ckbCreateSeqForOracle: TCheckBox;
ckbCreateIndexForForeignkey: TCheckBox;
ckbTableDialogViewModeByDefault: TCheckBox;
ckbQuotAllNames: TCheckBox;
ckbSaveTempFileOnExit: TCheckBox;
ckbWriteConstraintToDescribeStr: TCheckBox;
ckbLogicNamesForTableData: TCheckBox;
ckbQuotReservedNames: TCheckBox;
ckbBackupBeforeAlterColumn: TCheckBox;
ckbFieldGridShowLines: TCheckBox;
combLANG: TComboBox;
combNLSLang: TComboBox;
combHiveVersion: TComboBox;
edtCustFldtpName: TEdit;
edtCustFldtpPhyType: TEdit;
edtCustomPropUICaption: TEdit;
edtScreenDpi: TEdit;
edtPOSTGRESLIB: TComboBox;
edtFDGenNames: TEdit;
edtTpnRepPattern: TEdit;
edtTpnReplacement: TEdit;
edtAppDefFontName: TComboBox;
edtAppDefFontSize: TEdit;
edtAppFixWidthFontName: TComboBox;
edtAppFixWidthFontSize: TEdit;
edtAutoSaveMinutes: TEdit;
edtDmlGraphFontName: TComboBox;
edtFieldNameMaxDrawSize: TEdit;
edtFieldTypeMaxDrawSize: TEdit;
edtHugeModeTableCount: TEdit;
edtMYSQLLIB: TComboBox;
edtSQLSERVERLIB: TComboBox;
edtSQLITELIB: TComboBox;
edtMaxRowCountForTableData: TEdit;
edtOCILIB: TComboBox;
edtTableFieldMaxDrawCount: TEdit;
edtFDGenRule: TEdit;
GroupBoxHiveSQL: TGroupBox;
GroupBoxTbTabs: TGroupBox;
GroupBoxDBConnPostgre: TGroupBox;
GroupBoxKnownTbPrefix: TGroupBox;
GroupBoxCustDict: TGroupBox;
GroupBoxSysFldTypes: TGroupBox;
GroupBoxCustomFldTypes: TGroupBox;
GroupBoxTpNameReplaces: TGroupBox;
GroupBoxDispDmlGraph: TGroupBox;
GroupBoxMonoFont: TGroupBox;
GroupBoxAutoSave: TGroupBox;
GroupBoxDBConnMysql: TGroupBox;
GroupBoxDBConnSqlServer: TGroupBox;
GroupBoxDBConnSqlite: TGroupBox;
GroupBoxHugeMode: TGroupBox;
GroupBoxTableDataSQL: TGroupBox;
GroupBoxDBConnOracle: TGroupBox;
GroupBoxFieldDataGenRules: TGroupBox;
GroupBoxUI: TGroupBox;
GroupBoxSQLGen: TGroupBox;
GroupBoxOthersTb: TGroupBox;
GroupBoxBaseFont: TGroupBox;
Label1: TLabel;
lbNLSLang: TLabel;
lbScreenDpiInfo: TLabel;
lbKnownTbPrefixTip: TLabel;
LabelLayoutSpacer1: TLabel;
lbCustFldtpName: TLabel;
lbCustFldtpPhyType: TLabel;
lbCustPhyTpTip: TLabel;
lbAutoSaveTip: TLabel;
lbDispFontNote: TLabel;
lbCustDictTip: TLabel;
lbPostgreLib: TLabel;
lbHiveVersion: TLabel;
lbTpnReplacement1: TLabel;
lbTpnReplaceTip: TLabel;
lbDBConnNote1: TLabel;
lbFDGenTip: TLabel;
lbTpnRepPattern: TLabel;
lbTpnReplacement: TLabel;
lbCustFldtpTip: TLabel;
lbDBConnNote: TLabel;
LabelLayoutSpacer: TLabel;
lbAutoSaveMinutes: TLabel;
lbTableDataPreviewRows: TLabel;
lbDmlMaxFieldNameSize: TLabel;
lbDmlMaxFieldTypeSize: TLabel;
lbMysqlLib: TLabel;
lbSqlServerLib: TLabel;
lbSqliteLib: TLabel;
lbOciLib: TLabel;
lbMonoFontSize: TLabel;
lbMonoFontName: TLabel;
lbDmlFontName: TLabel;
lbDmlMaxTbFieldCount: TLabel;
lbLanguage: TLabel;
lbBaseFontName: TLabel;
lbBaseFontSize: TLabel;
lbAutoSaveMinutesTail: TLabel;
lbLanguageTip: TLabel;
lbHugeModeTableCount: TLabel;
lbHugeModeTableCountTip: TLabel;
lbTpnRepPattern1: TLabel;
ListBoxDefPhyTypes: TListBox;
ListBoxCustFldTps: TListBox;
ListBoxTpNameReplaces: TListBox;
ListBoxFDGenRules: TListBox;
MemoKnownTbPrefixs: TMemo;
MemoCustDict: TMemo;
OpenDialogDbLib: TOpenDialog;
PageControlMain: TPageControl;
Panel1: TPanel;
PanelPhyCustTps: TPanel;
PanelFieldTypes: TPanel;
PanelGen1: TPanel;
PanelSQL: TPanel;
PanelDBConn: TPanel;
PanelOthers: TPanel;
PanelDisp: TPanel;
ScrollBoxFieldTypes: TScrollBox;
tabshtFieldTypes: TTabSheet;
tabshtOthers: TTabSheet;
tabshtConnection: TTabSheet;
tabshtSQL: TTabSheet;
tabshtDisplay: TTabSheet;
tabshtGeneral: TTabSheet;
procedure btnCustFldtpNewClick(Sender: TObject);
procedure btnCustFldtpRemoveClick(Sender: TObject);
procedure btnFDGenNewClick(Sender: TObject);
procedure btnFDGenRemoveClick(Sender: TObject);
procedure btnMysqlLibBrsClick(Sender: TObject);
procedure btnOracleLibBrsClick(Sender: TObject);
procedure btnPostgreLibBrsClick(Sender: TObject);
procedure btnSqliteLibBrsClick(Sender: TObject);
procedure btnSqlServerLibBrsClick(Sender: TObject);
procedure btnTpnRepNewClick(Sender: TObject);
procedure btnTpnRepRemoveClick(Sender: TObject);
procedure ckbEnableCustomPropUIChange(Sender: TObject);
procedure edtCustFldtpNameChange(Sender: TObject);
procedure edtFDGenRuleChange(Sender: TObject);
procedure edtTpnRepPatternChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListBoxCustFldTpsClick(Sender: TObject);
procedure ListBoxFDGenRulesClick(Sender: TObject);
procedure ListBoxTpNameReplacesClick(Sender: TObject);
private
FCheckForUpdates: boolean;
FAutoSaveMinutes: integer;
FSaveTempFileOnExit: boolean;
FHugeModeTableCount: integer;
FMaxRowCountForTableData: integer;
FLogicNamesForTableData: boolean;
FCreateSeqForOracle: boolean;
FOCILIB: string;
FNLSLang: string;
FMYSQLLIB: string;
FSQLSERVERLIB: string;
FPOSTGRESLIB: string;
FSQLITELIB: string;
FBigIntForIntKeys: boolean;
FQuotReservedNames: boolean;
FQuotAllNames: boolean;
FBackupBeforeAlterColumn: boolean;
FWriteConstraintToDescribeStr: boolean;
FFieldGridShowLines :Boolean;
FAddColCommentToCreateTbSql: boolean;
FCreateForeignkeys: boolean;
FCreateIndexForForeignkey: boolean;
FHiveVersion: Integer;
FEnableCustomPropUI: boolean;
FCustomPropUICaption : String;
FEnableAdvTbProp: boolean;
FEnableTbPropRelations: boolean;
FEnableTbPropGenerate: boolean;
FEnableTbPropData: boolean;
FEnableTbPropUIDesign: boolean;
FUseOdbcDriverForMsSql: boolean;
FLANG: string;
FAppDefFontName: string;
FAppDefFontSize: integer;
FAppFixWidthFontName: string;
FAppFixWidthFontSize: integer;
FDmlGraphFontName: string;
FFieldNameMaxDrawSize: integer;
FFieldTypeMaxDrawSize: integer;
FTableFieldMaxDrawCount: integer;
FTableDialogViewModeByDefault : Boolean;
FFrameCustPhyFieldTypes: TFrameCustPhyFieldTypes;
FIsInitingFt: boolean;
procedure BrowseLibFile(AEdit: TComboBox; ALibName1, ALibName2: string);
procedure CheckCustFieldEditors;
public
procedure LoadSetting;
procedure SaveSetting;
procedure InitEditors;
end;
function ShowEzdmlSettings: boolean;
implementation
uses
WindowFuncs, IniFiles, CtMetaTable, AutoNameCapitalize, dmlstrs, postgres3dyn,
ocidyn, mysql57dyn, mssqlconn, dblib, sqlite3dyn, CtMetaCustomDb;
{$R *.lfm}
function ShowEzdmlSettings: boolean;
var
frm: TfrmSettings;
begin
Result := False;
frm := TfrmSettings.Create(Application.MainForm);
try
frm.LoadSetting;
if frm.ShowModal = mrOk then
begin
frm.SaveSetting;
Result := True;
end;
finally
frm.Free;
end;
end;
{ TfrmSettings }
procedure TfrmSettings.FormShow(Sender: TObject);
begin
btnOk.Left := btnCancel.Left - btnOk.Width - 10;
edtCustomPropUICaption.Left:=ckbEnableCustomPropUI.Left+ckbEnableCustomPropUI.Width+12;
end;
procedure TfrmSettings.ListBoxCustFldTpsClick(Sender: TObject);
var
I, po: integer;
S, V: string;
begin
I := ListBoxCustFldTps.ItemIndex;
if I < 0 then
S := ''
else
S := ListBoxCustFldTps.Items[I];
V := '';
po := Pos(':', S);
if po > 0 then
begin
V := Copy(S, po + 1, Length(S));
S := Copy(S, 1, po - 1);
end;
FIsInitingFt := True;
edtCustFldtpName.Text := S;
edtCustFldtpPhyType.Text := V;
FIsInitingFt := False;
CheckCustFieldEditors;
end;
procedure TfrmSettings.ListBoxFDGenRulesClick(Sender: TObject);
var
I, po: integer;
S, V: string;
begin
I := ListBoxFDGenRules.ItemIndex;
if I < 0 then
S := ''
else
S := ListBoxFDGenRules.Items[I];
V := '';
po := Pos(':', S);
if po > 0 then
begin
V := Copy(S, po + 1, Length(S));
S := Copy(S, 1, po - 1);
end;
FIsInitingFt := True;
edtFDGenRule.Text := S;
edtFDGenNames.Text := V;
FIsInitingFt := False;
CheckCustFieldEditors;
end;
procedure TfrmSettings.ListBoxTpNameReplacesClick(Sender: TObject);
var
I, po: integer;
S, V: string;
begin
I := ListBoxTpNameReplaces.ItemIndex;
if I < 0 then
S := ''
else
S := ListBoxTpNameReplaces.Items[I];
V := '';
po := Pos(':', S);
if po > 0 then
begin
V := Copy(S, po + 1, Length(S));
S := Copy(S, 1, po - 1);
end;
FIsInitingFt := True;
edtTpnRepPattern.Text := S;
edtTpnReplacement.Text := V;
FIsInitingFt := False;
CheckCustFieldEditors;
end;
procedure TfrmSettings.BrowseLibFile(AEdit: TComboBox; ALibName1, ALibName2: string
);
var
S: string;
begin
if AEdit = nil then
Exit;
if ALibName2 = ALibName1 then
ALibName2 := '';
S := '';
if ALibName1 <> '' then
S := ALibName1 + '|' + ALibName1;
if ALibName2 <> '' then
S := S + '|' + ALibName2 + '|' + ALibName2;
if S <> '' then
S := S + '|';
S := S + 'All files(*.*)|*.*';
with OpenDialogDbLib do
begin
Filter := S;
FileName := AEdit.Text;
if Execute then
AEdit.Text := FileName;
end;
end;
procedure TfrmSettings.CheckCustFieldEditors;
var
bSelA, bSelC, bSelD: Boolean;
begin
bSelA := ListBoxCustFldTps.ItemIndex >= 0;
bSelC := ListBoxTpNameReplaces.ItemIndex >= 0;
bSelD := ListBoxFDGenRules.ItemIndex >= 0;
edtCustFldtpName.Enabled := bSelA;
edtCustFldtpPhyType.Enabled := bSelA;
btnCustFldtpRemove.Enabled := bSelA;
edtTpnRepPattern.Enabled := bSelC;
edtTpnReplacement.Enabled := bSelC;
btnTpnRepRemove.Enabled := bSelC;
edtFDGenRule.Enabled := bSelD;
edtFDGenNames.Enabled := bSelD;
btnFDGenRemove.Enabled := bSelD;
end;
procedure TfrmSettings.FormCreate(Sender: TObject);
begin
PageControlMain.ActivePageIndex := 0;
FFrameCustPhyFieldTypes := TFrameCustPhyFieldTypes.Create(Self);
with FFrameCustPhyFieldTypes do
begin
Parent := PanelPhyCustTps;
Align := alClient;
end;
end;
procedure TfrmSettings.btnOracleLibBrsClick(Sender: TObject);
begin
BrowseLibFile(edtOCILIB, ocilib, 'dmoci.dll');
end;
procedure TfrmSettings.btnPostgreLibBrsClick(Sender: TObject);
begin
BrowseLibFile(edtPOSTGRESLIB, pqlib, '');
end;
procedure TfrmSettings.btnSqliteLibBrsClick(Sender: TObject);
begin
BrowseLibFile(edtSQLITELIB, Sqlite3Lib, '');
end;
procedure TfrmSettings.btnSqlServerLibBrsClick(Sender: TObject);
begin
BrowseLibFile(edtSQLSERVERLIB, DBLIBDLL, '');
end;
procedure TfrmSettings.btnTpnRepNewClick(Sender: TObject);
var
S: string;
begin
S := Trim(InputBox(srNewFieldTypeItemTitle, srNewFieldTypeItemPrompt, ''));
if S <> '' then
begin
ListBoxTpNameReplaces.ItemIndex := ListBoxTpNameReplaces.Items.Add(S);
ListBoxTpNameReplacesClick(nil);
end;
end;
procedure TfrmSettings.btnTpnRepRemoveClick(Sender: TObject);
var
I: integer;
begin
I := ListBoxTpNameReplaces.ItemIndex;
if I >= 0 then
begin
ListBoxTpNameReplaces.Items.Delete(I);
if I > ListBoxTpNameReplaces.Items.Count - 1 then
I := ListBoxTpNameReplaces.Items.Count - 1;
if I >= 0 then
ListBoxTpNameReplaces.ItemIndex := I;
ListBoxTpNameReplacesClick(nil);
end;
end;
procedure TfrmSettings.ckbEnableCustomPropUIChange(Sender: TObject);
begin
edtCustomPropUICaption.Visible:=ckbEnableCustomPropUI.Checked;
end;
procedure TfrmSettings.edtCustFldtpNameChange(Sender: TObject);
var
I: integer;
S, V: string;
begin
if FIsInitingFt then
Exit;
I := ListBoxCustFldTps.ItemIndex;
if I < 0 then
Exit;
S := Trim(edtCustFldtpName.Text);
if S = '' then
Exit;
V := Trim(edtCustFldtpPhyType.Text);
if V <> '' then
S := S + ':' + V;
ListBoxCustFldTps.Items[I] := S;
end;
procedure TfrmSettings.edtFDGenRuleChange(Sender: TObject);
var
I: integer;
S, V: string;
begin
if FIsInitingFt then
Exit;
I := ListBoxFDGenRules.ItemIndex;
if I < 0 then
Exit;
S := Trim(edtFDGenRule.Text);
if S = '' then
Exit;
V := Trim(edtFDGenNames.Text);
if V <> '' then
S := S + ':' + V;
ListBoxFDGenRules.Items[I] := S;
end;
procedure TfrmSettings.edtTpnRepPatternChange(Sender: TObject);
var
I: integer;
S, V: string;
begin
if FIsInitingFt then
Exit;
I := ListBoxTpNameReplaces.ItemIndex;
if I < 0 then
Exit;
S := Trim(edtTpnRepPattern.Text);
if S = '' then
Exit;
V := Trim(edtTpnReplacement.Text);
if V <> '' then
S := S + ':' + V;
ListBoxTpNameReplaces.Items[I] := S;
end;
procedure TfrmSettings.btnMysqlLibBrsClick(Sender: TObject);
begin
BrowseLibFile(edtMYSQLLIB, mysqllib, mysqlvlib);
end;
procedure TfrmSettings.btnCustFldtpNewClick(Sender: TObject);
var
S: string;
begin
S := Trim(InputBox(srNewFieldTypeItemTitle, srNewFieldTypeItemPrompt, ''));
if S <> '' then
begin
ListBoxCustFldTps.ItemIndex := ListBoxCustFldTps.Items.Add(S);
ListBoxCustFldTpsClick(nil);
end;
end;
procedure TfrmSettings.btnCustFldtpRemoveClick(Sender: TObject);
var
I: integer;
begin
I := ListBoxCustFldTps.ItemIndex;
if I >= 0 then
begin
ListBoxCustFldTps.Items.Delete(I);
if I > ListBoxCustFldTps.Items.Count - 1 then
I := ListBoxCustFldTps.Items.Count - 1;
if I >= 0 then
ListBoxCustFldTps.ItemIndex := I;
ListBoxCustFldTpsClick(nil);
end;
end;
procedure TfrmSettings.btnFDGenNewClick(Sender: TObject);
var
S: string;
begin
S := Trim(InputBox(srNewFieldTypeItemTitle, srNewFieldTypeItemPrompt, ''));
if S <> '' then
begin
ListBoxFDGenRules.ItemIndex := ListBoxFDGenRules.Items.Add(S);
ListBoxFDGenRulesClick(nil);
end;
end;
procedure TfrmSettings.btnFDGenRemoveClick(Sender: TObject);
var
I: integer;
begin
I := ListBoxFDGenRules.ItemIndex;
if I >= 0 then
begin
ListBoxFDGenRules.Items.Delete(I);
if I > ListBoxFDGenRules.Items.Count - 1 then
I := ListBoxFDGenRules.Items.Count - 1;
if I >= 0 then
ListBoxFDGenRules.ItemIndex := I;
ListBoxFDGenRulesClick(nil);
end;
end;
procedure TfrmSettings.LoadSetting;
procedure LoadFtList(AList: TStrings; ini: TIniFile; ASec: string);
var
I: integer;
S: string;
begin
I := 0;
AList.Clear;
while True do
begin
Inc(I);
S := Trim(ini.ReadString(ASec, IntToStr(I), ''));
if S = '' then
Break;
AList.Add(S);
end;
end;
procedure LoadCustDict;
var
S, fn: string;
begin
MemoCustDict.Lines.Clear;
fn := 'MyDict.txt';
S := GetFolderPathOfAppExe;
S := FolderAddFileName(S, fn);
if FileExists(S) then
MemoCustDict.Lines.LoadFromFile(S);
MemoCustDict.Modified := False;
end;
var
ini: TIniFile;
S: string;
procedure LoadComboHist(Combo: TComboBox; dbType: string);
begin
LoadFtList(Combo.Items, Ini, 'DbLibHist_'+dbType);
end;
begin
InitEditors;
S := GetAppDefTempPath;
if not DirectoryExists(S) then
ForceDirectories(S);
ini := TIniFile.Create(GetConfFileOfApp);
try
LoadComboHist(edtOCILIB, 'ORACLE');
LoadComboHist(edtMYSQLLIB, 'MYSQL');
LoadComboHist(edtPOSTGRESLIB, 'POSTGRESQL');
LoadComboHist(edtSQLSERVERLIB, 'SQLSERVER');
LoadComboHist(edtSQLITELIB, 'SQLITE');
//{1} := ini.Read{3}('Options', '{1}', F{1});
FCheckForUpdates := ini.ReadBool('Options', 'CheckForUpdates',
True);
FAutoSaveMinutes := ini.ReadInteger('Options', 'AutoSaveMinutes', 5);
FSaveTempFileOnExit := ini.ReadBool('Options', 'SaveTempFileOnExit',
True);
FHugeModeTableCount := ini.ReadInteger('Options', 'HugeModeTableCount',
500);
FMaxRowCountForTableData := ini.ReadInteger('Options', 'MaxRowCountForTableData',
25);
FLogicNamesForTableData := ini.ReadBool('Options', 'LogicNamesForTableData',
False);
FCreateSeqForOracle := ini.ReadBool('Options', 'CreateSeqForOracle',
False);
FOCILIB := ini.ReadString('Options', 'OCILIB', '');
if FOCILIB = '' then
FOCILIB := ini.ReadString('Options', 'OCIDLL', '');
FNLSLang := ini.ReadString('Options', 'NLSLang', '');
FMYSQLLIB := ini.ReadString('Options', 'MYSQLLIB', FMYSQLLIB);
FSQLSERVERLIB := ini.ReadString('Options', 'SQLSERVERLIB', FSQLSERVERLIB);
FUseOdbcDriverForMsSql := ini.ReadBool('Options', 'UseOdbcDriverForMsSql',
False);
FPOSTGRESLIB := ini.ReadString('Options', 'POSTGRESLIB', FPOSTGRESLIB);
FSQLITELIB := ini.ReadString('Options', 'SQLITELIB', FSQLITELIB);
FBigIntForIntKeys := ini.ReadBool('Options', 'BigIntForIntKeys',
False);
FQuotReservedNames := ini.ReadBool('Options', 'QuotReservedNames',
False);
FQuotAllNames := ini.ReadBool('Options', 'QuotAllNames',
False);
FBackupBeforeAlterColumn := ini.ReadBool('Options', 'BackupBeforeAlterColumn',
False);
FWriteConstraintToDescribeStr :=
ini.ReadBool('Options', 'WriteConstraintToDescribeStr',
True);
FFieldGridShowLines :=
ini.ReadBool('Options', 'FieldGridShowLines',
True);
FAddColCommentToCreateTbSql :=
ini.ReadBool('Options', 'AddColCommentToCreateTbSql', True);
FCreateForeignkeys :=
ini.ReadBool('Options', 'CreateForeignkeys', True);
FCreateIndexForForeignkey :=
ini.ReadBool('Options', 'CreateIndexForForeignkey', False);
FHiveVersion :=
ini.ReadInteger('Options', 'HiveVersion', 2);
FEnableCustomPropUI := ini.ReadBool('Options', 'EnableCustomPropUI',
False);
FCustomPropUICaption := ini.ReadString('Options', 'CustomPropUICaption', '');
FEnableAdvTbProp := ini.ReadBool('Options', 'EnableAdvTbProp',
False);
FEnableTbPropRelations := ini.ReadBool('Options', 'EnableTbPropRelations',
True);
FEnableTbPropGenerate := ini.ReadBool('Options', 'EnableTbPropGenerate',
True);
FEnableTbPropData := ini.ReadBool('Options', 'EnableTbPropData',
False);
FEnableTbPropUIDesign := ini.ReadBool('Options', 'EnableTbPropUIDesign',
False);
FLANG := ini.ReadString('Options', 'LANG', '');
FAppDefFontName := ini.ReadString('Options', 'AppDefFontName', '');
FAppDefFontSize := ini.ReadInteger('Options', 'AppDefFontSize', 0);
FAppFixWidthFontName := ini.ReadString('Options', 'AppFixWidthFontName',
'');
FAppFixWidthFontSize := ini.ReadInteger('Options', 'AppFixWidthFontSize',
0);
FDmlGraphFontName := ini.ReadString('Options', 'DmlGraphFontName',
'');
FFieldNameMaxDrawSize := ini.ReadInteger('Options', 'FieldNameMaxDrawSize',
64);
FFieldTypeMaxDrawSize := ini.ReadInteger('Options', 'FieldTypeMaxDrawSize',
48);
FTableFieldMaxDrawCount := ini.ReadInteger('Options', 'TableFieldMaxDrawCount',
50);
FTableDialogViewModeByDefault :=
ini.ReadBool('Options', 'TableDialogViewModeByDefault',
False);
LoadFtList(ListBoxCustFldTps.Items, Ini, 'CustFieldTypes');
LoadFtList(ListBoxDefPhyTypes.Items, Ini, 'DefaultFieldTypes');
FFrameCustPhyFieldTypes.Load(ListBoxDefPhyTypes.Items);
LoadFtList(ListBoxTpNameReplaces.Items, Ini, 'CustDataTypeReplaces');
LoadFtList(ListBoxFDGenRules.Items, Ini, 'CustFieldDataGenRules');
LoadFtList(MemoKnownTbPrefixs.Lines, Ini, 'TbNamePrefixDefs');
finally
ini.Free;
end;
combLANG.Text := FLANG;
ckbEnableCustomPropUI.Checked := FEnableCustomPropUI;
edtCustomPropUICaption.Text := FCustomPropUICaption;
ckbEnableAdvTbProp.Checked := FEnableAdvTbProp;
ckbEnableTbPropGenerate.Checked := FEnableTbPropGenerate;
ckbEnableTbPropRelations.Checked := FEnableTbPropRelations;
ckbEnableTbPropData.Checked := FEnableTbPropData;
ckbEnableTbPropUIDesign.Checked := FEnableTbPropUIDesign;
edtCustomPropUICaption.Visible:=ckbEnableCustomPropUI.Checked;
ckbCheckForUpdates.Checked := FCheckForUpdates;
edtAutoSaveMinutes.Text := IntToStr(FAutoSaveMinutes);
ckbSaveTempFileOnExit.Checked := FSaveTempFileOnExit;
edtHugeModeTableCount.Text := IntToStr(FHugeModeTableCount);
edtAppDefFontName.Text := FAppDefFontName;
edtAppDefFontSize.Text := IntToStr(FAppDefFontSize);
edtAppFixWidthFontName.Text := FAppFixWidthFontName;
edtAppFixWidthFontSize.Text := IntToStr(FAppFixWidthFontSize);
edtDmlGraphFontName.Text := FDmlGraphFontName;
edtFieldNameMaxDrawSize.Text := IntToStr(FFieldNameMaxDrawSize);
edtFieldTypeMaxDrawSize.Text := IntToStr(FFieldTypeMaxDrawSize);
edtTableFieldMaxDrawCount.Text := IntToStr(FTableFieldMaxDrawCount);
edtScreenDpi.Text := IntToStr(Screen.PixelsPerInch);
ckbBigIntForIntKeys.Checked := FBigIntForIntKeys;
ckbQuotReservedNames.Checked := FQuotReservedNames;
ckbQuotAllNames.Checked := FQuotAllNames;
ckbBackupBeforeAlterColumn.Checked := FBackupBeforeAlterColumn;
ckbAddColCommentToCreateTbSql.Checked := FAddColCommentToCreateTbSql;
ckbCreateForeignkeys.Checked := FCreateForeignkeys;
combHiveVersion.Text := IntToStr(FHiveVersion);
ckbCreateIndexForForeignkey.Checked := FCreateIndexForForeignkey;
ckbCreateSeqForOracle.Checked := FCreateSeqForOracle;
edtMaxRowCountForTableData.Text := IntToStr(FMaxRowCountForTableData);
ckbLogicNamesForTableData.Checked := FLogicNamesForTableData;
edtOCILIB.Text := FOCILIB;
combNLSLang.Text := FNLSLang;
edtMYSQLLIB.Text := FMYSQLLIB;
edtSQLSERVERLIB.Text := FSQLSERVERLIB;
ckbUseOdbcDriverForMsSql.Checked := FUseOdbcDriverForMsSql;
edtPOSTGRESLIB.Text := FPOSTGRESLIB;
edtSQLITELIB.Text := FSQLITELIB;
ckbWriteConstraintToDescribeStr.Checked := FWriteConstraintToDescribeStr;
ckbFieldGridShowLines.Checked := FFieldGridShowLines;
ckbTableDialogViewModeByDefault.Checked := FTableDialogViewModeByDefault;
{$ifdef WIN32}
lbDBConnNote.Caption := StringReplace(lbDBConnNote.Caption, '64', '32', []);
{$endif}
LoadCustDict;
end;
procedure TfrmSettings.SaveSetting;
procedure SaveFtList(AList: TStrings; ini: TIniFile; ASec: string);
var
I: integer;
begin
ini.EraseSection(ASec);
with AList do
for I := 0 to Count - 1 do
ini.WriteString(ASec, IntToStr(I + 1), Strings[I]);
end;
procedure SaveCustDict;
var
S, fn: string;
begin
if not MemoCustDict.Modified then
Exit;
fn := 'MyDict.txt';
S := GetFolderPathOfAppExe;
S := FolderAddFileName(S, fn);
if FileExists(S) then
MemoCustDict.Lines.SaveToFile(S)
else if Trim(MemoCustDict.Lines.Text) <> '' then
MemoCustDict.Lines.SaveToFile(S);
GetAutoNameCapitalizer.ReloadDictFile;
end;
var
ini: TIniFile;
S: string;
procedure SaveComboHist(Combo: TComboBox; dbType: string);
var
I: Integer;
begin
S:=Combo.Text;
if S<> '' then
begin
I := Combo.Items.IndexOf(S);
if I>0 then
Combo.Items.Move(I, 0)
else if I < 0 then
Combo.Items.Insert(0, S);
end;
SaveFtList(Combo.Items, Ini, 'DbLibHist_'+dbType);
end;
begin
FLANG := combLANG.Text;
FEnableCustomPropUI := ckbEnableCustomPropUI.Checked;
FCustomPropUICaption := edtCustomPropUICaption.Text;
FEnableAdvTbProp := ckbEnableAdvTbProp.Checked;
FEnableTbPropGenerate := ckbEnableTbPropGenerate.Checked;
FEnableTbPropRelations := ckbEnableTbPropRelations.Checked;
FEnableTbPropData := ckbEnableTbPropData.Checked;
FEnableTbPropUIDesign := ckbEnableTbPropUIDesign.Checked;
FCheckForUpdates := ckbCheckForUpdates.Checked;
FAutoSaveMinutes := StrToIntDef(edtAutoSaveMinutes.Text, FAutoSaveMinutes);
FSaveTempFileOnExit := ckbSaveTempFileOnExit.Checked;
FHugeModeTableCount := StrToIntDef(edtHugeModeTableCount.Text, FHugeModeTableCount);
FAppDefFontName := edtAppDefFontName.Text;
FAppDefFontSize := StrToIntDef(edtAppDefFontSize.Text, FAppDefFontSize);
FAppFixWidthFontName := edtAppFixWidthFontName.Text;
FAppFixWidthFontSize := StrToIntDef(edtAppFixWidthFontSize.Text, FAppFixWidthFontSize);
FDmlGraphFontName := edtDmlGraphFontName.Text;
FFieldNameMaxDrawSize := StrToIntDef(edtFieldNameMaxDrawSize.Text,
FFieldNameMaxDrawSize);
FFieldTypeMaxDrawSize := StrToIntDef(edtFieldTypeMaxDrawSize.Text,
FFieldTypeMaxDrawSize);
FTableFieldMaxDrawCount := StrToIntDef(edtTableFieldMaxDrawCount.Text,
FTableFieldMaxDrawCount);
FBigIntForIntKeys := ckbBigIntForIntKeys.Checked;
FQuotReservedNames := ckbQuotReservedNames.Checked;
FQuotAllNames := ckbQuotAllNames.Checked;
FBackupBeforeAlterColumn := ckbBackupBeforeAlterColumn.Checked;
FAddColCommentToCreateTbSql := ckbAddColCommentToCreateTbSql.Checked;
FCreateIndexForForeignkey := ckbCreateIndexForForeignkey.Checked;
FCreateForeignkeys := ckbCreateForeignkeys.Checked;
FHiveVersion := StrToIntDef(combHiveVersion.Text, FHiveVersion);
FCreateSeqForOracle := ckbCreateSeqForOracle.Checked;
FMaxRowCountForTableData := StrToIntDef(edtMaxRowCountForTableData.Text,
FMaxRowCountForTableData);
FLogicNamesForTableData := ckbLogicNamesForTableData.Checked;
FOCILIB := edtOCILIB.Text;
FMYSQLLIB := edtMYSQLLIB.Text;
FPOSTGRESLIB := edtPOSTGRESLIB.Text;
FSQLSERVERLIB := edtSQLSERVERLIB.Text;
FUseOdbcDriverForMsSql := ckbUseOdbcDriverForMsSql.Checked;
FSQLITELIB := edtSQLITELIB.Text;
{$ifndef WINDOWS}
if FNLSLang <> combNLSLang.Text then
begin
if combNLSLang.Text<>'' then
begin
//ShowMessage('Please manually add/set "export NLS_LANG='+combNLSLang.Text+'" in ~/.bash_profile');
end else
begin
//ShowMessage('Please manually remove "export NLS_LANG=xxx" in ~/.bash_profile');
end;
end;
{$endif}
FNLSLang := combNLSLang.Text;
FWriteConstraintToDescribeStr := ckbWriteConstraintToDescribeStr.Checked;
FFieldGridShowLines := ckbFieldGridShowLines.Checked;
FTableDialogViewModeByDefault := ckbTableDialogViewModeByDefault.Checked;
S := GetAppDefTempPath;
if not DirectoryExists(S) then
ForceDirectories(S);
ini := TIniFile.Create(GetConfFileOfApp);
try
SaveComboHist(edtOCILIB, 'ORACLE');
SaveComboHist(edtMYSQLLIB, 'MYSQL');
SaveComboHist(edtPOSTGRESLIB, 'POSTGRESQL');
SaveComboHist(edtSQLSERVERLIB, 'SQLSERVER');
SaveComboHist(edtSQLITELIB, 'SQLITE');
ini.WriteBool('Options', 'CheckForUpdates', FCheckForUpdates);
//ini.Write{3}('Options', '{1}', F{1});
ini.WriteInteger('Options', 'AutoSaveMinutes', FAutoSaveMinutes);
ini.WriteBool('Options', 'SaveTempFileOnExit', FSaveTempFileOnExit);
ini.WriteInteger('Options', 'HugeModeTableCount', FHugeModeTableCount);
ini.WriteInteger('Options', 'MaxRowCountForTableData', FMaxRowCountForTableData);
ini.WriteBool('Options', 'LogicNamesForTableData', FLogicNamesForTableData);
ini.WriteBool('Options', 'CreateSeqForOracle', FCreateSeqForOracle);
ini.WriteString('Options', 'OCILIB', FOCILIB);
ini.WriteString('Options', 'NLSLang', FNLSLang);
ini.WriteString('Options', 'MYSQLLIB', FMYSQLLIB);
ini.WriteString('Options', 'SQLSERVERLIB', FSQLSERVERLIB);
ini.WriteBool('Options', 'UseOdbcDriverForMsSql', FUseOdbcDriverForMsSql);
ini.WriteString('Options', 'POSTGRESLIB', FPOSTGRESLIB);
ini.WriteString('Options', 'SQLITELIB', FSQLITELIB);
ini.WriteBool('Options', 'BigIntForIntKeys', FBigIntForIntKeys);
ini.WriteBool('Options', 'QuotReservedNames', FQuotReservedNames);
ini.WriteBool('Options', 'QuotAllNames', FQuotAllNames);
ini.WriteBool('Options', 'BackupBeforeAlterColumn', FBackupBeforeAlterColumn);
ini.WriteBool('Options', 'WriteConstraintToDescribeStr',
FWriteConstraintToDescribeStr);
ini.WriteBool('Options', 'FieldGridShowLines', FFieldGridShowLines);
ini.WriteBool('Options', 'AddColCommentToCreateTbSql', FAddColCommentToCreateTbSql);
ini.WriteBool('Options', 'CreateForeignkeys', FCreateForeignkeys);
ini.WriteBool('Options', 'CreateIndexForForeignkey', FCreateIndexForForeignkey);
ini.WriteBool('Options', 'EnableCustomPropUI', FEnableCustomPropUI);
ini.WriteInteger('Options', 'HiveVersion', FHiveVersion);
ini.WriteString('Options', 'CustomPropUICaption', FCustomPropUICaption);
ini.WriteBool('Options', 'EnableAdvTbProp', FEnableAdvTbProp);
ini.WriteBool('Options', 'EnableTbPropGenerate', FEnableTbPropGenerate);
ini.WriteBool('Options', 'EnableTbPropRelations', FEnableTbPropRelations);
ini.WriteBool('Options', 'EnableTbPropData', FEnableTbPropData);
ini.WriteBool('Options', 'EnableTbPropUIDesign', FEnableTbPropUIDesign);
ini.WriteString('Options', 'LANG', FLANG);
ini.WriteString('Options', 'AppDefFontName', FAppDefFontName);
ini.WriteInteger('Options', 'AppDefFontSize', FAppDefFontSize);
ini.WriteString('Options', 'AppFixWidthFontName', FAppFixWidthFontName);
ini.WriteInteger('Options', 'AppFixWidthFontSize', FAppFixWidthFontSize);
ini.WriteString('Options', 'DmlGraphFontName', FDmlGraphFontName);
ini.WriteInteger('Options', 'FieldNameMaxDrawSize', FFieldNameMaxDrawSize);
ini.WriteInteger('Options', 'FieldTypeMaxDrawSize', FFieldTypeMaxDrawSize);
ini.WriteInteger('Options', 'TableFieldMaxDrawCount', FTableFieldMaxDrawCount);
ini.WriteBool('Options', 'TableDialogViewModeByDefault',
FTableDialogViewModeByDefault);
SaveFtList(ListBoxCustFldTps.Items, Ini, 'CustFieldTypes');
FFrameCustPhyFieldTypes.Save(ListBoxDefPhyTypes.Items);
SaveFtList(ListBoxDefPhyTypes.Items, Ini, 'DefaultFieldTypes');
SaveFtList(ListBoxTpNameReplaces.Items, Ini, 'CustDataTypeReplaces');
SaveFtList(ListBoxFDGenRules.Items, Ini, 'CustFieldDataGenRules');
SaveFtList(MemoKnownTbPrefixs.Lines, Ini, 'TbNamePrefixDefs');
finally
ini.Free;
end;
SaveCustDict;
end;
procedure TfrmSettings.InitEditors;
procedure InitLangs;
var
Sr: TSearchRec;
S, AFolderName: string;
begin
combLANG.Clear;
AFolderName := GetFolderPathOfAppExe('languages');
if not DirectoryExists(AFolderName) then
Exit;
if FindFirst(FolderAddFileName(AFolderName, '*.*'), SysUtils.faAnyFile,
Sr) = 0 then
try
repeat
if (Sr.Name = '.') or (Sr.Name = '..') then
Continue;
if (Sr.Attr and SysUtils.faDirectory) <> 0 then
begin
Continue;
end
else
begin
S := SR.Name;
if (Pos('ezdml_x.', LowerCase(S)) = 1) and
(LowerCase(ExtractFileExt(S)) = '.po') then
begin
if LowerCase(S) = 'ezdml_x.po' then
combLANG.Items.Add('en')
else
begin
S := Copy(S, 9, Length(S));
S := Copy(S, 1, Length(S) - 3);
if S <> '' then
combLANG.Items.Add(S);
end;
end;
end;
until FindNext(Sr) <> 0;
finally
FindClose(Sr);
end;
end;
begin
edtAppDefFontName.Items.Assign(Screen.Fonts);
edtAppFixWidthFontName.Items.Assign(Screen.Fonts);
edtDmlGraphFontName.Items.Assign(Screen.Fonts);
InitLangs;
CheckCustFieldEditors;
end;
end.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Pascal
1
https://gitee.com/iosfan/ezdml.git
git@gitee.com:iosfan/ezdml.git
iosfan
ezdml
ezdml
master

搜索帮助