Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitEditDictionary;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
- Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.ValEdit,
- Vcl.ExtCtrls, Vcl.StdCtrls;
- type
- TFrameEditDictionary = class(TFrame)
- PanelLeftBorder: TPanel;
- PanelRightBorder: TPanel;
- PanelBottomBorder: TPanel;
- PanelTopBorder: TPanel;
- ButtonMakeFavorite: TButton;
- ButtonDeleteWord: TButton;
- ButtonAddWord: TButton;
- ButtonSaveChange: TButton;
- PanelForFaQ: TPanel;
- ButtonHowWork: TButton;
- ButtonChangeWord: TButton;
- Dictionary: TValueListEditor;
- procedure DictionarySelectCell(Sender: TObject; ACol, ARow: Integer;
- var CanSelect: Boolean);
- procedure ButtonAddWordClick(Sender: TObject);
- procedure ButtonDeleteWordClick(Sender: TObject);
- procedure ButtonChangeWordClick(Sender: TObject);
- procedure ButtonSaveChangeClick(Sender: TObject);
- procedure ButtonMakeFavoriteClick(Sender: TObject);
- procedure ButtonHowWorkClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- implementation
- {$R *.dfm}
- uses UnitChangeWord, MainForm, UnitFavorites, UnitHelp;
- type
- TPartsOfSpeech = MainForm.TPartsOfSpeech;
- EnglStr = MainForm.EnglStr;
- RussStr = MainForm.RussStr;
- TWord = MainForm.TWord;
- const
- FILE_NAME = MainForm.FILE_NAME;
- TEMP_FILE_NAME = MainForm.TEMP_FILE_NAME;
- procedure TFrameEditDictionary.ButtonAddWordClick(Sender: TObject);
- var
- EnglishWord: EnglStr;
- RussianWord: RussStr;
- PartOfSpeech: TPartsOfSpeech;
- EnglishPresence, RussianPresence: Boolean;
- begin
- UnitChangeWord.FormChangeWord.EditEnglishWord.Text := '';
- UnitChangeWord.FormChangeWord.EditRussianWord.Text := '';
- UnitChangeWord.FormChangeWord.RadioGroupPartsOfSpeech.ItemIndex := -1;
- if UnitChangeWord.FormChangeWord.ShowModal = mrOk then
- begin
- with UnitChangeWord.FormChangeWord do
- begin
- RussianWord := EditRussianWord.Text;
- PartOfSpeech := MainForm.FormMenu.GetPartOfSpeech(EnglishWord, RadioGroupPartsOfSpeech, true);
- EnglishWord := MainForm.FormMenu.GetFinalAppearance(PartOfSpeech, EditEnglishWord.Text);
- EnglishPresence := MainForm.FormMenu.IsWordInDictionary(Dictionary, EnglishWord);
- RussianPresence := MainForm.FormMenu.IsWordInDictionary(Dictionary, RussianWord);
- if not(EnglishPresence) and not(RussianPresence) then
- begin
- Dictionary.InsertRow(RussianWord, EnglishWord, true);
- end;
- end;
- end;
- end;
- procedure TFrameEditDictionary.ButtonChangeWordClick(Sender: TObject);
- var
- EnglishWord: EnglStr;
- RussianWord: RussStr;
- PartOfSpeech: TPartsOfSpeech;
- EnglishPresence, RussianPresence: Boolean;
- begin
- RussianWord := Dictionary.Keys[Dictionary.Row];
- EnglishWord := Dictionary.Cells[1, Dictionary.Row];
- PartOfSpeech := MainForm.FormMenu.GetPartOfSpeech(EnglishWord, UnitChangeWord.FormChangeWord.RadioGroupPartsOfSpeech, false);
- UnitChangeWord.FormChangeWord.EditEnglishWord.Text := EnglishWord;
- UnitChangeWord.FormChangeWord.EditRussianWord.Text := RussianWord;
- if UnitChangeWord.FormChangeWord.ShowModal = mrOk then
- begin
- with UnitChangeWord.FormChangeWord do
- begin
- RussianWord := EditRussianWord.Text;
- PartOfSpeech := MainForm.FormMenu.GetPartOfSpeech(EnglishWord, RadioGroupPartsOfSpeech, true);
- EnglishWord := MainForm.FormMenu.GetFinalAppearance(PartOfSpeech, EditEnglishWord.Text);
- EnglishPresence := MainForm.FormMenu.IsWordInDictionary(Dictionary, EnglishWord);
- RussianPresence := MainForm.FormMenu.IsWordInDictionary(Dictionary, RussianWord);
- if not(EnglishPresence) and not(RussianPresence) then
- begin
- Dictionary.Keys[Dictionary.Row] := RussianWord;
- Dictionary.Cells[1, Dictionary.Row] := EnglishWord;
- end;
- end;
- end;
- end;
- procedure TFrameEditDictionary.ButtonDeleteWordClick(Sender: TObject);
- var
- CanSel: Boolean;
- begin
- CanSel := true;
- MainForm.FormMenu.DeleteWord(Dictionary);
- DictionarySelectCell(Sender, 0, Dictionary.Row, CanSel);
- end;
- procedure TFrameEditDictionary.ButtonHowWorkClick(Sender: TObject);
- begin
- UnitHelp.FormHelp.Show;
- end;
- procedure TFrameEditDictionary.ButtonMakeFavoriteClick(Sender: TObject);
- var
- EnglishPresence, RussianPresence: Boolean;
- begin
- EnglishPresence := MainForm.FormMenu.IsWordInDictionary(MainForm.FormMenu.FrameFavorites.Dictionary, Dictionary.Cells[1, Dictionary.Row]);
- RussianPresence := MainForm.FormMenu.IsWordInDictionary(MainForm.FormMenu.FrameFavorites.Dictionary, Dictionary.Keys[Dictionary.Row]);
- if not(EnglishPresence) and not(RussianPresence) then
- begin
- MainForm.FormMenu.WriteToFavorites(Dictionary.Row, Dictionary, FILE_FAVORITES);
- end;
- end;
- procedure TFrameEditDictionary.ButtonSaveChangeClick(Sender: TObject);
- begin
- MainForm.FormMenu.SaveDictionaryToFile(Dictionary, FILE_NAME);
- end;
- procedure TFrameEditDictionary.DictionarySelectCell(Sender: TObject; ACol,
- ARow: Integer; var CanSelect: Boolean);
- begin
- ButtonChangeWord.Enabled := true;
- if not(MainForm.FormMenu.IsRowEmpty(Dictionary, Dictionary.Row)) then
- begin
- ButtonMakeFavorite.Enabled := true;
- ButtonDeleteWord.Enabled := true;
- end
- else
- begin
- ButtonMakeFavorite.Enabled := false;
- ButtonDeleteWord.Enabled := false;
- end;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement