mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:36:30 +00:00
41 lines
1.4 KiB
C#
41 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) || timeStr.Length < 7)
|
|
return null;
|
|
|
|
//For some reason, TimeSpan.ParseExact doesn't work on every platform.
|
|
if (!int.TryParse(timeStr[0..1], out var hours))
|
|
return null;
|
|
if (!int.TryParse(timeStr[1..3], out var minutes))
|
|
return null;
|
|
if (!int.TryParse(timeStr[3..5], out var seconds))
|
|
return null;
|
|
if (!int.TryParse(timeStr[5..6], out var milliseconds))
|
|
return null;
|
|
return new TimeSpan(0, hours, minutes, seconds, milliseconds * 100);
|
|
}
|
|
} |