コード例 #1
0
        private async static void FileReceiver_FileTransferProgress(FileTransfer.FileTransfer2ProgressEventArgs e)
        {
            Activity?.Invoke();

            if (e.State == FileTransfer.FileTransferState.Error)
            {
                await progressNotifier?.FinishProgress("Receive failed.", "");
            }
            else if (e.State == FileTransfer.FileTransferState.Finished)
            {
                var intent = new Intent(context, typeof(HistoryListActivity)); //typeof(NotificationLaunchActivity));
                intent.PutExtra("itemGuid", e.Guid.ToString());

                if (e.TotalFiles == 1)
                {
                    await progressNotifier?.FinishProgress($"Received a file from {e.SenderName}", "Tap to view", intent, context);
                }
                else
                {
                    await progressNotifier?.FinishProgress($"Received {e.TotalFiles} files from {e.SenderName}", $"Tap to view", intent, context);
                }

                progressNotifier = null;
                Finish?.Invoke();
            }
            else if (e.State == FileTransfer.FileTransferState.DataTransfer)
            {
                progressNotifier?.SetProgressValue(1000, (int)(1000.0 * e.Progress), "Receiving...");
            }
        }
コード例 #2
0
        public static void InitProgressNotifier()
        {
            if (progressNotifier != null)
            {
                return;
            }

            progressNotifier = new ProgressNotifier(context, "Receive failed.");
            progressNotifier.SendInitialNotification("Connecting...", "");
        }
コード例 #3
0
        public static void InitProgressNotifier(string title = "Connecting...")
        {
            if (progressNotifier != null)
            {
                progressNotifier.UpdateTitle(title);
                return;
            }

            progressNotifier = new ProgressNotifier(context);
            progressNotifier.SendInitialNotification(title, "");
        }
コード例 #4
0
        private async static void FileReceiver_FileTransferProgress(FileTransfer.FileTransferProgressEventArgs e)
        {
            Activity?.Invoke();

            if (e.State == FileTransfer.FileTransferState.Error)
            {
                await progressNotifier?.FinishProgress("Receive failed.", "");
            }
            else if (e.State == FileTransfer.FileTransferState.Finished)
            {
                if (e.TotalFiles == 1)
                {
                    var intent = new Intent(context, typeof(NotificationLaunchActivity));
                    intent.PutExtra("action", "openFile");
                    intent.PutExtra("guid", e.Guid.ToString());

                    await progressNotifier?.FinishProgress($"Received a file from {e.SenderName}", "Tap to open", intent, context);
                }
                else
                {
                    await DataStorageProviders.HistoryManager.OpenAsync();

                    var hr = DataStorageProviders.HistoryManager.GetItem(e.Guid);
                    DataStorageProviders.HistoryManager.Close();
                    var rootPath = (hr.Data as ReceivedFileCollection).StoreRootPath;
                    await progressNotifier?.FinishProgress($"Received {e.TotalFiles} files from {e.SenderName}", $"They're located at {rootPath}");
                }

                progressNotifier = null;
                Finish?.Invoke();
            }
            else if (e.State == FileTransfer.FileTransferState.DataTransfer)
            {
                progressNotifier?.SetProgressValue((int)e.Total, (int)e.CurrentPart, "Receiving...");
            }
        }