Add() public méthode

Add the item to the list associated with this key.
public Add ( IList keyList, Slice obj ) : void
keyList IList
obj Slice
Résultat void
Exemple #1
0
		/// <summary>
		/// Create slices appropriate for current root object and layout, reusing any existing slices,
		/// and clearing out any that remain unused.
		/// </summary>
		private void CreateSlices()
		{
			m_currentSlice = null;
			ObjSeqHashMap previousSlices = new ObjSeqHashMap();
			List<Slice> dummySlices = new List<Slice>(Controls.Count);
			foreach (Slice slice in Controls)
			{
				if (slice.Key != null) // dummy slices may not have keys and shouldn't be reused.
					previousSlices.Add(slice.Key, slice);
				else
					dummySlices.Add(slice);
			}
			// Get rid of the dummies we aren't going to remove.
			foreach (Slice slice in dummySlices)
				RemoveSlice(slice);
			CreateSlicesFor(m_root, m_rootLayoutName, 0, 0, new ArrayList(20), previousSlices, null);
			// Clear out any slices NOT reused. Removing them from the collection both
			// removes them from the DataTree's controls collection and disposes them.
			foreach (IList sliceList in previousSlices.Values)
			{
				foreach (Slice gonner in sliceList)
				{
					RemoveSlice(gonner);
				}
			}
			ResetTabIndices(0);
		}
Exemple #2
0
		/// <summary>
		/// Create slices appropriate for current root object and layout, reusing any existing slices,
		/// and clearing out any that remain unused. If it is for a different object, reuse is more limited.
		/// </summary>
		private void CreateSlices(bool differentObject)
		{
			var watch = new Stopwatch();
			watch.Start();
			bool wasVisible = this.Visible;
			var previousSlices = new ObjSeqHashMap();
			int oldSliceCount = Slices.Count;
			ConstructingSlices = true;
			try
			{
				// Bizarrely, calling Hide has been known to cause OnEnter to be called in a slice; we need to suppress this,
				// hence guarding it by setting ConstructingSlices.
				Hide();
				if (m_currentSlice != null)
					m_currentSlice.SetCurrentState(false); // needs to know no longer current, may want to save something.
				m_currentSlice = null;
				if (differentObject)
					m_currentSliceNew = null;
				//if (differentObject)
				//	Slices.Clear();
				var dummySlices = new List<Slice>(Slices.Count);
				foreach (Slice slice in Slices)
				{
					slice.Visible = false;
					if (slice.Key != null) // dummy slices may not have keys and shouldn't be reused.
						previousSlices.Add(slice.Key, slice);
					else
						dummySlices.Add(slice);
				}
				bool gonnerHasToolTip = false; // Does any goner have one?
				// Get rid of the dummies we aren't going to remove.
				foreach (Slice slice in dummySlices)
				{
					gonnerHasToolTip |= slice.ToolTip != null;
					RemoveSlice(slice);
				}
				previousSlices.ClearUnwantedPart(differentObject);
				CreateSlicesFor(m_root, null, m_rootLayoutName, m_layoutChoiceField, 0, 0, new ArrayList(20), previousSlices, null);
				// Clear out any slices NOT reused. RemoveSlice both
				// removes them from the DataTree's controls collection and disposes them.
				foreach (Slice gonner in previousSlices.Values)
				{
					gonnerHasToolTip |= gonner.ToolTip != null;
					RemoveSlice(gonner);
				}
				if (gonnerHasToolTip)
				{
					// Since the dumb MS ToolTip class can't just remove one,
					// we have to remove them all and re-add the remaining ones
					// in order to have it really turn loose of the SliceTreeNode.
					m_tooltip.RemoveAll();
					foreach (Slice keeper in Slices)
						SetToolTip(keeper);
				}
				ResetTabIndices(0);
			}
			finally
			{
				ConstructingSlices = false;
			}
			if (wasVisible)
				Show();
			watch.Stop();
			// Uncomment this to investigate slice performance or issues with dissappearing slices
			//Debug.WriteLine("CreateSlices took " + watch.ElapsedMilliseconds + " ms. Originally had " + oldSliceCount + " controls; now " + Slices.Count);
			//previousSlices.Report();
		}