-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.pas
164 lines (136 loc) · 3.74 KB
/
MainForm.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
unit MainForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, LogViewFrame, Vcl.ExtCtrls, Vcl.StdCtrls, DemoInterfaces, Vcl.ToolWin, Vcl.ComCtrls, System.Actions, Vcl.ActnList, Vcl.ImgList, MemoFrame,
System.ImageList, Vcl.AppEvnts;
type
TMainWindow = class(TForm, IClipboardProvider)
Panel1: TPanel;
LogFrame1: TLogFrame;
Button1: TButton;
Button2: TButton;
ToolBar1: TToolBar;
ImageList1: TImageList;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ActionList1: TActionList;
actEditCut: TAction;
actEditCopy: TAction;
actEditPaste: TAction;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
AMemoFrame1: TAMemoFrame;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure LogFrame1LogMemoEnter(Sender: TObject);
procedure LogFrame1LogMemoExit(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormDeactivate(Sender: TObject);
procedure actEditCutExecute(Sender: TObject);
procedure actEditCopyExecute(Sender: TObject);
procedure actEditPasteExecute(Sender: TObject);
procedure ActionList1Update(Action: TBasicAction; var Handled: Boolean);
private
{ Private declarations }
FLogger : ILogger;
FClipboardProvider : IClipboardProvider;
protected
function CanCopy: Boolean;
function CanCut: Boolean;
function CanPaste: Boolean;
procedure Copy;
procedure Cut;
procedure Paste;
public
{ Public declarations }
end;
var
MainWindow: TMainWindow;
implementation
uses
ClipbrdController,
SecondForm;
{$R *.dfm}
var
count : Int64;
procedure TMainWindow.actEditCopyExecute(Sender: TObject);
begin
ClipboardController.Copy;
end;
procedure TMainWindow.actEditCutExecute(Sender: TObject);
begin
ClipboardController.Cut;
end;
procedure TMainWindow.actEditPasteExecute(Sender: TObject);
begin
ClipboardController.Paste;
end;
procedure TMainWindow.ActionList1Update(Action: TBasicAction;
var Handled: Boolean);
begin
actEditCut.Enabled := ClipboardController.CanCut;
actEditCopy.Enabled := ClipboardController.CanCopy;
actEditPaste.Enabled := ClipboardController.CanPaste;
Handled := true;
end;
procedure TMainWindow.Button1Click(Sender: TObject);
begin
FLogger.Log(Debug, 'Debug message');
end;
procedure TMainWindow.Button2Click(Sender: TObject);
begin
if AnotherForm = nil then
AnotherForm := TAnotherForm.Create(Application, FLogger);
AnotherForm.Show;
end;
function TMainWindow.CanCopy: Boolean;
begin
result := FClipboardProvider.CanCopy;
end;
function TMainWindow.CanCut: Boolean;
begin
result := FClipboardProvider.CanCut;
end;
function TMainWindow.CanPaste: Boolean;
begin
result := FClipboardProvider.CanPaste;
end;
procedure TMainWindow.Copy;
begin
FClipboardProvider.Copy;
end;
procedure TMainWindow.Cut;
begin
FClipboardProvider.Cut;
end;
procedure TMainWindow.FormActivate(Sender: TObject);
begin
ClipboardController.SetProvider(Self);
end;
procedure TMainWindow.FormCreate(Sender: TObject);
begin
FLogger := LogFrame1 as ILogger;
FClipboardProvider := LogFrame1 as IClipboardProvider;
AMemoFrame1.SetLogger(FLogger);
end;
procedure TMainWindow.FormDeactivate(Sender: TObject);
begin
ClipboardController.UnSetProvider(Self);
end;
procedure TMainWindow.LogFrame1LogMemoEnter(Sender: TObject);
begin
ClipboardController.SetProvider(Self);
end;
procedure TMainWindow.LogFrame1LogMemoExit(Sender: TObject);
begin
ClipboardController.UnSetProvider(Self);
end;
procedure TMainWindow.Paste;
begin
FClipboardProvider.Paste;
end;
end.