Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit main; |
2 | |||
3 | interface |
||
4 | |||
5 | uses |
||
6 | Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus, |
||
7 | StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns, |
||
8 | ActnList, ToolWin, ImgList, ShellAPI; |
||
9 | |||
10 | type |
||
11 | TMainForm = class(TForm) |
||
12 | MainMenu1: TMainMenu; |
||
13 | Window1: TMenuItem; |
||
14 | Help1: TMenuItem; |
||
15 | WindowCascadeItem: TMenuItem; |
||
16 | WindowTileItem: TMenuItem; |
||
17 | WindowArrangeItem: TMenuItem; |
||
18 | HelpAboutItem: TMenuItem; |
||
19 | WindowMinimizeItem: TMenuItem; |
||
20 | StatusBar: TStatusBar; |
||
21 | ActionList1: TActionList; |
||
22 | FileKategorien1: TAction; |
||
23 | FileExit1: TAction; |
||
24 | WindowCascade1: TWindowCascade; |
||
25 | WindowTileHorizontal1: TWindowTileHorizontal; |
||
26 | WindowArrangeAll1: TWindowArrange; |
||
27 | WindowMinimizeAll1: TWindowMinimizeAll; |
||
28 | HelpAbout1: TAction; |
||
29 | WindowTileVertical1: TWindowTileVertical; |
||
30 | WindowTileItem2: TMenuItem; |
||
31 | ToolBar2: TToolBar; |
||
32 | ToolButton3: TToolButton; |
||
33 | ToolButton9: TToolButton; |
||
34 | ToolButton8: TToolButton; |
||
35 | ToolButton10: TToolButton; |
||
36 | ToolButton11: TToolButton; |
||
37 | N1: TMenuItem; |
||
38 | Beenden1: TMenuItem; |
||
39 | Kategorie1: TMenuItem; |
||
40 | N2: TMenuItem; |
||
41 | JournalOpen: TMenuItem; |
||
42 | Timer1: TTimer; |
||
43 | Timer2: TTimer; |
||
44 | Neu1: TMenuItem; |
||
45 | AufUpdatesprfen1: TMenuItem; |
||
46 | FileNeu1: TAction; |
||
47 | FileJournal1: TAction; |
||
48 | ToolButton1: TToolButton; |
||
49 | ToolButton2: TToolButton; |
||
50 | HelpUpdates1: TAction; |
||
51 | ImageList2: TImageList; |
||
52 | procedure FileKategorien1Execute(Sender: TObject); |
||
53 | procedure HelpAbout1Execute(Sender: TObject); |
||
54 | procedure FileExit1Execute(Sender: TObject); |
||
55 | procedure FormCreate(Sender: TObject); |
||
56 | procedure JournalOpenClick(Sender: TObject); |
||
57 | procedure Timer1Timer(Sender: TObject); |
||
58 | procedure Timer2Timer(Sender: TObject); |
||
59 | procedure FormResize(Sender: TObject); |
||
60 | procedure Neu1Click(Sender: TObject); |
||
61 | procedure AufUpdates1Click(Sender: TObject); |
||
62 | private |
||
63 | CloseTimerInitialized: boolean; |
||
64 | CloseTimerMin: Integer; |
||
65 | end; |
||
66 | |||
67 | var |
||
68 | MainForm: TMainForm; |
||
69 | |||
70 | implementation |
||
71 | |||
72 | {$R *.dfm} |
||
73 | |||
74 | uses |
||
75 | about, categories, global, journal; |
||
76 | |||
77 | procedure TMainForm.FileKategorien1Execute(Sender: TObject); |
||
78 | begin |
||
79 | openCategoriesWindow(); |
||
80 | end; |
||
81 | |||
82 | procedure TMainForm.HelpAbout1Execute(Sender: TObject); |
||
83 | begin |
||
84 | AboutBox.ShowModal; |
||
85 | end; |
||
86 | |||
87 | procedure TMainForm.JournalOpenClick(Sender: TObject); |
||
88 | var |
||
89 | i: integer; |
||
90 | somethingfound: boolean; |
||
91 | begin |
||
92 | somethingfound := false; |
||
93 | |||
94 | for i := Screen.FormCount - 1 downto 0 do |
||
95 | begin |
||
96 | if Screen.Forms[i] is TMDIJournalForm then |
||
97 | begin |
||
98 | Screen.Forms[i].BringToFront; |
||
99 | Screen.Forms[i].WindowState := wsNormal; |
||
100 | somethingfound := true; |
||
101 | break; |
||
102 | end |
||
103 | end; |
||
104 | |||
105 | if not somethingfound then |
||
106 | begin |
||
107 | TMDIJournalForm.Create(Application); |
||
108 | end; |
||
109 | end; |
||
110 | |||
111 | procedure TMainForm.Neu1Click(Sender: TObject); |
||
112 | var |
||
113 | i: integer; |
||
114 | somethingfound: boolean; |
||
115 | begin |
||
116 | somethingfound := false; |
||
117 | |||
118 | for i := Screen.FormCount - 1 downto 0 do |
||
119 | begin |
||
120 | if Screen.Forms[i] is TMDICategories then |
||
121 | begin |
||
122 | TMDICategories(Screen.Forms[i]).DoNew; |
||
123 | somethingfound := true; |
||
124 | break; |
||
125 | end |
||
126 | end; |
||
127 | |||
128 | if not somethingfound then |
||
129 | begin |
||
130 | newDialog(''); // Aus der Wurzel erstellen |
||
131 | end; |
||
132 | end; |
||
133 | |||
134 | procedure TMainForm.Timer1Timer(Sender: TObject); |
||
135 | begin |
||
136 | // timer1.Enabled := false; |
||
137 | |||
138 | if not CloseTimerInitialized then |
||
139 | begin |
||
140 | CloseTimerMin := Screen.FormCount; |
||
141 | end; |
||
142 | |||
143 | if Screen.FormCount <= CloseTimerMin then |
||
144 | begin |
||
145 | if not CloseTimerInitialized then |
||
146 | begin |
||
147 | Kategorie1.Click; // Im OnShow ist das Ergebnis anders (Fenster zu klein, schwarze Ränder an abgerundeten Fensterkanten) |
||
148 | end |
||
149 | else |
||
150 | begin |
||
151 | if CfgOpenCatWhenEverythingClosed then Kategorie1.Click; // Das Fenster soll immer geöffnet werden, wenn alles andere geschlossen ist |
||
152 | end; |
||
153 | end; |
||
154 | |||
155 | if not CloseTimerInitialized then |
||
156 | begin |
||
157 | CloseTimerInitialized := true; |
||
158 | end; |
||
159 | end; |
||
160 | |||
161 | procedure TMainForm.Timer2Timer(Sender: TObject); |
||
162 | begin |
||
163 | StatusBar.Panels.Items[1].Text := DateTimeToStr(Now()); |
||
164 | end; |
||
165 | |||
166 | procedure TMainForm.AufUpdates1Click(Sender: TObject); |
||
167 | const |
||
168 | abbreviation = 'stackman'; |
||
169 | thisversion = '5.1'; |
||
170 | resourcestring |
||
171 | lng_no_new_version = 'Es ist keine neue Programmversion vorhanden.'; |
||
172 | lng_update_error = 'Ein Fehler ist aufgetreten. Wahrscheinlich ist keine Internetverbindung aufgebaut, oder der der ViaThinkSoft-Server temporär offline.'; |
||
173 | lng_caption_error = 'Fehler'; |
||
174 | lng_caption_information = 'Information'; |
||
175 | lng_update_new_version = 'Eine neue Programmversion (%s) ist vorhanden. Möchten Sie diese jetzt herunterladen?'; |
||
176 | const |
||
177 | url_comparison = 'http://www.viathinksoft.de/update/?id=%s&expect_version=%s'; |
||
178 | url_version = 'http://www.viathinksoft.de/update/?id=%s'; |
||
179 | url_download = 'http://www.viathinksoft.de/update/?id=@%s'; |
||
180 | res_nothing = 'NO_UPDATES'; |
||
181 | res_updates = 'UPDATE_AVAILABLE'; |
||
182 | var |
||
183 | temp: string; |
||
184 | begin |
||
185 | temp := GetHTML(Format(url_comparison, [abbreviation, thisversion])); |
||
186 | |||
187 | if temp = res_nothing then |
||
188 | begin |
||
189 | Application.MessageBox(PChar(lng_no_new_version), PChar(lng_caption_information), MB_OK + MB_ICONASTERISK); |
||
190 | end |
||
191 | else if temp = res_updates then |
||
192 | begin |
||
193 | temp := GetHTML(Format(url_version, [abbreviation])); |
||
194 | if Application.MessageBox(PChar(Format(lng_update_new_version, [temp])), PChar(lng_caption_information), MB_YESNO + MB_ICONASTERISK) = ID_YES then |
||
195 | begin |
||
196 | ShellExecute(application.handle, 'open', pchar(Format(url_download, [abbreviation])), '', '', sw_normal); |
||
197 | end; |
||
198 | end |
||
199 | else |
||
200 | begin |
||
201 | Application.MessageBox(PChar(lng_update_error), PChar(lng_caption_error), MB_OK + MB_ICONERROR) |
||
202 | end; |
||
203 | end; |
||
204 | |||
205 | procedure TMainForm.FileExit1Execute(Sender: TObject); |
||
206 | begin |
||
207 | Close; |
||
208 | end; |
||
209 | |||
210 | procedure TMainForm.FormCreate(Sender: TObject); |
||
211 | begin |
||
212 | if not DirectoryExists(getDataPath()) then |
||
213 | begin |
||
214 | ForceDirectories(getDataPath()); |
||
215 | end; |
||
216 | end; |
||
217 | |||
218 | procedure TMainForm.FormResize(Sender: TObject); |
||
219 | begin |
||
220 | StatusBar.Panels.Items[0].Width := StatusBar.Width - StatusBar.Panels.Items[1].Width; |
||
221 | end; |
||
222 | |||
223 | end. |