Skip to content

Commit

Permalink
Even better progress indication
Browse files Browse the repository at this point in the history
  • Loading branch information
valery-kirichenko committed Aug 18, 2021
1 parent 9fcc571 commit cc90fc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop" ToolsVersion="Current">
<PropertyGroup Label="Globals">
<Platforms>x64</Platforms>
<PackageVersion>1.2.0</PackageVersion>
<PackageVersion>1.2.1</PackageVersion>
<Company>Kirichenko Valery</Company>
<Product>ClipChopper</Product>
<AssemblyVersion>1.2.1</AssemblyVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<local:TimeSpanToSecondsConverter x:Key="TimeSpanToSecondsConverter" />
<local:TimeSpanFormatter x:Key="TimeSpanFormatter" />
</Window.Resources>
<Window.TaskbarItemInfo><TaskbarItemInfo x:Name="TaskbarProgress"></TaskbarItemInfo></Window.TaskbarItemInfo>

<Grid>
<Grid.ColumnDefinitions>
Expand Down
16 changes: 10 additions & 6 deletions ClipChopper/Applications/ClipChopper.DesktopApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Collections.ObjectModel;
using Ookii.Dialogs.Wpf;
using System.Threading.Tasks;
using System.Windows.Shell;

namespace ClipChopper.DesktopApp
{
Expand Down Expand Up @@ -226,9 +227,12 @@ private async void Save_Click(object sender, RoutedEventArgs eventArgs)

var ffmpegPath = Path.Combine(Unosquare.FFME.Library.FFmpegDirectory, "ffmpeg.exe");
Status.Text = "Looking for keyframes...";
TaskbarProgress.ProgressState = TaskbarItemProgressState.Normal;
var progress = new Progress<int>((value) =>
{
Status.Text = $"Looking for keyframes... {value}%";
TaskbarProgress.ProgressValue = value / 100.0d;
Console.WriteLine(TaskbarProgress.ProgressValue);
});
var startKeyframe = await Task.Run(() => KeyframeProber.FindClosestKeyframeTime(inputFile, _fragment.Start, progress));

Expand All @@ -247,16 +251,16 @@ private async void Save_Click(object sender, RoutedEventArgs eventArgs)
};

Status.Text = "Trimming...";
TaskbarProgress.ProgressState = TaskbarItemProgressState.Indeterminate;
await Task.Run(() =>
{
using (var ffmpeg = Process.Start(startInfo))
{
Debug.Assert(ffmpeg != null, nameof(ffmpeg) + " != null");
ffmpeg.OutputDataReceived += (s, e) => { Debug.WriteLine(e.Data); };
ffmpeg.WaitForExit();
}
using var ffmpeg = Process.Start(startInfo);
Debug.Assert(ffmpeg != null, nameof(ffmpeg) + " != null");
ffmpeg.OutputDataReceived += (s, e) => { Debug.WriteLine(e.Data); };
ffmpeg.WaitForExit();
});
Status.Text = "Done";
TaskbarProgress.ProgressState = TaskbarItemProgressState.None;
RefreshDirectory_Click(sender, eventArgs);
await Task.Delay(2000);
Status.Text = "";
Expand Down
7 changes: 7 additions & 0 deletions ClipChopper/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "5.0",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}

0 comments on commit cc90fc6

Please sign in to comment.