-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathYOTM.Main.pas
3508 lines (3209 loc) · 103 KB
/
YOTM.Main.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit YOTM.Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.ExtCtrls, Direct2D, D2D1, System.Generics.Collections,
HGM.Controls.PanelExt, Vcl.ComCtrls, System.Types, Vcl.StdCtrls,
System.UITypes, HGM.Controls.SpinEdit, Vcl.Grids, HGM.Controls.VirtualTable,
YOTM.DB, System.ImageList, Vcl.ImgList, HGM.Button, Vcl.WinXCalendars,
YOTM.Form.Notify.Task, Vcl.AppEvnts, Vcl.Menus, YOTM.DB.Comments,
YOTM.DB.Labels, YOTM.DB.Tasks, YOTM.DB.TaskRepeats, YOTM.DB.Times,
HGM.Common.Utils, YOTM.DB.LabelTypes, YOTM.DB.Notes, YOTM.Manager, HGM.Popup,
HGM.Controls.ColorGrid;
type
TFontItem = record
FontName: string;
class function Create(const FontName: string): TFontItem; static;
end;
TFontItems = TTableData<TFontItem>;
TTimeSection = record
TimeS, TimeE: TTime;
end;
TTimeSections = TList<TTimeSection>;
TCalendarCell = record
Text: string;
IsDate: Boolean;
IsDayOsWeek: Boolean;
DayOfWeek: Integer;
Date: TDate;
/// <summary>
/// Íå âûáðàííûé (íå òåêóùèé) ìåñÿö
/// </summary>
IsAnotherMonth: Boolean;
end;
TCalendarArray = array[0..6, 0..8] of record
Actual: Integer;
NotActual: Integer;
Deadlined: Integer;
Repeated: Integer;
end;
TNotifyItem = record
TaskID: Integer;
Form: TFormNotifyTask;
end;
TNotifyItems = class(TTableData<TNotifyItem>)
function FindByTask(TaskID: Integer): Integer;
function FindByForm(Form: TFormNotifyTask): Integer;
function Add(TaskID: Integer; Form: TFormNotifyTask): Integer; overload;
procedure Delete(Index: Integer);
procedure Clear;
end;
TWorkDays = array[1..7] of Boolean;
TViewMode = (vmToday, vmSelectedDate, vmDeadlined, vmInbox, vmLabel);
TSlide = (slTimes, slSettings, slCalendar, slNotes);
TFormMain = class(TForm)
TimerRepaint: TTimer;
TimerTime: TTimer;
PanelTimes: TPanel;
DrawPanel: TDrawPanel;
TableExTimes: TTableEx;
ImageList24: TImageList;
PanelSettings: TPanel;
Panel1: TPanel;
ButtonFlatTaskEnd: TButtonFlat;
ButtonFlatTaskStart: TButtonFlat;
PanelRight: TPanel;
PanelTasks: TPanel;
Shape1: TShape;
TableExTasks: TTableEx;
PanelTaskEdit: TPanel;
PanelClient: TPanel;
PanelCalendar: TPanel;
PopupMenuTaskStart: TPopupMenu;
MenuItemTaskStartFrom: TMenuItem;
ButtonFlatAddTime: TButtonFlat;
DrawGridCalendar: TDrawGrid;
ButtonFlat9: TButtonFlat;
PanelTask: TPanel;
Shape4: TShape;
TableExComments: TTableEx;
Panel2: TPanel;
ButtonFlatNewComment: TButtonFlat;
PanelTaskTop: TPanel;
ButtonFlatTaskClose: TButtonFlat;
ButtonFlatTaskState: TButtonFlat;
PanelTaskClient: TPanel;
PanelTaskComments: TPanel;
Shape5: TShape;
Shape6: TShape;
PopupMenuView: TPopupMenu;
MenuItemOpenLabels: TMenuItem;
PopupMenuTask: TPopupMenu;
MenuItemTaskDel: TMenuItem;
PanelTimeScale: TPanel;
Panel4: TPanel;
ButtonFlatCollapseScale: TButtonFlat;
Shape7: TShape;
PanelLeft: TPanel;
ButtonFlatDeadlined: TButtonFlat;
ButtonFlatTaskNow: TButtonFlat;
ButtonFlatTaskInbox: TButtonFlat;
Panel3: TPanel;
ButtonFlat7: TButtonFlat;
Calendar1: TCalendarPicker;
ButtonFlat6: TButtonFlat;
Label3: TLabel;
Shape8: TShape;
TimerAutoSaveTask: TTimer;
PanelTaskLabels: TPanel;
Shape9: TShape;
MenuItemTaskLabels: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
MenuItemTaskRename: TMenuItem;
N4: TMenuItem;
PanelTaskDAN: TPanel;
ButtonFlatTaskDAN: TButtonFlat;
ButtonFlatDANClose: TButtonFlat;
ButtonFlatViewMode: TButtonFlat;
ShapeBorder: TShape;
Shape11: TShape;
Shape12: TShape;
PanelTaskColor: TPanel;
ButtonFlatTaskColor: TButtonFlat;
ButtonFlatTaskColorClose: TButtonFlat;
PopupMenuViewProp: TPopupMenu;
MenuItemShowEnded: TMenuItem;
PanelNotes: TPanel;
PanelLog: TPanel;
MemoLog: TMemo;
Shape13: TShape;
PanelNoteTools: TPanel;
ButtonFlatSaveNote: TButtonFlat;
ButtonFlatLoadback: TButtonFlat;
PanelNoteInfo: TPanel;
Shape14: TShape;
Shape15: TShape;
LabelNoteModify: TLabel;
Label8: TLabel;
Shape16: TShape;
PopupMenuComment: TPopupMenu;
MenuItemCommentDel: TMenuItem;
PopupMenuTimes: TPopupMenu;
MenuItemDropTaskLink: TMenuItem;
MenuItemLinkWithTask: TMenuItem;
N1: TMenuItem;
N5: TMenuItem;
MenuItemTimeDelete: TMenuItem;
MenuItemTimeEdit: TMenuItem;
MenuItemTimeStartFrom: TMenuItem;
TrayIcon: TTrayIcon;
ImageListCalendar: TImageList;
ButtonFlatCurrentDate: TButtonFlat;
ButtonFlatAddTask: TButtonFlat;
DragBarTop: TDragPanel;
ButtonFlatMenuFile: TButtonFlat;
ButtonFlat4: TButtonFlat;
ButtonFlat5: TButtonFlat;
ButtonFlatMenuView: TButtonFlat;
PopupMenuFile: TPopupMenu;
MenuItemQuit: TMenuItem;
Shape10: TShape;
ScrollBoxLabels: TScrollBox;
Shape18: TShape;
Panel7: TPanel;
PanelWorkDays: TPanel;
Label6: TLabel;
Label7: TLabel;
Label9: TLabel;
ButtonFlat11: TButtonFlat;
ButtonFlatTimeFromHH: TButtonFlat;
ButtonFlat12: TButtonFlat;
ButtonFlat13: TButtonFlat;
ButtonFlatTimeFromMM: TButtonFlat;
ButtonFlat14: TButtonFlat;
ButtonFlat15: TButtonFlat;
ButtonFlatTimeToHH: TButtonFlat;
ButtonFlat16: TButtonFlat;
ButtonFlat17: TButtonFlat;
ButtonFlatTimeToMM: TButtonFlat;
ButtonFlat18: TButtonFlat;
Panel8: TPanel;
Panel9: TPanel;
Shape19: TShape;
Label1: TLabel;
Panel10: TPanel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
ButtonFlatWD1: TButtonFlat;
ButtonFlatWD2: TButtonFlat;
ButtonFlatWD3: TButtonFlat;
ButtonFlatWD4: TButtonFlat;
ButtonFlatWD5: TButtonFlat;
ButtonFlatWD6: TButtonFlat;
ButtonFlatWD7: TButtonFlat;
Shape17: TShape;
Panel11: TPanel;
Panel12: TPanel;
Panel13: TPanel;
Panel14: TPanel;
CheckBoxFlatMoreTasks: TCheckBoxFlat;
PopupMenuTray: TPopupMenu;
MenuItemTrayQuit: TMenuItem;
MenuItemTrayOpen: TMenuItem;
MenuItemTrayStartTask: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
ColorDialog: TColorDialog;
CheckBoxFlatShowCompleted: TCheckBoxFlat;
CheckBoxFlatHideOftenTasks: TCheckBoxFlat;
ButtonFlatTaskLabels: TButtonFlat;
EditNewComment: TRichEdit;
MemoNote: TRichEdit;
EditTaskName: TRichEdit;
MemoTaskDesc: TRichEdit;
PanelTextFormat: TPanel;
Panel18: TPanel;
Panel15: TPanel;
Panel16: TPanel;
Panel19: TPanel;
Panel20: TPanel;
Panel21: TPanel;
Shape22: TShape;
ImageListNotes: TImageList;
ButtonFlatDropDownFonts: TButtonFlat;
ButtonFlatFonts: TButtonFlat;
TableExFonts: TTableEx;
ButtonFlatFontSize: TButtonFlat;
ButtonFlatNoteSO: TButtonFlat;
ButtonFlatNoteUL: TButtonFlat;
ButtonFlatNoteItalic: TButtonFlat;
ButtonFlatNoteBold: TButtonFlat;
Panel22: TPanel;
ButtonFlatNoteSizeDown: TButtonFlat;
ButtonFlatNoteSizeUp: TButtonFlat;
ButtonFlatNoteSubText: TButtonFlat;
ButtonFlatNoteSuperText: TButtonFlat;
ButtonFlatNoteFG: TButtonFlat;
ButtonFlatNoteFGDrop: TButtonFlat;
ButtonFlatNoteBG: TButtonFlat;
ButtonFlatNoteBGDrop: TButtonFlat;
PanelNoteFGColor: TPanel;
ColorGridNoteFG: ThColorGrid;
Shape20: TShape;
ButtonFlatNoteFGColorAuto: TButtonFlat;
ButtonFlatFGColorDialog: TButtonFlat;
PanelNoteBGColor: TPanel;
Shape23: TShape;
ColorGridNoteBG: ThColorGrid;
ButtonFlatNoteBGNoColor: TButtonFlat;
ButtonFlatNoteAlLeft: TButtonFlat;
ButtonFlatNoteAlCenter: TButtonFlat;
ButtonFlatNoteAlRight: TButtonFlat;
ButtonFlatNoteAlWidth: TButtonFlat;
ButtonFlatNoteParLeft: TButtonFlat;
ButtonFlatNoteParRight: TButtonFlat;
FlowPanel1: TFlowPanel;
ButtonFlatTimes: TButtonFlat;
ButtonFlatCalendar: TButtonFlat;
ButtonFlatNotes: TButtonFlat;
ButtonFlatSettings: TButtonFlat;
Shape3: TShape;
ButtonFlatMinimize: TButtonFlat;
ButtonFlatClose: TButtonFlat;
PanelSelectCurDate: TPanel;
Calendar: TCalendarView;
MenuItemMoveTask: TMenuItem;
Shape2: TShape;
PanelNoteList: TPanel;
PanelNoteListCaption: TPanel;
Label2: TLabel;
ButtonFlatCollapseNoteList: TButtonFlat;
TableExNotes: TTableEx;
procedure TimerRepaintTimer(Sender: TObject);
procedure DrawPanelPaint(Sender: TObject);
procedure DrawPanelMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormCreate(Sender: TObject);
procedure TimerTimeTimer(Sender: TObject);
procedure DrawPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure DrawPanelMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure TableExTimesGetData(FCol, FRow: Integer; var Value: string);
procedure ButtonFlatCloseClick(Sender: TObject);
procedure FormPaint(Sender: TObject);
procedure ButtonFlatTaskStartClick(Sender: TObject);
procedure ButtonFlatTaskEndClick(Sender: TObject);
procedure TableExTimesItemColClick(Sender: TObject; MouseButton: TMouseButton; const Index: Integer);
procedure TableExTimesDrawCellData(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
procedure ButtonFlatSettingsClick(Sender: TObject);
procedure ButtonFlat7Click(Sender: TObject);
procedure ButtonFlat6Click(Sender: TObject);
procedure ButtonFlatMinimizeClick(Sender: TObject);
procedure ButtonFlatTimesClick(Sender: TObject);
procedure ButtonFlatCalendarClick(Sender: TObject);
procedure MenuItemTaskStartFromClick(Sender: TObject);
procedure ButtonFlatAddTimeClick(Sender: TObject);
procedure TableExTasksEdit(Sender: TObject; var Data: TTableEditStruct; ACol, ARow: Integer; var Allow: Boolean);
procedure TableExTasksEditOk(Sender: TObject; Value: string; ItemValue, ACol, ARow: Integer);
procedure ButtonFlatAddTaskClick(Sender: TObject);
procedure DrawGridCalendarDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
procedure TableExTasksEditCancel(Sender: TObject; ACol, ARow: Integer);
procedure ButtonFlat9Click(Sender: TObject);
procedure TableExCommentsGetData(FCol, FRow: Integer; var Value: string);
procedure TableExCommentsEdit(Sender: TObject; var Data: TTableEditStruct; ACol, ARow: Integer; var Allow: Boolean);
procedure TableExCommentsEditOk(Sender: TObject; Value: string; ItemValue, ACol, ARow: Integer);
procedure ButtonFlatTaskCloseClick(Sender: TObject);
procedure ButtonFlatNewCommentClick(Sender: TObject);
procedure TableExTasksDrawCellData(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
procedure MenuItemOpenLabelsClick(Sender: TObject);
procedure ButtonFlatMenuViewClick(Sender: TObject);
procedure ButtonFlatCollapseScaleClick(Sender: TObject);
procedure TableExTasksKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ButtonFlatTaskStateClick(Sender: TObject);
procedure ButtonFlatTaskNowClick(Sender: TObject);
procedure ButtonFlatTaskInboxClick(Sender: TObject);
procedure ButtonFlatDeadlinedClick(Sender: TObject);
procedure MenuItemTaskDelClick(Sender: TObject);
procedure TableExTasksMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure Calendar1CalendarDrawDayItem(Sender: TObject; DrawParams: TDrawViewInfoParams; CalendarViewViewInfo: TCellItemViewInfo);
procedure TableExTasksItemColClick(Sender: TObject; MouseButton: TMouseButton; const Index: Integer);
procedure MenuItemTaskLabelAddClick(Sender: TObject);
procedure PopupMenuTaskPopup(Sender: TObject);
procedure ButtonFlatDANCloseClick(Sender: TObject);
procedure ButtonFlatTaskDANClick(Sender: TObject);
procedure TableExTasksChangeItem(Sender: TObject; const Old: Integer; var New: Integer);
procedure ButtonFlatTaskColorCloseClick(Sender: TObject);
procedure ButtonFlatTaskColorClick(Sender: TObject);
procedure MenuItemShowEndedClick(Sender: TObject);
procedure ButtonFlatViewModeClick(Sender: TObject);
procedure ButtonFlatNotesClick(Sender: TObject);
procedure ButtonFlatSaveNoteClick(Sender: TObject);
procedure ButtonFlatLoadbackClick(Sender: TObject);
procedure ButtonFlat11Click(Sender: TObject);
procedure MemoTaskDescExit(Sender: TObject);
procedure ButtonFlatWD1Click(Sender: TObject);
procedure MenuItemCommentDelClick(Sender: TObject);
procedure TableExCommentsMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure TableExTimesMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure MenuItemTimeDeleteClick(Sender: TObject);
procedure TrayIconClick(Sender: TObject);
procedure DrawGridCalendarMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure DrawGridCalendarMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure DrawGridCalendarMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure DrawGridCalendarMouseEnter(Sender: TObject);
procedure DrawGridCalendarMouseLeave(Sender: TObject);
procedure EditNewTaskNameKeyPress(Sender: TObject; var Key: Char);
procedure ButtonFlatCurrentDateClick(Sender: TObject);
procedure TableExTasksHotOver(Sender: TObject);
procedure MenuItemLinkWithTaskClick(Sender: TObject);
procedure MenuItemDropTaskLinkClick(Sender: TObject);
procedure MenuItemTimeStartFromClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ButtonFlatMenuFileClick(Sender: TObject);
procedure MenuItemQuitClick(Sender: TObject);
procedure CheckBoxFlatMoreTasksClick(Sender: TObject);
procedure MenuItemTrayQuitClick(Sender: TObject);
procedure MenuItemTrayOpenClick(Sender: TObject);
procedure MenuItemTrayStartTaskClick(Sender: TObject);
procedure CheckBoxFlatHideOftenTasksClick(Sender: TObject);
procedure CheckBoxFlatShowCompletedClick(Sender: TObject);
procedure ButtonFlatTaskLabelsClick(Sender: TObject);
procedure EditNewCommentContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure EditTaskNameContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure EditNewTaskNameContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure MemoNoteContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean);
procedure ButtonFlatDropDownFontsClick(Sender: TObject);
procedure TableExFontsItemClick(Sender: TObject; MouseButton: TMouseButton; const Index: Integer);
procedure TableExFontsDrawCellData(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
procedure MemoNoteSelectionChange(Sender: TObject);
procedure ButtonFlatFontSizeMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure ButtonFlatFontSizeMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
procedure ButtonFlatFontSizeMouseEnter(Sender: TObject);
procedure EditNewCommentKeyPress(Sender: TObject; var Key: Char);
procedure ButtonFlatNoteTextAttrClick(Sender: TObject);
procedure ButtonFlatNoteSizeDownClick(Sender: TObject);
procedure ButtonFlatNoteSubTextClick(Sender: TObject);
procedure ButtonFlatFontsClick(Sender: TObject);
procedure ButtonFlatNoteFGDropClick(Sender: TObject);
procedure ColorGridNoteFGSelect(Sender: TObject);
procedure ButtonFlatNoteBGDropClick(Sender: TObject);
procedure SetNoteAligment(Sender: TObject);
procedure ButtonFlatNoteParLeftClick(Sender: TObject);
procedure ButtonFlatNoteParRightClick(Sender: TObject);
procedure ColorGridNoteBGSelect(Sender: TObject);
procedure ButtonFlatNoteFGClick(Sender: TObject);
procedure ButtonFlatNoteBGClick(Sender: TObject);
procedure MenuItemTimeEditClick(Sender: TObject);
procedure ButtonFlatNoteBGNoColorClick(Sender: TObject);
procedure ButtonFlatNoteFGColorAutoClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DrawGridCalendarClick(Sender: TObject);
procedure ButtonFlatFGColorDialogClick(Sender: TObject);
procedure CalendarDrawDayItem(Sender: TObject; DrawParams: TDrawViewInfoParams; CalendarViewViewInfo: TCellItemViewInfo);
procedure CalendarChange(Sender: TObject);
procedure MenuItemMoveTaskClick(Sender: TObject);
procedure TableExNotesGetData(FCol, FRow: Integer; var Value: string);
procedure ButtonFlatCollapseNoteListClick(Sender: TObject);
procedure TableExNotesDblClick(Sender: TObject);
protected
procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
procedure WMQueryEndSession(var Msg: TWMQueryEndSession); message WM_QUERYENDSESSION;
procedure WMSize(var Message: TWMSize); message WM_SIZE;
private
FFromHH, FFromMM, FToHH, FToMM: Word;
FLastDate: TDate; //Ðåàëüíàÿ äàòà (áåç âðåìåíè)
FPanelMouse: TPoint; //Ïîçèöèÿ ìûøè íà ïàíåëè
FWorkTimeMin: Integer; //Êîë-âî ìèíóò ìåæäó íà÷àëîì è êîíöîì ðàá. äíÿ
FNowTimeMin: Integer; //Êîë-âî ìèíóò òåêóùåãî âðåìåíè íàïðèìåð, åñëè ñåé÷àñ 02:05, òî çäåñü áóäåò 125 ìèíóò
FScaleRect: TRect; //Ðåàëüíûå ðàçìåðû øêàëû
FPanelMouseDown: Boolean; //Ìûøü íàæàòà íà øêàëå
FPanelMouseDownPos: TPoint; //Ïîçèöèÿ íàæàòèÿ ìûøè íà øêàëó
FRangeFrom: TTime; //Íà÷àëî ÂÛÁÎÐÀ âðåìåíè íà øêàëå
FRangeTo: TTime; //Êîíåö ÂÛÁÎÐÀ âðåìåíè íà øêàëå
FTimeItems: TTimeItems; //Ðàáîòû íàä çàäà÷àìè
FTaskItems: TTaskItems; //Çàäà÷è
FEmptyTask: TTaskItem;
FTasksOfCalendar: TTaskItems; //Ñïèñîê çàäà÷ â êàëåíäàðå
FLabelTypes: TLabelTypes;
FLabelItems: TLabelItems;
FComments: TCommentItems; //Êîììåíòàðèè ê çàäà÷å
FRepeatStates: TRepeatStates;
FNote: TNoteItem; //Çàïèñü íà äåíü
FTaskID: Integer; //Îòêðûòàÿ çàäà÷à
FCurrentDate: TDate; //Âûáðàííàÿ ïîëüçîâàòåëåì äàòà
FDoTimeSection: Boolean; //Èä¸ò ðàáîòà íàä çàäà÷åé
FNewTStartDate: TDateTime;
FNewTStart: TTime; //Âðåìÿ íà÷àëà ðàáîòû íàä çàäà÷åé
FNewTEnd: TTime; //Âðåìÿ îêîí÷àíèÿ ðàáîòû íàä çàäà÷åé
FNewTEndDate: TDateTime;
FNewTTask: Integer;
FNewTColor: TColor;
FNewTName: string;
FTimeItemUnderCursor: Integer; //Ýëåìåíò îòðåçêà âðåìåíè ïîä êóðñîðîì
FCurrentTime: TTime; //Òåêóùåå âðåìÿ (áåç äàòû)
FSelTime: TTime; //Âûáðàííîå âðåìÿ íà øêàëå
FCalendarMouseInside: Boolean;
FCalendarMouseCoord: TPoint;
FCalendarArray: TCalendarArray;
FVisNow: TControl;
FVisNeed: TControl;
FMonthOffset: Integer;
FViewMode: TViewMode;
FTimeManager: TManager;
FWorkDays: TWorkDays;
FNotifyItems: TNotifyItems;
FWindowsShutdown: Boolean;
FLastLabel: Integer;
FLastLabelCaption: string;
FPopupFonts: TFormPopup;
FPopupColor: TFormPopup;
FPopupCal: TFormPopup;
FFontItems: TFontItems;
FActualNotes: TActualNotes;
FDateChanging: Boolean;
function AddTask(Name: string = ''; Date: TDateTime = 0): TTaskItem;
function AddTaskTime(ADate, ADateEnd: TDate; TStart, TEnd: TTime; ATaskID: Integer; AColor: TColor): Boolean;
function DaysThisMonth: Integer;
function DeleteComment(ID: Integer): Boolean;
function DeleteTask(ID: Integer): Boolean;
function DeleteTime(ID: Integer): Boolean;
function GetCellInfo(ACol, ARow: Integer; var Info: TCalendarCell): string;
function GetCurrentTask: TTaskItem;
function GetDayCompletePercent: Integer;
function GetTaskSelected: Boolean;
function GetWorkDayEnd: TTime;
function GetWorkDayStart: TTime;
function StartTask(TimeStart: TTime): Boolean;
function StopTimeSection: Boolean;
procedure DoLog(Text: string);
procedure FAddTaskTime(const ADate, ADateEnd: TDate; TStart, TEnd: TTime; ATaskID: Integer; AColor: TColor; ADesc: string);
procedure HideTask;
procedure LoadNote(Date: TDate);
procedure MenuItemTaskLabelClick(Sender: TObject);
procedure MenuItemTaskLabelReset(Sender: TObject);
procedure NoteInfo;
procedure OnChangeItems;
procedure OpenTimeOverlay;
procedure ReloadCalendarData;
procedure ReloadLabelsTypes;
procedure SaveNote;
procedure SetButtonWCaption(Target, CloseButton: TButtonFlat; Panel: TPanel; ACaption: string; ACloseBotton: Boolean);
procedure SetCurrentDate(const Value: TDate);
procedure SetTimeManager(const Value: TManager);
procedure SetViewMode(const Value: TViewMode);
procedure SetWorkDayEnd(const Value: TTime);
procedure SetWorkDays(Days: TWorkDays);
procedure SetWorkDayStart(const Value: TTime);
procedure ShowTask(TaskID: Integer);
procedure SlideTo(Slide: TSlide);
procedure TaskNotify(Task: TTaskItem);
procedure TimeOverlayCallBack(Sender: TObject; State: Boolean);
procedure UpdateCalendar;
procedure UpdateCounts;
procedure UpdateDay;
procedure UpdateTaskNowButton;
procedure UpdateTaskPanel(TaskID: Integer = -1);
procedure UpdateTime;
procedure UpdateTimeOverlayData;
procedure UpdateViewModeParam;
procedure WorkDayStarted(Sender: TObject);
procedure UpdateViewMode;
procedure ProcLabelButton(Sender: TObject);
procedure BeforeChangeDay;
/// <summary>
/// Ïðîöåäóðà äëÿ ïîëíîãî ñîõðàíåíèÿ âñåõ èçìåíåíèÿ
/// </summary>
procedure SaveAll;
procedure SaveTaskDescription;
procedure SetButtonCheckColor(Button: TButtonFlat; Value: Boolean);
procedure SetCalendarDate(Value: TDateTime);
procedure ShowForm;
public
AccentColor: TColor;
BackgroundColor: TColor;
SelectionColor: TColor;
HotOverColor: TColor;
ForegroundColor: TColor;
ButtonIconColor: TColor;
procedure Error(E: Exception; const Message: string = '');
procedure Initializate;
procedure OnCloseNotifyAction(TaskID: Integer);
procedure Quit;
procedure SetTaskComplete(TaskID: Integer; Deadline: TDate; State: Boolean);
property CurrentDate: TDate read FCurrentDate write SetCurrentDate;
property CurrentTask: TTaskItem read GetCurrentTask;
property TaskItems: TTaskItems read FTaskItems;
property TaskSelected: Boolean read GetTaskSelected;
property TimeManager: TManager read FTimeManager write SetTimeManager;
property ViewMode: TViewMode read FViewMode write SetViewMode;
property WorkDayEnd: TTime read GetWorkDayEnd write SetWorkDayEnd;
property WorkDays: TWorkDays read FWorkDays write SetWorkDays;
property WorkDayStart: TTime read GetWorkDayStart write SetWorkDayStart;
end;
const
StartOfWeek = 1; //ïí
GlobalAnimateEnable = False;
var
FormMain: TFormMain;
FWndFrameSize: Integer;
FAnimate: Integer = 0;
FAnimateDo: Boolean = False;
FItemLast: Integer = -1;
FItemCur: Integer = -1;
function GetMins(Time: TTime): Integer;
function GetTime(Mins: Integer): TTime;
procedure ShowPopupMenu(Menu: TPopupMenu);
procedure SetButtonCheck(Button: TButtonFlat; Value: Boolean);
implementation
uses
Math, YOTM.Form.EditTime, DateUtils, YOTM.Form.Dialog, YOTM.Form.SelectLabels,
Winapi.CommCtrl, YOTM.Form.DateNotify, YOTM.Form.OverlayTime,
HGM.Common.DateUtils, YOTM.Form.DateEdit;
{$R *.dfm}
procedure TFormMain.Error(E: Exception; const Message: string = '');
begin
DoLog(Message);
end;
procedure SetButtonCheck(Button: TButtonFlat; Value: Boolean);
begin
if Value then
Button.ImageIndex := 18
else
Button.ImageIndex := 19;
end;
procedure TFormMain.SetButtonCheckColor(Button: TButtonFlat; Value: Boolean);
begin
if Value then
Button.ColorNormal := HotOverColor
else
Button.ColorNormal := ForegroundColor;
end;
procedure TFormMain.WMSysCommand(var Message: TWMSysCommand);
begin
case Message.CmdType of
SC_CLOSE:
Close;
SC_MINIMIZE:
ShowWindow(Handle, SW_HIDE);
SC_MAXIMIZE:
ShowWindow(Handle, SW_MAXIMIZE);
SC_RESTORE:
ShowWindow(Handle, SW_RESTORE);
else
inherited;
end;
end;
procedure ShowPopupMenu(Menu: TPopupMenu);
var
Pt: TPoint;
begin
Pt := Mouse.CursorPos;
Menu.Popup(Pt.X, Pt.Y);
end;
procedure AnimateControlLeft(TargetObject: TControl; HaveTime: Cardinal; ToValue: Integer);
var
i, delta: Integer;
begin
if GlobalAnimateEnable then
begin
delta := (ToValue - TargetObject.Left) div HaveTime;
for i := 1 to HaveTime do
begin
TargetObject.Left := TargetObject.Left + delta;
Application.ProcessMessages;
end;
end;
TargetObject.Left := ToValue;
end;
procedure AnimateControlHeight(TargetObject: TControl; HaveTime: Cardinal; ToValue: Integer);
var
i, delta: Integer;
begin
if GlobalAnimateEnable then
begin
delta := (ToValue - TargetObject.Height) div HaveTime;
for i := 1 to HaveTime do
begin
TargetObject.Height := TargetObject.Height + delta;
Application.ProcessMessages;
end;
end;
TargetObject.Height := ToValue;
end;
procedure AnimateControlTop(TargetObject: TControl; HaveTime: Cardinal; ToValue: Integer);
var
i, delta: Integer;
begin
if GlobalAnimateEnable then
begin
delta := (ToValue - TargetObject.Top) div HaveTime;
for i := 1 to HaveTime do
begin
TargetObject.Top := TargetObject.Top + delta;
Application.ProcessMessages;
end;
end;
TargetObject.Top := ToValue;
end;
procedure AnimateControlTopLeft(TargetObject: TControl; HaveTime: Cardinal; ToValueL, ToValueT: Integer);
var
i, deltaT, deltaL: Integer;
begin
if GlobalAnimateEnable then
begin
deltaT := (ToValueT - TargetObject.Top) div HaveTime;
deltaL := (ToValueL - TargetObject.Left) div HaveTime;
for i := 1 to HaveTime do
begin
TargetObject.Top := TargetObject.Top + deltaT;
TargetObject.Left := TargetObject.Left + deltaL;
TargetObject.Repaint;
Application.ProcessMessages;
end;
end;
TargetObject.Top := ToValueT;
TargetObject.Left := ToValueL;
end;
function GetMins(Time: TTime): Integer;
var
H, M, S, MSec: Word;
begin
DecodeTime(Time, H, M, S, MSec);
Result := H * 60 + M;
end;
function GetTime(Mins: Integer): TTime;
var
H, M: Word;
begin
H := Mins div 60;
M := Mins mod 60;
Result := EncodeTime(H, M, 0, 0);
end;
function DaysPerMonth(AYear, AMonth: Integer): Integer;
const
DaysInMonth: array[1..12] of Integer = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
begin
Result := DaysInMonth[AMonth];
if (AMonth = 2) and IsLeapYear(AYear) then
Inc(Result); { leap-year Feb is special }
end;
function GetDateElement(Dt: TDate; Index: Integer): Integer;
var
AYear, AMonth, ADay: Word;
begin
DecodeDate(Dt, AYear, AMonth, ADay);
case Index of
1:
Result := AYear;
2:
Result := AMonth;
3:
Result := ADay;
else
Result := -1;
end;
end;
procedure TFormMain.ReloadCalendarData;
var
Cell: TCalendarCell;
i, j: Integer;
FirstDate: TDateTime;
NotCompleted: Integer;
begin
GetCellInfo(0, 1, Cell);
FirstDate := Cell.Date;
GetCellInfo(DrawGridCalendar.ColCount - 1, DrawGridCalendar.RowCount - 1, Cell);
FTasksOfCalendar.TaskFilter := tkfDated;
FTasksOfCalendar.CalcOftenRepeat := FTaskItems.CalcOftenRepeat;
FTasksOfCalendar.ShowEndedTask := FTaskItems.ShowEndedTask;
FTasksOfCalendar.UseDatePeriod := True;
FTasksOfCalendar.DatePeriod := TDatePeriod.Create(FirstDate, Cell.Date);
FTasksOfCalendar.Reload;
NotCompleted := 0;
for i := 0 to FTasksOfCalendar.Count - 1 do
if (not FTasksOfCalendar[i].State) and (FTasksOfCalendar[i].Deadline) and (DateOf(FTasksOfCalendar[i].DateDeadline) <= DateOf(Now)) then
if (not FTasksOfCalendar[i].IsOftenRepeat) or FTasksOfCalendar.CalcOftenRepeat then
Inc(NotCompleted);
for i := 1 to DrawGridCalendar.RowCount - 1 do
for j := 0 to DrawGridCalendar.ColCount - 1 do
begin
GetCellInfo(j, i, Cell);
FTasksOfCalendar.ListCount(Cell.Date, FCalendarArray[j, i].Actual, FCalendarArray[j, i].NotActual, FCalendarArray[j, i].Deadlined, FCalendarArray[j, i].Repeated);
end;
ButtonFlatCalendar.NotifyVisible := NotCompleted > 0;
FTasksOfCalendar.Clear;
DrawGridCalendar.Repaint;
end;
procedure TFormMain.UpdateCalendar;
var
AYear, AMonth, ADay: Word;
FirstDate: TDateTime;
begin
DecodeDate(CurrentDate, AYear, AMonth, ADay);
FirstDate := EncodeDate(AYear, AMonth, 1);
FMonthOffset := 2 - ((DayOfWeek(FirstDate) - StartOfWeek + 7) mod 7);
DrawGridCalendar.RowHeights[0] := PanelTaskEdit.Height + ShapeBorder.Height;
DrawGridCalendar.DefaultColWidth := DrawGridCalendar.ClientWidth div DrawGridCalendar.ColCount;
DrawGridCalendar.ColWidths[DrawGridCalendar.ColCount - 1] := DrawGridCalendar.DefaultColWidth + DrawGridCalendar.ClientWidth mod DrawGridCalendar.ColCount;
ReloadCalendarData;
end;
function TFormMain.DaysThisMonth: Integer;
begin
Result := DaysPerMonth(GetDateElement(CurrentDate, 1), GetDateElement(CurrentDate, 2));
end;
function SetDay(Date: TDateTime; Day: Byte): TDateTime;
var
Y, M, D, HH, MM, SS, MS: Word;
begin
DecodeDateTime(Date, Y, M, D, HH, MM, SS, MS);
Result := EncodeDateTime(Y, M, Day, HH, MM, SS, MS);
end;
function TFormMain.GetCellInfo(ACol, ARow: Integer; var Info: TCalendarCell): string;
var
DayNum: Integer;
Dt: TDate;
begin
if ARow = 0 then
begin
Info.Date := 0;
Info.IsDate := False;
Info.IsDayOsWeek := True;
Info.DayOfWeek := (StartOfWeek + ACol) mod 7 + 1;
Info.IsAnotherMonth := False;
Info.Text := FormatSettings.ShortDayNames[(StartOfWeek + ACol) mod 7 + 1];
end
else
begin
Info.IsDayOsWeek := False;
Info.Date := 0;
Info.IsDate := True;
Info.DayOfWeek := (StartOfWeek + ACol) mod 7 + 1;
DayNum := FMonthOffset + ACol + (ARow - 2) * 7;
Info.IsAnotherMonth := False;
if (DayNum < 1) or (DayNum > DaysThisMonth) then
begin
Info.IsAnotherMonth := True;
Info.Text := '';
Dt := CurrentDate;
if (DayNum < 1) then
begin
Dt := SetDay(CurrentDate, 1) + (DayNum - 1);
Info.Text := IntToStr(MonthDays[IsLeapYear(YearOf(Dt)), MonthOf(Dt)] + DayNum);
end
else
begin
Dt := SetDay(Dt, MonthDays[IsLeapYear(YearOf(Dt)), MonthOf(Dt)]) + (DayNum - MonthDays[IsLeapYear(YearOf(Dt)), MonthOf(Dt)]);
Info.Text := IntToStr(DayNum - DaysThisMonth);
end;
Info.Date := Dt;
end
else
begin
Dt := SetDay(CurrentDate, DayNum);
Info.Date := Dt;
Info.Text := IntToStr(DayNum);
end;
end;
Result := Info.Text;
end;
function TFormMain.GetCurrentTask: TTaskItem;
begin
if IndexInList(TableExTasks.ItemIndex, FTaskItems.Count) then
Result := FTaskItems[TableExTasks.ItemIndex]
else
begin
Result := FEmptyTask;
end;
end;
function TFormMain.GetDayCompletePercent: Integer;
begin
Result := Max(0, Round((FNowTimeMin - GetMins(WorkDayStart)) / (FWorkTimeMin / 100)));
end;
procedure TFormMain.DrawGridCalendarClick(Sender: TObject);
var
Cell: TCalendarCell;
begin
GetCellInfo(DrawGridCalendar.Col, DrawGridCalendar.Row, Cell);
if Cell.IsDate then
begin
SetCalendarDate(Cell.Date);
ViewMode := vmSelectedDate;
end;
end;
procedure TFormMain.DrawGridCalendarDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
Cell: TCalendarCell;
txt: string;
tmp: TRect;
begin
GetCellInfo(ACol, ARow, Cell);
with Rect, DrawGridCalendar.Canvas do
begin
if Cell.IsDate then
begin
if Cell.IsAnotherMonth then
Brush.Color := ForegroundColor//Color;
else
Brush.Color := BackgroundColor;
end
else
begin
Brush.Color := ForegroundColor;
end;
if Cell.IsDate and FCalendarMouseInside and (Point(ACol, ARow) = FCalendarMouseCoord) then
Brush.Color := ColorDarker(Brush.Color, 40);
if SameDate(Cell.Date, CurrentDate) then
Brush.Color := ColorDarker(AccentColor);
Brush.Style := bsSolid;
FillRect(Rect);
if Cell.IsDayOsWeek then
begin
Brush.Color := BackgroundColor;
tmp := System.Classes.Rect(Rect.Left, Rect.Bottom - ShapeBorder.Height, Rect.Right, Rect.Bottom);
FillRect(tmp);
end;
if IsToday(Cell.Date) then
begin
Brush.Style := bsClear;
Pen.Color := AccentColor;
Rectangle(Rect);
Brush.Style := bsSolid;
Brush.Color := AccentColor;
tmp := Rect;
tmp.Inflate(-1, -1);
tmp.Width := Round(tmp.Width / 100 * GetDayCompletePercent);
FillRect(tmp);
end;
Brush.Style := bsClear;
Font.Color := $00F2F2F2;
Font.Size := 15;
TextRect(Rect, Left + (Right - Left - TextWidth(Cell.Text)) div 2, Top + (Bottom - Top - TextHeight(Cell.Text)) div 2, Cell.Text);
if Cell.Text = '1' then
begin
Font.Size := 8;
txt := FormatDateTime('mmm', Cell.Date);
TextRect(Rect, Left + (Right - Left - TextWidth(txt)) div 2, Top + 2, txt);
end;
if FCalendarArray[ACol, ARow].Deadlined > 0 then
begin
ImageListCalendar.Draw(DrawGridCalendar.Canvas, Rect.Left + 2, Rect.Top + 2, 2, True);
end
else if (FCalendarArray[ACol, ARow].Actual > 0) or (FCalendarArray[ACol, ARow].Repeated > 0) then
begin
ImageListCalendar.Draw(DrawGridCalendar.Canvas, Rect.Left + 2, Rect.Top + 2, 1, True);
end
else if FCalendarArray[ACol, ARow].NotActual > 0 then
begin
ImageListCalendar.Draw(DrawGridCalendar.Canvas, Rect.Left + 2, Rect.Top + 2, 0, True);
end; {
if FCalendarArray[ACol, ARow].Repeated > 0 then
begin
Rect.Offset(0, Rect.Height-10);
rect.Height:=10;
Rectangle(Rect);
// ImageListCalendar.Draw(DrawGridCalendar.Canvas, Rect.Left + 2, Rect.Top + 2, 0, True);
end; }
end;
end;
procedure TFormMain.DrawGridCalendarMouseEnter(Sender: TObject);
begin
FCalendarMouseInside := True;
end;
procedure TFormMain.DrawGridCalendarMouseLeave(Sender: TObject);
begin
FCalendarMouseInside := False;
end;
procedure TFormMain.DrawGridCalendarMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Cell: TCalendarCell;
C, R: Integer;
begin
DrawGridCalendar.MouseToCell(X, Y, C, R);
if FCalendarMouseInside then
begin
FCalendarMouseCoord := Point(C, R);
DrawGridCalendar.Repaint;
end;
GetCellInfo(C, R, Cell);
if DrawGridCalendar.Hint <> DateToStr(Cell.Date) then
begin
Application.CancelHint;
DrawGridCalendar.Hint := DateToStr(Cell.Date);
end
else
begin
DrawGridCalendar.Hint := DateToStr(Cell.Date);
end;
end;
procedure TFormMain.DrawGridCalendarMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
Handled := True;
end;
procedure TFormMain.DrawGridCalendarMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean);
begin
Handled := True;
end;
procedure TFormMain.DrawPanelMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
FPanelMouseDownPos := Point(X, Y);
case Button of
TMouseButton.mbLeft: