示例#1
0
 /// <summary>
 /// Initializes a new instance of the DownloadViewModel class.
 /// </summary>
 public DownloadViewModel(string url, string programName)
 {
     DownloadCommand       = new DownloadCommand(this);
     CancelDownloadCommand = new CancelDownloadCommand(this);
     this.url         = url;
     this.programName = programName;
 }
示例#2
0
 private Updater()
 {
     CheckCommand = new DelegateCommand(async() =>
     {
         CheckCommand.CanExecute = false;
         bool result             = await TryFindUpdateAsync();
         Status = result ? UpdaterStatus.Download : UpdaterStatus.Check;
         if (result && isautoupdate)
         {
             DispatcherHelper.UIDispatcher.Invoke(() =>
             {
                 if (MessageBox.Show($"{StringTable.Update_Text_Download}{NewVersion}",
                                     StringTable.Update, MessageBoxButton.OKCancel, MessageBoxImage.Information)
                     == MessageBoxResult.OK)
                 {
                     new AboutWindow {
                         Owner = Application.Current.MainWindow
                     }
                 }
                 .ShowDialog();
             });
             if (Config.Current.AutoDownloadUpdate)
             {
                 DownloadCommand.Execute(null);
             }
             else
             {
                 isautoupdate = false;
             }
         }
示例#3
0
        private static bool RunCommands()
        {
            ICommand cmd = new HelpCommand();

            if (!string.IsNullOrEmpty(ArgSettings.Help))
            {
                cmd = new HelpCommand();
            }
            else if (ArgSettings.List)
            {
                cmd = new ListCommand();
            }
            else if (ArgSettings.Remove)
            {
                cmd = new RemoveCommand();
            }
            else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) &&
                     ArgumentsHelper.IsValidUri(ArgSettings.Destination) &&
                     ArgumentsHelper.IsValidAzureConnection(ArgSettings.SourceConnection))
            {
                cmd = new CopyCommand();
            }
            else if (ArgumentsHelper.IsValidUri(ArgSettings.Source) &&
                     ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Destination))
            {
                cmd = new DownloadCommand();
            }
            else if (ArgumentsHelper.IsValidFileSystemPath(ArgSettings.Source) &&
                     ArgumentsHelper.IsValidUri(ArgSettings.Destination))
            {
                cmd = new UploadCommand();
            }

            return(cmd.Execute());
        }
示例#4
0
 public DownloadListViewModel()
 {
     _downloadFileService = new DownloadFileService();
     DownloadAllCmd       = new DownloadCommand(DownloadAll);
     CancelAllCmd         = new DownloadCommand(CancelAll);
     LoadFiles();
 }
        public void Execute(DownloadCommand command)
        {
            if (Connection == null)
            {
                Console.WriteLine("There is no connection to server!");

                return;
            }

            var localFileName = $"Resources{Path.DirectorySeparatorChar}{command.FileName}";

            var fileInfo   = new FileInfo(localFileName);
            var fileLength = fileInfo.Exists ? fileInfo.Length : 0;

            var message = new FileInfoCommand()
            {
                CommandType = CommandType.DownloadFileRequest,
                ClientId    = ClientId,
                FileName    = command.FileName,
                IsExist     = fileInfo.Exists,
                Size        = fileLength
            };

            Connection.Send(message);

            var serverFileInfoResponse = Connection.Receive().Deserialize <FileInfoCommand>();

            if (serverFileInfoResponse.FileName == null)
            {
                Console.WriteLine("File not found!");
                return;
            }

            var stopwatch = new Stopwatch();

            stopwatch.Restart();
            Connection.Send(serverFileInfoResponse);

            var bytesReceived = 0;

            using (var fileStream = File.OpenWrite(localFileName))
                using (var binaryWriter = new BinaryWriter(fileStream))
                {
                    binaryWriter.BaseStream.Seek(0, SeekOrigin.End);

                    while (bytesReceived < serverFileInfoResponse.Size - fileLength)
                    {
                        var filePart = Connection.Receive();

                        binaryWriter.Write(filePart);
                        binaryWriter.Flush();

                        bytesReceived += filePart.Length;
                    }
                }

            stopwatch.Stop();
            Console.WriteLine($"File successfully downloaded! " +
                              $"Average upload speed is {((double)bytesReceived / (1024 * 1024)) / (((double)stopwatch.ElapsedMilliseconds + 1) / 1000)} Mbps.");
        }
示例#6
0
        private static void GetCommandToExecute(string command, out ICommand commandToExecute, ExtractCommand extractCommand)
        {
            switch (command)
            {
            case "d":
                Console.Write("Enter delay between download calls: ");
                string timeOutInput = Console.ReadLine();

                if (!int.TryParse(timeOutInput, out int timeOut))
                {
                    timeOut = 2000;
                }

                commandToExecute = new DownloadCommand(timeOut, extractCommand.links);
                return;

            case "p":
                commandToExecute = new PrintCommand(extractCommand.links);
                return;

            case "s":
                commandToExecute = new SaveCommand(extractCommand.links, ReadSaveFilePath());
                return;
            }

            commandToExecute = null;
        }
        /// <summary>
        ///     Downloads the content from Amazon S3 and writes it to the specified file.
        ///     If the key is not specified in the request parameter,
        ///     the file name will used as the key name.
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to download an Amazon S3 object.
        /// </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task DownloadAsync(TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            CheckForBlockedArn(request.BucketName, "Download");
            var command = new DownloadCommand(this._s3Client, request);

            return(command.ExecuteAsync(cancellationToken));
        }
 private void InitCommands()
 {
     OpenCommand              = new OpenCommand(this);
     ApplyCommand             = new ApplyCommand(this);
     FlipCommand              = new FlipCommand(this);
     HistogramEqualizeCommand = new HistogramEqualizeCommand(this);
     HistogramStretchCommand  = new HistogramStretchCommand(this);
     CropCommand              = new CropCommand(this);
     InpaintCommand           = new InpaintCommand(this);
     ResizeCommand            = new ResizeCommand(this);
     RotateCommand            = new RotateCommand(this);
     SaveAsCommand            = new SaveAsCommand(this);
     SaveCommand              = new SaveCommand(this);
     ZoomCommand              = new ZoomCommand(this);
     ResetCommand             = new ResetCommand(this);
     CloseCommand             = new CloseCommand(this);
     SelectToolCommand        = new SelectToolCommand(this);
     UndoCommand              = new UndoCommand(this);
     RedoCommand              = new RedoCommand(this);
     DropboxCommand           = new DropboxCommand(this);
     DownloadCommand          = new DownloadCommand(this);
     UploadCommand            = new UploadCommand(this);
     DCommand       = new DCommand(this);
     ECommand       = new ECommand(this);
     PrewittCommand = new PrewittCommand(this);
 }
 public DownloadFileViewModel(StorageFolder folder)
 {
     //_downloadFileService = new DownloadFileService();
     DownloadCmd = new DownloadCommand(Download);
     CancelCmd   = new DownloadCommand(Cancel);
     OpenCmd     = new DownloadCommand(Open);
     _folder     = folder;
 }
示例#10
0
        public void ExecuteDownloadTest()
        {
            var result = new DownloadCommand().Execute(new Args.DownloadArgs()
            {
                download = "216g4r"
            });

            Assert.AreEqual(true, File.Exists(result));
        }
示例#11
0
        public void LoopTest()
        {
            var result = new DownloadCommand().Execute(new Args.DownloadArgs()
            {
                download = "2pd8gk", full = true
            });

            Assert.AreEqual(true, File.Exists(result));
        }
示例#12
0
        public void GifTest()
        {
            var result = new DownloadCommand().Execute(new Args.DownloadArgs()
            {
                download = "1wjjeh", gif = true
            });

            Assert.AreEqual(true, File.Exists(result));
        }
示例#13
0
        public async Task GivenThatTheFeedHasMissingPackagesVerifyExistingPackagesAreDownloaded()
        {
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                        using (var cache2 = new LocalCache())
                            using (var outputFolder = new TestFolder())
                            {
                                var log         = new TestLogger();
                                var fileSystem  = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                                var fileSystem2 = new PhysicalFileSystem(cache2, UriUtility.CreateUri(target.Root));
                                var settings    = new LocalSettings();

                                await InitCommand.RunAsync(settings, fileSystem, log);

                                var expected = new List <string>();

                                for (var i = 0; i < 100; i++)
                                {
                                    var package = new TestNupkg("a", $"{i}.0.0");
                                    package.Save(packagesFolder);

                                    if (i != 50)
                                    {
                                        expected.Add($"a.{i}.0.0.nupkg");
                                    }
                                }

                                await PushCommand.RunAsync(settings, fileSystem, new List <string>() { packagesFolder }, false, false, log);

                                var root = new DirectoryInfo(target);
                                foreach (var file in root.GetFiles("a.50.0.0*", SearchOption.AllDirectories))
                                {
                                    // Corrupt the feed
                                    file.Delete();
                                }

                                var success = await DownloadCommand.RunAsync(settings, fileSystem2, outputFolder, false, log);

                                var fileNames = Directory.GetFiles(outputFolder, "*.nupkg", SearchOption.AllDirectories)
                                                .Select(e => Path.GetFileName(e))
                                                .OrderBy(e => e, StringComparer.OrdinalIgnoreCase)
                                                .ToArray();

                                success.ShouldBeEquivalentTo(false, "the feed is not valid");

                                fileNames.ShouldBeEquivalentTo(expected, "all files but the deleted one");

                                log.GetMessages().Should().NotContain("The feed does not contain any packages");
                                log.GetMessages().Should().Contain("Failed to download all packages!");

                                foreach (var file in expected)
                                {
                                    log.GetMessages().Should().Contain(file);
                                }
                            }
        }
示例#14
0
        public void TestMethod1()
        {
            FTP             myftp = new FTP("192.168.18.29", 21);
            DownloadCommand cmd   = new DownloadCommand(myftp, "Game.dll", "G:\\");

            cmd.Execute();
            Thread.Sleep(10);
            DownloadContinue cmd2 = (DownloadContinue)cmd.Abort();

            cmd2.Execute();
        }
        public ToolTabViewModel(Tools tools)
        {
            Tools                  = tools;
            ButtonDownload         = "翻訳ファイルをダウンロード";
            ButtonApplyTranslation = "翻訳を適用";
            ButtonApplyFont        = "フォントを適用";
            ButtonRevertToEnglish  = "英語に戻す";
            IsProgress             = Tools.ToReactivePropertyAsSynchronized(x => x.IsProgress, convert: x => x.Inverse(), convertBack: x => x.Inverse());

            DownloadCommand.Subscribe(_ => Tools.Download());
            ApplyTranslationCommand.Subscribe(_ => Tools.ApplyTranslation());
            ApplyFontsCommand.Subscribe(_ => Tools.ApplyFonts());
            RevertToEnglishCommand.Subscribe(_ => Tools.ApplyTranslation(true));
        }
示例#16
0
        /// <summary>
        /// Initialize the view model.
        /// </summary>
        public AdcpUtilitiesViewModel()
            : base("ADCP Utilities")
        {
            // Set Event Aggregator
            _events = IoC.Get <IEventAggregator>();

            // Compass Cal command
            CompassCalCommand = ReactiveCommand.Create();
            CompassCalCommand.Subscribe(_ => CompassCal());

            // Compass Utility command
            CompassUtilityCommand = ReactiveCommand.Create();
            CompassUtilityCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.CompassUtilityView)));

            // Terminal command
            TerminalCommand = ReactiveCommand.Create();
            TerminalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.TerminalView)));

            // Download command
            DownloadCommand = ReactiveCommand.Create();
            DownloadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DownloadDataView)));

            // Upload Firmware command
            UploadCommand = ReactiveCommand.Create();
            UploadCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.UpdateFirmwareView)));

            // Screen data command
            ScreenCommand = ReactiveCommand.Create();
            ScreenCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.ScreenDataView)));

            VmOptionsCommand = ReactiveCommand.Create();
            VmOptionsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.VesselMountOptionsView)));

            // Predicition Model command
            PredicitionModelCommand = ReactiveCommand.Create();
            PredicitionModelCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.AdcpPredictionModelView)));

            // RTI Compass Calibration Model command
            RtiCompassCalCommand = ReactiveCommand.Create();
            RtiCompassCalCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.RtiCompassCalView)));

            // Diagnostics View command
            DiagnosticsCommand = ReactiveCommand.Create();
            DiagnosticsCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DiagnosticView)));

            // Data Output View command
            DataOutputCommand = ReactiveCommand.Create();
            DataOutputCommand.Subscribe(_ => _events.PublishOnUIThread(new ViewNavEvent(ViewNavEvent.ViewId.DataOutputView)));
        }
示例#17
0
        public void GivenThatTheFeedIsNotInitializedVerifyCommandFails()
        {
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                        using (var outputFolder = new TestFolder())
                        {
                            var log        = new TestLogger();
                            var fileSystem = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                            var settings   = new LocalSettings();

                            Func <Task> action = async() => await DownloadCommand.RunAsync(settings, fileSystem, outputFolder, false, log);

                            action.ShouldThrow <InvalidOperationException>("the feed is not initialized");
                        }
        }
示例#18
0
        /// <summary>
        /// Adds the platform-specific commands.
        /// </summary>
        partial void AddPlatformCommands()
        {
            IntellicartToolsMenuCommand.MenuParent = RootCommandGroup.ToolsMenuCommand;
            var fileDownloadCommand = DownloadCommand.Clone();

            fileDownloadCommand.Weight       = 0.04;
            fileDownloadCommand.MenuItemName = DownloadCommand.ContextMenuItemName;
            fileDownloadCommand.MenuParent   = RootCommandGroup.FileMenuCommand;
            var fileBrowseAndDownloadCommand = BrowseAndDownloadCommand.Clone();

            fileBrowseAndDownloadCommand.Weight       = 0.05;
            fileBrowseAndDownloadCommand.MenuItemName = BrowseAndDownloadCommand.ContextMenuItemName;
            fileBrowseAndDownloadCommand.MenuParent   = RootCommandGroup.FileMenuCommand;
            CommandList.Add(IntellicartToolsMenuCommand.CreateSeparator(CommandLocation.Before));
            CommandList.Add(fileDownloadCommand);
            CommandList.Add(fileBrowseAndDownloadCommand);
            CommandList.Add(fileBrowseAndDownloadCommand.CreateSeparator(CommandLocation.After));
        }
示例#19
0
    private Commands()
    {
        commands["login"]    = new LoginCommand();         //坐席CFG登录
        commands["logout"]   = new LogoutCommand();        //坐席CFG登出
        commands["ms"]       = new MonitorStartCommand();  //坐席登录CFG后,监听事件
        commands["mc"]       = new MakeCallCommand();      //外呼电话
        commands["download"] = new DownloadCommand();
        commands["alon"]     = new AgentLogOnCommand();    //坐席ACD登录
        commands["aloff"]    = new AgentLogOffCommand();   //坐席ACD登出
        commands["ags"]      = new AgentGetStateCommand(); //获取坐席当前状态(就绪3、置忙4、事后处理5)
        commands["ass"]      = new AgentSetStateCommand(); //设置坐席当前状态(就绪3、置忙4、事后处理5)
        commands["rc"]       = new ReleaseCallCommand();   //挂断电话
        commands["cc"]       = new ConsultCallCommand();   //电话转接
        commands["rnc"]      = new ReconnectCallCommand(); //电话恢复转接

        commands["ac"]  = new AnswerCallCommand();         //接电话  需要硬件接通
        commands["hc"]  = new HoldCallCommand();           //电话保持
        commands["rtc"] = new RetrieveCallCommand();       //电话恢复
    }
示例#20
0
 /// <summary>
 /// 下载文件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void menu_download_Click(object sender, EventArgs e)
 {
     try
     {
         ToolStripMenuItem   load = (ToolStripMenuItem)sender;
         string              path = load.Tag.ToString();
         string              destination;
         FolderBrowserDialog Fbd = new FolderBrowserDialog();
         if (Fbd.ShowDialog() == DialogResult.OK)
         {
             destination = Fbd.SelectedPath + "\\";
             TransferCommand transfer = new DownloadCommand(myFTP, path, destination);
             transfer.Execute();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#21
0
        public async Task GivenThatTheFeedHasSymbolsPackagesVerifyDownloadCommandSucceeds()
        {
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                        using (var cache2 = new LocalCache())
                            using (var outputFolder = new TestFolder())
                            {
                                var log         = new TestLogger();
                                var fileSystem  = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                                var fileSystem2 = new PhysicalFileSystem(cache2, UriUtility.CreateUri(target.Root));
                                var settings    = new LocalSettings();

                                var success = await InitCommand.RunAsync(settings, fileSystem, enableCatalog : false, enableSymbols : true, log : log, token : CancellationToken.None);

                                var packageA        = new TestNupkg("a", "1.0.0");
                                var packageASymbols = new TestNupkg("a", "1.0.0");
                                packageASymbols.Nuspec.IsSymbolPackage = true;
                                packageA.Save(packagesFolder.Root);
                                packageASymbols.Save(packagesFolder.Root);

                                success &= await PushCommand.RunAsync(settings, fileSystem, new List <string>() { packagesFolder }, false, false, log);

                                success &= await DownloadCommand.RunAsync(settings, fileSystem2, outputFolder, false, log);

                                var fileNames = Directory.GetFiles(outputFolder, "*.nupkg", SearchOption.AllDirectories)
                                                .Select(e => Path.GetFileName(e))
                                                .OrderBy(e => e, StringComparer.OrdinalIgnoreCase)
                                                .ToArray();

                                success.ShouldBeEquivalentTo(true, "the feed is valid");

                                fileNames.ShouldBeEquivalentTo(new[] { "a.1.0.0.nupkg", "a.1.0.0.symbols.nupkg" });

                                log.GetMessages().Should().NotContain("The feed does not contain any packages");
                                log.GetMessages().Should().Contain("a.1.0.0.nupkg");
                                log.GetMessages().Should().Contain("a.1.0.0.symbols.nupkg");
                            }
        }
示例#22
0
        private void TargetIf_AppProgressEvent(ProgressArgs arg)
        {
            int idx = _listItems.FindIndex(x => x.Id == arg.ImageID && (int)x.Protocol == arg.ExtraInfo);

            if (idx >= 0 && arg.TotalBytes > 0) // 유효한 파일 다운로드 중..
            {
                int progress = (int)(arg.SentBytes * 100 / arg.TotalBytes);

                UpdateProgress(idx, progress);
            }
            else if (arg.ExtraInfo == (int)QProtocol.All)
            {
                if (_targetIf != null)
                {
                    _targetIf.AppProgressEvent -= TargetIf_AppProgressEvent;
                }

                if (FbMode == FBMode.Download && arg.TotalBytes > 0)
                {
                    Main.PrintImagesList(_listItems);
                }

                Log.i("All {0} is Completed.", FbMode == FBMode.Download ? "Download" : "Dump");
                this.TotalStatus = string.Format("{0} is completed {1}.",
                                                 FbMode == FBMode.Download ? "<download>" : "<dump>",
                                                 arg.TotalBytes > 0 ? "successfully" : "but failed");

                FbMode = FBMode.None;
                bool ok = arg.TotalBytes > 0;
                Pages.TopMessageBox.ShowMsg(
                    string.Format("A task is completed.\n\n<Result>\n\t{0}", ok ? "Success" : "Fail - refer logs"), ok);

                this.UIThread(delegate
                {
                    DownloadCommand.RaiseCanExecuteChanged();
                    DumpCommand.RaiseCanExecuteChanged();
                });
            }
        }
            private async Task Run(FileInfo torrent)
            {
                var(dto, benc) = await BaseCommand.GetTorrentFileDtoAsync(torrent);

                var infoHash = benc["info"] !.Hash();

                byte[] peerId = CreateRandomPeerId();

                Console.WriteLine($"torrent download v2 hash: {Convert.ToHexString(infoHash)}");

                var endpoints = await DownloadCommand.GetTrackerPeersAsync(dto, infoHash, peerId);

                Console.WriteLine($"endpoints: {endpoints.Length}");

                foreach (var peerEndpoint in endpoints)
                {
                    try {
                        using var peer = await PeerConnection.EstablishConnection(peerEndpoint, TimeSpan.FromSeconds(1.5));

                        peer.MessageReceived += msg => Console.WriteLine($"{peerEndpoint} => {msg.GetType()}");
                        await peer.SendMessage(
                            new Handshake(new byte[8], infoHash, peerId)
                            );

                        await peer.SendMessage(new Unchoke());

                        await peer.SendMessage(new Interested());

                        await Task.Delay(20000);
                    }
                    catch (Exception e) {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.Error.WriteLine($"[{peerEndpoint}]: ERR\n{e.Message} {e.StackTrace}\n");
                        Console.ResetColor();
                        continue;
                    }
                }
            }
示例#24
0
        public async Task GivenThatTheFeedIsEmptyVerifyDownloadCommandSucceeds()
        {
            using (var packagesFolder = new TestFolder())
                using (var target = new TestFolder())
                    using (var cache = new LocalCache())
                        using (var cache2 = new LocalCache())
                            using (var outputFolder = new TestFolder())
                            {
                                var log         = new TestLogger();
                                var fileSystem  = new PhysicalFileSystem(cache, UriUtility.CreateUri(target.Root));
                                var fileSystem2 = new PhysicalFileSystem(cache2, UriUtility.CreateUri(target.Root));
                                var settings    = new LocalSettings();

                                await InitCommand.RunAsync(settings, fileSystem, log);

                                var success = await DownloadCommand.RunAsync(settings, fileSystem2, outputFolder, false, log);

                                success.ShouldBeEquivalentTo(true, "the feed is valid");

                                Directory.GetFiles(outputFolder, "*.nupkg", SearchOption.AllDirectories).Length.ShouldBeEquivalentTo(0, "the feed is empty");

                                log.GetMessages().Should().Contain("The feed does not contain any packages");
                            }
        }
示例#25
0
        //private DxxUrl CreateDxxUrl() {
        //    var driver = Driver.Value;
        //    var uri = new Uri(Url.Value);
        //    return new DxxUrl(uri, driver, driver.GetNameFromUri(uri, "link"), IsMain ? "from main" : "from sub");
        //}

        private void InitializeCommands()
        {
            GoBackCommand.Subscribe(() => {
                GoBack();
            });
            GoForwardCommand.Subscribe(() => {
                GoForward();
            });
            ReloadCommand.Subscribe(() => {
                Reload();
            });
            StopCommand.Subscribe(() => {
                Stop();
            });
            BookmarkCommand.Subscribe((v) => {
                if (string.IsNullOrEmpty(v) || !v.StartsWith("http"))
                {
                    IsBookmarked.Value = false;
                    return;
                }
                if (IsBookmarked.Value)
                {
                    Bookmarks.Value.AddBookmark("", v);
                }
                else
                {
                    Bookmarks.Value.RemoveBookmark(v);
                    Url.Value = v;
                }
            });
            NavigateCommand.Subscribe((v) => {
                Navigate(v);
            });
            ClearURLCommand.Subscribe((v) => {
                Url.Value = "";
            });
            AnalyzeCommand.Subscribe((v) => {
                if (v == null)
                {
                    v = Url.Value;
                }
                var aw = new DxxAnalysisWindow(v);
                //aw.Owner = Owner;
                aw.Show();
            });
            CopyCommand.Subscribe((v) => {
                Clipboard.SetData(DataFormats.Text, v);
            });
            DownloadCommand.Subscribe(() => {
                if (IsTarget.Value || IsContainer.Value)
                {
                    DxxDriverManager.Instance.Download(Url.Value, null, "");
                }
            });
            ListingCommand.Subscribe(async() => {
                if (IsContainerList.Value)
                {
                    var uri     = new Uri(Url.Value);
                    var dxxUrl  = new DxxUrl(uri, Driver.Value, Driver.Value.GetNameFromUri(uri), "");
                    var targets = await Driver.Value.LinkExtractor.ExtractTargets(dxxUrl);
                    if (targets != null && targets.Count > 0)
                    {
                        TargetList.Value = new ObservableCollection <DxxTargetInfo>(targets);
                    }
                    else
                    {
                        TargetList.Value?.Clear();
                    }
                }
            });

            SetupDriverCommand.Subscribe(() => {
                DxxDriverManager.Instance.Setup(Driver.Value, Owner);
            });

            FrameSelectCommand.Subscribe((v) => {
                if (IsMain)
                {
                    RequestLoadInSubview.OnNext(v);
                }
                else
                {
                    Navigate(v);
                }
            });
        }
示例#26
0
        static int HandleArguments(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Try running `stuff help`");
                return(1);
            }
            var command  = args[0];
            var shifted  = args.Skip(1).ToArray();
            var _options = new List <string>();
            int i;

            for (i = 0; i < args.Length; i++)
            {
                if (args[i] == "--")
                {
                    break;
                }
                else if (args[i].StartsWith("--"))
                {
                    _options.Add(args[i]);
                }
                else
                {
                    break;
                }
            }
            var options = _options.ToArray();

            switch (command)
            {
            case "search":
            case "s":
                return(SearchCommand.HandleCommandLine(shifted, options));

            case "ksp":
                return(KSPCommand.HandleCommandLine(shifted, options));

            case "info":
                return(InfoCommand.HandleCommandLine(shifted, options));

            case "changelog":
                return(ChangelogCommand.HandleCommandLine(shifted, options));

            case "download":
                return(DownloadCommand.HandleCommandLine(shifted, options));

            case "help":
                Console.WriteLine(
                    "\nStuffManager Commands:\n\n" +
                    "\tsearch    -- Search KerbalStuff\n" +
                    "\tksp       -- Run KSP\n" +
                    "\tinfo      -- Provide info about a mod\n" +
                    "\tchangelog -- Display a mod's changelog\n" +
                    "\tdownload  -- Download a mod\n" +
                    "\thelp      -- Display this help\n"
                    );
                return(0);
            }
            Console.WriteLine("Command not found. Try `stuff help`.");
            return(1);
        }
示例#27
0
        /// <summary>
        /// Initiates the asynchronous execution of the Download operation.
        /// <seealso cref="M:Amazon.S3.Transfer.TransferUtility.Download"/>
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to download an Amazon S3 object.
        /// </param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the AsyncState property.</param>
        /// <exception cref="T:System.ArgumentNullException"></exception>
        /// <exception cref="T:System.Net.WebException"></exception>
        /// <exception cref="T:Amazon.S3.AmazonS3Exception"></exception>
        /// <returns>An IAsyncResult that can be used to poll, or wait for results, or both.
        /// This values is also needed when invoking EndDownload.</returns>
        public IAsyncResult BeginDownload(TransferUtilityDownloadRequest request, AsyncCallback callback, object state)
        {
            BaseCommand command = new DownloadCommand(this._s3Client, request);

            return(beginOperation(command, callback, state));
        }
示例#28
0
        /// <summary>
        ///     Downloads the content from Amazon S3 and writes it to the specified file.
        ///     If the key is not specified in the request parameter,
        ///     the file name will used as the key name.
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to download an Amazon S3 object.
        /// </param>
        public void Download(TransferUtilityDownloadRequest request)
        {
            BaseCommand command = new DownloadCommand(this._s3Client, request);

            command.Execute();
        }
 public DownloadFileViewModel()
 {
     DownloadCmd = new DownloadCommand(Download);
     CancelCmd   = new DownloadCommand(Cancel);
     OpenCmd     = new DownloadCommand(Open);
 }
        /// <summary>
        ///     Downloads the content from Amazon S3 and writes it to the specified file.
        ///     If the key is not specified in the request parameter,
        ///     the file name will used as the key name.
        /// </summary>
        /// <param name="request">
        ///     Contains all the parameters required to download an Amazon S3 object.
        /// </param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task DownloadAsync(TransferUtilityDownloadRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var command = new DownloadCommand(this._s3Client, request);

            return(command.ExecuteAsync(cancellationToken));
        }