Exemplo n.º 1
0
        private static void InvokeProgressEvent(uint currentFileSlicesCount, uint currentFileSlice, FileTransferState state)
        {
            if (state == FileTransferState.Finished)
            {
                throw new InvalidOperationException();
            }

            FileTransferProgressEventArgs ea = null;

            if (!isQueue)
            {
                ea = new FileTransferProgressEventArgs {
                    CurrentPart = currentFileSlice + 1, Total = currentFileSlicesCount, State = FileTransferState.DataTransfer, Guid = requestGuid, SenderName = senderName, TotalFiles = filesCount
                };
                System.Diagnostics.Debug.WriteLine(ea.CurrentPart + " / " + ea.Total);
            }
            else if (state == FileTransferState.QueueList)
            {
                ea = new FileTransferProgressEventArgs {
                    CurrentPart = 0, Total = 0, State = FileTransferState.QueueList, Guid = requestGuid, SenderName = senderName, TotalFiles = filesCount
                };
                System.Diagnostics.Debug.WriteLine("Downloading queue data...");
            }
            else
            {
                ea = new FileTransferProgressEventArgs {
                    CurrentPart = (ulong)(queueSlicesFinished + currentFileSlice + 1), Total = (ulong)queueTotalSlices, State = FileTransferState.QueueList, Guid = requestGuid, SenderName = senderName, TotalFiles = filesCount
                };
                System.Diagnostics.Debug.WriteLine(ea.CurrentPart + " / " + ea.Total);
            }

            FileTransferProgress?.Invoke(ea);
        }
Exemplo n.º 2
0
 private static void LegacyFileReceiver_FileTransferProgress(FileTransferProgressEventArgs e)
 {
     FileTransferProgress?.Invoke(new FileTransfer2ProgressEventArgs
     {
         Guid                  = e.Guid,
         SenderName            = e.SenderName,
         State                 = e.State,
         TotalBytes            = e.Total * Constants.FileSliceMaxLength,
         TotalTransferredBytes = e.CurrentPart * Constants.FileSliceMaxLength,
         TotalFiles            = e.TotalFiles,
     });
 }