mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:26:31 +00:00
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Windows;
|
|
|
|
namespace Azaion.Annotator.DTO;
|
|
|
|
public class FormState
|
|
{
|
|
public MediaFileInfo? CurrentMedia { get; set; }
|
|
public string VideoName => string.IsNullOrEmpty(CurrentMedia?.Name)
|
|
? ""
|
|
: Path.GetFileNameWithoutExtension(CurrentMedia.Name).Replace(" ", "");
|
|
|
|
public string CurrentMrl { get; set; }
|
|
public Size CurrentVideoSize { get; set; }
|
|
public TimeSpan CurrentVideoLength { get; set; }
|
|
|
|
public int CurrentVolume { get; set; } = 100;
|
|
public ObservableCollection<AnnotationResult> AnnotationResults { get; set; } = [];
|
|
public WindowsEnum ActiveWindow { 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; }
|
|
}
|
|
} |