Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Do remaining initialization once we (might) have a selection.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        void Init()
        {
            if (m_sel == null)
            {
                return;
            }
            if (m_sel.SelType == VwSelType.kstPicture)
            {
                // TextSelInfo doesn't work; but we can get a good approximation of much of the
                // information like this.
                // Out variables for AllTextSelInfo.
                int          ihvoRoot;
                int          tagTextProp;
                int          cpropPrevious;
                int          ichAnchor;
                int          ichEnd;
                int          ws;
                bool         fAssocPrev;
                int          ihvoEnd;
                ITsTextProps ttpBogus;
                // Main array of information retrieved from sel that made combo.
                SelLevInfo[] rgvsli;

                // Analysis can now be zero (e.g., displaying alternate case form for non-existent WfiWordform)
                // and I don't believe it's a problem for the code below (JohnT).
                //				if (sandbox.Analysis == 0)
                //				{
                //					// We aren't fully initialized yet, so don't do anything.
                //					return null;
                //				}
                try
                {
                    int cvsli = m_sel.CLevels(false) - 1;
                    rgvsli = SelLevInfo.AllTextSelInfo(m_sel, cvsli,
                                                       out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
                                                       out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
                }
                catch (Exception)
                {
                    // If anything goes wrong just give up.
                    return;
                }
                m_ichA = ichAnchor;
                m_ichE = ichEnd;
                if (rgvsli.Length > 0)
                {
                    m_hvoObjA = m_hvoObjE = rgvsli[0].hvo;
                }
                m_tagA = m_tagE = tagTextProp;
            }
            else
            {
                m_sel.TextSelInfo(true, out m_tssE, out m_ichE, out m_fAssocPrev, out m_hvoObjE, out m_tagE, out m_wsE);
                m_sel.TextSelInfo(false, out m_tssA, out m_ichA, out m_fAssocPrev, out m_hvoObjA, out m_tagA, out m_wsA);
            }
            m_fIsRange = m_sel.IsRange;
            m_selType  = m_sel.SelType;
        }
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do remaining initialization once we (might) have a selection.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		void Init()
		{
			if (m_sel == null)
				return;
			if (m_sel.SelType == VwSelType.kstPicture)
			{
				// TextSelInfo doesn't work; but we can get a good approximation of much of the
				// information like this.
				// Out variables for AllTextSelInfo.
				int ihvoRoot;
				int tagTextProp;
				int cpropPrevious;
				int ichAnchor;
				int ichEnd;
				int ws;
				bool fAssocPrev;
				int ihvoEnd;
				ITsTextProps ttpBogus;
				// Main array of information retrived from sel that made combo.
				SelLevInfo[] rgvsli;

				// Analysis can now be zero (e.g., displaying alterate case form for non-existent WfiWordform)
				// and I don't believe it's a problem for the code below (JohnT).
				//				if (sandbox.Analysis == 0)
				//				{
				//					// We aren't fully initialized yet, so don't do anything.
				//					return null;
				//				}
				try
				{
					int cvsli = m_sel.CLevels(false) - 1;
					rgvsli = SelLevInfo.AllTextSelInfo(m_sel, cvsli,
						out ihvoRoot, out tagTextProp, out cpropPrevious, out ichAnchor, out ichEnd,
						out ws, out fAssocPrev, out ihvoEnd, out ttpBogus);
				}
				catch (Exception)
				{
					// If anything goes wrong just give up.
					return;
				}
				m_ichA = ichAnchor;
				m_ichE = ichEnd;
				if (rgvsli.Length > 0)
					m_hvoObjA = m_hvoObjE = rgvsli[0].hvo;
				m_tagA = m_tagE = tagTextProp;
			}
			else
			{
				m_sel.TextSelInfo(true, out m_tssE, out m_ichE, out m_fAssocPrev, out m_hvoObjE, out m_tagE, out m_wsE);
				m_sel.TextSelInfo(false, out m_tssA, out m_ichA, out m_fAssocPrev, out m_hvoObjA, out m_tagA, out m_wsA);
			}
			m_fIsRange = m_sel.IsRange;
			m_selType = m_sel.SelType;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// find a selection of the given selType in the RootBox starting at xMin coordinate and spanning xMaxCountOfPixels along the mid y-coordinate
		/// of the given selOrig, by the direction and increment of dxPixelIncrement.
		/// </summary>
		/// <param name="selOrig">the selection from which we calculate the y-coordinate along which to scan.</param>
		/// <param name="selType">the type of selection we're looking for.</param>
		/// <param name="xMin">the starting x coordinate from which to scan.</param>
		/// <param name="xMaxCountOfPixels">the number of x units to scan from xMin.</param>
		/// <param name="dx">number and direction of pixels to probe for selType. a positive value
		/// will scan right, and a negative value will scan left. must be nonzero.</param>
		/// <returns></returns>
		private IVwSelection FindNearestSelectionType(IVwSelection selOrig, VwSelType selType, uint xMin, uint xMaxCountOfPixels, int dxPixelIncrement)
		{
			IVwSelection sel = null;
			if (dxPixelIncrement == 0)
				throw new ArgumentException(String.Format("dxPixelIncrement({0}) must be nonzero", dxPixelIncrement));

			SIL.Utils.Rect rect;
			selOrig.GetParaLocation(out rect);
			int y = rect.top + (rect.bottom - rect.top) / 2;
			Point pt = new Point((int)xMin, y);
			uint xLim = 0;
			if (dxPixelIncrement > 0)
			{
				// set our bounds for searching forward.
				xLim = xMin + xMaxCountOfPixels;
				// truncate if necessary.
				if (xLim > RootBox.Width)
					xLim = (uint)RootBox.Width;
			}
			else
			{
				// set our bounds for searching backward.
				// truncate if necessary.
				if (xMin > xMaxCountOfPixels)
					xLim = xMin - xMaxCountOfPixels;
				else
					xLim = 0;
			}
			while (dxPixelIncrement < 0 && pt.X > xLim ||
				dxPixelIncrement > 0 && pt.X < xLim)
			{
				using (new HoldGraphics(this))
				{
					Rectangle rcSrcRoot;
					Rectangle rcDstRoot;
					GetCoordRects(out rcSrcRoot, out rcDstRoot);
					sel = m_rootb.MakeSelAt(pt.X, pt.Y, rcSrcRoot, rcDstRoot, false);
					if (sel != null && sel.SelType == selType)
						break;
					else
						sel = null;
				}
				pt.X += dxPixelIncrement;
			}
			return sel;
		}