private protected override void OnStart()
        {
            ParameterMonitoring progressMonitoring = ProcessMonitor.ParameterMonitorings["Progress"];

            ProcessMonitor.Finished         += ProcessMonitorFinished;
            progressMonitoring.ValueUpdated += ProgressUpdated;

            void ProcessMonitorFinished(object sender, EventArgs e)
            {
                ProcessMonitor.Finished         -= ProcessMonitorFinished;
                progressMonitoring.ValueUpdated -= ProgressUpdated;
            }

            void ProgressUpdated(object sender, ParameterUpdatedEventArgs e)
            {
                Dictionary <string, string> keyValuePairs = (Dictionary <string, string>)e.NewValue;

                if (keyValuePairs.TryGetValue("size", out string size))
                {
                    Match sizeMatch = Regex.Match(size, @"(?<Size>\d+)(?<Units>.+)");
                    _convertProgress.ConvertedBytes = DigitalStorageManager.GetBytes(double.Parse(sizeMatch.Groups["Size"].Value), sizeMatch.Groups["Units"].Value);
                }

                if (keyValuePairs.TryGetValue("bitrate", out string bitrate))
                {
                    Match bitrateMatch = Regex.Match(bitrate, @"(?<Size>\d+(?:\.\d+)?)(?<Units>.+)its\/s");
                    _convertProgress.Bitrate = DigitalStorageManager.GetBytes(double.Parse(bitrateMatch.Groups["Size"].Value), bitrateMatch.Groups["Units"].Value);
                }
            }
        }
Beispiel #2
0
                long?GetDownloadSpeed()
                {
                    string downloadSpeed = match.Groups["DownloadSpeed"].Value;

                    if (downloadSpeed == string.Empty)
                    {
                        return(null);
                    }

                    return(DigitalStorageManager.GetBytes(double.Parse(downloadSpeed), match.Groups["DownloadSpeedUnits"].Value));
                }