Advertisement
ksyshshot

курсач 4

May 28th, 2023
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 2.69 KB | Source Code | 0 0
  1. unit UnitFavorites;
  2.  
  3. interface
  4.  
  5. uses
  6.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  7.   Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.ValEdit,
  8.   Vcl.ExtCtrls, Vcl.StdCtrls;
  9.  
  10. type
  11.   TFrameFavorites = class(TFrame)
  12.     Dictionary: TValueListEditor;
  13.     PanelTools: TPanel;
  14.     PanelLeft: TPanel;
  15.     PanelRight: TPanel;
  16.     PanelBottom: TPanel;
  17.     ButtonDelFavorite: TButton;
  18.     ButtonSaveChange: TButton;
  19.     ButtonMakeFlashCard: TButton;
  20.     PanelForFaQ: TPanel;
  21.     ButtonHowWork: TButton;
  22.     procedure DictionarySelectCell(Sender: TObject; ACol, ARow: Integer;
  23.       var CanSelect: Boolean);
  24.     procedure ButtonDelFavoriteClick(Sender: TObject);
  25.     procedure ButtonSaveChangeClick(Sender: TObject);
  26.     procedure ButtonMakeFlashCardClick(Sender: TObject);
  27.     procedure ButtonHowWorkClick(Sender: TObject);
  28.   private
  29.     { Private declarations }
  30.   public
  31.     { Public declarations }
  32.   end;
  33.  
  34. implementation
  35.  
  36. {$R *.dfm}
  37.  
  38. uses MainForm, UnitHelp;
  39.  
  40. type
  41.     TWord = MainForm.TWord;
  42.     TPartsOfSpeech = MainForm.TPartsOfSpeech;
  43.  
  44. const
  45.     FILE_FAVORITES = MainForm.FILE_FAVORITES;
  46.  
  47. procedure TFrameFavorites.ButtonDelFavoriteClick(Sender: TObject);
  48. var
  49.     CanSel: Boolean;
  50. begin
  51.     CanSel := true;
  52.     MainForm.FormMenu.DeleteWord(Dictionary);
  53.     DictionarySelectCell(Sender, 0, Dictionary.Row, CanSel);
  54. end;
  55.  
  56. procedure TFrameFavorites.ButtonHowWorkClick(Sender: TObject);
  57. begin
  58.     UnitHelp.FormHelp.Show;
  59. end;
  60.  
  61. procedure TFrameFavorites.ButtonMakeFlashCardClick(Sender: TObject);
  62. var
  63.     EnglishPresence, RussianPresence: Boolean;
  64. begin
  65.     EnglishPresence := MainForm.FormMenu.IsWordInDictionary(MainForm.FormMenu.FrameFlashCards.DictionaryChangeWordSet, Dictionary.Cells[1, Dictionary.Row]);
  66.     RussianPresence := MainForm.FormMenu.IsWordInDictionary(MainForm.FormMenu.FrameFlashCards.DictionaryChangeWordSet, Dictionary.Keys[Dictionary.Row]);
  67.     if not(EnglishPresence) and not(RussianPresence) then
  68.     begin
  69.         MainForm.FormMenu.WriteToFavorites(Dictionary.Row, Dictionary, FILE_FLASHCARDS);
  70.     end;
  71. end;
  72.  
  73. procedure TFrameFavorites.ButtonSaveChangeClick(Sender: TObject);
  74. begin
  75.     MainForm.FormMenu.SaveDictionaryToFile(Dictionary, FILE_FAVORITES);
  76. end;
  77.  
  78. procedure TFrameFavorites.DictionarySelectCell(Sender: TObject; ACol,
  79.   ARow: Integer; var CanSelect: Boolean);
  80. begin
  81.     if not(MainForm.FormMenu.IsRowEmpty(Dictionary, Dictionary.Row)) then
  82.     begin
  83.         ButtonDelFavorite.Enabled := true;
  84.         ButtonMakeFlashCard.Enabled := true;
  85.     end
  86.     else
  87.     begin
  88.         ButtonDelFavorite.Enabled := false;
  89.         ButtonMakeFlashCard.Enabled := false;
  90.     end;
  91. end;
  92.  
  93. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement