-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
76 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
SimpleFFmpegGUI.WPF/ViewModels/FFmpegOutputPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using CommunityToolkit.Mvvm.Input; | ||
using SimpleFFmpegGUI.Model; | ||
using System; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Windows; | ||
|
||
namespace SimpleFFmpegGUI.WPF.ViewModels | ||
{ | ||
public partial class FFmpegOutputPageViewModel : ViewModelBase | ||
{ | ||
public FFmpegOutputPageViewModel() | ||
{ | ||
Logger.Log += Logger_Log; | ||
} | ||
public ObservableCollection<Log> Outputs { get; } = new ObservableCollection<Log>(); | ||
|
||
[RelayCommand] | ||
private void ClearAll() | ||
{ | ||
Outputs.Clear(); | ||
} | ||
|
||
[RelayCommand] | ||
private void CopyAll() | ||
{ | ||
try | ||
{ | ||
Clipboard.SetText(string.Join(Environment.NewLine, Outputs.Select(p => p.Message))); | ||
QueueSuccessMessage("已复制内容到剪贴板"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
QueueErrorMessage("复制内容失败", ex); | ||
} | ||
} | ||
|
||
private async void Logger_Log(object sender, LogEventArgs e) | ||
{ | ||
await System.Windows.Application.Current.Dispatcher.InvokeAsync(() => | ||
{ | ||
if (e.Log.Message.StartsWith("frame=") | ||
&& Outputs.Count > 0 && Outputs[^1].Message.StartsWith("frame=")) | ||
{ | ||
Outputs[^1] = e.Log; | ||
} | ||
else | ||
{ | ||
Outputs.Add(e.Log); | ||
} | ||
}); | ||
} | ||
} | ||
} |