private void MapProgress(IProgressIndicator progressIndicator, ProgressChangedEventArgs args)
        {
            if (args.CurrentValue.HasValue)
            {
                progressIndicator?.SetValue(args.CurrentValue.Value);
            }

            if (args.IsIndeterminate == true)
            {
                progressIndicator?.SetIndeterminate();
            }

            if (args.MaxValue.HasValue)
            {
                progressIndicator?.SetMaxValue(args.MaxValue.Value);
            }

            if (args.Progress == true)
            {
                progressIndicator?.Progress();
            }

            if (args.Regress == true)
            {
                progressIndicator?.Regress();
            }
        }
예제 #2
0
        static public void Copy(string srcPath,  string dstPath,  IProgressIndicator progressIndicator)
        {
            int bufferSize = 100000;

            var fi       =  new FileInfo(srcPath);
            var srcFile  =  new FileStream(srcPath,  FileMode.Open);
            var dstFile  =  new FileStream(dstPath,  FileMode.CreateNew);
            byte[]  buffer  =  new byte[bufferSize];
            int readedSize;
            int step  =  0;
            progressIndicator.Progress("Start copy",  0);
            do 
            {
                readedSize  =  srcFile.Read(buffer,  0,  bufferSize);
                dstFile.Write(buffer,  0,  bufferSize);
                step++;
                progressIndicator.Progress("Progress copy",  (int)  fi.Length  /  (step  *  readedSize));
            }  while (readedSize  !=  0);
            progressIndicator.Progress("Finish copy",  100);
        }
예제 #3
0
        static public void Copy(string srcPath, string dstPath, IProgressIndicator progressIndicator)
        {
            var fi = new FileInfo(srcPath);

            var srcFile = new FileStream(srcPath, FileMode.Open);
            var dstFile = new FileStream(dstPath, FileMode.CreateNew);

            byte[] buffer = new byte[bufferSize];
            int    readedSize;
            int    step = 0;

            progressIndicator.Progress("Start copy", 0);

            do
            {
                readedSize = srcFile.Read(buffer, 0, bufferSize);
                dstFile.Write(buffer, 0, bufferSize);
                step++;

                progressIndicator.Progress("Progress copy", (int)((step * readedSize) * 100 / fi.Length));
            } while (readedSize != 0);

            progressIndicator.Progress("Finish copy", 100);
        }