Skip to content

Commit 2ca4bc8

Browse files
committed
Improve Export Video GUI
1 parent f90350f commit 2ca4bc8

2 files changed

Lines changed: 37 additions & 9 deletions

File tree

PhotoToys/Custom UI/SimpleUI.cs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,31 @@ where pa is ImageParameter impa && impa.IsVideoMode
251251
var totalFrames = vidcapture.FrameCount;
252252
var dialog = new ContentDialog
253253
{
254-
Content = new ProgressBar
254+
Content = new FluentVerticalStack
255255
{
256-
//Value = 50,
257-
}.Assign(out var progressRing),
256+
Children =
257+
{
258+
new ProgressBar
259+
{
260+
//Value = 50,
261+
}.Assign(out var progressBar),
262+
new TextBlock
263+
{
264+
265+
}.Assign(out var PercentageProgress),
266+
new TextBlock
267+
{
268+
269+
}.Assign(out var AverageRenderSpeed),
270+
new TextBlock
271+
{
272+
273+
}.Assign(out var EstimatedTime)
274+
}
275+
},
258276
XamlRoot = Result.XamlRoot,
259277
};
278+
DateTime dateTime;
260279
async Task RunLoop()
261280
{
262281
await Task.Run(async delegate
@@ -267,11 +286,19 @@ await Task.Run(async delegate
267286
for (int i = 0; i < totalFrames; i++)
268287
{
269288
video.PosFrames = i;
270-
if (i % 10 == 0)
271-
dialog.DispatcherQueue.TryEnqueue(delegate
272-
{
273-
progressRing.Value = (double)(i+1) / totalFrames * 100;
274-
});
289+
//if (i % 10 == 0)
290+
dialog.DispatcherQueue.TryEnqueue(delegate
291+
{
292+
var progress = (double)(i + 1) / totalFrames * 100;
293+
progressBar.Value = progress;
294+
var renderFPS = i / (DateTime.Now - dateTime).TotalSeconds;
295+
var estimatedseconds = (totalFrames - i) / (renderFPS + 1e-3);
296+
const double onedayinseconds = 60 * 60 * 24;
297+
298+
PercentageProgress.Text = $"{progress:N2}% ({i + 1}/{totalFrames})";
299+
AverageRenderSpeed.Text = $"Average Render Speed: {renderFPS:N2} frames per second";
300+
EstimatedTime.Text = $"Estimated Time left: {(estimatedseconds > onedayinseconds ? "More than a day" : TimeSpan.FromSeconds((totalFrames - i) / (renderFPS + 1e-3))):c}";
301+
});
275302
if (video.Result is null) break;
276303
TaskCompletionSource<Mat> result = new();
277304
OnExecute?.Invoke(x =>
@@ -284,6 +311,7 @@ await Task.Run(async delegate
284311
writer.Release();
285312
});
286313
};
314+
dateTime = DateTime.Now;
287315
_ = dialog.ShowAsync();
288316

289317
await RunLoop();

PhotoToys/PhotoToys.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
1919
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
2020
<GenerateTestArtifacts>True</GenerateTestArtifacts>
21-
<AppxBundle>Auto</AppxBundle>
21+
<AppxBundle>Always</AppxBundle>
2222
<AppxBundlePlatforms>x86|x64|arm64</AppxBundlePlatforms>
2323
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
2424
<GenerateTemporaryStoreCertificate>True</GenerateTemporaryStoreCertificate>

0 commit comments

Comments
 (0)