@@ -21,10 +21,12 @@ public partial class MainForm : Form
2121 public MediaPlayer MainMediaPlayer { get ; private set ; }
2222
2323 private Button btnStart , btnStop , btnBrowse , btnFullscreen , btnSettings , btnPrevMonth , btnNextMonth , btnHelp ;
24+ private Button btn7Days , btn14Days , btnCustomRange ;
2425 private TextBox txtStoragePath , txtAppSearch , txtOcrSearch ;
2526 private DateTimePicker datePicker ;
2627 private TrackBar timeTrackBar ;
27- private Label lblStatus , lblInfo , lblTime , lblPath , lblAppFilter , lblMonth , lblFormatBadge , lblOcrSearch ;
28+ private Label lblStatus , lblInfo , lblTime , lblPath , lblAppFilter , lblMonth , lblFormatBadge , lblOcrSearch , lblCurrentAppName ;
29+ private PictureBox picCurrentAppIcon ;
2830 private DarkListBox lstAppFilter ;
2931 private DarkListBox lstNotes ;
3032 private SuggestionForm _suggestionForm ;
@@ -136,7 +138,7 @@ private void InitializeControllers()
136138 _historyViewController = new HistoryViewController (
137139 MainPictureBox , MainVideoView ,
138140 timeTrackBar , lstAppFilter , txtAppSearch ,
139- lblTime , lblInfo , chkAutoScroll , lblFormatBadge ,
141+ lblTime , lblCurrentAppName , picCurrentAppIcon , lblInfo , chkAutoScroll , lblFormatBadge ,
140142 _frameRepository , _iconManager ,
141143 _currentSettings , _ocrDb , txtOcrSearch ,
142144 LibVLC , MainMediaPlayer ) ;
@@ -412,9 +414,26 @@ private void InitializeComponent()
412414 statsTabControl . TabPages . Add ( tabPageHourly ) ;
413415 tabPageStats . Controls . Add ( statsTabControl ) ;
414416 datePicker = new DateTimePicker { Location = new Point ( 12 , 15 ) , Format = DateTimePickerFormat . Short , Width = 100 } ;
415- datePicker . ValueChanged += ( s , e ) =>
417+
418+ bool dateChangedUnsuppressed = false ;
419+ datePicker . ValueChanged += async ( s , e ) =>
416420 {
417- if ( ! _suppressDateEvent ) _historyViewController ? . LoadFramesForDate ( datePicker . Value ) ;
421+ if ( ! _suppressDateEvent )
422+ {
423+ dateChangedUnsuppressed = true ;
424+ if ( _historyViewController != null ) await _historyViewController . LoadFramesForDate ( datePicker . Value ) ;
425+ }
426+ } ;
427+ datePicker . DropDown += ( s , e ) =>
428+ {
429+ dateChangedUnsuppressed = false ;
430+ } ;
431+ datePicker . CloseUp += async ( s , e ) =>
432+ {
433+ if ( ! _suppressDateEvent && ! dateChangedUnsuppressed && _historyViewController != null && ( _historyViewController . IsRangeMode || _historyViewController . IsGlobalMode ) )
434+ {
435+ await _historyViewController . LoadFramesForDate ( datePicker . Value ) ;
436+ }
418437 } ;
419438
420439 var dateMenu = new ContextMenuStrip ( ) ;
@@ -454,7 +473,44 @@ private void InitializeComponent()
454473
455474 timeTrackBar = new TrackBar { Location = new Point ( 190 , 15 ) , Size = new Size ( tabPageView . ClientSize . Width - 364 , 45 ) , Anchor = AnchorStyles . Top | AnchorStyles . Left | AnchorStyles . Right , TickStyle = TickStyle . None , Minimum = 0 , Maximum = 100 } ;
456475 lblTime = new Label { Name = "lblTime" , AutoSize = true , Location = new Point ( timeTrackBar . Right - 66 , timeTrackBar . Bottom + - 22 ) , TextAlign = ContentAlignment . TopRight , Anchor = AnchorStyles . Top | AnchorStyles . Right } ;
457- chkAutoScroll = new CheckBox { Location = new Point ( 12 , 65 ) , AutoSize = true , Checked = false } ;
476+
477+ picCurrentAppIcon = new PictureBox { Size = new Size ( 16 , 16 ) , SizeMode = PictureBoxSizeMode . Zoom , BackColor = Color . Transparent } ;
478+ lblCurrentAppName = new Label { AutoSize = false , AutoEllipsis = true , Height = 20 , Width = 200 , TextAlign = ContentAlignment . MiddleRight , BackColor = Color . Transparent , ForeColor = Color . LightGray } ;
479+
480+ btn7Days = new Button { Location = new Point ( 12 , 44 ) , Size = new Size ( 30 , 24 ) , Text = "7" } ;
481+ btn7Days . Click += ( s , e ) => {
482+ var end = DateTime . Now . Date ;
483+ var start = end . AddDays ( - 7 ) ;
484+ _historyViewController ? . LoadFramesForRange ( start , end ) ;
485+ } ;
486+
487+ btn14Days = new Button { Location = new Point ( 47 , 44 ) , Size = new Size ( 30 , 24 ) , Text = "14" } ;
488+ btn14Days . Click += ( s , e ) => {
489+ var end = DateTime . Now . Date ;
490+ var start = end . AddDays ( - 14 ) ;
491+ _historyViewController ? . LoadFramesForRange ( start , end ) ;
492+ } ;
493+
494+ btnCustomRange = new Button { Location = new Point ( 82 , 44 ) , Size = new Size ( 30 , 24 ) } ;
495+ btnCustomRange . Paint += ( s , e ) => {
496+ e . Graphics . SmoothingMode = System . Drawing . Drawing2D . SmoothingMode . AntiAlias ;
497+ using ( var pen = new Pen ( btnCustomRange . ForeColor , 1.5f ) )
498+ {
499+ int m = 6 ;
500+ int h = btnCustomRange . Height ;
501+ int w = btnCustomRange . Width ;
502+ e . Graphics . DrawLine ( pen , m , m + 2 , m , h - m - 2 ) ;
503+ e . Graphics . DrawLine ( pen , w - m , m + 2 , w - m , h - m - 2 ) ;
504+ e . Graphics . DrawLine ( pen , m , h / 2 , w - m , h / 2 ) ;
505+ e . Graphics . DrawLine ( pen , m , h / 2 , m + 3 , h / 2 - 3 ) ;
506+ e . Graphics . DrawLine ( pen , m , h / 2 , m + 3 , h / 2 + 3 ) ;
507+ e . Graphics . DrawLine ( pen , w - m , h / 2 , w - m - 3 , h / 2 - 3 ) ;
508+ e . Graphics . DrawLine ( pen , w - m , h / 2 , w - m - 3 , h / 2 + 3 ) ;
509+ }
510+ } ;
511+ btnCustomRange . Click += ( s , e ) => ShowRangeSelectionDialog ( ) ;
512+
513+ chkAutoScroll = new CheckBox { Location = new Point ( 12 , 80 ) , AutoSize = true , Checked = false } ;
458514 chkAutoScroll . CheckedChanged += ( s , e ) =>
459515 {
460516 if ( chkAutoScroll . Checked && _historyViewController != null )
@@ -474,8 +530,10 @@ private void InitializeComponent()
474530 MainVideoView = new VideoView { Location = new Point ( 12 , 100 ) , Size = new Size ( tabPageView . ClientSize . Width - 214 , tabPageView . ClientSize . Height - 112 ) , Anchor = AnchorStyles . Top | AnchorStyles . Bottom | AnchorStyles . Left , Visible = false , MediaPlayer = MainMediaPlayer } ;
475531 MainVideoView . DoubleClick += BtnFullscreen_Click ;
476532
477- tabPageView . Controls . AddRange ( new Control [ ] { datePicker , timeTrackBar , lblTime , chkGlobalSearch , lblOcrSearch , txtOcrSearch , lblAppFilter , txtAppSearch , lstAppFilter , lstNotes , chkAutoScroll , btnFullscreen , lblInfo , lblFormatBadge , MainPictureBox , MainVideoView } ) ;
533+ tabPageView . Controls . AddRange ( new Control [ ] { datePicker , btn7Days , btn14Days , btnCustomRange , timeTrackBar , lblTime , picCurrentAppIcon , lblCurrentAppName , chkGlobalSearch , lblOcrSearch , txtOcrSearch , lblAppFilter , txtAppSearch , lstAppFilter , lstNotes , chkAutoScroll , btnFullscreen , lblInfo , lblFormatBadge , MainPictureBox , MainVideoView } ) ;
478534 lblFormatBadge . BringToFront ( ) ;
535+ lblCurrentAppName . BringToFront ( ) ;
536+ picCurrentAppIcon . BringToFront ( ) ;
479537
480538 mainTabControl . TabPages . Add ( tabPageView ) ;
481539 mainTabControl . TabPages . Add ( tabPageStats ) ;
@@ -960,7 +1018,24 @@ private void UpdateLayout()
9601018 if ( newTrackBarWidth > 50 )
9611019 {
9621020 timeTrackBar . SetBounds ( trackBarLeft , timeTrackBar . Top , newTrackBarWidth , timeTrackBar . Height ) ;
963- lblTime . Left = timeTrackBar . Right - 66 ;
1021+
1022+ lblCurrentAppName . Top = timeTrackBar . Bottom - 20 ;
1023+ lblCurrentAppName . Left = timeTrackBar . Right - lblCurrentAppName . Width ;
1024+
1025+ lblTime . Top = lblCurrentAppName . Bottom - 2 ;
1026+ lblTime . Left = timeTrackBar . Right - Math . Max ( 66 , lblTime . Width ) ;
1027+
1028+ int textLeftEdge = lblCurrentAppName . Left ;
1029+ if ( ! string . IsNullOrEmpty ( lblCurrentAppName . Text ) )
1030+ {
1031+ int textWidth = TextRenderer . MeasureText ( lblCurrentAppName . Text , lblCurrentAppName . Font ) . Width ;
1032+ if ( textWidth > lblCurrentAppName . Width ) textWidth = lblCurrentAppName . Width ;
1033+ textLeftEdge = lblCurrentAppName . Right - textWidth ;
1034+ if ( textLeftEdge < lblCurrentAppName . Left ) textLeftEdge = lblCurrentAppName . Left ;
1035+ }
1036+
1037+ picCurrentAppIcon . Left = textLeftEdge - picCurrentAppIcon . Width - 5 ;
1038+ picCurrentAppIcon . Top = lblCurrentAppName . Top + ( lblCurrentAppName . Height - picCurrentAppIcon . Height ) / 2 ;
9641039 }
9651040
9661041 if ( lblFormatBadge != null )
0 commit comments