Esempio n. 1
0
        private void QueueDownload(ExtendedMod mod)
        {
            lock (MissingMods)
            {
                MissingMods.ToList().Where(x => x.Md5 == mod.Md5 && x.FileName == mod.FileName).ToList()
                .ForEach(x => x.IsIndeterminateProcess = true);
            }

            _downloadClient.QueueDownload(mod, string.Empty);
        }
Esempio n. 2
0
        private void InitializeAutoDownloader()
        {
            if (_apiBase.IsUserPremium() && _apiBase.IsUserLoggedIn())
            {
                var missingMods = MissingMods.ToList();

                foreach (var mod in missingMods)
                {
                    if (!_failedDownloads.Contains(mod))
                    {
                        QueueDownload(mod);
                    }
                }
            }
        }
Esempio n. 3
0
        private void DownloadUpdate(object sender, ExtendedMod e)
        {
            if (e.CurrentDownloadProgress == 100)
            {
                _installBase.ModpackMods.Where(x => x.Md5 == e.Md5).ToList()
                .ForEach(x => x.FilePath = e.FilePath);

                var matchingMods = MissingMods.Where(x => x.Md5 == e.Md5).ToList();

                foreach (var matchingMod in matchingMods)
                {
                    Application.Current.Dispatcher.BeginInvoke((Action) delegate
                    {
                        _missingModsLocked = true;

                        if (MissingMods.IndexOf(matchingMod) != -1)
                        {
                            MissingMods.RemoveAt(MissingMods.IndexOf(matchingMod));
                            RemainingMissingModCount--;
                        }

                        _missingModsLocked = false;
                    });
                }
            }

            else
            {
                var missingMods = MissingMods.ToList();
                foreach (var matchingMissingMod in missingMods.Where(x => x.Md5 == e.Md5).ToList())
                {
                    Application.Current.Dispatcher.BeginInvoke((Action) delegate
                    {
                        _missingModsLocked = true;

                        var index = MissingMods.IndexOf(matchingMissingMod);
                        if (index == -1)
                        {
                            return;
                        }

                        MissingMods[MissingMods.IndexOf(matchingMissingMod)].CurrentDownloadProgress = e.CurrentDownloadProgress;
                        _missingModsLocked = false;
                    });
                }
            }
        }
Esempio n. 4
0
        private async void QueueDownload(object caller, PipedData pipedData)
        {
            lock (MissingMods)
            {
                if (!MissingMods.ToList().Any(x => x.FileId == pipedData.FileId && x.ModId == pipedData.ModId) || !_apiBase.IsUserLoggedIn())
                {
                    return;
                }

                var downloadUrl       = _apiEndpoints.GenerateModDownloadLinkAsync(pipedData).Result;
                var matchingModObject = MissingMods.ToList().First(x => x.FileId == pipedData.FileId && x.ModId == pipedData.ModId);

                MissingMods.ToList().First(x => x == matchingModObject).IsIndeterminateProcess = true;

                if (matchingModObject == null)
                {
                    return;
                }

                _downloadClient.QueueDownload(matchingModObject, downloadUrl);
            }
        }
Esempio n. 5
0
        private async void FindAndValidateMod(ExtendedMod mod)
        {
            var possibleArchiveMatch = await _fileSystemBrowser.OpenFileBrowserAsync($"{mod.ModName}|{mod.FileName}|All Matching Extensions|*{Path.GetExtension(mod.FileName)}|All Files|*.*",
                                                                                     $"Please select the matching mod archive: {mod.FileName}");

            if (string.IsNullOrEmpty(possibleArchiveMatch))
            {
                return;
            }

            var filteredMissingMods = _validate.ValidateTargetModArchive(possibleArchiveMatch, MissingMods.ToList());

            RemainingMissingModCount = filteredMissingMods.Count;

            await Application.Current.Dispatcher.BeginInvoke((Action) delegate
            {
                _missingModsLocked = true;
                MissingMods        = new RangeObservableCollection <ExtendedMod>();
                MissingMods.AddRange(filteredMissingMods);
                _missingModsLocked = false;
            });
        }