コード例 #1
0
        public async Task PasteSelectedFilesAsync(string destinationDirectory)
        {
            var selectedFilesString = await _clipboardService.GetTextAsync();

            var startIndex = UrlPrefix.Length;
            var files      = selectedFilesString
                             .Split()
                             .Select(f => f.Substring(startIndex))
                             .ToArray();

            await _operationsService.CopyFilesAsync(files, destinationDirectory);
        }
コード例 #2
0
        public void CopyClipboardTextWhenApplicationBecomesVisible()
        {
            const string clipboardText     = "SomeText";
            var          visibilitySubject = new Subject <bool>();

            A.CallTo(() => _clipboardService.GetTextAsync(A <CancellationToken> .Ignored)).Returns(Task.FromResult(Option <string> .AsOption(clipboardText)));
            A.CallTo(() => _windowService.IsVisibleObservable).Returns(visibilitySubject);
            var viewModel = CreateViewModel();

            visibilitySubject.OnNext(true);

            Assert.AreEqual(clipboardText, viewModel.Text.Value);
        }
コード例 #3
0
        public async Task PasteFilesAsync(string destinationDirectory)
        {
            var selectedFilesString = await _clipboardService.GetTextAsync();

            if (string.IsNullOrWhiteSpace(selectedFilesString))
            {
                return;
            }

            var startIndex = UrlPrefix.Length;
            var files      = selectedFilesString
                             .Split()
                             .Where(t => t.StartsWith(UrlPrefix))
                             .Select(f => f[startIndex..])
コード例 #4
0
    private async Task <IReadOnlyList <string> > GetFilesAsync()
    {
        var selectedFilesString = await _clipboardService.GetTextAsync();

        if (string.IsNullOrWhiteSpace(selectedFilesString))
        {
            return(Array.Empty <string>());
        }

        var startIndex = UrlPrefix.Length;

        return(selectedFilesString
               .Split(_environmentService.NewLine)
               .Where(t => t.StartsWith(UrlPrefix))
               .Select(f => f[startIndex..])
コード例 #5
0
        public async Task PasteFilesAsync(string destinationDirectory)
        {
            var selectedFilesString = await _clipboardService.GetTextAsync();

            if (string.IsNullOrWhiteSpace(selectedFilesString))
            {
                return;
            }

            var startIndex = UrlPrefix.Length;
            var files      = selectedFilesString
                             .Split()
                             .Where(t => t.StartsWith(UrlPrefix))
                             .Select(f => f.Substring(startIndex))
                             .ToArray();

            if (files.Any())
            {
                await _operationsService.CopyAsync(files, destinationDirectory);
            }
        }