-
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
7 changed files
with
113 additions
and
120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using FzLib; | ||
using System; | ||
using System.Globalization; | ||
using System.Windows.Data; | ||
|
||
namespace SimpleFFmpegGUI.WPF.Converters | ||
{ | ||
public class Bitrate2StringConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
long num = System.Convert.ToInt64(value); | ||
string str = NumberConverter.ByteToFitString(num, 2, " bps", " Kbps", " Mbps", " Gbps", " Tbps"); | ||
return str; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using CommunityToolkit.Mvvm.Input; | ||
using FzLib; | ||
using Microsoft.Win32; | ||
using Newtonsoft.Json.Linq; | ||
using SimpleFFmpegGUI.Manager; | ||
using SimpleFFmpegGUI.Model.MediaInfo; | ||
using SimpleFFmpegGUI.WPF.Messages; | ||
using System; | ||
using System.ComponentModel; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace SimpleFFmpegGUI.WPF.ViewModels | ||
{ | ||
public partial class MediaInfoPageViewModel : ViewModelBase | ||
{ | ||
[ObservableProperty] | ||
private string filePath; | ||
|
||
[ObservableProperty] | ||
private MediaInfoGeneral mediaInfo; | ||
public MediaInfoPageViewModel() | ||
{ | ||
} | ||
|
||
protected override async void OnPropertyChanged(PropertyChangedEventArgs e) | ||
{ | ||
base.OnPropertyChanged(e); | ||
if (e.PropertyName == nameof(FilePath)) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(FilePath) && System.IO.File.Exists(FilePath)) | ||
{ | ||
await ShowInfoAsync(); | ||
} | ||
} | ||
} | ||
|
||
private async Task ShowInfoAsync() | ||
{ | ||
SendMessage(new WindowEnableMessage(false)); | ||
try | ||
{ | ||
MediaInfo = await MediaInfoManager.GetMediaInfoAsync(FilePath); | ||
} | ||
catch (Exception ex) | ||
{ | ||
QueueErrorMessage("读取媒体信息失败", ex); | ||
} | ||
finally | ||
{ | ||
SendMessage(new WindowEnableMessage(true)); | ||
} | ||
} | ||
|
||
[RelayCommand] | ||
private void BrowseFile() | ||
{ | ||
var dialog = new OpenFileDialog().AddAllFilesFilter(); | ||
SendMessage(new FileDialogMessage(dialog)); | ||
|
||
string path = dialog.FileName; | ||
if (path != null) | ||
{ | ||
FilePath = path; | ||
} | ||
} | ||
|
||
} | ||
} |