Skip to content

Commit

Permalink
fix for #63 Long Video doesnt show up fully
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekmotyl committed Aug 6, 2022
1 parent d050eae commit 93714fc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
22 changes: 21 additions & 1 deletion src/SimpleVideoCutter/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,27 @@ public static bool IsOnScreen(System.Drawing.Point RecLocation, System.Drawing.S
return PixelsVisible >= (Rec.Width * Rec.Height) * MinPercentOnScreen;
}


public static string ToNormalizedString(this TimeSpan time, bool includeFractionalSeconds = false)
{
if (time.TotalDays >= 1.0)
{
return includeFractionalSeconds ?
string.Format($"{time:dd\\:hh\\:mm\\:ss\\:fff}") :
string.Format($"{time:dd\\:hh\\:mm\\:ss}");
}
else if (time.TotalHours >= 1.0)
{
return includeFractionalSeconds ?
string.Format($"{time:hh\\:mm\\:ss\\:fff}") :
string.Format($"{time:hh\\:mm\\:ss}");
}
else
{
return includeFractionalSeconds ?
string.Format($"{time:mm\\:ss\\:fff}") :
string.Format($"{time:mm\\:ss}");
}
}
}

public class Debouncer
Expand Down
10 changes: 3 additions & 7 deletions src/SimpleVideoCutter/VideoCutterTimeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,7 @@ private void VideoCutterTimeline_Paint(object sender, PaintEventArgs e)
var posXPixel = (position - offset) * PixelsPerMilliseconds();
if (posXPixel >= -ClientRectangle.Width && posXPixel <= ClientRectangle.Width)
{
string text;
if (time.TotalHours > 1)
text = string.Format($"{time:hh\\:mm\\:ss}");
else
text = string.Format($"{time:mm\\:ss}");
string text = time.ToNormalizedString();

var size = e.Graphics.MeasureString(text, this.Font);

Expand Down Expand Up @@ -692,12 +688,12 @@ private void VideoCutterTimeline_Paint(object sender, PaintEventArgs e)
// info area text
{
var time = TimeSpan.FromMilliseconds(Position);
var text = string.Format($"{GlobalStrings.VideoCutterTimeline_Time}: {time:hh\\:mm\\:ss\\:fff} ");
var text = string.Format($"{GlobalStrings.VideoCutterTimeline_Time}: {time.ToNormalizedString(true)} ");
if (HoverPosition != null)
{
var normalizedHover = HoverPosition.Value;
var hoverTime = TimeSpan.FromMilliseconds(HoverPosition.Value);
text = text + string.Format($" {GlobalStrings.VideoCutterTimeline_HoveredTime}: {hoverTime:hh\\:mm\\:ss\\:fff} ");
text = text + string.Format($" {GlobalStrings.VideoCutterTimeline_HoveredTime}: {hoverTime.ToNormalizedString(true)} ");

if (timelineTooltip != null)
text += " " + timelineTooltip.Text.Replace("\n", "; ");
Expand Down

0 comments on commit 93714fc

Please sign in to comment.