public void Initialize(ProcessPropertiesDto properties, ProcessViewModel process, ITargetedRestClient restClient) { _restClient = restClient; StaticPropertiesDto = properties; PropertiesDto = properties; Process = process; if (process.ParentProcessId != 0) { string parentProcess; if (process.ParentViewModel != null) { parentProcess = process.Name; } else { parentProcess = "<" + Tx.T("TaskManager:NotAvailable") + ">"; } ParentProcessString = $"{parentProcess} ({process.ParentProcessId})"; } Icon = ImageUtilities.GetBitmapImage(properties.Icon); Status = properties.Status; InitializeChannel().Forget(); UpdateActiveConnections().Forget(); }
public ClientPanelViewModel(ITargetedRestClient restClient, IMazeRestClient mazeRestClient, ClientViewModel clientViewModel, IWindowService windowService, ClipboardSynchronizer clipboardSynchronizer) { _mazeRestClient = mazeRestClient; _windowService = windowService; _clipboardSynchronizer = clipboardSynchronizer; _clientViewModel = clientViewModel; _restClient = restClient; Title = $"{clientViewModel.Username} [{clientViewModel.LatestSession.IpAddress}]"; ComputerPowerCommands = new List <ButtonAction> { new ButtonAction(Tx.T("ClientPanel:Power.LogOff"), () => SystemPowerResource.LogOff(restClient)), new ButtonAction(Tx.T("ClientPanel:Power.Shutdown"), () => SystemPowerResource.Shutdown(restClient)), new ButtonAction(Tx.T("ClientPanel:Power.Restart"), () => SystemPowerResource.Restart(restClient)) }; SystemProgramsCommands = new List <ButtonAction> { new ButtonAction(Tx.T("ClientPanel:RemotePrograms.TaskManager"), () => ProgramsResource.StartTaskManager(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.RegEdit"), () => ProgramsResource.StartRegEdit(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.DeviceManager"), () => ProgramsResource.StartDeviceManager(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.ControlPanel"), () => ProgramsResource.StartControlPanel(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.ComputerManagement"), () => ProgramsResource.StartComputerManagement(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.EventLog"), () => ProgramsResource.StartEventLog(restClient)), new ButtonAction(Tx.T("ClientPanel:RemotePrograms.Services"), () => ProgramsResource.StartServices(restClient)) }; }
public static async Task <TChannel> CreateChannel <TChannel>(this IRequestBuilder requestBuilder, ITargetedRestClient client, CancellationToken cancellationToken) where TChannel : IAwareDataChannel { using (var request = requestBuilder.Build()) { return(await client.OpenChannel <TChannel>(request, cancellationToken)); } }
public RemoteFileSystem(IMemoryCache globalCache, ITargetedRestClient restClient) { _globalCache = globalCache; _restClient = restClient; _localCache = new ConcurrentDictionary <string, CachedDirectory>(_caseInsensitivePaths ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); InvalidFileNameChars = Path.GetInvalidFileNameChars().ToImmutableHashSet(); }
public static Task <RemoteDesktopChannel> CreateScreenChannel(ComponentOptions captureOptions, ComponentOptions encoderOptions, ITargetedRestClient restClient) { var requestBuilder = CreateRequest(HttpVerb.Get, "screen"); requestBuilder.Message.Headers.Add("capture", captureOptions.ToString()); requestBuilder.Message.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue(encoderOptions.ToString(), 1)); return(requestBuilder.CreateChannel <RemoteDesktopChannel>(restClient, CancellationToken.None)); }
public TaskManagerViewModel(IShellStatusBar statusBar, ITargetedRestClient restClient, IWindowService windowService) { _statusBar = statusBar; _windowService = windowService; _restClient = restClient; _refreshTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(10) }; _refreshTimer.Tick += RefreshTimerOnTick; }
public void Initialize(FileViewModel fileViewModel, ITargetedRestClient restClient) { _fileViewModel = fileViewModel; _restClient = restClient; ExecuteDto = new ExecuteFileDto { FileName = fileViewModel.Source.Path }; if (!ExecuteDto.FileName.EndsWith(".exe")) { ExecuteDto.UseShellExecute = true; } }
public void Initialize(FileViewModel fileViewModel, FilePropertiesDto dto, ITargetedRestClient restClient) { var properties = GeneralPropertyViewModel.CreateFileProperties(fileViewModel, dto).ToList(); GeneralProperties = CreateGeneralProperties(properties); Entry = fileViewModel; DetailsViewModel = new DetailsPropertyViewModel(dto.Properties); if (!Entry.IsDirectory) { HashViewModels = Enum.GetValues(typeof(FileHashAlgorithm)).Cast <FileHashAlgorithm>() .Select(x => new ComputeHashViewModel(Entry.Source.Path, x, restClient)).ToList(); } }
public RegistryTreeViewModel(ITargetedRestClient restClient, IShellStatusBar statusBar) { _restClient = restClient; _statusBar = statusBar; Entries = new EntriesHelper <RegistryKeyViewModel>(); Selection = new TreeRootSelector <RegistryKeyViewModel, IntegratedRegistryKey>(Entries) { Comparers = new[] { new RegistryPathComparer() } }; Entries.SetEntries(new[] { RegistryHive.ClassesRoot, RegistryHive.CurrentUser, RegistryHive.LocalMachine, RegistryHive.Users, RegistryHive.CurrentUser }.Select(CreateHiveViewModel)); }
public RegistryKeyViewModel(RegistryTreeViewModel rootTreeViewModel, IntegratedRegistryKey registryKey, ITargetedRestClient restClient, IShellStatusBar statusBar, RegistryKeyViewModel parentViewModel) { RegistryKey = registryKey; _rootTreeViewModel = rootTreeViewModel; _restClient = restClient; _statusBar = statusBar; Parent = parentViewModel; Entries = new EntriesHelper <RegistryKeyViewModel>(LoadSubKeys); Selection = new TreeSelector <RegistryKeyViewModel, IntegratedRegistryKey>(registryKey, this, parentViewModel == null ? rootTreeViewModel.Selection : parentViewModel.Selection, Entries); if (!registryKey.HasSubKeys) { Entries.SetEntries(Enumerable.Empty <RegistryKeyViewModel>()); } }
public FileExplorerViewModel(IShellStatusBar statusBar, IWindowService windowService, IMemoryCache cache, ITargetedRestClient client, IAppDispatcher dispatcher, IImageProvider imageProvider) { StatusBar = statusBar; Window = windowService; RestClient = client; FileSystem = new RemoteFileSystem(cache, RestClient); ImageProvider = imageProvider; Dispatcher = dispatcher; ProcessingEntries = new ObservableCollection <ProcessingEntryViewModel>(); NavigationBarViewModel = new NavigationBarViewModel(); DirectoryTreeViewModel = new DirectoryTreeViewModel(); EntriesViewModel = new EntriesViewModel(); FileTransferManagerViewModel = new FileTransferManagerViewModel(); foreach (var childViewModel in new IFileExplorerChildViewModel[] { NavigationBarViewModel, DirectoryTreeViewModel, EntriesViewModel, FileTransferManagerViewModel }) { childViewModel.Initialize(this); } }
public MessageBoxViewModel(ITargetedRestClient restClient, IWindowService windowService, IShellStatusBar statusBar) { _windowService = windowService; _statusBar = statusBar; _restClient = restClient; }
public static Task <List <DirectoryEntry> > QueryDirectories(string path, ITargetedRestClient restClient) => CreateRequest().AddQueryParam("path", path).AddQueryParam("directoriesOnly", "true").Execute(restClient) .Return <List <DirectoryEntry> >();
public static Task <DirectoryEntry> GetDirectoryEntry(string path, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, "directory").AddQueryParam("path", path).Execute(restClient).Return <DirectoryEntry>();
public ComputeHashViewModel(string path, FileHashAlgorithm hashAlgorithm, ITargetedRestClient restClient) { _path = path; HashAlgorithm = hashAlgorithm; _restClient = restClient; }
public static Task <string[]> GetFileVerbs(string path, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, "file/verbs").AddQueryParam("path", path).Execute(restClient).Return <string[]>();
public static Task <CallTransmissionChannel <IProcessWatcher> > GetProcessWatcher(ITargetedRestClient restClient) => restClient.CreateChannel <TaskManagerResource, IProcessWatcher>("processWatcher");
public static Task <string> ExpandEnvironmentVariables(string path, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, "path").AddQueryParam("path", path).Execute(restClient).Return <string>();
public static Task <ProcessPropertiesDto> GetProperties(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/properties").Execute(restClient).Return <ProcessPropertiesDto>();
public static Task Resume(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/resume").Execute(restClient);
public static Task KillTree(int rootProcessId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, rootProcessId + "/killTree").Execute(restClient);
public static Task BringToFront(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/window/bringToFront").Execute(restClient);
public static Task Close(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/window/close").Execute(restClient);
public static Task DeleteFile(string path, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Delete, "file").AddQueryParam("path", path).Execute(restClient);
public static Task Suspend(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/suspend").Execute(restClient);
public static Task MoveDirectory(string path, string newPath, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Patch, "directory").AddQueryParam("path", path).AddQueryParam("newPath", newPath).Execute(restClient);
public static Task SetPriority(int processId, ProcessPriorityClass priority, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/setPriority").AddQueryParam("priority", ((int)priority).ToString()).Execute(restClient);
public static Task <FilePropertiesDto> GetFileProperties(string path, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, "file/properties").AddQueryParam("path", path).Execute(restClient).Return <FilePropertiesDto>();
public static Task <List <ActiveConnectionDto> > GetConnections(int processId, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Get, processId + "/connections").Execute(restClient).Return <List <ActiveConnectionDto> >();
public static Task ExecuteFile(ExecuteFileDto dto, bool waitForExit, ITargetedRestClient restClient) => CreateRequest(HttpVerb.Post, "file/execute", dto).AddQueryParam("waitForExit", waitForExit.ToString()).Execute(restClient);