Ejemplo n.º 1
0
        /// <summary>
        /// Handles the <see cref="INotifyCollectionChanged.CollectionChanged"/> event of the list of
        /// managed mods.
        /// </summary>
        /// <remarks>
        /// This checks for the newest information for mods that are added to the mod manager.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="NotifyCollectionChangedEventArgs"/> describing the event arguments.</param>
        private void RegisteredMods_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (!EnvironmentInfo.Settings.CheckForNewModVersions)
            {
                return;
            }
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
            case NotifyCollectionChangedAction.Replace:
                foreach (IMod modMod in e.NewItems)
                {
                    ((Func <IMod, IModInfo>)CheckForUpdate).BeginInvoke(modMod, GotNewVersionNumber, modMod);
                }
                break;

            case NotifyCollectionChangedAction.Remove:
            case NotifyCollectionChangedAction.Reset:
                foreach (IMod modMod in e.OldItems)
                {
                    m_oclNewInfo.RemoveAll(x => x.Mod == modMod);
                }
                break;
            }
        }