mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:26:31 +00:00
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using System.Globalization;
|
|
using System.IO;
|
|
using System.Windows;
|
|
|
|
namespace Azaion.Annotator.DTO;
|
|
|
|
public class FormState
|
|
{
|
|
public SelectionState SelectionState { get; set; } = SelectionState.None;
|
|
|
|
public string CurrentFile { get; set; } = null!;
|
|
public Size CurrentVideoSize { get; set; }
|
|
public string VideoName => Path.GetFileNameWithoutExtension(CurrentFile).Replace(" ", "");
|
|
public TimeSpan CurrentVideoLength { get; set; }
|
|
public int CurrentVolume { get; set; } = 100;
|
|
public List<AnnotationResult> AnnotationResults { get; set; } = [];
|
|
|
|
public string GetTimeName(TimeSpan ts) => $"{VideoName}_{ts:hmmssf}";
|
|
|
|
public TimeSpan? GetTime(string name)
|
|
{
|
|
var timeStr = name.Split("_").LastOrDefault();
|
|
if (string.IsNullOrEmpty(timeStr))
|
|
return null;
|
|
|
|
try
|
|
{
|
|
//For some reason, TimeSpan.ParseExact doesn't work on every platform.
|
|
return new TimeSpan(
|
|
days: 0,
|
|
hours: int.Parse(timeStr[0..1]),
|
|
minutes: int.Parse(timeStr[1..3]),
|
|
seconds: int.Parse(timeStr[3..5]),
|
|
milliseconds: int.Parse(timeStr[5..6]) * 100);
|
|
}
|
|
catch (Exception e) { return null; }
|
|
}
|
|
}
|