fGLOptions.pas 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. unit fGLOptions;
  2. interface
  3. uses
  4. Winapi.Windows,
  5. Winapi.Messages,
  6. System.SysUtils,
  7. System.UITypes,
  8. System.Variants,
  9. System.Classes,
  10. System.IniFiles,
  11. Vcl.Graphics,
  12. Vcl.Controls,
  13. Vcl.Forms,
  14. Vcl.Dialogs,
  15. Vcl.StdCtrls,
  16. Vcl.ExtCtrls,
  17. //
  18. dImages,
  19. dDialogs,
  20. fGLForm;
  21. type
  22. TFormOptions = class(TGLForm)
  23. CheckBoxAxis: TCheckBox;
  24. PanelBackground: TPanel;
  25. ButtonOk: TButton;
  26. procedure FormCreate(Sender: TObject);
  27. procedure FormClose(Sender: TObject; var Action: TCloseAction);
  28. procedure ButtonOKClick(Sender: TObject);
  29. procedure PanelBackgroundClick(Sender: TObject);
  30. procedure CheckBoxAxisClick(Sender: TObject);
  31. private
  32. public
  33. CurLangID : Word;
  34. procedure ReadIniFile; override;
  35. procedure WriteIniFile;
  36. end;
  37. var
  38. FormOptions: TFormOptions;
  39. //---------------------------------------------------------------------------
  40. implementation
  41. {$R *.dfm}
  42. uses
  43. fGLSViewer;
  44. procedure TFormOptions.FormCreate(Sender: TObject);
  45. begin
  46. inherited;
  47. ReadIniFile;
  48. end;
  49. procedure TFormOptions.FormClose(Sender: TObject; var Action: TCloseAction);
  50. begin
  51. WriteIniFile;
  52. inherited;
  53. end;
  54. procedure TFormOptions.ReadIniFile;
  55. begin
  56. inherited;
  57. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  58. with IniFile do
  59. try
  60. CheckBoxAxis.Checked := ReadBool(Name, CheckBoxAxis.Name, True);
  61. PanelBackground.Color := ReadInteger(Name, PanelBackground.Name, 0);
  62. finally
  63. IniFile.Free;
  64. end;
  65. end;
  66. procedure TFormOptions.WriteIniFile;
  67. begin
  68. IniFile := TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  69. with IniFile do
  70. try
  71. WriteBool(Name, CheckBoxAxis.Name, CheckBoxAxis.Checked);
  72. WriteInteger(Name, PanelBackground.Name, PanelBackground.Color);
  73. finally
  74. IniFile.Free;
  75. end;
  76. inherited;
  77. end;
  78. procedure TFormOptions.CheckBoxAxisClick(Sender: TObject);
  79. begin
  80. if CheckBoxAxis.Checked then
  81. frmGLSViewer.DCAxis.Visible := True
  82. else
  83. frmGLSViewer.DCAxis.Visible := False;
  84. end;
  85. procedure TFormOptions.PanelBackgroundClick(Sender: TObject);
  86. begin
  87. dmDialogs.ColorDialog.Color := PanelBackground.Color;
  88. if dmDialogs.ColorDialog.Execute then
  89. begin
  90. PanelBackground.Color := dmDialogs.ColorDialog.Color;
  91. frmGLSViewer.ApplyBgColor;
  92. end;
  93. end;
  94. procedure TFormOptions.ButtonOKClick(Sender: TObject);
  95. var
  96. FileName: TFileName;
  97. begin
  98. FileName := ChangeFileExt(ParamStr(0), '.ini');
  99. if FileExists(UpperCase(FileName)) then
  100. DeleteFile(UpperCase(FileName)); //to exclude dublicated sections for each language
  101. end;
  102. end.