diff --git a/src/WorkFlowCheck.MAUI/Handlers/ProgressableStreamContent.cs b/src/WorkFlowCheck.MAUI/Handlers/ProgressableStreamContent.cs new file mode 100644 index 0000000..0605057 --- /dev/null +++ b/src/WorkFlowCheck.MAUI/Handlers/ProgressableStreamContent.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.MAUI.Handlers +{ + public class ProgressableStreamContent : HttpContent + { + private readonly Stream _stream; + private readonly int _bufferSize; + private readonly Action _progress; + + public ProgressableStreamContent(Stream stream, int bufferSize, Action progress) + { + _stream = stream; + _bufferSize = bufferSize; + _progress = progress; + } + + protected override async Task SerializeToStreamAsync(Stream stream, TransportContext context) + { + var buffer = new byte[_bufferSize]; + long totalBytesRead = 0; + int bytesRead; + + while ((bytesRead = await _stream.ReadAsync(buffer, 0, buffer.Length)) > 0) + { + await stream.WriteAsync(buffer, 0, bytesRead); + totalBytesRead += bytesRead; + _progress(totalBytesRead, _stream.Length); + } + } + + protected override bool TryComputeLength(out long length) + { + length = _stream.Length; + return true; + } + } + +} diff --git a/src/WorkFlowCheck.MAUI/MainPage.xaml b/src/WorkFlowCheck.MAUI/MainPage.xaml index be85abe..fd3f6af 100644 --- a/src/WorkFlowCheck.MAUI/MainPage.xaml +++ b/src/WorkFlowCheck.MAUI/MainPage.xaml @@ -2,13 +2,19 @@ + Title="Főmenü" + BackgroundColor="#f0f0f0"> - + - +