Ejemplo n.º 1
0
        private void ItemRemoved(
            IProjectItem item,
            string itemName, // itemName is neccessary because we misuse ItemRemove sometimes when the item is renamed
            EventFiring firing)
        {
            string itemDir = ProjectFolder.GetFolderPart(itemName);

            int remainingCount = int.MaxValue;

            if (_directories.ContainsKey(itemDir)) // it can happen that the directory is already removed, thus we test first if there still is the directory
            {
                var s = _directories[itemDir];
                s.Remove(item);
                remainingCount = s.Count;
            }

            if (firing == EventFiring.Enabled)
            {
                EhSelfChanged(Main.NamedObjectCollectionChangedEventArgs.FromItemRemoved(item, itemName));
            }

            if (null != itemDir && 0 == remainingCount)
            {
                DirectoryRemoved(itemDir);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Resumes changed events, either with taking the accumulated event data into account (see <see cref="Resume(ref ISuspendToken)"/>) or discarding the accumulated event data (see <see cref="ResumeSilently"/>,
 /// depending on the provided argument <paramref name="eventFiring"/>.
 /// </summary>
 /// <param name="suspendToken">The suspend token.</param>
 /// <param name="eventFiring">This argument determines if the events are resumed taking the event data into account, or the resume is silent, i.e. accumulated event data are discarded.</param>
 public void Resume(ref ISuspendToken suspendToken, EventFiring eventFiring)
 {
     if (null != suspendToken)
     {
         suspendToken.Resume(eventFiring);
         suspendToken = null;
     }
 }
Ejemplo n.º 3
0
        private void ItemAdded(IProjectItem item, string itemName, EventFiring firing)
        {
            string itemDir = ProjectFolder.GetFolderPart(itemName);

            DirectoryAdded(itemDir);
            _directories[itemDir].Add(item);

            if (firing == EventFiring.Enabled)
            {
                EhSelfChanged(Main.NamedObjectCollectionChangedEventArgs.FromItemAdded(item));
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
		/// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true.
		/// </summary>
		/// <param name="token"></param>
		/// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param>
		/// <returns>The event count accumulated during the suspend phase.</returns>
		public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent)
		{
			int result = 0;
			if (token != null)
			{
				if (firingOfResumeEvent == EventFiring.Suppressed)
				{
					token.ResumeSilently();
				}

				token.Dispose(); // the OnResume function is called from the SuppressToken
				token = null;
			}
			return result;
		}
Ejemplo n.º 5
0
        /// <summary>
        /// Decrease the suspend level by disposing the suppress token. The token will fire the Resume event
        /// if the suppress level falls to zero. You can suppress the resume event by setting argument 'suppressResumeEvent' to true.
        /// </summary>
        /// <param name="token"></param>
        /// <param name="firingOfResumeEvent">Designates whether or not to fire the resume event.</param>
        /// <returns>The event count accumulated during the suspend phase.</returns>
        public int Resume(ref ISuspendToken token, EventFiring firingOfResumeEvent)
        {
            int result = 0;

            if (token != null)
            {
                if (firingOfResumeEvent == EventFiring.Suppressed)
                {
                    token.ResumeSilently();
                }

                token.Dispose(); // the OnResume function is called from the SuppressToken
                token = null;
            }
            return(result);
        }
Ejemplo n.º 6
0
            public void Resume(EventFiring eventFiring)
            {
                switch (eventFiring)
                {
                case EventFiring.Enabled:
                    Resume();
                    break;

                case EventFiring.Suppressed:
                    ResumeSilently();
                    break;

                default:
                    throw new NotImplementedException(string.Format("Unknown option: {0}", eventFiring));
                }
            }
Ejemplo n.º 7
0
        private void ItemRenamed(IProjectItem item, string oldName, string newName, EventFiring firing)
        {
            string oldDir = ProjectFolder.GetFolderPart(oldName);
            string newDir = ProjectFolder.GetFolderPart(newName);

            if (oldDir != newDir)                 // only then it is neccessary to do something
            {
                ItemAdded(item, newName, firing); // to do it in this order (first add, then remove) helps to prevent unneccessary removal of folders and then re-creation
                ItemRemoved(item, oldName, firing);
            }
            else
            {
                if (firing == EventFiring.Enabled)
                {
                    EhSelfChanged(Main.NamedObjectCollectionChangedEventArgs.FromItemRenamed(item, oldName));
                }
            }
        }
Ejemplo n.º 8
0
			public void Resume(EventFiring eventFiring)
			{
				switch (eventFiring)
				{
					case EventFiring.Enabled:
						Resume();
						break;

					case EventFiring.Suppressed:
						ResumeSilently();
						break;

					default:
						throw new NotImplementedException(string.Format("Unknown option: {0}", eventFiring));
				}
			}
Ejemplo n.º 9
0
        public void TestMethod1()
        {
            EventFiring fire = new EventFiring();

            fire.FireTheEventInitiator();
        }