mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-08 17:42:31 +02:00
a626cfdc72
- (Add) Allow to pause and resume operations (#654) - (Add) `Layer.FirstTransitionLayer` - (Add) `Layer.LastTransitionLayer` - (Add) File format: Elegoo GOO - (Add) PrusaSlicer Printer: Elegoo Mars 4 - (Improvement) Allocate maximum GPU memory for Skia up to 256 MB - (Improvement) Set and sanitize transition layers exposure time from last bottom layer and first normal layer instead of global times (#659) - (Change) CXDLP: Default version from 2 to 3 - (Fix) UI was not rendering with GPU (ANGLE) - (Fix) `Layer.IsTransitionLayer` was returning the wrong value - (Upgrade) .NET from 6.0.13 to 6.0.14
103 lines
2.8 KiB
C#
103 lines
2.8 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using Avalonia.Threading;
|
|
using System;
|
|
using System.Timers;
|
|
using UVtools.Core.Operations;
|
|
using UVtools.WPF.Structures;
|
|
|
|
namespace UVtools.WPF;
|
|
|
|
public partial class MainWindow
|
|
{
|
|
#region Members
|
|
public OperationProgress Progress { get; } = new();
|
|
private readonly Timer _progressTimer = new(200) { AutoReset = true };
|
|
private long _progressLastTotalSeconds;
|
|
private LogItem _progressLogItem;
|
|
private bool _isProgressVisible;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public bool IsProgressVisible
|
|
{
|
|
get => _isProgressVisible;
|
|
set => RaiseAndSetIfChanged(ref _isProgressVisible, value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
public void InitProgress()
|
|
{
|
|
_progressTimer.Elapsed += (sender, args) =>
|
|
{
|
|
var elapsedSeconds = Progress.StopWatch.ElapsedMilliseconds / 1000;
|
|
if (_progressLastTotalSeconds == elapsedSeconds) return;
|
|
/*Debug.WriteLine(StopWatch.ElapsedMilliseconds);
|
|
Debug.WriteLine(elapsedSeconds);
|
|
Debug.WriteLine(_lastTotalSeconds);*/
|
|
_progressLastTotalSeconds = elapsedSeconds;
|
|
|
|
|
|
Dispatcher.UIThread.InvokeAsync(() => Progress.TriggerRefresh(), DispatcherPriority.Render);
|
|
|
|
};
|
|
}
|
|
|
|
public void ProgressOnClickPauseResume()
|
|
{
|
|
if (!Progress.CanCancel) return;
|
|
DialogResult = DialogResults.Cancel;
|
|
Progress.CanCancel = false;
|
|
Progress.TokenSource.Cancel();
|
|
}
|
|
|
|
public void ProgressOnClickCancel()
|
|
{
|
|
if (!Progress.CanCancel) return;
|
|
DialogResult = DialogResults.Cancel;
|
|
Progress.CanCancel = false;
|
|
Progress.TokenSource.Cancel();
|
|
Progress.IsPaused = false;
|
|
}
|
|
|
|
public void ProgressShow(string title, bool canCancel = true)
|
|
{
|
|
IsGUIEnabled = false;
|
|
Progress.Init(canCancel);
|
|
Progress.Title = title;
|
|
_progressLogItem = new(title);
|
|
|
|
Progress.StopWatch.Restart();
|
|
_progressLastTotalSeconds = 0;
|
|
|
|
if (!_progressTimer.Enabled)
|
|
{
|
|
_progressTimer.Start();
|
|
}
|
|
|
|
Progress.TriggerRefresh();
|
|
|
|
IsProgressVisible = true;
|
|
|
|
InvalidateVisual();
|
|
}
|
|
|
|
public void ProgressFinish()
|
|
{
|
|
_progressTimer.Stop();
|
|
Progress.StopWatch.Stop();
|
|
_progressLogItem.ElapsedTime = Math.Round(Progress.StopWatch.Elapsed.TotalSeconds, 2);
|
|
App.MainWindow.AddLog(_progressLogItem);
|
|
IsProgressVisible = false;
|
|
InvalidateVisual();
|
|
}
|
|
} |