Esempio n. 1
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;
                    });
                }
            }
        }