SIL.FieldWorks.Common.Controls.IntOnSubfieldChooserBEditControl.DoIt C# (CSharp) Method

DoIt() public method

public DoIt ( IEnumerable itemsToChange, SIL.FieldWorks.Common.Controls.ProgressState state ) : void
itemsToChange IEnumerable
state SIL.FieldWorks.Common.Controls.ProgressState
return void
		public override void DoIt(IEnumerable<int> itemsToChange, ProgressState state)
		{
			m_cache.DomainDataByFlid.BeginUndoTask(XMLViewsStrings.ksUndoBulkEdit, XMLViewsStrings.ksRedoBulkEdit);
			ISilDataAccess sda = m_cache.DomainDataByFlid;

			int val = (m_combo.SelectedItem as IntComboItem).Value;
			int i = 0;
			// Report progress 50 times or every 100 items, whichever is more (but no more than once per item!)
			int interval = Math.Min(100, Math.Max(itemsToChange.Count() / 50, 1));
			if (m_flidSub == LexEntryRefTags.kflidHideMinorEntry)
			{
				// we present this to the user as "Show" instead of "Hide"
				if (val == 0)
					val = 1;
				else
					val = 0;
				foreach (int hvoItem in itemsToChange)
				{
					i++;
					if (i % interval == 0)
					{
						state.PercentDone = i * 100 / itemsToChange.Count();
						state.Breath();
					}
					Debug.Assert(m_sda.get_IntProp(hvoItem, CmObjectTags.kflidClass) == LexEntryRefTags.kClassId);
					int valOld = m_sda.get_IntProp(hvoItem, m_flidSub);
					if (valOld != val)
						sda.SetInt(hvoItem, m_flidSub, val);
				}
			}
			else
			{
				foreach (int hvoItem in itemsToChange)
				{
					i++;
					if (i % interval == 0)
					{
						state.PercentDone = i * 100 / itemsToChange.Count();
						state.Breath();
					}
					int hvoField = sda.get_ObjectProp(hvoItem, m_flid);
					if (hvoField == 0)
						continue;
					int valOld = GetValueOfField(sda, hvoField);
					if (valOld == val)
						continue;
					SetValueOfField(sda, hvoField, val);
				}
			}
			m_cache.DomainDataByFlid.EndUndoTask();
		}