private void PrivatePull( List<DroidExplorer.Core.IO.FileInfo> files, System.IO.DirectoryInfo destPath )
{
this.TotalItems = files.Count;
if ( this.TotalItems == 0 ) {
this.DialogResult = DialogResult.Cancel;
}
foreach ( var fi in files ) {
this.TotalSize += fi.Size;
}
SpeedTest ( );
SetItemsRemainingStatus ( this.TotalItems.ToString ( ) );
SetCopyInfoLabel ( );
SetTitle ( );
DroidExplorer.Core.Threading.ThreadPool pool = new DroidExplorer.Core.Threading.ThreadPool ( 1 );
foreach ( var fi in files ) {
PushState ps = new PushState ( );
ps.RemotePath = fi.FullPath;
ps.File = new System.IO.FileInfo ( System.IO.Path.Combine ( destPath.FullName, fi.ToSafeFileName ( ) ) );
pool.Queue<PushState> ( delegate ( object o ) {
PushState pushState = (PushState)o;
try {
System.IO.FileInfo resultFile = CommandRunner.Instance.PullFile ( pushState.RemotePath );
if ( !pushState.File.Directory.Exists ) {
pushState.File.Directory.Create ( );
}
if ( string.Compare ( pushState.File.FullName, resultFile.FullName, true ) != 0 ) {
resultFile.CopyTo ( pushState.File.FullName, true );
}
if ( this.InvokeRequired ) {
this.Invoke ( new SetFromStatusLabelDelegate ( this.SetFromStatus ), new object[] { Environment.MachineName, ps.File.Name,
CommandRunner.Instance.DefaultDevice, ps.RemotePath } );
this.Invoke ( new SetLabelStatusDelegate ( this.SetItemsRemainingStatus ), new object[] { ( --this.TotalItems ).ToString ( ) } );
} else {
SetFromStatus ( Environment.MachineName, ps.File.Name, CommandRunner.Instance.DefaultDevice, ps.RemotePath );
SetItemsRemainingStatus ( ( --this.TotalItems ).ToString ( ) );
}
} catch ( Exception ex ) {
this.LogError ( ex.Message, ex );
TransferException = ex;
this.DialogResult = DialogResult.Abort;
this.OnTransferError ( EventArgs.Empty );
}
if ( this.TotalItems == 0 ) {
this.DialogResult = DialogResult.OK;
this.OnTransferComplete ( EventArgs.Empty );
if ( !this.IsDisposed ) {
if ( this.InvokeRequired ) {
this.Invoke ( new GenericDelegate ( this.Close ) );
} else {
this.Close ( );
}
}
}
}, ps );
}
if ( files.Count > 0 ) {
SetFromStatus ( CommandRunner.Instance.DefaultDevice, System.IO.Path.Combine ( destPath.FullName, files[0].Name ), Environment.MachineName, files[0].Name );
}
pool.Start ( );
}