void airServer_UserWantToSendFiles(Air.SendFiles sendFiles, AirServer.IPEndPointHolder remotePoint, TcpClient client) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new AirServer.UserSendsFiles(airServer_UserWantToSendFiles), new object[] { sendFiles, remotePoint, client }); return; } foreach (UserIcon userIcon in PanelOfUsers.Children) { if (userIcon.RemotePoint.Equals(remotePoint)) { if (MessageBox.Show(this, string.Format("\"{0}\" wants to share {1} file(s) (~{2:0.00} MB) with you. Would you like to receive them now?", userIcon.TextDisplayName.Text, sendFiles.Count, sendFiles.Size / 1024f), "AirFileExchange - Receiving files", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { userIcon.IsCanceled = false; userIcon.LastStatus = UserIcon.OperationStatus.None; airServer.ReceiveFilesFromAsync(remotePoint, client, sendFiles, true, userIcon, new AirServer.UserReceiveFilesProgress(airServer_UserReceiveFilesProgress), new AirServer.UserReceiveFilesComplete(airServer_UserReceiveFilesComplete)); } else { airServer.ReceiveFilesFromAsync(remotePoint, client, sendFiles, false, userIcon, null, new AirServer.UserReceiveFilesComplete(airServer_UserReceiveFilesComplete)); } return; } } }
void airServer_UserPresenceGotTimeout(AirServer.IPEndPointHolder remotePoint) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new AirServer.UserPresenceTimeout(airServer_UserPresenceGotTimeout), new object[] { remotePoint }); return; } foreach (UserIcon userIcon in PanelOfUsers.Children) { if (userIcon.RemotePoint.Equals(remotePoint)) { userIcon.Remove(); break; } } }
void airServer_UserPresenceReceivedRequest(Air.RequestPresence request, AirServer.IPEndPointHolder remotePoint) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new AirServer.UserPresenceRequest(airServer_UserPresenceReceivedRequest), new object[] { request, remotePoint }); return; } if (!remotePoint.IsMine) { UserIcon userIcon = new UserIcon(); userIcon.RemotePoint = remotePoint; userIcon.TextDisplayName.Text = request.UserInfo.DisplayName; userIcon.TextComputerName.Text = request.UserInfo.ComputerName; userIcon.ImageIcon.Source = AirFileExchange.Air.Helper.ImageFromBase64(request.UserInfo.Icon); userIcon.Click += new EventHandler(userIcon_Click); userIcon.DropFileList += new UserIcon.EventDropFileList(userIcon_DropFileList); PanelOfUsers.Children.Add(userIcon); userIcon.Popup(); } }
void airServer_UserReceiveFilesComplete(AirFileExchange.Air.SendFiles sendFiles, AirServer.IPEndPointHolder remotePoint, object state, Exception e) { if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new AirServer.UserReceiveFilesComplete(airServer_UserReceiveFilesComplete), new object[] { sendFiles, remotePoint, state, e }); return; } UserIcon userIcon = (UserIcon)state; userIcon.ProgressValue = 0; userIcon.LastStatus = e == null ? UserIcon.OperationStatus.Success : UserIcon.OperationStatus.Failed; }
void airServer_UserReceiveFilesProgress(AirFileExchange.Air.SendFile sendFile, AirServer.IPEndPointHolder remotePoint, long receivedCurrent, long currentSize, long receivedTotal, long totalSize, object state, out bool cancel) { UserIcon userIcon = (UserIcon)state; cancel = isClosed || userIcon.IsCanceled; if (Dispatcher.Thread != Thread.CurrentThread) { Dispatcher.BeginInvoke(new AirServer.UserReceiveFilesProgress(airServer_UserReceiveFilesProgress), new object[] { sendFile, remotePoint, receivedCurrent, currentSize, receivedTotal, totalSize, state, cancel }); return; } userIcon.ProgressValue = 10000 * receivedTotal / totalSize; }