Ghost1372

everything can be handy

SpeedGraph

Property

Name
MaxSpeed
Total
BackgroundCircleDistance
SpeedLineVisibility
SpeedTextVisibility
SpeedText
AutoUpdateSpeedText

Methods

Name
AddPoint
SetSpeed
ResetGraph
Error
Pause
Normal

Example

1
<dev:SpeedGraph x:Name="SpeedGraphSample" />
1
2
3
4
ulong _totalBytes = 1024UL * 1024 * 500; // 500 MB
SpeedGraphSample.Total = _totalBytes;
SpeedGraphSample.MaxSpeed = 1024;
SpeedGraphSample.SetSpeed(50, 500);

Here we can simulate a file copy operation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
private bool _isSimulating;
private Random _random = new();

private async void StartFileCopy()
{
ulong _totalBytes = 1024UL * 1024 * 500; // 500 MB

SpeedGraphSample.Normal();

if (_isSimulating)
return;

SpeedGraphSample.ResetGraph();

_isSimulating = true;

ulong copiedBytes = 0;
SpeedGraphSample.Total = _totalBytes;

while (copiedBytes < _totalBytes)
{
// Simulate varying copy speed (8–100 MB/s)
ulong speed = (ulong)(_random.Next(8, 100) * 1024 * 1024);

// Add progress (simulate ~1/3 second per chunk)
copiedBytes += speed / 3;
if (copiedBytes > _totalBytes)
copiedBytes = _totalBytes;

double percent = (double)copiedBytes / _totalBytes * 100.0;

// Update SpeedGraph
SpeedGraphSample.SetSpeed(percent, speed);
// Update text

// Wait before next tick
await Task.Delay(100);
}

_isSimulating = false;
}

DevWinUI

Demo

you can run demo and see this feature.

0%