make resizable panels

fix duration bug
This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-07-22 18:01:54 +03:00
parent f452059407
commit d130e6fdcf
4 changed files with 41 additions and 18 deletions
+1
View File
@@ -4,3 +4,4 @@ obj
.vs
*.DotSettings*
*.user
log*
+1
View File
@@ -5,5 +5,6 @@ public class VideoFileInfo
public string Name { get; set; } = null!;
public string Path { get; set; } = null!;
public TimeSpan Duration { get; set; }
public string DurationStr => $"{Duration:h\\:mm\\:ss}";
public bool HasAnnotations { get; set; }
}
+17 -5
View File
@@ -62,6 +62,7 @@
<ColumnDefinition Width="250" />
<ColumnDefinition Width="4"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="4"/>
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
@@ -81,10 +82,11 @@
</MenuItem>
</Menu>
<Grid
HorizontalAlignment="Stretch"
Grid.Column="0"
Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="220" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<TextBox
@@ -124,7 +126,7 @@
DisplayMemberBinding="{Binding Path=Name}"/>
<GridViewColumn Width="Auto"
Header="Тривалість"
DisplayMemberBinding="{Binding Path=Duration}"/>
DisplayMemberBinding="{Binding Path=DurationStr}"/>
</GridView>
</ListView.View>
</ListView>
@@ -144,7 +146,7 @@
CanUserResizeColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn
Width="60"
Width="50"
Header="Клавіша"
CanUserSort="False">
<DataGridTemplateColumn.HeaderStyle>
@@ -178,6 +180,7 @@
ResizeDirection="Columns"
Grid.Column="1"
Grid.Row="1"
Grid.RowSpan="3"
ResizeBehavior="PreviousAndNext"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
@@ -189,11 +192,20 @@
x:Name="VideoView">
<controls:CanvasEditor x:Name="Editor" Background="#01000000" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</wpf:VideoView>
<DataGrid x:Name="DgAnnotations"
<GridSplitter
Background="DarkGray"
ResizeDirection="Columns"
Grid.Column="3"
Grid.Row="1"
Grid.RowSpan="3"
ResizeBehavior="PreviousAndNext"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
/>
<DataGrid x:Name="DgAnnotations"
Grid.Column="4"
Grid.Row="1"
Grid.RowSpan="3"
Background="Black"
RowBackground="#252525"
Foreground="White"
+15 -6
View File
@@ -12,6 +12,7 @@ using Newtonsoft.Json;
using Point = System.Windows.Point;
using Size = System.Windows.Size;
using IntervalTree;
using Microsoft.Extensions.Logging;
namespace Azaion.Annotator;
@@ -24,6 +25,7 @@ public partial class MainWindow
private readonly IConfigRepository _configRepository;
private readonly HelpWindow _helpWindow;
private readonly ILogger<MainWindow> _logger;
public ObservableCollection<AnnotationClass> AnnotationClasses { get; set; } = new();
private bool _suspendLayout;
@@ -39,7 +41,8 @@ public partial class MainWindow
IMediator mediator,
FormState formState,
IConfigRepository configRepository,
HelpWindow helpWindow)
HelpWindow helpWindow,
ILogger<MainWindow> logger)
{
InitializeComponent();
_libVLC = libVLC;
@@ -49,6 +52,7 @@ public partial class MainWindow
_configRepository = configRepository;
_config = _configRepository.Get();
_helpWindow = helpWindow;
_logger = logger;
VideoView.Loaded += VideoView_Loaded;
Closed += OnFormClosed;
@@ -217,15 +221,16 @@ public partial class MainWindow
var files = dir.GetFiles("mp4", "mov").Select(x =>
{
_mediaPlayer.Media = new Media(_libVLC, x.FullName);
return new VideoFileInfo
var media = new Media(_libVLC, x.FullName);
media.Parse();
var fInfo = new VideoFileInfo
{
Name = x.Name,
Path = x.FullName,
Duration = TimeSpan.FromMilliseconds(_mediaPlayer.Media.Duration),
HasAnnotations = labelNames.ContainsKey(Path.GetFileNameWithoutExtension(x.Name).Replace(" ", ""))
};
media.ParsedChanged += (_, _) => fInfo.Duration = TimeSpan.FromMilliseconds(media.Duration);
return fInfo;
}).ToList();
LvFiles.ItemsSource = new ObservableCollection<VideoFileInfo>(files);
@@ -271,7 +276,11 @@ public partial class MainWindow
ReloadFiles();
}
private void PlayClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.Play));
private void PlayClick(object sender, RoutedEventArgs e)
{
_mediator.Publish(new PlaybackControlEvent(_mediaPlayer.CanPause ? PlaybackControlEnum.Pause : PlaybackControlEnum.Play));
}
private void PauseClick(object sender, RoutedEventArgs e)=> _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.Pause));
private void StopClick(object sender, RoutedEventArgs e) => _mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.Stop));