remove warnings

This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-05-18 18:05:01 +03:00
parent dd0ece36f2
commit 0290d1699c
5 changed files with 30 additions and 25 deletions
@@ -14,8 +14,8 @@ public class AnnotationControl : Border
private readonly Grid _grid; private readonly Grid _grid;
private readonly TextBlock _classNameLabel; private readonly TextBlock _classNameLabel;
private AnnotationClass _annotationClass; private AnnotationClass _annotationClass = null!;
public AnnotationClass AnnotationClass public AnnotationClass AnnotationClass
{ {
get => _annotationClass; get => _annotationClass;
+6 -6
View File
@@ -22,15 +22,15 @@ public class CanvasEditor : Canvas
private readonly Line _verticalLine; private readonly Line _verticalLine;
private readonly TextBlock _classNameHint; private readonly TextBlock _classNameHint;
private Rectangle _curRec; private Rectangle _curRec = new();
private AnnotationControl _curAnn; private AnnotationControl _curAnn = null!;
private const int MIN_SIZE = 20; private const int MIN_SIZE = 20;
public FormState FormState { get; set; }
public IMediator Mediator { get; set; }
private AnnotationClass _currentAnnClass; public FormState FormState { get; set; } = null!;
public IMediator Mediator { get; set; } = null!;
private AnnotationClass _currentAnnClass = null!;
public AnnotationClass CurrentAnnClass public AnnotationClass CurrentAnnClass
{ {
get => _currentAnnClass; get => _currentAnnClass;
@@ -7,7 +7,7 @@ namespace Azaion.Annotator.Controls
{ {
public delegate void ValueChange(double oldValue, double newValue); public delegate void ValueChange(double oldValue, double newValue);
public event ValueChange? ValueChanged; public new event ValueChange? ValueChanged;
public UpdatableProgressBar() : base() public UpdatableProgressBar() : base()
{ {
+15 -14
View File
@@ -24,13 +24,11 @@ public partial class MainWindow
private readonly HelpWindow _helpWindow; private readonly HelpWindow _helpWindow;
private readonly TimeSpan _annotationTime = TimeSpan.FromSeconds(1); private readonly TimeSpan _annotationTime = TimeSpan.FromSeconds(1);
public ObservableCollection<AnnotationClass> AnnotationClasses { get; set; } public ObservableCollection<AnnotationClass> AnnotationClasses { get; set; } = new();
private bool _suspendLayout; private bool _suspendLayout;
public Dictionary<string, List<AnnotationInfo>> Annotations { get; set; } = new(); public Dictionary<string, List<AnnotationInfo>> Annotations { get; set; } = new();
public bool ShowHelpOnStart { get; set; }
public MainWindow(LibVLC libVLC, MediaPlayer mediaPlayer, public MainWindow(LibVLC libVLC, MediaPlayer mediaPlayer,
IMediator mediator, IMediator mediator,
FormState formState, FormState formState,
@@ -72,8 +70,7 @@ public partial class MainWindow
if (LvFiles.Items.IsEmpty) if (LvFiles.Items.IsEmpty)
BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.Initial]); BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.Initial]);
ShowHelpOnStart = _config.ShowHelpOnStart; if (_config.ShowHelpOnStart)
if (ShowHelpOnStart)
_helpWindow.Show(); _helpWindow.Show();
} }
@@ -131,15 +128,17 @@ public partial class MainWindow
}).ToList(); }).ToList();
//remove annotations: either in 1 sec, either earlier if there is next annotation in a dictionary //remove annotations: either in 1 sec, either earlier if there is next annotation in a dictionary
var strs = curTime.Split("_"); var timeStr = curTime.Split("_").LastOrDefault();
var timeStr = strs.LastOrDefault(); if (!int.TryParse(timeStr, out var time))
var ts = TimeSpan.FromMilliseconds(int.Parse(timeStr)*100); return;
var timeSpanRemove = Enumerable.Range(1, ((int)_annotationTime.TotalMilliseconds / 100) - 1)
var ts = TimeSpan.FromMilliseconds(time * 100);
var timeSpanRemove = Enumerable.Range(1, (int)_annotationTime.TotalMilliseconds / 100 - 1)
.Select(x => .Select(x =>
{ {
var time = TimeSpan.FromMilliseconds(x * 100); var timeNext = TimeSpan.FromMilliseconds(x * 100);
var fName = _formState.GetTimeName(ts.Add(time)); var fName = _formState.GetTimeName(ts.Add(timeNext));
return Annotations.ContainsKey(fName) ? time : (TimeSpan?)null; return Annotations.ContainsKey(fName) ? timeNext : (TimeSpan?)null;
}).FirstOrDefault(x => x != null) ?? _annotationTime; }).FirstOrDefault(x => x != null) ?? _annotationTime;
_ = Task.Run(async () => _ = Task.Run(async () =>
@@ -240,8 +239,10 @@ public partial class MainWindow
}; };
if (dlg.ShowDialog() != CommonFileDialogResult.Ok) if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
return; return;
if (!string.IsNullOrEmpty(dlg.FileName))
_config.VideosDirectory = dlg.FileName;
_config.VideosDirectory = dlg.FileName;
ReloadFiles(); ReloadFiles();
} }
+6 -2
View File
@@ -25,9 +25,13 @@ public class PlayerControlHandler(LibVLC libVLC, MediaPlayer mediaPlayer, MainWi
{ Key.Delete, PlaybackControlEnum.RemoveSelectedAnns }, { Key.Delete, PlaybackControlEnum.RemoveSelectedAnns },
{ Key.X, PlaybackControlEnum.RemoveAllAnns } { Key.X, PlaybackControlEnum.RemoveAllAnns }
}; };
public async Task Handle(AnnClassSelectedEvent notification, CancellationToken cancellationToken) => public async Task Handle(AnnClassSelectedEvent notification, CancellationToken cancellationToken)
{
SelectClass(notification.AnnotationClass); SelectClass(notification.AnnotationClass);
await Task.CompletedTask;
}
private void SelectClass(AnnotationClass annClass) private void SelectClass(AnnotationClass annClass)
{ {