⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 progressmonitor.cs

📁 C# Library [Disassembled] to read barcodes from image
💻 CS
字号:
namespace J4L.Vision.Progress.core
{
    using J4L.Vision.Progress;
    using System;

    public class ProgressMonitor
    {
        private double currentPercent = 0.0;
        private int currentStep = 0;
        private DateTime lastReport;
        private IProgressListener listener;
        private int numberOfSteps = 0;
        private int numberofStepsSubprocess = 0;
        private double percentStep = 0.0;

        public ProgressMonitor(IProgressListener l, double steps)
        {
            this.listener = l;
            this.percentStep = 100.0 / steps;
            this.numberOfSteps = (int)steps;
            this.currentStep = 0;
            this.currentPercent = 0.0;
        }

        public void endSubProcess()
        {
            this.currentPercent += this.percentStep;
            if (this.currentStep == this.numberOfSteps)
            {
                this.currentPercent = 100.0;
            }
            if (this.listener != null)
            {
                this.listener.onProgress(this.currentPercent, "");
            }
            this.lastReport = DateTime.Now;
        }

        public void reportProgress(double step)
        {
            double percentage = (step / ((double) this.numberofStepsSubprocess)) * 100.0;
            percentage = (percentage * this.percentStep) / 100.0;
            percentage += this.currentPercent;
            if ((this.listener != null) && (DateTime.Now.Subtract(this.lastReport).TotalSeconds > 2.0))
            {
                this.listener.onProgress(percentage, "");
                this.lastReport = DateTime.Now;
            }
        }

        public void startSubProcess(int steps)
        {
            this.currentStep++;
            this.numberofStepsSubprocess = steps;
            if (this.listener != null)
            {
                this.listener.onProgress(this.currentPercent, "");
            }
            this.lastReport = DateTime.Now;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -