mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
feat(wpf): order danmaku merge files by their path
This commit is contained in:
parent
0c30c49ebb
commit
071087bea1
|
@ -6,16 +6,26 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||||
xmlns:l="https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension"
|
xmlns:l="https://github.com/XAMLMarkupExtensions/WPFLocalizationExtension"
|
||||||
|
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
|
||||||
l:LocalizeDictionary.DesignCulture=""
|
l:LocalizeDictionary.DesignCulture=""
|
||||||
l:ResxLocalizationProvider.DefaultAssembly="BililiveRecorder.WPF"
|
l:ResxLocalizationProvider.DefaultAssembly="BililiveRecorder.WPF"
|
||||||
l:ResxLocalizationProvider.DefaultDictionary="Strings"
|
l:ResxLocalizationProvider.DefaultDictionary="Strings"
|
||||||
mc:Ignorable="d" DataContext="{x:Null}"
|
mc:Ignorable="d" DataContext="{x:Null}"
|
||||||
d:DesignHeight="450" d:DesignWidth="800"
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
Title="ToolboxDanmakuMergerPage">
|
Title="ToolboxDanmakuMergerPage">
|
||||||
|
<ui:Page.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/DensityStyles/Compact.xaml" />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<CollectionViewSource x:Key="cvs">
|
||||||
|
<CollectionViewSource.SortDescriptions>
|
||||||
|
<scm:SortDescription PropertyName="Path" Direction="Ascending"/>
|
||||||
|
</CollectionViewSource.SortDescriptions>
|
||||||
|
</CollectionViewSource>
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ui:Page.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Resources>
|
|
||||||
<ResourceDictionary Source="pack://application:,,,/ModernWpf;component/DensityStyles/Compact.xaml" />
|
|
||||||
</Grid.Resources>
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
|
@ -28,7 +38,7 @@
|
||||||
<Button Margin="0,0,5,0" Content="{l:Loc Toolbox_Merge_Button_AddFile}" Click="AddFile_Click"/>
|
<Button Margin="0,0,5,0" Content="{l:Loc Toolbox_Merge_Button_AddFile}" Click="AddFile_Click"/>
|
||||||
<Button Content="{l:Loc Toolbox_Merge_Button_Merge}" Click="Merge_Click"/>
|
<Button Content="{l:Loc Toolbox_Merge_Button_Merge}" Click="Merge_Click"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<ListView Grid.Row="3" Margin="5" x:Name="listView" AllowDrop="True" Drop="DragDrop">
|
<ListView Grid.Row="3" Margin="5" x:Name="listView" ItemsSource="{Binding Source={StaticResource cvs}}" AllowDrop="True" Drop="DragDrop">
|
||||||
<ListView.View>
|
<ListView.View>
|
||||||
<GridView AllowsColumnReorder="False">
|
<GridView AllowsColumnReorder="False">
|
||||||
<GridViewColumn>
|
<GridViewColumn>
|
||||||
|
@ -41,7 +51,8 @@
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
<GridViewColumn Header="偏移量(秒)" Width="120">
|
<GridViewColumn Header="偏移量(秒)" Width="120">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate><!--
|
<DataTemplate>
|
||||||
|
<!--
|
||||||
<ui:NumberBox Minimum="0" SmallChange="1" LargeChange="10" Text="{Binding Offset,UpdateSourceTrigger=PropertyChanged}"
|
<ui:NumberBox Minimum="0" SmallChange="1" LargeChange="10" Text="{Binding Offset,UpdateSourceTrigger=PropertyChanged}"
|
||||||
SpinButtonPlacementMode="Inline" ValidationMode="InvalidInputOverwritten"/>
|
SpinButtonPlacementMode="Inline" ValidationMode="InvalidInputOverwritten"/>
|
||||||
-->
|
-->
|
||||||
|
|
|
@ -6,6 +6,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using BililiveRecorder.ToolBox;
|
using BililiveRecorder.ToolBox;
|
||||||
using BililiveRecorder.ToolBox.Tool.DanmakuMerger;
|
using BililiveRecorder.ToolBox.Tool.DanmakuMerger;
|
||||||
|
@ -32,7 +33,9 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
public ToolboxDanmakuMergerPage()
|
public ToolboxDanmakuMergerPage()
|
||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
this.listView.ItemsSource = this.Files;
|
|
||||||
|
var cvs = (CollectionViewSource)this.FindResource("cvs");
|
||||||
|
cvs.Source = this.Files;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveFile_Click(object sender, RoutedEventArgs e)
|
private void RemoveFile_Click(object sender, RoutedEventArgs e)
|
||||||
|
@ -86,7 +89,8 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
|
|
||||||
private async Task AddFilesAsync(string[] paths)
|
private async Task AddFilesAsync(string[] paths)
|
||||||
{
|
{
|
||||||
var req = new DanmakuStartTimeRequest { Inputs = paths };
|
// filter duplicate file paths
|
||||||
|
var req = new DanmakuStartTimeRequest { Inputs = paths.Where(x => !this.Files.Any(f => f.Path == x)).ToArray() };
|
||||||
var handler = new DanmakuStartTimeHandler();
|
var handler = new DanmakuStartTimeHandler();
|
||||||
var resp = await handler.Handle(req, default, default).ConfigureAwait(true);
|
var resp = await handler.Handle(req, default, default).ConfigureAwait(true);
|
||||||
|
|
||||||
|
@ -111,9 +115,6 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
{
|
{
|
||||||
item.Offset = (int)(item.StartTime - minTime).TotalSeconds;
|
item.Offset = (int)(item.StartTime - minTime).TotalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.listView.DataContext = null;
|
|
||||||
this.listView.DataContext = this.Files;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable VSTHRD100 // Avoid async void methods
|
#pragma warning disable VSTHRD100 // Avoid async void methods
|
||||||
|
@ -188,7 +189,7 @@ namespace BililiveRecorder.WPF.Pages
|
||||||
|
|
||||||
logger.Debug("弹幕合并结果 {@Response}", resp);
|
logger.Debug("弹幕合并结果 {@Response}", resp);
|
||||||
|
|
||||||
if (resp.Status != ResponseStatus.Cancelled && resp.Status != ResponseStatus.OK)
|
if (resp.Status is not ResponseStatus.Cancelled and not ResponseStatus.OK)
|
||||||
{
|
{
|
||||||
logger.Warning(resp.Exception, "弹幕合并时发生错误 (@Status)", resp.Status);
|
logger.Warning(resp.Exception, "弹幕合并时发生错误 (@Status)", resp.Status);
|
||||||
await Task.Run(() => ShowErrorMessageBox(resp)).ConfigureAwait(true);
|
await Task.Run(() => ShowErrorMessageBox(resp)).ConfigureAwait(true);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user