Skip to content

Commit 463a887

Browse files
committed
The application name is now displayed under the timeline. Quick filter buttons have been added under the calendar. The bug preventing website renaming has been fixed.
1 parent 099e7b2 commit 463a887

5 files changed

Lines changed: 230 additions & 22 deletions

File tree

Recap/Resources/AppFilterController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,16 @@ private void RenderChildren(NodeData parentNode, string parentRaw, string parent
824824
bool isGroupExpanded = _expandedGroups.Contains(fullGroupKey) || isSearch;
825825

826826
string displayChildName = childName;
827-
if (level == 2 && parentRaw != null && parentRaw.Contains("|github.com") && childName.Contains("/") && childName.Split('/').Length == 2)
827+
bool hasAlias = false;
828+
string aliasKey = $"{parentRaw}|{childName}";
829+
830+
if (_aliases != null && _aliases.TryGetValue(aliasKey, out string aliasName))
831+
{
832+
displayChildName = aliasName;
833+
hasAlias = true;
834+
}
835+
836+
if (!hasAlias && level == 2 && parentRaw != null && parentRaw.Contains("|github.com") && childName.Contains("/") && childName.Split('/').Length == 2)
828837
{
829838
string[] splitRepo = childName.Split('/');
830839
displayChildName = $"{splitRepo[1]} - {splitRepo[0]}";

Recap/Resources/HistoryViewController.cs

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class HistoryViewController : IDisposable
3030

3131
private readonly AppFilterController _appFilterController;
3232
private readonly TimelineController _timelineController;
33+
private readonly IconManager _iconManager;
3334

3435
private readonly TimelineDataManager _dataManager;
3536
private readonly MediaPlayerController _mediaController;
@@ -38,10 +39,13 @@ public class HistoryViewController : IDisposable
3839
private List<FrameIndex> _pendingFrames = new List<FrameIndex>();
3940
private bool _isInitialLoad = true;
4041
private bool _isGlobalMode = false;
42+
public bool IsGlobalMode => _isGlobalMode;
4143

4244
private DateTime _currentStartDate = DateTime.Today;
4345
private DateTime _currentEndDate = DateTime.Today;
4446

47+
public bool IsRangeMode => _currentStartDate.Date != _currentEndDate.Date;
48+
4549
private List<string> _selectedAppFilter = null;
4650

4751
private System.Windows.Forms.Timer _uiTimer;
@@ -74,6 +78,8 @@ public HistoryViewController(
7478
DarkListBox lstAppFilter,
7579
TextBox txtAppSearch,
7680
Label lblTime,
81+
Label lblCurrentAppName,
82+
PictureBox picCurrentAppIcon,
7783
Label lblInfo,
7884
CheckBox chkAutoScroll,
7985
Label lblFormatBadge,
@@ -92,6 +98,7 @@ public HistoryViewController(
9298
_settings = settings;
9399
_ocrDb = ocrDb;
94100
_txtOcrSearch = txtOcrSearch;
101+
_iconManager = iconManager;
95102

96103
_dataManager = new TimelineDataManager(frameRepository, ocrDb, settings);
97104
_mediaController = new MediaPlayerController(libVLC, mediaPlayer);
@@ -107,7 +114,7 @@ public HistoryViewController(
107114

108115
_appFilterController = new AppFilterController(lstAppFilter, txtAppSearch, iconManager, _ocrDb, _frameRepository, settings);
109116
lstAppFilter.ShowFrameCount = settings.ShowFrameCount;
110-
_timelineController = new TimelineController(timeTrackBar, lblTime, lblInfo, chkAutoScroll, null, frameRepository, iconManager);
117+
_timelineController = new TimelineController(timeTrackBar, lblTime, lblCurrentAppName, picCurrentAppIcon, lblInfo, chkAutoScroll, null, frameRepository, iconManager);
111118

112119
_appFilterController.FilterChanged += OnAppFilterChanged;
113120
_appFilterController.AppHidden += OnAppHidden;
@@ -307,6 +314,45 @@ private void OnOcrSearchKeyDown(object sender, KeyEventArgs e)
307314
}
308315

309316

317+
private string CleanAppNameForUI(string rawName)
318+
{
319+
if (string.IsNullOrEmpty(rawName)) return "";
320+
321+
var parts = rawName.Split('|');
322+
string displayName = "";
323+
324+
if (parts.Length >= 3 && parts[1].Equals("YouTube", StringComparison.OrdinalIgnoreCase))
325+
{
326+
string title = parts[2];
327+
int vIndex = title.LastIndexOf(" [v=");
328+
if (vIndex > 0)
329+
{
330+
title = title.Substring(0, vIndex);
331+
}
332+
displayName = title;
333+
}
334+
else if (parts.Length >= 2)
335+
{
336+
displayName = parts[parts.Length - 1];
337+
}
338+
else
339+
{
340+
displayName = rawName;
341+
}
342+
343+
if (displayName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
344+
{
345+
displayName = displayName.Substring(0, displayName.Length - 4);
346+
}
347+
348+
if (displayName.Length > 0 && char.IsLower(displayName[0]) && parts.Length < 2)
349+
{
350+
displayName = char.ToUpper(displayName[0]) + displayName.Substring(1);
351+
}
352+
353+
return displayName;
354+
}
355+
310356
private async void OnSearchKeyDown(object sender, KeyEventArgs e)
311357
{
312358
if (e.KeyCode == Keys.Enter && _settings.GlobalSearch)
@@ -325,7 +371,26 @@ private void OnUiTimerTick(object sender, EventArgs e)
325371
{
326372
var miniFrame = _dataManager.FilteredFrames[_wantedFrameIndex];
327373

328-
_timelineController.UpdateTimeLabel(miniFrame.GetTime(), _isGlobalMode);
374+
bool isRangeMode = _currentStartDate.Date != _currentEndDate.Date;
375+
_timelineController.UpdateTimeLabel(miniFrame.GetTime(), _isGlobalMode || isRangeMode);
376+
377+
string rawAppName = "";
378+
if (_dataManager.AppMap.TryGetValue(miniFrame.AppId, out string name))
379+
{
380+
rawAppName = name;
381+
}
382+
else
383+
{
384+
var frameData = _frameRepository.GetFrameIndex(miniFrame.TimestampTicks);
385+
if (frameData.TimestampTicks != 0)
386+
{
387+
rawAppName = frameData.AppName;
388+
}
389+
}
390+
391+
Image appIcon = _iconManager.GetIcon(rawAppName);
392+
string cleanName = CleanAppNameForUI(rawAppName);
393+
_timelineController.UpdateCurrentApp(cleanName, appIcon);
329394

330395
if (_ocrTextForm != null && !_ocrTextForm.IsDisposed)
331396
{

Recap/Resources/MainForm.cs

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

Recap/Resources/TimelineController.cs

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public class TimelineController : IDisposable
1010

1111
private readonly TrackBar _timeTrackBar;
1212
private readonly Label _lblTime;
13+
private readonly Label _lblCurrentAppName;
14+
private readonly PictureBox _picCurrentAppIcon;
1315
private readonly Label _lblInfo;
1416
private readonly CheckBox _chkAutoScroll;
1517
private readonly DateTimePicker _datePicker;
@@ -24,6 +26,8 @@ public class TimelineController : IDisposable
2426
public TimelineController(
2527
TrackBar timeTrackBar,
2628
Label lblTime,
29+
Label lblCurrentAppName,
30+
PictureBox picCurrentAppIcon,
2731
Label lblInfo,
2832
CheckBox chkAutoScroll,
2933
DateTimePicker datePicker,
@@ -32,6 +36,8 @@ public TimelineController(
3236
{
3337
_timeTrackBar = timeTrackBar;
3438
_lblTime = lblTime;
39+
_lblCurrentAppName = lblCurrentAppName;
40+
_picCurrentAppIcon = picCurrentAppIcon;
3541
_lblInfo = lblInfo;
3642
_chkAutoScroll = chkAutoScroll;
3743
_datePicker = datePicker;
@@ -81,6 +87,8 @@ public void SetFrames(List<MiniFrame> frames, bool isLiveUpdate, bool isInitialL
8187
_timeTrackBar.Minimum = 0;
8288
_timeTrackBar.Maximum = 0;
8389
_lblTime.Text = "";
90+
if (_lblCurrentAppName != null) _lblCurrentAppName.Text = "";
91+
if (_picCurrentAppIcon != null) _picCurrentAppIcon.Image = null;
8492
UpdateInfoLabel();
8593
}
8694
else
@@ -117,18 +125,6 @@ public void Navigate(int offset)
117125
}
118126
}
119127

120-
public void UpdateTimeLabel(DateTime time, bool showDate)
121-
{
122-
if (showDate)
123-
{
124-
_lblTime.Text = $"{time:HH:mm:ss}\n{time:dd.MM.yyyy}";
125-
}
126-
else
127-
{
128-
_lblTime.Text = time.ToString("HH:mm:ss");
129-
}
130-
}
131-
132128
public void UpdateInfoLabel()
133129
{
134130
if (_currentFrames == null || _currentFrames.Count == 0)
@@ -235,5 +231,67 @@ public void Dispose()
235231

236232
_previewManager?.Dispose();
237233
}
234+
235+
public void UpdateCurrentApp(string displayName, System.Drawing.Image icon)
236+
{
237+
if (_lblCurrentAppName != null)
238+
{
239+
_lblCurrentAppName.Text = displayName;
240+
}
241+
if (_picCurrentAppIcon != null)
242+
{
243+
_picCurrentAppIcon.Image = icon;
244+
}
245+
246+
SyncAppInfoLayout();
247+
}
248+
249+
public void UpdateTimeLabel(DateTime time, bool showDate)
250+
{
251+
if (_lblTime == null) return;
252+
253+
if (showDate)
254+
{
255+
_lblTime.Text = $"{time:HH:mm:ss}\n{time:dd.MM.yyyy}";
256+
}
257+
else
258+
{
259+
_lblTime.Text = time.ToString("HH:mm:ss");
260+
}
261+
262+
Application.DoEvents();
263+
SyncAppInfoLayout();
264+
}
265+
266+
private void SyncAppInfoLayout()
267+
{
268+
if (_lblCurrentAppName == null || _picCurrentAppIcon == null || _lblTime == null) return;
269+
270+
_lblCurrentAppName.Top = _timeTrackBar.Bottom - 20;
271+
_lblCurrentAppName.Left = _timeTrackBar.Right - _lblCurrentAppName.Width;
272+
273+
_lblTime.Top = _lblCurrentAppName.Bottom - 2;
274+
_lblTime.Left = _timeTrackBar.Right - _lblTime.Width;
275+
276+
if (!string.IsNullOrEmpty(_lblCurrentAppName.Text))
277+
{
278+
int textWidth = TextRenderer.MeasureText(_lblCurrentAppName.Text, _lblCurrentAppName.Font).Width;
279+
280+
if (textWidth > _lblCurrentAppName.Width)
281+
{
282+
textWidth = _lblCurrentAppName.Width;
283+
}
284+
285+
int textLeftEdge = _lblCurrentAppName.Right - textWidth;
286+
287+
if (textLeftEdge < _lblCurrentAppName.Left)
288+
{
289+
textLeftEdge = _lblCurrentAppName.Left;
290+
}
291+
292+
_picCurrentAppIcon.Left = textLeftEdge - _picCurrentAppIcon.Width - 5;
293+
_picCurrentAppIcon.Top = _lblCurrentAppName.Top + (_lblCurrentAppName.Height - _picCurrentAppIcon.Height) / 2;
294+
}
295+
}
238296
}
239297
}

0 commit comments

Comments
 (0)