private async void FetchDevicesList() { var devices = (await CloudClipboardService.GetDevices(accountId))?.OrderBy(x => x.Name ?? ""); if (devices == null) { return; } foreach (var item in devices) { if ((item.Name ?? "").ToLower() == CurrentDevice.GetDeviceName().ToLower()) { currentDeviceId = item.DeviceID; //Don't set the property directly, so we don't send a request with the same value. receiveCloudClipboardOnThisDeviceChecked = item.CloudClipboardEnabled; OnPropertyChanged("ReceiveCloudClipboardOnThisDeviceChecked"); ReceiveCloudClipboardOnThisDeviceEnabled = true; continue; } Devices.Add(new DeviceItem(item.CloudClipboardEnabled) { AccountID = item.AccountID, DeviceID = item.DeviceID, Name = item.Name, Type = (item.FormFactor == null) ? DeviceType.Unknown : (item.FormFactor.ToLower() == "phone") ? DeviceType.Phone : DeviceType.PC, }); } }
private async void SendClipboardItem() { if (willSendAfterLimit) { return; } try { var elapsed = (DateTime.UtcNow - lastSendTime); if (elapsed < TimeSpan.FromSeconds(11)) { Debug.WriteLine("Waiting..."); willSendAfterLimit = true; await Task.Delay(TimeSpan.FromSeconds(11) - elapsed); willSendAfterLimit = false; } string text = ViewModel.ClipboardActivities[0].Text; Debug.WriteLine("Sending..."); lastSendTime = DateTime.UtcNow; await CloudClipboardService.SendCloudClipboard(Settings.Data.AccountId, text, CurrentDevice.GetDeviceName()); } catch (Exception ex) { Debug.WriteLine($"SendClipboardItem exception: {ex.Message}"); } }