Example #1
0
    private static void DownloadModAndExit(string downloadUrl)
    {
        if (downloadUrl.StartsWith($"{Constants.ReloadedProtocol}:", StringComparison.InvariantCultureIgnoreCase))
        {
            downloadUrl = downloadUrl.Substring(Constants.ReloadedProtocol.Length + 1);
        }

        var package   = new WebDownloadablePackage(new Uri(downloadUrl), true);
        var viewModel = new DownloadPackageViewModel(package, IoC.Get <LoaderConfig>());

        _ = viewModel.StartDownloadAsync();

        Actions.ShowFetchPackageDialog(viewModel);
        Actions.DisplayMessagebox(Resources.PackageDownloaderDownloadCompleteTitle.Get(), Resources.PackageDownloaderDownloadCompleteDescription.Get(), new Actions.DisplayMessageBoxParams()
        {
            Type            = Actions.MessageBoxType.Ok,
            StartupLocation = Actions.WindowStartupLocation.CenterScreen,
            Timeout         = TimeSpan.FromSeconds(8)
        });
    }
Example #2
0
    /// <summary>
    /// Shows the dialog for downloading dependencies given a result of dependency resolution.
    /// </summary>
    /// <param name="resolveResult">Result of resolving for missing packages.</param>
    /// <param name="token">Used to cancel the operation.</param>
    public static void DownloadPackages(ModDependencyResolveResult resolveResult, CancellationToken token = default)
    {
        if (!HasInternetConnection)
        {
            return;
        }

        if (resolveResult.FoundDependencies.Count <= 0)
        {
            return;
        }

        var viewModel = new DownloadPackageViewModel(resolveResult.FoundDependencies, IoC.Get <LoaderConfig>());

        viewModel.Text = Resources.PackageDownloaderDownloadingDependencies.Get();

#pragma warning disable CS4014
        viewModel.StartDownloadAsync(); // Fire and forget.
#pragma warning restore CS4014
        Actions.SynchronizationContext.Send(state =>
        {
            Actions.ShowFetchPackageDialog.Invoke(viewModel);
        }, null);
    }