Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
autodotua committed Jun 7, 2023
1 parent a479ca0 commit 8f0f26e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 53 deletions.
97 changes: 50 additions & 47 deletions SimpleFFmpegGUI.WPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ namespace SimpleFFmpegGUI.WPF
public partial class MainWindow : Window
{
private readonly QueueManager queue;
private TaskList taskPanel;
private bool hasShownTrayMessage = false;
private StatusPanel statusPanel;
private TaskList taskPanel;
private FzLib.Program.Runtime.TrayIcon tray;
public MainWindow(MainWindowViewModel viewModel, QueueManager queue)
{
Expand All @@ -53,6 +54,9 @@ public MainWindow(MainWindowViewModel viewModel, QueueManager queue)
this.queue = queue;
}

public event EventHandler UiCompressModeChanged;

public bool IsUiCompressMode { get; private set; }
public MainWindowViewModel ViewModel { get; set; }

/// <summary>
Expand Down Expand Up @@ -144,10 +148,13 @@ protected override void OnClosing(CancelEventArgs e)
}
tray.Show();
Hide();
tray.ShowMessage("任务将在后台继续执行");
if (!hasShownTrayMessage)
{
hasShownTrayMessage = true;
tray.ShowMessage("任务将在后台继续执行");
}
}
}

protected override async void OnContentRendered(EventArgs e)
{
base.OnContentRendered(e);
Expand Down Expand Up @@ -277,45 +284,6 @@ private void PresetsButton_Click(object sender, RoutedEventArgs e)
AddNewTab<PresetsPage>();
}

private async void SettingButton_Click(object sender, RoutedEventArgs e)
{
await ShowTopTabAsync<SettingPage>();
}

private void StartButton_Click(object sender, RoutedEventArgs e)
{
if (!TaskManager.HasQueueTasks())
{
this.CreateMessage().QueueError("没有排队中的任务");
return;
}
queue.StartQueue();
}

private void TasksButton_Click(object sender, RoutedEventArgs e)
{
AddNewTab<TasksPage>();
}

private void TestButton_Click(object sender, RoutedEventArgs e)
{
var window = App.ServiceProvider.GetService<TestWindow>();
window.Owner = this;
window.Show();
}

private void Window_Closing(object sender, CancelEventArgs e)
{
Config.Instance.Save();
}

private void Window_StateChanged(object sender, EventArgs e)
{
Config.Instance.WindowMaximum = WindowState == WindowState.Maximized;
}

public bool IsUiCompressMode { get; private set; }

private void ResetUI(bool force = false)
{
if (tab.SelectedIndex == 0 && !topTab.HasContent
Expand Down Expand Up @@ -354,13 +322,19 @@ void RemoveFromGrid()
}
}

public event EventHandler UiCompressModeChanged;
private async void SettingButton_Click(object sender, RoutedEventArgs e)
{
await ShowTopTabAsync<SettingPage>();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
private void StartButton_Click(object sender, RoutedEventArgs e)
{
taskPanel = new TaskList() { Margin = new Thickness(8, 0, 0, 0) };
statusPanel = new StatusPanel() { Margin = new Thickness(12) };
ResetUI(true);
if (!TaskManager.HasQueueTasks())
{
this.CreateMessage().QueueError("没有排队中的任务");
return;
}
queue.StartQueue();
}

private void Tab_SelectionChanged(object sender, SelectionChangedEventArgs e)
Expand All @@ -371,6 +345,35 @@ private void Tab_SelectionChanged(object sender, SelectionChangedEventArgs e)
}
ResetUI();
}

private void TasksButton_Click(object sender, RoutedEventArgs e)
{
AddNewTab<TasksPage>();
}

private void TestButton_Click(object sender, RoutedEventArgs e)
{
var window = App.ServiceProvider.GetService<TestWindow>();
window.Owner = this;
window.Show();
}

private void Window_Closing(object sender, CancelEventArgs e)
{
Config.Instance.Save();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
taskPanel = new TaskList() { Margin = new Thickness(8, 0, 0, 0) };
statusPanel = new StatusPanel() { Margin = new Thickness(12) };
ResetUI(true);
}

private void Window_StateChanged(object sender, EventArgs e)
{
Config.Instance.WindowMaximum = WindowState == WindowState.Maximized;
}
}

public class MainWindowViewModel : INotifyPropertyChanged
Expand Down
20 changes: 14 additions & 6 deletions SimpleFFmpegGUI.WPF/Panels/CodeArgumentsPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,30 +299,38 @@ protected override async void OnDrop(DragEventArgs e)
var file = files[0];
try
{
IsEnabled = false;
var info = await MediaInfoManager.GetMediaInfoAsync(file);
var videoArgs = MediaInfoManager.ConvertToVideoArguments(info);
ViewModel.Video = videoArgs.Adapt<VideoArgumentsWithSwitch>();
if(videoArgs.Crf.HasValue)
if (videoArgs.Crf.HasValue)
{
ViewModel.Video.EnableCrf = true;
}
if(videoArgs.AverageBitrate.HasValue)
if (videoArgs.AverageBitrate.HasValue)
{
ViewModel.Video.EnableAverageBitrate= true;
ViewModel.Video.EnableAverageBitrate = true;
}
if(videoArgs.MaxBitrate.HasValue)
if (videoArgs.MaxBitrate.HasValue)
{
ViewModel.Video.EnableMaxBitrate= true;
ViewModel.Video.EnableMaxBitrate = true;
}
this.CreateMessage().QueueSuccess("已加载指定视频参数");
}
catch (Exception ex)
{
this.CreateMessage().QueueError("解析视频编码参数失败", ex);
}
}
finally
{
IsEnabled = true;
}

}
}

}

public CodeArgumentsPanelViewModel ViewModel { get; } = App.ServiceProvider.GetService<CodeArgumentsPanelViewModel>();
}

Expand Down

0 comments on commit 8f0f26e

Please sign in to comment.