1
0
mirror of synced 2024-12-23 09:43:08 +01:00

Added: Pause and Copy buttons to Observer.MonitorForm

Added: Verbose/Info/Warning/Error buttons to test application
This commit is contained in:
Mark van Renswoude 2014-05-20 19:17:23 +00:00
parent b96c2a9d72
commit 7d3a23295c
7 changed files with 426 additions and 122 deletions

BIN
Resources/Copy.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
Resources/Pause.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -19,29 +19,28 @@ object MainForm: TMainForm
object pcObservers: TPageControl
AlignWithMargins = True
Left = 8
Top = 113
Top = 169
Width = 595
Height = 361
Height = 305
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
Margins.Bottom = 8
ActivePage = tsNamedPipe
ActivePage = tsEvent
Align = alClient
TabOrder = 0
OnChange = pcObserversChange
ExplicitTop = 113
ExplicitHeight = 361
object tsEvent: TTabSheet
Caption = 'Event Observer '
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
ExplicitHeight = 333
object mmoEvent: TMemo
AlignWithMargins = True
Left = 8
Top = 8
Width = 571
Height = 317
Height = 261
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
@ -50,19 +49,18 @@ object MainForm: TMainForm
ReadOnly = True
ScrollBars = ssVertical
TabOrder = 0
ExplicitHeight = 317
end
end
object tsFile: TTabSheet
Caption = 'File Observer'
ImageIndex = 1
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
ExplicitHeight = 333
end
object tsNamedPipe: TTabSheet
Caption = 'Named Pipe Observer'
ImageIndex = 2
ExplicitHeight = 333
end
end
object pnlButtons: TPanel
@ -87,6 +85,7 @@ object MainForm: TMainForm
Cancel = True
Caption = 'Close'
TabOrder = 1
OnClick = btnCloseClick
end
object btnMonitorForm: TButton
Left = 0
@ -105,7 +104,7 @@ object MainForm: TMainForm
Left = 8
Top = 8
Width = 595
Height = 97
Height = 153
Margins.Left = 8
Margins.Top = 8
Margins.Right = 8
@ -115,7 +114,7 @@ object MainForm: TMainForm
TabOrder = 2
DesignSize = (
595
97)
153)
object lblMessage: TLabel
Left = 16
Top = 32
@ -125,7 +124,7 @@ object MainForm: TMainForm
end
object lblException: TLabel
Left = 16
Top = 59
Top = 99
Width = 51
Height = 13
Caption = 'Exception:'
@ -140,19 +139,19 @@ object MainForm: TMainForm
Text = 'Hello world!'
OnKeyDown = edtMessageKeyDown
end
object btnSend: TButton
Left = 500
Top = 29
object btnVerbose: TButton
Left = 92
Top = 56
Width = 75
Height = 21
Anchors = [akLeft, akTop, akRight]
Caption = '&Send'
Caption = 'Verbose'
TabOrder = 1
OnClick = btnSendClick
OnClick = btnLogClick
end
object edtException: TEdit
Left = 92
Top = 56
Top = 96
Width = 402
Height = 21
Anchors = [akLeft, akTop, akRight]
@ -161,8 +160,8 @@ object MainForm: TMainForm
OnKeyDown = edtExceptionKeyDown
end
object btnException: TButton
Left = 500
Top = 56
Left = 92
Top = 123
Width = 75
Height = 21
Anchors = [akLeft, akTop, akRight]
@ -170,5 +169,35 @@ object MainForm: TMainForm
TabOrder = 3
OnClick = btnExceptionClick
end
object btnInfo: TButton
Left = 173
Top = 56
Width = 75
Height = 21
Anchors = [akLeft, akTop, akRight]
Caption = 'Info'
TabOrder = 4
OnClick = btnLogClick
end
object btnWarning: TButton
Left = 254
Top = 56
Width = 75
Height = 21
Anchors = [akLeft, akTop, akRight]
Caption = 'Warning'
TabOrder = 5
OnClick = btnLogClick
end
object btnError: TButton
Left = 335
Top = 56
Width = 75
Height = 21
Anchors = [akLeft, akTop, akRight]
Caption = 'Error'
TabOrder = 6
OnClick = btnLogClick
end
end
end

View File

@ -15,7 +15,7 @@ uses
type
TMainForm = class(TForm)
btnClose: TButton;
btnSend: TButton;
btnVerbose: TButton;
edtMessage: TEdit;
GroupBox1: TGroupBox;
lblMessage: TLabel;
@ -29,11 +29,15 @@ type
btnException: TButton;
tsNamedPipe: TTabSheet;
btnMonitorForm: TButton;
btnInfo: TButton;
btnWarning: TButton;
btnError: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure pcObserversChange(Sender: TObject);
procedure btnSendClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure btnLogClick(Sender: TObject);
procedure edtExceptionKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure edtMessageKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure btnExceptionClick(Sender: TObject);
@ -78,7 +82,9 @@ begin
SetLogResourceString(@LogMonitorFormColumnMessage, 'Melding');
SetLogResourceString(@LogMonitorFormButtonClear, 'Wissen');
SetLogResourceString(@LogMonitorFormButtonCopyDetails, 'Kopieren');
SetLogResourceString(@LogMonitorFormButtonSaveDetails, 'Opslaan');
SetLogResourceString(@LogMonitorFormStatusPaused, 'Gepauseerd: %d melding(en) overgeslagen');
FLog := TX2Log.Create;
FLog.SetExceptionStrategy(TX2LogmadExceptExceptionStrategy.Create);
@ -156,9 +162,22 @@ begin
end;
procedure TMainForm.btnSendClick(Sender: TObject);
procedure TMainForm.btnCloseClick(Sender: TObject);
begin
FLog.Info(edtMessage.Text);
Close;
end;
procedure TMainForm.btnLogClick(Sender: TObject);
begin
if Sender = btnVerbose then
FLog.Verbose(edtMessage.Text)
else if Sender = btnInfo then
FLog.Info(edtMessage.Text)
else if Sender = btnWarning then
FLog.Warning(edtMessage.Text)
else if Sender = btnError then
FLog.Error(edtMessage.Text);
end;

View File

@ -40,8 +40,12 @@ resourcestring
{ Caption of the toolbar buttons }
LogMonitorFormButtonClear = 'Clear';
LogMonitorFormButtonCopyDetails = 'Copy';
LogMonitorFormButtonSaveDetails = 'Save';
{ Status messages }
LogMonitorFormStatusPaused = 'Paused: %d log message(s) skipped';
function GetLogLevelText(ALogLevel: TX2LogLevel): string;

View File

@ -12,6 +12,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
ShowHint = True
OnClose = FormClose
OnShow = FormShow
PixelsPerInch = 96
@ -20,7 +21,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Left = 634
Top = 0
Width = 6
Height = 500
Height = 496
Align = alRight
ResizeStyle = rsUpdate
ExplicitLeft = 637
@ -30,43 +31,45 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Left = 640
Top = 0
Width = 350
Height = 500
Height = 496
Align = alRight
BevelOuter = bvNone
TabOrder = 0
ExplicitHeight = 519
ExplicitHeight = 500
object tbDetails: TToolBar
Left = 0
Top = 0
Width = 350
Height = 22
AutoSize = True
ButtonWidth = 51
ButtonWidth = 52
Images = ilsLog
List = True
ShowCaptions = True
TabOrder = 0
object tbSaveDetails: TToolButton
object tbCopyDetails: TToolButton
Left = 0
Top = 0
Caption = 'Save'
Enabled = False
ImageIndex = 5
Action = actCopyDetails
AutoSize = True
end
object tbSaveDetails: TToolButton
Left = 56
Top = 0
Action = actSaveDetails
AutoSize = True
end
end
object pnlBorder: TPanel
Left = 0
Top = 22
Width = 350
Height = 478
Height = 474
Align = alClient
BevelKind = bkFlat
BevelOuter = bvNone
TabOrder = 1
ExplicitLeft = 80
ExplicitTop = 240
ExplicitWidth = 185
ExplicitHeight = 41
ExplicitHeight = 478
object HeaderControl1: THeaderControl
Left = 0
Top = 0
@ -80,13 +83,12 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Width = 346
end>
NoSizing = True
ExplicitTop = 29
end
object reDetails: TRichEdit
Left = 0
Top = 17
Width = 346
Height = 457
Height = 453
Align = alClient
BorderStyle = bsNone
Font.Charset = ANSI_CHARSET
@ -99,8 +101,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
ReadOnly = True
ScrollBars = ssBoth
TabOrder = 1
ExplicitTop = 29
ExplicitHeight = 486
ExplicitHeight = 457
end
end
end
@ -108,19 +109,16 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Left = 0
Top = 0
Width = 634
Height = 500
Height = 496
Align = alClient
BevelOuter = bvNone
TabOrder = 1
ExplicitLeft = 408
ExplicitTop = 256
ExplicitWidth = 185
ExplicitHeight = 41
ExplicitHeight = 500
object vstLog: TVirtualStringTree
Left = 0
Top = 22
Width = 634
Height = 478
Height = 474
Align = alClient
Header.AutoSizeIndex = 2
Header.Font.Charset = DEFAULT_CHARSET
@ -129,6 +127,7 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible, hoHeaderClickAutoSort]
HintMode = hmHint
Images = ilsLog
TabOrder = 0
TreeOptions.PaintOptions = [toHideFocusRect, toShowButtons, toShowDropmark, toThemeAware]
@ -137,10 +136,9 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
OnFreeNode = vstLogFreeNode
OnGetText = vstLogGetText
OnGetImageIndex = vstLogGetImageIndex
OnGetHint = vstLogGetHint
OnInitNode = vstLogInitNode
ExplicitTop = 0
ExplicitWidth = 637
ExplicitHeight = 519
ExplicitHeight = 478
Columns = <
item
Options = [coAllowClick, coDraggable, coEnabled, coParentBidiMode, coParentColor, coShowDropMark, coVisible, coAllowFocus]
@ -164,40 +162,173 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
Width = 634
Height = 22
AutoSize = True
ButtonWidth = 52
ButtonWidth = 56
Caption = 'tbLog'
Images = ilsLog
List = True
ShowCaptions = True
TabOrder = 1
ExplicitWidth = 637
object tbClear: TToolButton
Left = 0
Top = 0
Action = actClear
AutoSize = True
Caption = 'Clear'
Enabled = False
ImageIndex = 6
OnClick = tbClearClick
end
object tbPause: TToolButton
Left = 56
Top = 0
Action = actPause
Style = tbsCheck
end
end
end
object sbStatus: TStatusBar
AlignWithMargins = True
Left = 0
Top = 500
Width = 990
Height = 19
Margins.Left = 0
Margins.Top = 4
Margins.Right = 0
Margins.Bottom = 0
Panels = <>
ExplicitLeft = 504
ExplicitTop = 272
ExplicitWidth = 0
SimplePanel = True
end
object ilsLog: TImageList
Left = 584
Top = 48
Bitmap = {
494C010107004000540010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000002000000001002000000000000020
494C0101090040007C0010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000003000000001002000000000000030
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B5845800D074
1100CD6E0900D1720900C98546000000000000000000C6824500CF720D00CD6E
0900D1720900B886590000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000CD711100FFAD
1400FF9F0100FFA30000E27A00000000000000000000E07E0C00FFAA0F00FF9F
0100FFA30000D172090000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000C9660600FF9F
0100FD960000FF9F0100DD7700000000000000000000D6710100FD960000FD96
0000FF9F0100CF6D060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000C35F0600F48E
0000F48E0000FD960000DD7700000000000000000000D06A0000F6900000F48E
0000FF9F0100C966060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000BE5C0600EE88
0000EC860000F48E0000D06A00000000000000000000C9660600EC860000EC86
0000F48E0000C966060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000BE5C0600E27A
0000E27A0000EE880000CF6D06000000000000000000C35F0600E27A0000EC86
0000EC860000C35F060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B14F0600DE78
0000DE780000E27A0000C96606000000000000000000C35F0600DD770000DD77
0000E27A0000BE5C060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B14F0600D06A
0000DD770000DD770000C35F06000000000000000000BA540100D06A0000DD77
0000DD770000BA54010000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000AD4C0C00D172
0900C9660600D06A0000BA5401000000000000000000B6540A00D06F0C00C966
0600D06A0000BA54010000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000AD4C0C00D382
3700CD721D00D0741100BE5C06000000000000000000B3561500D07F3300CD72
1D00D0741100B14F060000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A5491300D795
5E00D0854400D68B4300B75A16000000000000000000B1592000D7955E00D382
3700D68B4300AD4C0C0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A4491900DDAD
8700D59A6B00D9A06D00B15920000000000000000000B15D2A00DDAD8700D59A
6B00D9A06D00A94D150000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A7522700EED8
C600E6C4A800ECCCAF00B96939000000000000000000B7673A00EED6C100E6C4
A800ECCCAF00AB57280000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A16C5600A449
19009F441200A4491900AA6544000000000000000000AA654400A44919009F44
1200A4491900A26E580000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -212,113 +343,113 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
1100895E4600A7ABAB00B9B2AB00C8C7C300C9C9CC00AFAFAF0099A2A8008238
0D00A7471100A34B2100A47763000000000000000000000000002427AE00161C
AC005A5AA90000000000000000000000000000000000000000005353A9004F4F
A200000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
A20000000000000000000000000000000000000000009B7C6B009B7C6B009B7C
6B009B7C6B009B7C6B009B7C6B009B7C6B009B7C6B009B7C6B009B7C6B000000
00000000000000000000000000000000000000000000000000009B776600FFFF
FF00FAF4E900FAF4E900FAF4E900FAF4E900FAF4E900FAF4E900FAF4E900F9EF
E000F9EFE00097796700000000000000000000000000BC764500BE631700CD79
27009E877000B9875900CE700D00DCAF7A00FEFFFF00FEFFFF00D9E2EA00AD70
2400DD943500ECBE7500A4450E0000000000000000004E4EAB001844F600194D
F8001031D2002427AE000000000000000000000000004E4EAB000928D7000928
D7000313B3004E4EAB0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
D7000313B3004E4EAB000000000000000000000000009B776600FFFFFF00FBF5
EC00FBF5EC00FBF5EC00FBF5EC00FAF3E600FBF5EC00F8EDDA00977967000000
0000000000000000000000000000000000000000000000000000A27F6F00FFFF
FF00DDC1B400DDC1B400DDC1B400DDC1B400DDBEAD00DDBEAD00DCBAA500DCBA
A500F9EFE00097796700000000000000000000000000C9680D00C0702800C36C
1E00A7876B00AE7C5A00BA580900C69A6C00D9DFE500FEFFFF00F4F9FC00A363
1D00D5872D00E5AF6900A4450E0000000000000000002022B1002451F9001F52
FF00194DF8001744E8001017AF00000000004747AC000928D7001344F9001041
F6000E3EF600041ABC006F6FAA00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A3807000FFFF
F6000E3EF600041ABC006F6FAA000000000000000000A3807000FFFFFF00DBC3
BB00DBC1B700DBBFB200DBBDAF00DBBDAF00DAB8A500FAF3E60097796700B081
8F00975668009653640097566800000000000000000000000000A3807000FFFF
FF00DBC4BD00DBC4BD00DDC1B400DDC1B400DDBEAD00DDBEAD00DCBAA500DCBA
A500FAF4E9009B7C6C00000000000000000000000000C9680D00BB682300BF66
1900B4906E00B37C6000AF490000B5875E00BFC6CD00D5DEE400FEFFFF00A363
1D00D5872D00E5AF6900A4450E000000000000000000000000001832DB00295A
FF002451F9002451F9001A4AF200060EAF000F30DD00164AFE001344F9001041
F6000E3EF6000E3EF6002C2CA200000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000A9877800FFFF
F6000E3EF6000E3EF6002C2CA2000000000000000000A9877800FFFFFF00DBC7
C200DBC3BB00DBC1B700DBBFB200DBBDAF00DAB8A500FBF5EC009B7C6B00E3CF
D000E3CFD000E2C2C20096536400000000000000000000000000A9877800FFFF
FF00DBC6C200DBC4BD00DBC4BD00DDC1B400DBBFB400DCBAA500DDBEAD00DDBE
AD00FAF4E90097796700000000000000000000000000C9680D00BF661900BF66
1900B07D5800C1BFBD00B0ACA80098918B009A8E8400A3978A00AEA79F009058
1F00A7672300DA954200A4450E0000000000000000007777B3001832DB003A6F
FF00295AFF00295AFF00295AFF002451F900194DF800194DF8001344F9001344
F9000E3EF600161CAC0000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000AB897A00FFFF
F9000E3EF600161CAC00000000000000000000000000AB897A00FFFFFF00DBC7
C200DBC3BB00DBC3BB00DBBFB200DBBDAF00DAB8A500FBF5EC009B7C6B00D4AE
B900CB90A100E3CFD00096536400000000000000000000000000AB897A00FFFF
FF00DBC6C200DBC6C200DBC4BD00DBC4BD00DBBFB400DCBAA500DDBEAD00DCBA
A500FAF4E9009B7C6C00000000000000000000000000C9670A00B55D1B00B55D
1B00BA580900BA580900BA580900C2620E00C5671000C8691300C8691300CD79
2700D07F2A00D3893200A4450E000000000000000000000000006B6BB6001A25
C5003A6FFF003668FF00295AFF00295AFF002451F900194DF8001F52FF00123D
ED002427AE000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000AB897A00FFFF
ED002427AE0000000000000000000000000000000000AB897A00FFFFFF00DBC7
C200DBC3BB00DBC3BB00DBBFB200DBBDAF00DBBFB200FBF5EC009B7C6B00D4AE
B900CB90A100E4D0D00096536400000000000000000000000000AB897A00FFFF
FF00DBC6C200DBC4BD00DBC4BD00DBC4BD00DDC1B400DBBFB400DCBAA500DDBE
AD00FAF4E9009B7C6C00000000000000000000000000C9680D00B0551400B169
3300AF714200AF714200AF714200B0764200B0764200B0764200B0764200B076
4200BD804100D5872D00A4450E00000000000000000000000000000000000000
00002F2FB3002E4EE7003668FF00295AFF00295AFF002451F900123DED002C2C
A200000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B1908000FFFF
A2000000000000000000000000000000000000000000AF8F8000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FDFAF600FDFAF600FDFAF600FBF5EC009B7C6B00D5B1
BC00CB90A100E4D0D00098576B00000000000000000000000000B1908000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FCF9F500FCF9F500FCF9F500FAF4
E900FAF4E9009B7C6C00000000000000000000000000C2620E00AF490000B39D
8900E6F2FB00E4EDF300E4EDF300E4EDF300E1E9EF00D9E2EA00DFE3E600D9E2
EA00AD9A8A00D07F2600A4450E00000000000000000000000000000000000000
000000000000253FDF003A6FFF003668FF00295AFF00295AFF001B46EA002427
AE00000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000AF8F8000FFFF
AE000000000000000000000000000000000000000000AF8F8000FFFFFF00DFCE
CC00DBC7C200DBC7C200DBC3BB00DBC1B700DBBDAF00F0E8E0009F807000D5B1
BC00CB90A100E4DBDB0096536400000000000000000000000000AF8F8000FFFF
FF00DFCDCB00DFCDCB00DBC6C200DBC4BD00DBC4BD00DDC1B400DDBEAD00DDBE
AD00FCF9F5009B7C6C00000000000000000000000000C9670A00A8430300B899
8400FEFFFF00D4D3D200BEBDBC00C1BFBD00C1BFBD00C2C1C000C9C9CC00DFE3
E600B19B8500CD792700A4450E00000000000000000000000000000000000000
00002B2CC0004B7CFF004170FF003A6FFF003A6FFF00295AFF00295AFF001031
D2004A4AB2000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B1908000FFFF
D2004A4AB20000000000000000000000000000000000AF8F8000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00A3807000A3807000A3807000A3807000E4DB
DB00E4DBDB00E4D0D0009A5B6E00000000000000000000000000B1908000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FCF9F500FCF9F500FAF4
E900F0E8E0009B7C6C00000000000000000000000000C2620E00A23C0000B899
8400FEFFFF00E4EDF300EEEEEE00EEEEEE00EEEEEE00E5E4E300DFE3E600E5E4
E300AD9A8A00CD792700A4450E00000000000000000000000000000000000000
0000253FDF00527CFA004170FF003464FF000C13C1004170FF00295AFF002451
F9000B1DC2000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B1908000FFFF
F9000B1DC20000000000000000000000000000000000B8988800FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FDFAF600A3807000F5E2D900B18E7E00C39C9F00D4AE
B900CE98A700DFCECC0097566800000000000000000000000000B1908000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FCF9F500A3807000A380
7000A3807000A3807000000000000000000000000000C2620E00A23C0000BC9C
8A00FEFFFF00DDDCDB00C1BFBD00C2C1C000C2C1C000C1BFBD00C9C9CC00E1E9
EF00B19B8500CD771F00A4450E00000000000000000000000000000000004F4F
BD00527CFA005081FF004B7CFF001A25C500000000001A25C5003A6FFF002451
F9001A4AF2001419B10000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B8988800FFFF
F9001A4AF2001419B100000000000000000000000000B8988800FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00A3807000B18E7E00CFC3BD00E6E2E200A25B
7100A25B7100A25B7100A25B7100000000000000000000000000B8988800FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FCF9F500FFFFFF00A3807000F5E2
D900B08E7D00AB9E9800000000000000000000000000C2620E009A310000BC9C
8A00FEFFFF00FEFFFF00EEEEEE00EEEEEE00EEEEEE00E5E4E300E5E4E300EEEE
EE00B39D8900C2701D00A9480D0000000000000000000000000000000000252D
D6006A9CFF005788FF002B46E7006B6BB60000000000000000001A25C500295A
FF002451F9001439DD004747AC00000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B8988800FFFF
FF002451F9001439DD004747AC000000000000000000B8988800B8988800AF8F
8000B18E7E00B18E7E00AC887700A3807000CFC3BD00E6E2E200E6E2E200A25B
7100E0C1CA00AA697E00A9919800000000000000000000000000B8988800FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00A3807000B08E
7D00AB9E980000000000000000000000000000000000C562060093280000BC9C
8A00FEFFFF00E5E4E300D1CFCC00D1CFCC00C9C9CC00D1CFCC00D4D3D200E4ED
F300B9A38C008A4F1400B0551400000000000000000000000000000000004B4B
C8003951E2005081FF002B2CC000000000000000000000000000000000001628
D300265AFF000F2EE3002022B100000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000B8988800B898
000000000000C194A300E6E2E200E6E2E200E6E2E200E6E2E200E6E2E200A25B
7100AA697E00A991980000000000000000000000000000000000B8988800B898
8800B1908000B1908000B08E7D00B08E7D00AC887700AC887700A3807000AB9E
98000000000000000000000000000000000000000000BF8D5800C0540200C8A4
8300D4D3D200D4D3D200D4D3D200D4D3D200C9C9CC00C8C7C300C1BFBD00BEBD
BC00B1947B00C0540200B07D5800000000000000000000000000000000000000
0000000000003E3EB90000000000000000000000000000000000000000006B6B
B6002F2FB3000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000AF728500AF728500AC6D8000AC6D8000AC6D8000A6627600A25B
7100A99198000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
@ -455,16 +586,46 @@ object X2LogObserverMonitorForm: TX2LogObserverMonitorForm
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000200000000100010000000000000100000000000000000000
000000000000000000000000FFFFFF00FFFFFFFFFFFF0000C003C001C7CF0000
C003800183830000C003800181010000C0038001C0010000C003800180030000
C0038001C0070000C0038001F00F0000C0038001F80F0000C0038001F0070000
C0038001F0070000C0038001E0830000C0038001E0C10000C0078001E1E10000
C00F8001FBE70000FFFFFFFFFFFF0000FFFFFFFFFFFFFFFFF81FF81FFFFF8001
2800000040000000300000000100010000000000800100000000000000000000
000000000000000000000000FFFFFF00FFFF000000000000C183000000000000
C183000000000000C183000000000000C183000000000000C183000000000000
C183000000000000C183000000000000C183000000000000C183000000000000
C183000000000000C183000000000000C183000000000000C183000000000000
C183000000000000FFFF000000000000FFFFFFFFFFFFFFFFC003C001C7CF801F
C00380018383801FC003800181018001C0038001C0018001C003800180038001
C0038001C0078001C0038001F00F8001C0038001F80F8001C0038001F0078001
C0038001F0078001C0038001E0838001C0038001E0C18001C0078001E1E1F803
C00F8001FBE7F807FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF81FF81FFFFF8001
F00FF00F80038001E007E00780018001C003C003800180018001800180018001
80018001C003800180018001E003800180018001E007800180018001F00F8001
80018001F00F8001C003C003F81F8001E007C007F81F8001F00FE00FFC3F8001
F81FF81FFE7F8001FFFFFFFFFFFFFFFF00000000000000000000000000000000
000000000000}
end
object alLog: TActionList
Images = ilsLog
Left = 512
Top = 48
object actClear: TAction
Caption = 'Clear'
ImageIndex = 6
OnExecute = actClearExecute
end
object actCopyDetails: TAction
Caption = 'Copy'
ImageIndex = 7
OnExecute = actCopyDetailsExecute
end
object actSaveDetails: TAction
Caption = 'Save'
ImageIndex = 5
Visible = False
end
object actPause: TAction
AutoCheck = True
Caption = 'Pause'
ImageIndex = 8
OnExecute = actPauseExecute
end
end
end

View File

@ -1,18 +1,20 @@
unit X2Log.Observer.MonitorForm;
// #ToDo3 -oMvR: 20-5-2014: pause button
interface
uses
System.Classes,
System.Generics.Collections,
Vcl.ComCtrls,
Vcl.Controls,
Vcl.ExtCtrls,
Vcl.Forms,
Vcl.ImgList,
Vcl.StdCtrls,
Vcl.ToolWin,
VirtualTrees,
Winapi.Messages,
X2Log.Intf, Vcl.StdCtrls, Vcl.ComCtrls, Vcl.ExtCtrls, Vcl.ToolWin;
X2Log.Intf, Vcl.ActnList;
const
@ -34,21 +36,34 @@ type
tbClear: TToolButton;
tbSaveDetails: TToolButton;
sbStatus: TStatusBar;
tbCopyDetails: TToolButton;
alLog: TActionList;
actClear: TAction;
actCopyDetails: TAction;
actSaveDetails: TAction;
actPause: TAction;
tbPause: TToolButton;
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure vstLogInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
procedure vstLogFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
procedure vstLogGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; TextType: TVSTTextType; var CellText: string);
procedure vstLogGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex; var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
procedure vstLogGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
procedure vstLogFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex);
procedure tbClearClick(Sender: TObject);
procedure actClearExecute(Sender: TObject);
procedure actCopyDetailsExecute(Sender: TObject);
procedure actPauseExecute(Sender: TObject);
private class var
FInstances: TDictionary<IX2Log,TX2LogObserverMonitorForm>;
private
FFreeOnClose: Boolean;
FLogToAttach: IX2Log;
FLogAttached: Boolean;
FPausedLogCount: Integer;
function GetPaused: Boolean;
protected
class function GetInstance(ALog: IX2Log; out AForm: TX2LogObserverMonitorForm): Boolean;
class procedure RemoveInstance(AForm: TX2LogObserverMonitorForm);
@ -59,8 +74,13 @@ type
procedure WMEnable(var Msg: TWMEnable); message WM_ENABLE;
procedure CMReenable(var Msg: TMessage); message CM_REENABLE;
procedure UpdateUI;
procedure UpdateStatus;
property LogToAttach: IX2Log read FLogToAttach;
property LogAttached: Boolean read FLogAttached;
property Paused: Boolean read GetPaused;
property PausedLogCount: Integer read FPausedLogCount write FPausedLogCount;
public
class function Instance(ALog: IX2Log): TX2LogObserverMonitorForm;
@ -81,6 +101,7 @@ implementation
uses
System.DateUtils,
System.SysUtils,
Vcl.Clipbrd,
Winapi.Windows,
X2Log.Constants;
@ -212,7 +233,10 @@ begin
vstLog.Header.Columns[ColumnMessage].Text := GetLogResourceString(@LogMonitorFormColumnMessage);
tbClear.Caption := GetLogResourceString(@LogMonitorFormButtonClear);
tbCopyDetails.Caption := GetLogResourceString(@LogMonitorFormButtonCopyDetails);
tbSaveDetails.Caption := GetLogResourceString(@LogMonitorFormButtonSaveDetails);
UpdateUI;
end;
@ -266,15 +290,24 @@ var
nodeData: PLogEntryNodeData;
begin
// #ToDo1 -oMvR: 20-5-2014: thread safety; Log is not guaranteed to be called in the main thread!
if GetCurrentThreadId <> MainThreadID then
exit;
{ Ensure thread safety; TThread.Queue will run the procedure immediately
if Log is called from the main thread, or queue it asynchronously }
TThread.Queue(nil,
procedure
begin
if not Paused then
begin
node := vstLog.AddChild(nil);
nodeData := vstLog.GetNodeData(node);
nodeData^.Initialize(ALevel, AMessage, ADetails);
node := vstLog.AddChild(nil);
nodeData := vstLog.GetNodeData(node);
nodeData^.Initialize(ALevel, AMessage, ADetails);
tbClear.Enabled := True;
UpdateUI;
end else
begin
PausedLogCount := PausedLogCount + 1;
UpdateStatus;
end;
end);
end;
@ -292,6 +325,34 @@ begin
end;
procedure TX2LogObserverMonitorForm.UpdateUI;
var
hasDetails: Boolean;
begin
actClear.Enabled := (vstLog.RootNodeCount > 0);
hasDetails := (Length(reDetails.Text) > 0);
actCopyDetails.Enabled := hasDetails;
actSaveDetails.Enabled := hasDetails;
end;
procedure TX2LogObserverMonitorForm.UpdateStatus;
begin
if Paused then
sbStatus.SimpleText := ' ' + Format(GetLogResourceString(@LogMonitorFormStatusPaused), [PausedLogCount])
else
sbStatus.SimpleText := '';
end;
function TX2LogObserverMonitorForm.GetPaused: Boolean;
begin
Result := actPause.Checked;
end;
procedure TX2LogObserverMonitorForm.vstLogInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode;
var InitialStates: TVirtualNodeInitStates);
var
@ -332,6 +393,20 @@ begin
end;
procedure TX2LogObserverMonitorForm.vstLogGetHint(Sender: TBaseVirtualTree; Node: PVirtualNode; Column: TColumnIndex;
var LineBreakStyle: TVTTooltipLineBreakStyle; var HintText: string);
var
nodeData: PLogEntryNodeData;
begin
if Column = ColumnLevel then
begin
nodeData := Sender.GetNodeData(Node);
HintText := GetLogLevelText(nodeData^.Level);
end;
end;
procedure TX2LogObserverMonitorForm.vstLogGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind;
Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
var
@ -370,13 +445,29 @@ begin
reDetails.Text := nodeData^.Details;
end else
reDetails.Text := '';
UpdateUI;
end;
procedure TX2LogObserverMonitorForm.tbClearClick(Sender: TObject);
procedure TX2LogObserverMonitorForm.actClearExecute(Sender: TObject);
begin
vstLog.Clear;
tbClear.Enabled := False;
UpdateUI;
end;
procedure TX2LogObserverMonitorForm.actCopyDetailsExecute(Sender: TObject);
begin
if Length(reDetails.Text) > 0 then
Clipboard.AsText := reDetails.Text;
end;
procedure TX2LogObserverMonitorForm.actPauseExecute(Sender: TObject);
begin
PausedLogCount := 0;
UpdateStatus;
end;
end.