/// <inheritdoc />
    public DownloadPackageDialog(DownloadPackageViewModel viewModel)
    {
        InitializeComponent();
        ViewModel = viewModel;

        // Close on completion if task already started.
        if (ViewModel.DownloadTask != null)
        {
            ViewModel.DownloadTask.ContinueWith(task =>
            {
                ActionWrappers.ExecuteWithApplicationDispatcher(this.Close);
            });

            Button.IsEnabled = false;
        }

        Closed += OnClosed;
    }
Ejemplo n.º 2
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)
        });
    }
Ejemplo n.º 3
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);
    }
Ejemplo n.º 4
0
 private static bool ShowFetchPackageDialog(DownloadPackageViewModel viewmodel) => ShowDialogAndGetResult(new DownloadPackageDialog(viewmodel));