Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/MainForm.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download) (as text)
Sun Feb 22 14:38:06 2015 UTC (9 years, 1 month ago) by yamat0jp
File MIME type: text/x-pascal
File size: 42159 byte(s)


1 yamat0jp 2 unit MainForm;
2    
3     interface
4    
5     uses
6     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7     Dialogs, StdCtrls, ComCtrls, ToolWin, Menus, ExtCtrls, ExtDlgs,
8     ImgList, Clipbrd, Buttons, Jpeg, ShellAPI, System.Types, System.UITypes;
9    
10     type
11     TRecordType = (Edit, Phot, Ray);
12    
13     TMyData = record
14     Point: TPoint;
15     Frame: TColor;
16     Back: TColor;
17     Bold: integer;
18     Radio: integer;
19     Count: integer;
20     end;
21    
22     TMyRecord = record
23     case RecType: TRecordType of
24     Edit:
25     (Font: TFont;
26     Distance: integer;
27     topleft: TPoint;
28     SideColor: TColor;
29     Shadow, gaze: Boolean);
30     Phot:
31     (path: string[255];
32     range: TRect);
33     Ray:
34     (At, Zt: TPoint;
35     Color: TColor;
36     Width: integer);
37     end;
38    
39     TDrawTarget = (onCap, onBuffer, onImage);
40    
41     TForm1 = class(TForm)
42     Image1: TImage;
43     MainMenu1: TMainMenu;
44     ScrollBox1: TScrollBox;
45     SavePictureDialog1: TSavePictureDialog;
46     ToolBar1: TToolBar;
47     PopupMenu1: TPopupMenu;
48     ToolButton1: TToolButton;
49     ToolBar2: TToolBar;
50     Let: TToolButton;
51     Pic: TToolButton;
52     PopupMenu2: TPopupMenu;
53     Delete1: TMenuItem;
54     File1: TMenuItem;
55     New3: TMenuItem;
56     N1: TMenuItem;
57     Exit1: TMenuItem;
58     Edit2: TMenuItem;
59     Save2: TMenuItem;
60     Help1: TMenuItem;
61     About1: TMenuItem;
62     ToolButton2: TToolButton;
63     ToolButton3: TToolButton;
64     ToolButton7: TToolButton;
65     ToolButton8: TToolButton;
66     N1001001: TMenuItem;
67     N3001501: TMenuItem;
68     Set1: TMenuItem;
69     N4: TMenuItem;
70     ColorDialog1: TColorDialog;
71     N7: TMenuItem;
72     Clip1: TToolButton;
73     StatusBar1: TStatusBar;
74     N2001001: TMenuItem;
75     N3201201: TMenuItem;
76     Pen1: TToolButton;
77     PNG1: TToolButton;
78     PopupMenu3: TPopupMenu;
79     N11: TMenuItem;
80     N21: TMenuItem;
81     N31: TMenuItem;
82     N41: TMenuItem;
83     N51: TMenuItem;
84     N61: TMenuItem;
85     N71: TMenuItem;
86     N81: TMenuItem;
87     N5: TMenuItem;
88     N10: TMenuItem;
89     PageControl1: TPageControl;
90     TabSheet1: TTabSheet;
91     Edit1: TEdit;
92     TabSheet2: TTabSheet;
93     TabSheet3: TTabSheet;
94     Image3: TImage;
95     ComboBox1: TComboBox;
96     ComboBox2: TComboBox;
97     Shape1: TShape;
98     Button1: TButton;
99     Image2: TImage;
100     Label1: TLabel;
101     Cap: TImage;
102     OpenPictureDialog1: TOpenPictureDialog;
103     ImageList1: TImageList;
104     Repaint: TToolButton;
105     Copy1: TMenuItem;
106     N2: TMenuItem;
107     Label7: TLabel;
108     N8: TMenuItem;
109     ToolButton4: TToolButton;
110     ScrollBar4: TScrollBar;
111     Label8: TLabel;
112     Label10: TLabel;
113     RadioButton1: TRadioButton;
114     RadioButton2: TRadioButton;
115     RadioButton3: TRadioButton;
116     Label11: TLabel;
117     Shape4: TShape;
118     TabSheet4: TTabSheet;
119     Shape3: TShape;
120     Label4: TLabel;
121     ScrollBar2: TScrollBar;
122     Label6: TLabel;
123     Shape2: TShape;
124     Label3: TLabel;
125     GroupBox1: TGroupBox;
126     ScrollBar1: TScrollBar;
127     Label5: TLabel;
128     Label2: TLabel;
129     Shape5: TShape;
130     CheckBox2: TCheckBox;
131     CheckBox1: TCheckBox;
132     Label9: TLabel;
133     Open1: TToolButton;
134     SaveAs1: TToolButton;
135     ToolButton9: TToolButton;
136     New1: TToolButton;
137     Save1: TToolButton;
138     OpenDialog1: TOpenDialog;
139     SaveDialog1: TSaveDialog;
140     Open2: TMenuItem;
141     SaveAs2: TMenuItem;
142     Save3: TMenuItem;
143     N3: TMenuItem;
144     N6: TMenuItem;
145     N12: TMenuItem;
146     N15: TMenuItem;
147     N9: TMenuItem;
148     Help2: TMenuItem;
149     N13: TMenuItem;
150     Panel1: TPanel;
151     ListBox1: TListBox;
152     ToolBar3: TToolBar;
153     ToolButton5: TToolButton;
154     ToolButton6: TToolButton;
155     ToolButton10: TToolButton;
156     ToolButton11: TToolButton;
157     Item1: TMenuItem;
158     N14: TMenuItem;
159     N16: TMenuItem;
160     Delete2: TMenuItem;
161     N17: TMenuItem;
162     N18: TMenuItem;
163     ToolButton12: TToolButton;
164     Base: TToolButton;
165     N19: TMenuItem;
166     N20: TMenuItem;
167     N22: TMenuItem;
168     effect1: TMenuItem;
169     N23: TMenuItem;
170     mix: TToolButton;
171     N24: TMenuItem;
172     N25: TMenuItem;
173     CheckBox3: TCheckBox;
174     CheckBox4: TCheckBox;
175     procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
176     Shift: TShiftState; X, Y: integer);
177     procedure Save1Click(Sender: TObject);
178     procedure New1Click(Sender: TObject);
179     procedure FormCreate(Sender: TObject);
180     procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
181     Shift: TShiftState; X, Y: integer);
182     procedure Image1MouseMove(Sender: TObject; Shift: TShiftState;
183     X, Y: integer);
184     procedure FormDestroy(Sender: TObject);
185     procedure Delete1Click(Sender: TObject);
186     procedure About1Click(Sender: TObject);
187     procedure Exit1Click(Sender: TObject);
188     procedure N1001001Click(Sender: TObject);
189     procedure N3001501Click(Sender: TObject);
190     procedure Clip1Click(Sender: TObject);
191     procedure Paste2Click(Sender: TObject);
192     procedure N2001001Click(Sender: TObject);
193     procedure N3201201Click(Sender: TObject);
194     procedure N6Click(Sender: TObject);
195     procedure Button1Click(Sender: TObject);
196     procedure ScrollBar1Change(Sender: TObject);
197     procedure ListBox1Click(Sender: TObject);
198     procedure ComboBox2Change(Sender: TObject);
199     procedure Shape2MouseDown(Sender: TObject; Button: TMouseButton;
200     Shift: TShiftState; X, Y: integer);
201     procedure CapMouseMove(Sender: TObject; Shift: TShiftState; X, Y: integer);
202     procedure CapMouseUp(Sender: TObject; Button: TMouseButton;
203     Shift: TShiftState; X, Y: integer);
204     procedure Shape3MouseDown(Sender: TObject; Button: TMouseButton;
205     Shift: TShiftState; X, Y: integer);
206     procedure CapMouseDown(Sender: TObject; Button: TMouseButton;
207     Shift: TShiftState; X, Y: integer);
208     procedure SpeedButton1Click(Sender: TObject);
209     procedure SpeedButton2Click(Sender: TObject);
210     procedure ListBox1Exit(Sender: TObject);
211     procedure PicClick(Sender: TObject);
212     procedure LetClick(Sender: TObject);
213     procedure ComboBox1Change(Sender: TObject);
214     procedure RepaintClick(Sender: TObject);
215     procedure N4Click(Sender: TObject);
216     procedure Pen1Click(Sender: TObject);
217     procedure ListBox1KeyDown(Sender: TObject; var Key: Word;
218     Shift: TShiftState);
219     procedure PageControl1Change(Sender: TObject);
220     procedure ScrollBar4Change(Sender: TObject);
221     procedure Shape4MouseDown(Sender: TObject; Button: TMouseButton;
222     Shift: TShiftState; X, Y: integer);
223     procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
224     Shift: TShiftState; X, Y: integer);
225     procedure ScrollBar4Enter(Sender: TObject);
226     procedure RadioButton3Click(Sender: TObject);
227     procedure Shape5MouseDown(Sender: TObject; Button: TMouseButton;
228     Shift: TShiftState; X, Y: integer);
229     procedure Quality(Sender: TObject);
230     procedure Open1Click(Sender: TObject);
231     procedure SaveAs1Click(Sender: TObject);
232     procedure PNG1Click(Sender: TObject);
233     procedure N12Click(Sender: TObject);
234     procedure N9Click(Sender: TObject);
235     procedure N15Click(Sender: TObject);
236     procedure Help2Click(Sender: TObject);
237     procedure ListBox1DragOver(Sender, Source: TObject; X, Y: integer;
238     State: TDragState; var Accept: Boolean);
239     procedure ListBox1DragDrop(Sender, Source: TObject; X, Y: integer);
240     procedure ToolButton10Click(Sender: TObject);
241     procedure TabSheet1MouseDown(Sender: TObject; Button: TMouseButton;
242     Shift: TShiftState; X, Y: integer);
243     procedure ToolButton5Click(Sender: TObject);
244     procedure ToolButton6Click(Sender: TObject);
245     procedure N17Click(Sender: TObject);
246     procedure N18Click(Sender: TObject);
247     procedure ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
248     Shift: TShiftState; X, Y: integer);
249     procedure BaseClick(Sender: TObject);
250     procedure N20Click(Sender: TObject);
251     procedure RadioButton1Click(Sender: TObject);
252     procedure mixClick(Sender: TObject);
253     procedure N25Click(Sender: TObject);
254     private
255     St, Gt: TPoint;
256     Rb, Buf: Boolean;
257     Buffer: TBitmap;
258     Project: String;
259     procedure Wall;
260     procedure Super;
261     procedure Edit(const Index: integer; const Sender: TCanvas);
262     procedure Picture(const Index: integer; const target: TDrawTarget);
263     procedure Drawline(const Index: integer; const Sender: TCanvas);
264     procedure Capfree;
265     procedure NewBanner(const Size: TPoint);
266     procedure TestFont;
267     procedure ListClear;
268     procedure BtnWall;
269     procedure SaveJPG(const Quality: integer);
270     procedure Press(const Quality: integer);
271     procedure Open;
272     procedure editinfo(const Index: integer);
273     procedure WMDropFiles(var Msg: TWMDropFiles); message WM_DROPFILES;
274     { Private ���� }
275     public
276     { Public ���� }
277     end;
278    
279     var
280     Form1: TForm1;
281    
282     implementation
283    
284     uses About, Unit2, info;
285    
286     {$R *.dfm}
287    
288     procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
289     Shift: TShiftState; X, Y: integer);
290     begin
291     if ListBox1.ItemIndex > -1 then
292     Capfree;
293     if Button = mbLeft then
294     begin
295     St := Point(X, Y);
296     Gt := St;
297     Rb := true;
298     Buf := false;
299     if Let.Down = true then
300     Image1.Canvas.Font.Name := ComboBox1.Text;
301     end;
302     end;
303    
304     procedure TForm1.Save1Click(Sender: TObject);
305     begin
306     SavePictureDialog1.FilterIndex := 1;
307     Press(100);
308     end;
309    
310     procedure TForm1.New1Click(Sender: TObject);
311     var
312     APoint: TPoint;
313     s: array [0 .. 1] of string;
314     begin
315     with OKRightDlg do
316     begin
317     s[0] := Edit1.Text;
318     s[1] := Edit2.Text;
319     if ShowModal = mrOK then
320     begin
321     APoint := Point(StrToInt(Edit1.Text), StrToInt(Edit2.Text));
322     if (APoint.X < 1000) and (APoint.Y < 1000) then
323     begin
324     Project := 'untitled';
325     NewBanner(APoint);
326     end
327     else
328     begin
329     Edit1.Text := s[0];
330     Edit2.Text := s[1];
331     end;
332     end
333     else
334     begin
335     Edit1.Text := s[0];
336     Edit2.Text := s[1];
337     end;
338     end;
339     end;
340    
341     procedure TForm1.NewBanner(const Size: TPoint);
342     var
343     bmp: TBitmap;
344     begin
345     if Cap.Visible = true then
346     begin
347     Cap.Hide;
348     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
349     end;
350     ListClear;
351     bmp := TBitmap.Create;
352     try
353     bmp.Width := Size.X;
354     bmp.Height := Size.Y;
355     Image1.Picture.Bitmap.Assign(bmp);
356     Buffer.Assign(bmp);
357     finally
358     bmp.Free;
359     end;
360     Wall;
361     end;
362    
363     procedure TForm1.FormCreate(Sender: TObject);
364     var
365     i: integer;
366     begin
367     // [Air PC] //
368     ComboBox1.Items := Screen.Fonts;
369     ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(Image2.Canvas.Font.Name);
370     with Image1.Canvas do
371     begin
372     Pen.Color := clFuchsia;
373     Pen.Style := psDash;
374     Pen.Mode := pmNotXor;
375     end;
376     Rb := false;
377     Buffer := TBitmap.Create;
378     Buffer.TransparentMode := tmFixed;
379     NewBanner(Point(350, 190));
380     with Image2.Canvas do
381     begin
382     CopyMode := cmWhiteness;
383     Font.Height := 25;
384     end;
385     with Cap.Canvas do
386     begin
387     Pen.Style := psDash;
388     Pen.Color := clFuchsia;
389     Pen.Mode := pmNotXor;
390     end;
391     TestFont;
392     Project := 'untitled';
393     N18.Enabled := FileExists('Banner2_neo.html');
394     DragAcceptFiles(Handle, true);
395     for i := 1 to ParamCount do
396     if CompareText(ExtractFileExt(ParamStr(i)), '.ami') = 0 then
397     begin
398     OpenDialog1.FileName := ParamStr(1);
399     Open;
400     break;
401     end;
402     end;
403    
404     procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
405     Shift: TShiftState; X, Y: integer);
406     var
407     ARect: TRect;
408     p: ^TMyRecord;
409     w: string;
410     const
411     a = 10;
412     begin
413     if Rb = true then
414     begin
415     StatusBar1.Panels[0].Text := 'X:' + IntToStr(X) + '/ Y:' + IntToStr(Y);
416     Rb := false;
417     if Pen1.Down then
418     begin
419     Image1.Canvas.Pen.Mode := pmCopy;
420     Image1.Canvas.Pen.Style := psSolid;
421     New(p);
422     p^.RecType := Ray;
423     p^.At := St;
424     p^.Zt := Gt;
425     p^.Color := Shape3.Brush.Color;
426     p^.Width := ScrollBar2.Position;
427     Drawline(ListBox1.Items.AddObject('Line', Pointer(p)), Image1.Canvas);
428     with Image1.Canvas do
429     begin
430     Pen.Mode := pmNotXor;
431     Pen.Style := psDash;
432     Pen.Color := clFuchsia;
433     Pen.Width := 1;
434     end;
435     end
436     else
437     begin
438     if St.X > Gt.X then
439     begin
440     ARect.Left := Gt.X;
441     ARect.Right := St.X;
442     end
443     else
444     begin
445     ARect.Left := St.X;
446     ARect.Right := Gt.X;
447     end;
448     if St.Y > Gt.Y then
449     begin
450     ARect.Top := Gt.Y;
451     ARect.Bottom := St.Y;
452     end
453     else
454     begin
455     ARect.Top := St.Y;
456     ARect.Bottom := Gt.Y;
457     end;
458     Image1.Canvas.Rectangle(ARect);
459     if ((ARect.Right - ARect.Left) < a) and ((ARect.Bottom - ARect.Top) < a)
460     then
461     Exit;
462     Rb := false;
463     if Let.Down and (Edit1.Text <> '') then
464     begin
465     w := Edit1.Text;
466     if ARect.Right - ARect.Left < (Length(w) - 1) * ScrollBar1.Position then
467     Exit;
468     New(p);
469     p^.RecType := TRecordType.Edit;
470     p^.Font:=Image2.Canvas.Font;
471     p^.Font.Height := ARect.Bottom - ARect.Top;
472     p^.Distance := ScrollBar1.Position;
473     p^.topleft := ARect.topleft;
474     p^.Shadow := CheckBox2.Checked;
475     p^.gaze := CheckBox1.Checked;
476     p^.SideColor := Shape5.Brush.Color;
477     Edit(ListBox1.Items.AddObject(Edit1.Text, Pointer(p)), Image1.Canvas);
478     end
479     else if Pic.Down and (OpenPictureDialog1.FileName <> '') then
480     begin
481     New(p);
482     p^.RecType := Phot;
483     p^.path := OpenPictureDialog1.FileName;
484     p^.range := ARect;
485     Picture(ListBox1.Items.AddObject(ExtractFileName(p^.path), Pointer(p)
486     ), onImage);
487     end;
488     end;
489     Gt := St;
490     end;
491     end;
492    
493     procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState;
494     X, Y: integer);
495     var
496     cs: TSize;
497     wd: integer;
498     w: WideString;
499     begin
500     if Rb = true then
501     begin
502     if St.X > X then
503     wd := St.X - X
504     else
505     wd := X - St.X;
506     with Image1.Canvas do
507     if Pen1.Down then
508     begin
509     MoveTo(St.X, St.Y);
510     LineTo(Gt.X, Gt.Y);
511     Gt := Point(X, Y);
512     MoveTo(St.X, St.Y);
513     LineTo(Gt.X, Gt.Y);
514     end
515     else if (Let.Down) and (Edit1.Text <> '') then
516     begin
517     w := Edit1.Text;
518     if (Length(w) - 1) * ScrollBar1.Position < wd then
519     begin
520     Rectangle(Rect(St.X, St.Y, Gt.X, Gt.Y));
521     cs := Image2.Canvas.TextExtent(w);
522     Gt.X := X;
523     Gt.Y := Round(St.Y + cs.cy / cs.cx * (wd - ScrollBar1.Position *
524     (Length(w) - 1)));
525     Rectangle(Rect(St.X, St.Y, Gt.X, Gt.Y));
526     end;
527     end
528     else if OpenPictureDialog1.FileName <> '' then
529     begin
530     Rectangle(Rect(St.X, St.Y, Gt.X, Gt.Y));
531     Gt.X := X;
532     Gt.Y := Round(St.Y + Image3.Picture.Height / Image3.Picture.Width * wd);
533     Rectangle(Rect(St.X, St.Y, Gt.X, Gt.Y));
534     end;
535     StatusBar1.Panels[1].Text := 'Width=' + IntToStr(wd) + ' Height=' +
536     IntToStr(Gt.Y - St.Y);
537     end;
538     StatusBar1.Panels[0].Text := 'X:' + IntToStr(X) + '/ Y:' + IntToStr(Y);
539     end;
540    
541     procedure TForm1.TestFont;
542     const
543     a = 22;
544     b = 3;
545     begin
546     Image2.Canvas.FillRect(Rect(0,0,Image2.Width,Image2.Height));
547     SetTextCharacterExtra(Image2.Canvas.Handle, ScrollBar1.Position);
548     Image2.Canvas.TextOut(a, b, 'a��A');
549     end;
550    
551     procedure TForm1.FormDestroy(Sender: TObject);
552     var
553     p: Pointer;
554     i: Integer;
555     begin
556     for i := 0 to ListBox1.Count-1 do
557     begin
558     p:=Pointer(ListBox1.Items.Objects[i]);
559     Dispose(p);
560     end;
561     Buffer.Free;
562     end;
563    
564     procedure TForm1.ListClear;
565     var
566     i: integer;
567     p: Pointer;
568     begin
569     for i := 0 to ListBox1.Items.Count - 1 do
570     begin
571     p:=Pointer(ListBox1.Items.Objects[i]);
572     Dispose(p);
573     end;
574     ListBox1.Clear;
575     end;
576    
577     procedure TForm1.CapMouseMove(Sender: TObject; Shift: TShiftState;
578     X, Y: integer);
579     begin
580     if ssLeft in Shift then
581     begin
582     Cap.Left := Cap.Left + X - St.X;
583     Cap.Top := Cap.Top + Y - St.Y;
584     end;
585     end;
586    
587     procedure TForm1.CapMouseUp(Sender: TObject; Button: TMouseButton;
588     Shift: TShiftState; X, Y: integer);
589     var
590     s: ^TMyRecord;
591     begin
592     if Button = mbLeft then
593     if ListBox1.ItemIndex > -1 then
594     begin
595     s := Pointer(ListBox1.Items.Objects[ListBox1.ItemIndex]);
596     if s^.RecType = TRecordType.Edit then
597     s^.topleft := Point(Cap.Left - Image1.Left, Cap.Top - Image1.Top)
598     else if s^.RecType = Phot then
599     s^.range := Rect(Cap.Left - Image1.Left, Cap.Top - Image1.Top,
600     Cap.Left - Image1.Left + Cap.Width, Cap.Top - Image1.Top +
601     Cap.Height);
602     end;
603     end;
604    
605     procedure TForm1.CapMouseDown(Sender: TObject; Button: TMouseButton;
606     Shift: TShiftState; X, Y: integer);
607     var
608     s: ^TMyRecord;
609     begin
610     case Button of
611     mbLeft:
612     St := Point(X, Y);
613     mbMiddle:
614     Capfree;
615     mbRight:
616     begin
617     s := Pointer(ListBox1.Items.Objects[ListBox1.ItemIndex]);
618     if s^.RecType = TRecordType.Edit then
619     editinfo(ListBox1.ItemIndex);
620     end;
621     end;
622     end;
623    
624     procedure TForm1.editinfo(const Index: integer);
625     var
626     p: ^TMyRecord;
627     i: integer;
628     begin
629     OKBottomDlg := TOKBottomDlg.Create(self);
630     try
631     p := Pointer(ListBox1.Items.Objects[index]);
632     with OKBottomDlg do
633     begin
634     i := p^.Font.Height;
635     Edit1.Text := IntToStr(i);
636     Label3.Caption := IntToStr(Cap.Width);
637     ComboBox1.Items := Screen.Fonts;
638     ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(p^.Font.Name);
639     CheckBox1.Checked := p^.gaze;
640     CheckBox2.Checked := p^.Shadow;
641     if p^.gaze = true then
642     Shape1.Brush.Color := p^.SideColor
643     else
644     Shape1.Brush.Color := Form1.Shape5.Brush.Color;
645     Shape2.Brush.Color := p^.Font.Color;
646     ScrollBar1.Position := p^.Distance;
647     if ShowModal = mrOK then
648     begin
649     p^.Font.Height := StrToIntDef(Edit1.Text, i);
650     p^.Font.Name := ComboBox1.Items[ComboBox1.ItemIndex];
651     p^.gaze := CheckBox1.Checked;
652     p^.Shadow := CheckBox2.Checked;
653     p^.SideColor := Shape1.Brush.Color;
654     p^.Font.Color := Shape2.Brush.Color;
655     p^.Distance := ScrollBar1.Position;
656     ListBox1.Items.Objects[index] := Pointer(p);
657     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
658     Edit(index, Cap.Picture.Bitmap.Canvas);
659     Cap.Canvas.Rectangle(0, 0, Cap.Width, Cap.Height);
660     end;
661     end;
662     finally
663     OKBottomDlg.Free;
664     end;
665     end;
666    
667     procedure TForm1.Capfree;
668     begin
669     Cap.Hide;
670     ListBox1.ItemIndex := -1;
671     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
672     Super;
673     end;
674    
675     procedure TForm1.Delete1Click(Sender: TObject);
676     var
677     i: integer;
678     p: ^TMyRecord;
679     begin
680     i := ListBox1.ItemIndex;
681     if i > -1 then
682     begin
683     p:=Pointer(ListBox1.Items.Objects[i]);
684     Dispose(p);
685     ListBox1.Items.Delete(i);
686     end;
687     Cap.Hide;
688     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
689     end;
690    
691     procedure TForm1.About1Click(Sender: TObject);
692     begin
693     AboutBox := TAboutBox.Create(self);
694     try
695     AboutBox.ShowModal;
696     finally
697     AboutBox.Free;
698     end;
699     end;
700    
701     procedure TForm1.Exit1Click(Sender: TObject);
702     begin
703     Close;
704     end;
705    
706     procedure TForm1.N1001001Click(Sender: TObject);
707     begin
708     NewBanner(Point(88, 31));
709     end;
710    
711     procedure TForm1.N3001501Click(Sender: TObject);
712     begin
713     NewBanner(Point(264, 93));
714     end;
715    
716     procedure TForm1.Clip1Click(Sender: TObject);
717     begin
718     if ListBox1.ItemIndex > -1 then
719     Capfree;
720     Clipboard.Assign(Image1.Picture);
721     end;
722    
723     procedure TForm1.Paste2Click(Sender: TObject);
724     begin
725     if Cap.Visible then
726     begin
727     Cap.Hide;
728     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
729     end;
730     if Clipboard.HasFormat(CF_BITMAP) then
731     Image1.Picture.Bitmap.Assign(Clipboard);
732     end;
733    
734     procedure TForm1.N2001001Click(Sender: TObject);
735     begin
736     NewBanner(Point(176, 62));
737     end;
738    
739     procedure TForm1.N3201201Click(Sender: TObject);
740     begin
741     NewBanner(Point(350, 190));
742     end;
743    
744     procedure TForm1.Shape2MouseDown(Sender: TObject; Button: TMouseButton;
745     Shift: TShiftState; X, Y: integer);
746     begin
747     ColorDialog1.Color := Shape2.Brush.Color;
748     if (Button = mbLeft) and ColorDialog1.Execute then
749     begin
750     Shape2.Brush.Color := ColorDialog1.Color;
751     Image2.Canvas.Font.Color := ColorDialog1.Color;
752     TestFont;
753     end;
754     end;
755    
756     procedure TForm1.N6Click(Sender: TObject);
757     begin
758     PageControl1.ActivePageIndex := 2;
759     Pen1.Down := true;
760     Shape3MouseDown(nil, mbLeft, [], 0, 0);
761     end;
762    
763     procedure TForm1.SaveJPG(const Quality: integer);
764     var
765     jpg: TJpegImage;
766     s: String;
767     begin
768     s := LowerCase(ExtractFileExt(SavePictureDialog1.FileName));
769     if (s <> '.jpg') and (s <> '.jpeg') then
770     SavePictureDialog1.FileName :=
771     ChangeFileExt(SavePictureDialog1.FileName, '.jpeg');
772     jpg := TJpegImage.Create;
773     try
774     jpg.Assign(Image1.Picture.Bitmap);
775     jpg.CompressionQuality := Quality;
776     jpg.SaveToFile(SavePictureDialog1.FileName);
777     finally
778     jpg.Free;
779     end;
780     end;
781    
782     procedure TForm1.Button1Click(Sender: TObject);
783     begin
784     if OpenPictureDialog1.Execute then
785     begin
786     Image3.Picture.LoadFromFile(OpenPictureDialog1.FileName);
787     Label1.Caption := ExtractFileName(OpenPictureDialog1.FileName);
788     end;
789     end;
790    
791     procedure TForm1.ScrollBar1Change(Sender: TObject);
792     begin
793     TestFont;
794     end;
795    
796     procedure TForm1.Picture(const Index: integer; const target: TDrawTarget);
797     var
798     p: ^TMyRecord;
799     PRec: TMyRecord;
800     Pic: TPicture;
801     begin
802     p := Pointer(ListBox1.Items.Objects[Index]);
803     PRec := p^;
804     Pic := TPicture.Create;
805     try
806     if PRec.path = OpenPictureDialog1.FileName then
807     Pic.Graphic := Image3.Picture.Graphic
808     else
809     Pic.LoadFromFile(PRec.path);
810     Pic.Graphic.Transparent := true;
811     case target of
812     onCap:
813     begin
814     Cap.Picture.Graphic.Width := PRec.range.Right - PRec.range.Left;
815     Cap.Picture.Graphic.Height := PRec.range.Bottom - PRec.range.Top;
816     Cap.Canvas.StretchDraw(Rect(0, 0, Cap.Width, Cap.Height),
817     Pic.Graphic);
818     Cap.Top := PRec.range.Top + Image1.Top;
819     Cap.Left := PRec.range.Left + Image1.Left;
820     end;
821     onBuffer:
822     Buffer.Canvas.StretchDraw(PRec.range, Pic.Graphic);
823     onImage:
824     Image1.Canvas.StretchDraw(PRec.range, Pic.Graphic);
825     end;
826     finally
827     Pic.Free;
828     end;
829     end;
830    
831     procedure TForm1.ListBox1Click(Sender: TObject);
832     var
833     p: ^TMyRecord;
834     i: integer;
835     begin
836     Super;
837     if Cap.Visible then
838     begin
839     Cap.Hide;
840     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
841     end;
842     i := ListBox1.ItemIndex;
843     if i = -1 then
844     Exit;
845     p := Pointer(ListBox1.Items.Objects[i]);
846     if p^.RecType = Ray then
847     begin
848     Image1.Canvas.MoveTo(p^.At.X, p^.At.Y);
849     Image1.Canvas.LineTo(p^.Zt.X, p^.Zt.Y);
850     if St.X < Gt.X then
851     ScrollBox1.HorzScrollBar.Position := St.X
852     else
853     ScrollBox1.HorzScrollBar.Position := Gt.X;
854     if St.Y < Gt.Y then
855     ScrollBox1.VertScrollBar.Position := St.Y
856     else
857     ScrollBox1.VertScrollBar.Position := Gt.Y;
858     end
859     else
860     begin
861     if p^.RecType = TRecordType.Edit then
862     Edit(i, Cap.Picture.Bitmap.Canvas)
863     else if p^.RecType = Phot then
864     Picture(i, onCap);
865     ScrollBox1.VertScrollBar.Position := Cap.Top - Image1.Top;
866     ScrollBox1.HorzScrollBar.Position := Cap.Left - Image1.Left;
867     Cap.Canvas.Rectangle(Rect(0, 0, Cap.Width, Cap.Height));
868     Cap.Show;
869     end;
870     Buf := false;
871     end;
872    
873     procedure TForm1.Super;
874     var
875     i, j: integer;
876     p: ^TMyRecord;
877     begin
878     Wall;
879     Image1.Canvas.Pen.Mode := pmCopy;
880     Image1.Canvas.Pen.Style := psSolid;
881     j := ListBox1.ItemIndex;
882     for i := 0 to ListBox1.Items.Count - 1 do
883     if i <> j then
884     begin
885     p := Pointer(ListBox1.Items.Objects[i]);
886     if p^.RecType = TRecordType.Edit then
887     Edit(i, Image1.Canvas)
888     else if p^.RecType = Phot then
889     Picture(i, onImage)
890     else if p^.RecType = Ray then
891     Drawline(i, Image1.Canvas);
892     end;
893     with Image1.Canvas.Pen do
894     begin
895     Color := clFuchsia;
896     Style := psDash;
897     Mode := pmNotXor;
898     Width := 1;
899     end;
900     end;
901    
902     procedure TForm1.ComboBox2Change(Sender: TObject);
903     begin
904     with Image2.Canvas.Font do
905     begin
906     case ComboBox2.ItemIndex of
907     0:
908     Style := [];
909     1:
910     Style := [fsBold];
911     2:
912     Style := [fsItalic];
913     3:
914     Style := [fsBold, fsItalic];
915     end;
916     if CheckBox3.Checked then
917     Style := Style + [fsUnderLine];
918     if CheckBox4.Checked then
919     Style := Style + [fsStrikeOut];
920     end;
921     TestFont;
922     end;
923    
924     procedure TForm1.Shape3MouseDown(Sender: TObject; Button: TMouseButton;
925     Shift: TShiftState; X, Y: integer);
926     begin
927     ColorDialog1.Color := Shape3.Brush.Color;
928     if (Button = mbLeft) and ColorDialog1.Execute then
929     Shape3.Brush.Color := ColorDialog1.Color;
930     end;
931    
932     procedure TForm1.SpeedButton1Click(Sender: TObject);
933     var
934     i: integer;
935     begin
936     i := ListBox1.ItemIndex;
937     if i > 0 then
938     begin
939     ListBox1.Items.Move(i, i - 1);
940     ListBox1.ItemIndex := i - 1;
941     end;
942     end;
943    
944     procedure TForm1.SpeedButton2Click(Sender: TObject);
945     var
946     i: integer;
947     begin
948     i := ListBox1.ItemIndex;
949     if (-1 < i) and (i < ListBox1.Items.Count - 1) then
950     begin
951     ListBox1.Items.Move(i, i + 1);
952     ListBox1.ItemIndex := i + 1;
953     end;
954     end;
955    
956     procedure TForm1.Edit(const Index: integer; const Sender: TCanvas);
957     var
958     Pt: TPoint;
959     QRec: ^TMyRecord;
960     s: string;
961     target: Boolean;
962     begin
963     target := (Sender = Cap.Picture.Bitmap.Canvas) or (Sender = Cap.Canvas);
964     s := ListBox1.Items[Index];
965     QRec := Pointer(ListBox1.Items.Objects[Index]);
966     Sender.Font:=QRec^.Font;
967     if target = true then
968     begin
969     Pt := Point(0, 0);
970     Cap.Top := QRec^.topleft.Y + Image1.Top;
971     Cap.Left := QRec^.topleft.X + Image1.Left;
972     Cap.Picture.Bitmap.Width := Sender.TextWidth(s) + QRec^.Distance *
973     (Length(s) - 1);
974     Cap.Picture.Bitmap.Height := QRec^.Font.Height;
975     end
976     else
977     Pt := QRec^.topleft;
978     with Sender do
979     begin
980     SetBkMode(Handle, Transparent);
981     SetTextCharacterExtra(Handle, QRec.Distance);
982     if QRec^.Shadow = true then
983     begin
984     Font.Color := $00CCCCCC;
985     TextOut(Pt.X + 5, Pt.Y + 5, s);
986     end;
987     if QRec^.gaze = true then
988     begin
989     if fsStrikeOut in QRec^.Font.Style then
990     Font.Style := Font.Style - [fsStrikeOut];
991     Font.Height := QRec^.Font.Height - 1;
992     Font.Color := QRec^.SideColor;
993     TextOut(Pt.X, Pt.Y, s);
994     TextOut(Pt.X, Pt.Y + 1, s);
995     TextOut(Pt.X, Pt.Y + 2, s);
996     TextOut(Pt.X + 2, Pt.Y, s);
997     TextOut(Pt.X + 2, Pt.Y + 1, s);
998     TextOut(Pt.X + 2, Pt.Y + 2, s);
999     if fsStrikeOut in QRec^.Font.Style then
1000     Font.Style := Font.Style + [fsStrikeOut];
1001     end;
1002     Font.Color := QRec^.Font.Color;
1003     if QRec^.gaze = true then
1004     TextOut(Pt.X + 1, Pt.Y + 1, s)
1005     else
1006     TextOut(Pt.X, Pt.Y, s);
1007     end;
1008     end;
1009    
1010     procedure TForm1.ListBox1Exit(Sender: TObject);
1011     begin
1012     if ListBox1.ItemIndex > -1 then
1013     Capfree;
1014     end;
1015    
1016     procedure TForm1.PicClick(Sender: TObject);
1017     begin
1018     PageControl1.ActivePageIndex := 1;
1019     end;
1020    
1021     procedure TForm1.LetClick(Sender: TObject);
1022     begin
1023     PageControl1.ActivePageIndex := 0;
1024     end;
1025    
1026     procedure TForm1.ComboBox1Change(Sender: TObject);
1027     begin
1028     Image2.Canvas.Font.Name := ComboBox1.Text;
1029     TestFont;
1030     end;
1031    
1032     procedure TForm1.RepaintClick(Sender: TObject);
1033     begin
1034     Capfree;
1035     end;
1036    
1037     procedure TForm1.N4Click(Sender: TObject);
1038     begin
1039     PageControl1.ActivePageIndex := 1;
1040     Pic.Down := true;
1041     Button1Click(nil);
1042     end;
1043    
1044     procedure TForm1.Pen1Click(Sender: TObject);
1045     begin
1046     PageControl1.ActivePageIndex := 2;
1047     end;
1048    
1049     procedure TForm1.ListBox1KeyDown(Sender: TObject; var Key: Word;
1050     Shift: TShiftState);
1051     begin
1052     if Key = VK_DELETE then
1053     Delete1Click(nil);
1054     end;
1055    
1056     procedure TForm1.PageControl1Change(Sender: TObject);
1057     begin
1058     case PageControl1.ActivePageIndex of
1059     0:
1060     Let.Down := true;
1061     1:
1062     Pic.Down := true;
1063     2:
1064     Pen1.Down := true;
1065     end;
1066     end;
1067    
1068     procedure TForm1.ScrollBar4Change(Sender: TObject);
1069     begin
1070     if Buf = false then
1071     begin
1072     ScrollBar4Enter(nil);
1073     Buf := true;
1074     end;
1075     if RadioButton2.Checked then
1076     begin
1077     Wall;
1078     Image1.Canvas.Draw(0, 0, Buffer);
1079     end
1080     else
1081     begin
1082     Image1.Canvas.Brush.Color := Shape4.Brush.Color;
1083     Image1.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
1084     if RadioButton3.Checked then
1085     BtnWall;
1086     Image1.Canvas.Draw(0, 0, Buffer);
1087     end;
1088     end;
1089    
1090     procedure TForm1.Shape4MouseDown(Sender: TObject; Button: TMouseButton;
1091     Shift: TShiftState; X, Y: integer);
1092     begin
1093     ColorDialog1.Color := Shape4.Brush.Color;
1094     if (Button = mbLeft) and ColorDialog1.Execute then
1095     begin
1096     Shape4.Brush.Color := ColorDialog1.Color;
1097     Super;
1098     end;
1099     end;
1100    
1101     procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
1102     Shift: TShiftState; X, Y: integer);
1103     begin
1104     ColorDialog1.Color := Shape1.Brush.Color;
1105     if (Button = mbLeft) and ColorDialog1.Execute then
1106     begin
1107     Shape1.Brush.Color := ColorDialog1.Color;
1108     if RadioButton1.Checked = false then
1109     begin
1110     ScrollBar4Change(nil);
1111     Super;
1112     end;
1113     end;
1114     end;
1115    
1116     procedure TForm1.ScrollBar4Enter(Sender: TObject);
1117     var
1118     i: integer;
1119     p: ^TMyRecord;
1120     begin
1121     Buffer.Canvas.Brush.Color := clWhite;
1122     Buffer.Canvas.FillRect(Rect(0, 0, Buffer.Width, Buffer.Height));
1123     Buffer.Width := Image1.Width;
1124     Buffer.Height := Image1.Height;
1125     Buffer.TransparentColor := clWhite;
1126     Buffer.Transparent := true;
1127     Buffer.Canvas.Pen.Style := psSolid;
1128     Buffer.Canvas.Pen.Mode := pmCopy;
1129     for i := 0 to ListBox1.Items.Count - 1 do
1130     begin
1131     p := Pointer(ListBox1.Items.Objects[i]);
1132     if p^.RecType = TRecordType.Edit then
1133     Edit(i, Buffer.Canvas)
1134     else if p^.RecType = Phot then
1135     Picture(i, onBuffer)
1136     else if p^.RecType = Ray then
1137     Drawline(i, Buffer.Canvas);
1138     end;
1139     end;
1140    
1141     procedure TForm1.Wall;
1142     var
1143     i: integer;
1144     begin
1145     if RadioButton2.Checked then
1146     begin
1147     i := ScrollBar4.Position;
1148     Image1.Canvas.Brush.Color := Shape1.Brush.Color;
1149     Image1.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
1150     Image1.Canvas.Brush.Color := Shape4.Brush.Color;
1151     Image1.Canvas.FillRect(Rect(i, i, Image1.Width - i, Image1.Height - i));
1152     end
1153     else
1154     begin
1155     Image1.Canvas.Brush.Color := Shape4.Brush.Color;
1156     Image1.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
1157     if RadioButton3.Checked then
1158     BtnWall;
1159     end;
1160     end;
1161    
1162     procedure TForm1.BtnWall;
1163     var
1164     bmp: TBitmap;
1165     i: integer;
1166     begin
1167     i := ScrollBar4.Position;
1168     bmp := TBitmap.Create;
1169     try
1170     bmp.Width := Image1.Width;
1171     bmp.Height := Image1.Height;
1172     with bmp.Canvas do
1173     begin
1174     Brush.Color := $00FFFFFF;
1175     FillRect(Rect(0, 0, bmp.Width, bmp.Height));
1176     Pen.Style := psSolid;
1177     Pen.Color := $00DDDDDD;
1178     MoveTo(0, 0);
1179     LineTo(i, i);
1180     LineTo(i, bmp.Height - i);
1181     LineTo(bmp.Width - i, bmp.Height - i);
1182     LineTo(bmp.Width, bmp.Height);
1183     Brush.Color := $00DDDDDD;
1184     FloodFill(0, 1, $00DDDDDD, fsBorder);
1185     end;
1186     Image1.Canvas.CopyMode := cmSrcAnd;
1187     Image1.Canvas.Draw(0, 0, bmp);
1188     Image1.Canvas.CopyMode := cmSrcCopy;
1189     finally
1190     bmp.Free;
1191     end;
1192     end;
1193    
1194     procedure TForm1.RadioButton3Click(Sender: TObject);
1195     begin
1196     BtnWall;
1197     Super;
1198     end;
1199    
1200     procedure TForm1.Shape5MouseDown(Sender: TObject; Button: TMouseButton;
1201     Shift: TShiftState; X, Y: integer);
1202     begin
1203     ColorDialog1.Color := Shape5.Brush.Color;
1204     if (Button = mbLeft) and ColorDialog1.Execute then
1205     begin
1206     Shape5.Brush.Color := ColorDialog1.Color;
1207     CheckBox1.Checked := true;
1208     end;
1209     end;
1210    
1211     procedure TForm1.Press(const Quality: integer);
1212     var
1213     s: String;
1214     begin
1215     SavePictureDialog1.FileName := '';
1216     if SavePictureDialog1.Execute then
1217     begin
1218     if ListBox1.ItemIndex > -1 then
1219     Capfree;
1220     s := LowerCase(ExtractFileExt(SavePictureDialog1.FileName));
1221     if (s = '.jpeg') or (s = '.jpg') then
1222     begin
1223     SaveJPG(Quality);
1224     Showmessage('�O������BMP�`���������������������������������B');
1225     end
1226     else if SavePictureDialog1.FilterIndex = 2 then
1227     begin
1228     SaveJPG(Quality);
1229     Showmessage('�O������BMP�`��������������������������������');
1230     end
1231     else
1232     begin
1233     if Quality < 100 then
1234     Showmessage('BMP�`�������������������B���k���s�����������������B');
1235     s := SavePictureDialog1.FileName;
1236     if CompareText(ExtractFileExt(s), '.bmp') <> 0 then
1237     s := ChangeFileExt(s, '.bmp');
1238     Image1.Picture.SaveToFile(s);
1239     end;
1240     end;
1241     end;
1242    
1243     procedure TForm1.Quality(Sender: TObject);
1244     var
1245     i: integer;
1246     begin
1247     SavePictureDialog1.FilterIndex := 2;
1248     if Sender = N11 then
1249     i := 10
1250     else if Sender = N21 then
1251     i := 20
1252     else if Sender = N31 then
1253     i := 30
1254     else if Sender = N41 then
1255     i := 40
1256     else if Sender = N51 then
1257     i := 50
1258     else if Sender = N61 then
1259     i := 60
1260     else if Sender = N71 then
1261     i := 70
1262     else if Sender = N81 then
1263     i := 80
1264     else
1265     i := 90;
1266     Press(i);
1267     end;
1268    
1269     procedure TForm1.Open1Click(Sender: TObject);
1270     begin
1271     if OpenDialog1.Execute then
1272     Open;
1273     end;
1274    
1275     procedure TForm1.Open;
1276     var
1277     Data: TMyData;
1278     p: ^TMyRecord;
1279     f: TFileStream;
1280     t: TMemoryStream;
1281     i: integer;
1282     begin
1283     Project := OpenDialog1.FileName;
1284     f:=TFileStream.Create(Project,fmOpenRead);
1285     t:=TMemoryStream.Create;
1286     try
1287     f.ReadBuffer(Pointer(@Data)^,SizeOf(Data));
1288     NewBanner(Data.Point);
1289     Shape1.Brush.Color := Data.Frame;
1290     Shape4.Brush.Color := Data.Back;
1291     ScrollBar4.Position := Data.Bold;
1292     case Data.Radio of
1293     0:
1294     RadioButton1.Checked := true;
1295     1:
1296     RadioButton2.Checked := true;
1297     2:
1298     RadioButton3.Checked := true;
1299     end;
1300     t.CopyFrom(f,Data.Count);
1301     t.Position:=0;
1302     ListBox1.Items.LoadFromStream(t);
1303     for i := 0 to ListBox1.Items.Count-1 do
1304     begin
1305     New(p);
1306     f.ReadBuffer(Pointer(p)^,SizeOf(TMyRecord));
1307     ListBox1.Items.Objects[i]:=Pointer(p);
1308     end;
1309     finally
1310     f.Free;
1311     t.Free;
1312     end;
1313     Super;
1314     end;
1315    
1316     procedure TForm1.SaveAs1Click(Sender: TObject);
1317     var
1318     Data: TMyData;
1319     f: TFileStream;
1320     s: TMemoryStream;
1321     p: ^TMyRecord;
1322     i: integer;
1323     begin
1324     Data.Point := Point(Image1.Width, Image1.Height);
1325     Data.Frame := Shape1.Brush.Color;
1326     Data.Back := Shape4.Brush.Color;
1327     Data.Bold := ScrollBar4.Position;
1328     if RadioButton1.Checked then
1329     Data.Radio := 0
1330     else if RadioButton2.Checked then
1331     Data.Radio := 1
1332     else if RadioButton3.Checked then
1333     Data.Radio := 2;
1334     if (Project = 'untitled') or (Sender = SaveAs2) then
1335     begin
1336     SaveDialog1.FileName := Project;
1337     if SaveDialog1.Execute then
1338     Project := SaveDialog1.FileName;
1339     end;
1340     f:=TFileStream.Create(Project,fmCreate);
1341     s:=TMemoryStream.Create;
1342     try
1343     ListBox1.Items.SaveToStream(s);
1344     Data.Count:=s.Size;
1345     f.WriteBuffer(Pointer(@Data)^,SizeOf(Data));
1346     f.CopyFrom(s,0);
1347     for i := 0 to ListBox1.Items.Count - 1 do
1348     begin
1349     p := Pointer(ListBox1.Items.Objects[i]);
1350     f.WriteBuffer(Pointer(p)^,SizeOf(TMyRecord));
1351     end;
1352     f.Size:=f.Position;
1353     finally
1354     f.Free;
1355     s.Free;
1356     end;
1357     end;
1358    
1359     procedure TForm1.PNG1Click(Sender: TObject);
1360     begin
1361     SavePictureDialog1.FilterIndex := 2;
1362     Press(50);
1363     end;
1364    
1365     procedure TForm1.N12Click(Sender: TObject);
1366     begin
1367     PageControl1.ActivePageIndex := 0;
1368     Let.Down := true;
1369     Shape2MouseDown(nil, mbLeft, [], 0, 0);
1370     end;
1371    
1372     procedure TForm1.N9Click(Sender: TObject);
1373     begin
1374     PageControl1.ActivePageIndex := 0;
1375     Let.Down := true;
1376     Shape5MouseDown(nil, mbLeft, [], 0, 0);
1377     end;
1378    
1379     procedure TForm1.N15Click(Sender: TObject);
1380     begin
1381     PageControl1.ActivePageIndex := 3;
1382     Shape1MouseDown(nil, mbLeft, [], 0, 0);
1383     end;
1384    
1385     procedure TForm1.Help2Click(Sender: TObject);
1386     begin
1387     Application.HelpCommand(HELP_FINDER, 0);
1388     end;
1389    
1390     procedure TForm1.ListBox1DragOver(Sender, Source: TObject; X, Y: integer;
1391     State: TDragState; var Accept: Boolean);
1392     begin
1393     Accept := (Source = ListBox1);
1394     end;
1395    
1396     procedure TForm1.ListBox1DragDrop(Sender, Source: TObject; X, Y: integer);
1397     var
1398     i: integer;
1399     begin
1400     if Source = ListBox1 then
1401     begin
1402     i := ListBox1.ItemAtPos(Point(X, Y), false);
1403     if i = -1 then
1404     begin
1405     Super;
1406     Exit;
1407     end;
1408     if (i > ListBox1.ItemIndex) or (i > ListBox1.Items.Count - 1) then
1409     dec(i);
1410     ListBox1.Items.Move(ListBox1.ItemIndex, i);
1411     ListBox1.ItemIndex := i;
1412     end;
1413     end;
1414    
1415     procedure TForm1.ToolButton10Click(Sender: TObject);
1416     var
1417     i: integer;
1418     p: Pointer;
1419     begin
1420     i := ListBox1.ItemIndex;
1421     if i > -1 then
1422     begin
1423     p:=Pointer(ListBox1.Items.Objects[i]);
1424     Dispose(p);
1425     ListBox1.Items.Delete(i);
1426     if Cap.Visible then
1427     begin
1428     Cap.Hide;
1429     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
1430     end
1431     else
1432     Capfree;
1433     end;
1434     end;
1435    
1436     procedure TForm1.TabSheet1MouseDown(Sender: TObject; Button: TMouseButton;
1437     Shift: TShiftState; X, Y: integer);
1438     begin
1439     if ListBox1.ItemIndex > -1 then
1440     Capfree;
1441     end;
1442    
1443     procedure TForm1.ToolButton5Click(Sender: TObject);
1444     var
1445     i: integer;
1446     begin
1447     i := ListBox1.ItemIndex;
1448     if i > 0 then
1449     begin
1450     ListBox1.Items.Move(i, i - 1);
1451     ListBox1.ItemIndex := i - 1;
1452     end;
1453     end;
1454    
1455     procedure TForm1.ToolButton6Click(Sender: TObject);
1456     var
1457     i: integer;
1458     begin
1459     i := ListBox1.ItemIndex;
1460     if (i > -1) and (i < ListBox1.Items.Count - 1) then
1461     begin
1462     ListBox1.Items.Move(i, i + 1);
1463     ListBox1.ItemIndex := i + 1;
1464     end;
1465     end;
1466    
1467     procedure TForm1.N17Click(Sender: TObject);
1468     begin
1469     if ListBox1.ItemIndex > -1 then
1470     Capfree;
1471     end;
1472    
1473     procedure TForm1.N18Click(Sender: TObject);
1474     begin
1475     ShellExecute(Handle, 'open', PChar('Banner2_neo.html'), '',
1476     PChar(ExtractFilePath(Application.ExeName)), SW_SHOWDEFAULT);
1477     end;
1478    
1479     procedure TForm1.ListBox1MouseDown(Sender: TObject; Button: TMouseButton;
1480     Shift: TShiftState; X, Y: integer);
1481     begin
1482     if (Button <> mbLeft) or (ListBox1.ItemAtPos(Point(X, Y), true) = -1) then
1483     begin
1484     if ListBox1.ItemIndex > -1 then
1485     Capfree;
1486     end
1487     else
1488     ListBox1.BeginDrag(true, 1);
1489     end;
1490    
1491     procedure TForm1.WMDropFiles(var Msg: TWMDropFiles);
1492     var
1493     FileName: array [0 .. 255] of char;
1494     ix: integer;
1495     intFiles: integer;
1496     begin
1497     intFiles := DragQueryFile(Msg.Drop, $FFFFFFFF, FileName, SizeOf(FileName));
1498     for ix := 0 to intFiles - 1 do
1499     begin
1500     DragQueryFile(Msg.Drop, ix, FileName, SizeOf(FileName));
1501     if CompareText(ExtractFileExt(FileName), '.ami') = 0 then
1502     begin
1503     OpenDialog1.FileName := FileName;
1504     Open;
1505     break;
1506     end;
1507     end;
1508     DragFinish(Msg.Drop);
1509     end;
1510    
1511     procedure TForm1.BaseClick(Sender: TObject);
1512     var
1513     bmp: TBitmap;
1514     ARect: TRect;
1515     i: integer;
1516     begin
1517     if Clipboard.HasFormat(CF_BITMAP) then
1518     begin
1519     if Cap.Visible then
1520     begin
1521     Cap.Hide;
1522     Cap.Canvas.FillRect(Rect(0, 0, Image1.Width, Image1.Height));
1523     end;
1524     Wall;
1525     i := ScrollBar4.Position;
1526     if RadioButton1.Checked then
1527     ARect := Rect(0, 0, Image1.Width, Image1.Height)
1528     else
1529     ARect := Rect(i, i, Image1.Width - i, Image1.Height - i);
1530     ScrollBar4Enter(nil);
1531     bmp := TBitmap.Create;
1532     try
1533     bmp.Assign(Clipboard);
1534     Image1.Canvas.CopyRect(ARect, bmp.Canvas, ARect);
1535     finally
1536     bmp.Free;
1537     end;
1538     Image1.Canvas.Draw(0, 0, Buffer);
1539     end
1540     else
1541     N20Click(nil);
1542     end;
1543    
1544     procedure TForm1.N20Click(Sender: TObject);
1545     var
1546     s: string;
1547     Pic: TPicture;
1548     begin
1549     s := OpenPictureDialog1.FileName;
1550     if OpenPictureDialog1.Execute then
1551     begin
1552     Pic := TPicture.Create;
1553     try
1554     Pic.LoadFromFile(OpenPictureDialog1.FileName);
1555     Clipboard.Assign(Pic.Graphic);
1556     finally
1557     Pic.Free;
1558     end;
1559     BaseClick(nil);
1560     end;
1561     OpenPictureDialog1.FileName := s;
1562     end;
1563    
1564     procedure TForm1.RadioButton1Click(Sender: TObject);
1565     begin
1566     ScrollBar4Enter(nil);
1567     ScrollBar4Change(nil);
1568     end;
1569    
1570     procedure TForm1.mixClick(Sender: TObject);
1571     var
1572     i: integer;
1573     bmp: TBitmap;
1574     p: ^TMyRecord;
1575     begin
1576     if Cap.Visible then
1577     begin
1578     Cap.Hide;
1579     Cap.Canvas.FillRect(Rect(0, 0, Cap.Width, Cap.Height));
1580     ListBox1.ItemIndex := -1;
1581     end;
1582     Buffer.Canvas.FillRect(Rect(0, 0, Buffer.Width, Buffer.Height));
1583     Buffer.TransparentColor := clWhite;
1584     Buffer.Transparent := true;
1585     Buffer.Canvas.CopyMode := cmSrcAnd;
1586     bmp := TBitmap.Create;
1587     try
1588     bmp.Width := Image1.Width;
1589     bmp.Height := Image1.Height;
1590     for i := 0 to ListBox1.Items.Count - 1 do
1591     begin
1592     p := Pointer(ListBox1.Items.Objects[i]);
1593     if p^.RecType = Phot then
1594     Picture(i, onImage)
1595     else
1596     begin
1597     bmp.Canvas.FillRect(Rect(0, 0, bmp.Width, bmp.Height));
1598     if p^.RecType = TRecordType.Edit then
1599     Edit(i, bmp.Canvas)
1600     else
1601     Drawline(i, bmp.Canvas);
1602     Buffer.Canvas.Draw(0, 0, bmp);
1603     end;
1604     end;
1605     finally
1606     bmp.Free;
1607     end;
1608     Image1.Canvas.Draw(0, 0, Buffer);
1609     Buffer.Canvas.CopyMode := cmSrcCopy;
1610     end;
1611    
1612     procedure TForm1.Drawline(const Index: integer; const Sender: TCanvas);
1613     var
1614     s: ^TMyRecord;
1615     begin
1616     s := Pointer(ListBox1.Items.Objects[Index]);
1617     Sender.Pen.Color := s^.Color;
1618     Sender.Pen.Width := s^.Width;
1619     Sender.MoveTo(s^.At.X, s^.At.Y);
1620     Sender.LineTo(s^.Zt.X, s^.Zt.Y);
1621     end;
1622    
1623     procedure TForm1.N25Click(Sender: TObject);
1624     begin
1625     BaseClick(nil);
1626     mixClick(nil);
1627     end;
1628    
1629     end.

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26