| 1 | unit UFormImportPattern;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 9 | UAcronym;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormImportPattern }
|
|---|
| 14 |
|
|---|
| 15 | TFormImportPattern = class(TForm)
|
|---|
| 16 | ButtonCancel: TButton;
|
|---|
| 17 | ButtonOk: TButton;
|
|---|
| 18 | CheckBoxRepetition: TCheckBox;
|
|---|
| 19 | ComboBoxAction: TComboBox;
|
|---|
| 20 | ComboBoxVariable: TComboBox;
|
|---|
| 21 | EditBlockEnd: TEdit;
|
|---|
| 22 | EditBlockStart: TEdit;
|
|---|
| 23 | Label10: TLabel;
|
|---|
| 24 | Label11: TLabel;
|
|---|
| 25 | Label8: TLabel;
|
|---|
| 26 | Label9: TLabel;
|
|---|
| 27 | procedure FormCreate(Sender: TObject);
|
|---|
| 28 | procedure FormShow(Sender: TObject);
|
|---|
| 29 | private
|
|---|
| 30 | procedure InitControls;
|
|---|
| 31 | public
|
|---|
| 32 | procedure Save(Pattern: TImportPattern);
|
|---|
| 33 | procedure Load(Pattern: TImportPattern);
|
|---|
| 34 | end;
|
|---|
| 35 |
|
|---|
| 36 | var
|
|---|
| 37 | FormImportPattern: TFormImportPattern;
|
|---|
| 38 |
|
|---|
| 39 | implementation
|
|---|
| 40 |
|
|---|
| 41 | {$R *.lfm}
|
|---|
| 42 |
|
|---|
| 43 | uses
|
|---|
| 44 | UCore;
|
|---|
| 45 |
|
|---|
| 46 | { TFormImportPattern }
|
|---|
| 47 |
|
|---|
| 48 | procedure TFormImportPattern.FormShow(Sender: TObject);
|
|---|
| 49 | begin
|
|---|
| 50 | InitControls;
|
|---|
| 51 | end;
|
|---|
| 52 |
|
|---|
| 53 | procedure TFormImportPattern.FormCreate(Sender: TObject);
|
|---|
| 54 | begin
|
|---|
| 55 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
|---|
| 56 | InitControls;
|
|---|
| 57 | end;
|
|---|
| 58 |
|
|---|
| 59 | procedure TFormImportPattern.InitControls;
|
|---|
| 60 | var
|
|---|
| 61 | I: TImportPatternFlag;
|
|---|
| 62 | J: TImportVariable;
|
|---|
| 63 | Index: Integer;
|
|---|
| 64 | begin
|
|---|
| 65 | Index := ComboBoxAction.ItemIndex;
|
|---|
| 66 | while ComboBoxAction.Items.Count > 0 do
|
|---|
| 67 | ComboBoxAction.Items.Delete(ComboBoxAction.Items.Count - 1);
|
|---|
| 68 | while ComboBoxAction.Items.Count <= Integer(High(ImportPatternFlagString)) do
|
|---|
| 69 | ComboBoxAction.Items.Add('');
|
|---|
| 70 | for I := Low(TImportPatternFlag) to High(TImportPatternFlag) do
|
|---|
| 71 | ComboBoxAction.Items[Integer(I)] := ImportPatternFlagString[I];
|
|---|
| 72 | ComboBoxAction.ItemIndex := Index;
|
|---|
| 73 |
|
|---|
| 74 | Index := ComboBoxVariable.ItemIndex;
|
|---|
| 75 | ComboBoxVariable.Items.Clear;
|
|---|
| 76 | while ComboBoxVariable.Items.Count > 0 do
|
|---|
| 77 | ComboBoxVariable.Items.Delete(ComboBoxVariable.Items.Count - 1);
|
|---|
| 78 | while ComboBoxVariable.Items.Count <= Integer(High(ImportVariableString)) do
|
|---|
| 79 | ComboBoxVariable.Items.Add('');
|
|---|
| 80 | for J := Low(TImportVariable) to High(TImportVariable) do
|
|---|
| 81 | ComboBoxVariable.Items[Integer(J)] := ImportVariableString[J];
|
|---|
| 82 | ComboBoxVariable.ItemIndex := Index;
|
|---|
| 83 | end;
|
|---|
| 84 |
|
|---|
| 85 | procedure TFormImportPattern.Save(Pattern: TImportPattern);
|
|---|
| 86 | begin
|
|---|
| 87 | Pattern.StartString := EditBlockStart.Text;
|
|---|
| 88 | Pattern.EndString := EditBlockEnd.Text;
|
|---|
| 89 | Pattern.Variable := TImportVariable(ComboBoxVariable.ItemIndex);
|
|---|
| 90 | Pattern.Flag := TImportPatternFlag(ComboBoxAction.ItemIndex);
|
|---|
| 91 | Pattern.Repetition := CheckBoxRepetition.Checked;
|
|---|
| 92 | end;
|
|---|
| 93 |
|
|---|
| 94 | procedure TFormImportPattern.Load(Pattern: TImportPattern);
|
|---|
| 95 | begin
|
|---|
| 96 | EditBlockStart.Text := Pattern.StartString;
|
|---|
| 97 | EditBlockEnd.Text := Pattern.EndString;
|
|---|
| 98 | ComboBoxVariable.ItemIndex := Integer(Pattern.Variable);
|
|---|
| 99 | ComboBoxAction.ItemIndex := Integer(Pattern.Flag);
|
|---|
| 100 | CheckBoxRepetition.Checked := Pattern.Repetition;
|
|---|
| 101 | end;
|
|---|
| 102 |
|
|---|
| 103 | end.
|
|---|
| 104 |
|
|---|