Example #1
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Sets the selection by calling <c>IVwRootBox.MakeRangeSelection</c>.
		/// </summary>
		/// <param name="rootSite">The root site</param>
		/// <param name="fInstall">Makes the selection the current selection</param>
		/// <param name="fMakeVisible">Determines whether or not to make the selection visible.
		/// </param>
		/// <param name="scrollOption">Where to scroll the selection</param>
		/// <returns>The selection, null if it could not return a valid one.</returns>
		/// -----------------------------------------------------------------------------------
		public virtual IVwSelection SetSelection(IVwRootSite rootSite, bool fInstall,
			bool fMakeVisible, VwScrollSelOpts scrollOption)
		{
			if (rootSite == null || rootSite.RootBox == null)
				return null;
			m_rootSite = rootSite;
			try
			{
				IVwSelection sel = MakeRangeSelection(rootSite.RootBox, fInstall);
				if (sel == null)
					return null;

				if (fInstall && !sel.IsValid)
				{
					// We rarely expect to have an invalid selection after we install a new selection,
					// but it's possible for selection side-effects to have invalidated it
					// (e.g. highlighting a row in a browse view cf. LT-5033.)
					sel = MakeRangeSelection(rootSite, fInstall);
				}
				if (sel.IsValid)
					m_vwSel = sel;
				else
					m_vwSel = null;

				if (fMakeVisible && m_vwSel != null)
					rootSite.ScrollSelectionIntoView(m_vwSel, scrollOption);

				return m_vwSel;
			}
			catch (COMException)
			{
				return null;
			}
			catch(Exception)
			{
				Debug.Assert(false, "Exceptional condition encountered while making selection.");
// ReSharper disable HeuristicUnreachableCode
				return null; //Um, asserts don't happen in release you overzealous Heuristic.
// ReSharper restore HeuristicUnreachableCode
			}
		}
Example #2
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Sets the selection by calling <c>IVwRootBox.MakeRangeSelection</c>.
		/// </summary>
		/// <param name="rootSite">The root site</param>
		/// <param name="fInstall">Makes the selection the current selection</param>
		/// <param name="fMakeVisible">Determines whether or not to make the selection visible.
		/// </param>
		/// <param name="scrollOption">Where to scroll the selection</param>
		/// <returns>The selection, null if it could not return a valid one.</returns>
		/// -----------------------------------------------------------------------------------
		public virtual IVwSelection SetSelection(IVwRootSite rootSite, bool fInstall,
			bool fMakeVisible, VwScrollSelOpts scrollOption)
		{
			if (rootSite == null || rootSite.RootBox == null)
				return null;
			try
			{
				IVwSelection sel = MakeRangeSelection(rootSite.RootBox, fInstall);
				if (fInstall && !sel.IsValid)
				{
					// We rarely expect to have an invalid selection after we install a new selection,
					// but it's possible for selection side-effects to have invalidated it
					// (e.g. highlighting a row in a browse view cf. LT-5033.)
					sel = MakeRangeSelection(rootSite, fInstall);
				}
				if (sel.IsValid)
					m_vwSel = sel;
				else
					m_vwSel = null;

				if (fMakeVisible && m_vwSel != null)
					rootSite.ScrollSelectionIntoView(m_vwSel, scrollOption);

				return m_vwSel;
			}
			catch
			{
				return null;
			}
		}