private void AddElements(List <ButtonElement> list, IEnumerable <ProcessListResponseItem> filtered) { var index = 0; foreach (var item in filtered.Where(d => d.ProcessName.Contains(_itemProcessName)).OrderBy(d => d.ProcessId)) { var buttonElement = new ButtonElement(); buttonElement.Clickable = true; buttonElement.ButtonText = $"Kill {item.ProcessId}"; var scopedIndex = index; buttonElement.ButtonAction = async() => { if (await this.GetAgent().DesktopClient.KillProcessByIdAsync(TimeSpan.FromSeconds(5), item.ProcessId)) { this.DataSource.RemoveAt(scopedIndex); ToastHelper.DisplaySuccess(true, ToastLength.Short); } else { ToastHelper.DisplaySuccess(false, ToastLength.Short); } }; list.Add(buttonElement); index++; } }
private async void DataSourceOnUpdateRequired(object sender, AudioFeedResponseItem e) { try { var result = await _agent.FullDesktopClient.UpdateAudioFeedAsync(new UpdateAudioFeedRequest() { Item = e }); ToastHelper.DisplaySuccess(result.Success, ToastLength.Short); if (result.Success) { var feeds = await _agent.FullDesktopClient.GetAudioFeedsAsync(new AudioFeedRequest()); if (_recyclerView.GetAdapter() is AudioApplicationDataSource audioDataSource) { var match = feeds.Items.FirstOrDefault(d => d.Id == e.Id); if (match != null) { audioDataSource.UpdateSingle(match); } } } } catch (Exception exception) { Log.Error(exception); ToastHelper.Display("Update failed", ToastLength.Short); } }
private async Task <List <ButtonElement> > GenerateData() { using var agent = this.GetAgent(); var hostCommands = await agent.DesktopClient.GetHostCommandsAsync(TimeSpan.FromSeconds(5)); var results = new List <ButtonElement>(); foreach (var command in hostCommands) { results.Add(new ButtonElement() { Clickable = true, ButtonText = command.Title, ButtonAction = async() => { var result = await agent.DesktopClient.InvokeHostCommand(TimeSpan.FromSeconds(5), command.CommandId); ToastHelper.DisplaySuccess(result, ToastLength.Short); } }); } if (hostCommands.Count == 0) { results.Add(new ButtonElement() { ButtonText = "No commands available", ButtonAction = () => {} }); } return(results); }
private async void AbortOnClick(object sender, EventArgs e) { var agent = this.GetAgent(); SystemStateManager.AbortAllTimers(agent.Address); var result = await agent.DesktopClient.AbortShutDownAsync(TimeSpan.FromSeconds(5)); ToastHelper.DisplaySuccess(result, ToastLength.Short); }
private async Task <bool> TrySendInput(string message) { #if DEBUG await Task.Delay(3000); #endif if (await this.GetAgent().DesktopClient.SendKeysAsync(message)) { ToastHelper.DisplaySuccess(true, ToastLength.Short); return(true); } else { ToastHelper.DisplaySuccess(false, ToastLength.Long); return(false); } }
private async void MonitorOffOnClick(object sender, EventArgs e) { var result = await this.GetAgent().DesktopClient.MonitorOffAsync(TimeSpan.FromSeconds(10)); ToastHelper.DisplaySuccess(result, ToastLength.Short); }
private async void LockWorkstationOnClick(object sender, EventArgs e) { var result = await this.GetAgent().DesktopClient.LockWorkStationAsync(TimeSpan.FromSeconds(5)); ToastHelper.DisplaySuccess(result, ToastLength.Short); }