当前位置: 首页>>代码示例>>C#>>正文


C# IVwSelection.SetSelectionProps方法代码示例

本文整理汇总了C#中IVwSelection.SetSelectionProps方法的典型用法代码示例。如果您正苦于以下问题:C# IVwSelection.SetSelectionProps方法的具体用法?C# IVwSelection.SetSelectionProps怎么用?C# IVwSelection.SetSelectionProps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IVwSelection的用法示例。


在下文中一共展示了IVwSelection.SetSelectionProps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleKeyboardChange

		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// When the user has selected a keyboard from the system tray, adjust the language of
		/// the selection to something that matches, if possible.
		/// </summary>
		/// <param name="vwsel">Selection</param>
		/// <param name="wsMatch">Writing system determined from keyboard change</param>
		/// -----------------------------------------------------------------------------------
		public virtual void HandleKeyboardChange(IVwSelection vwsel, int wsMatch)
		{
			CheckDisposed();
			// Get the writing system factory associated with the root box.
			if (m_rootb == null || !GotCacheOrWs)
				return; // For paranoia.

			if (vwsel == null)
			{
				// Delay handling it until we get a selection.
				m_wsPending = wsMatch;
				return;
			}
			bool fRange = vwsel.IsRange;
			if (fRange)
			{
				// Delay handling it until we get an insertion point.
				m_wsPending = wsMatch;
				return;
			}

			ITsTextProps[] vttp;
			IVwPropertyStore[] vvps;
			int cttp;

			SelectionHelper.GetSelectionProps(vwsel, out vttp, out vvps, out cttp);

			if (cttp == 0)
				return;
			Debug.Assert(cttp == 1);

			// If nothing changed, avoid the infinite loop that happens when we change the selection
			// and update the system keyboard, which in turn tells the program to change its writing system.
			// (This is a problem on Windows 98.)
			int wsTmp;
			int var;
			wsTmp = vttp[0].GetIntPropValues((int)FwTextPropType.ktptWs, out var);
			if (wsTmp == wsMatch)
				return;

			ITsPropsBldr tpb = vttp[0].GetBldr();
			tpb.SetIntPropValues((int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, wsMatch);
			vttp[0] = tpb.GetTextProps();
			vwsel.SetSelectionProps(cttp, vttp);
			SelectionChanged(m_rootb, m_rootb.Selection); // might NOT be vwsel any more
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:55,代码来源:SimpleRootSite.cs

示例2: HandleKeyboardChange


//.........这里部分代码省略.........
				if (nLangIdWs != 0 && nLangIdWs == nLangId)
				{
					wsMatch = vws[iws];
					break;
				}
				if (iws == 0 && nLangIdWs == 0 && nLangId == defaultLangId)
				{
					// The writing system of the current selection doesn't have any keyboard specified,
					// and we've set the keyboard to the default. This is acceptable; leave as is.
					wsMatch = vws[iws];
					break;
				}
				if (nLangIdWs == 0 && nLangId == defaultLangId && wsDefault == -1)
				{
					// Use this old writing system as the default.
					wsDefault = vws[iws];
				}
				if (wsCurrentLang == -1)
				{
					int nLangIdCurrent = ws.CurrentInputLanguage;
					if (nLangId == nLangIdCurrent)
						wsCurrentLang = vws[iws];
				}
			}

			if (wsMatch == -1)
			{
				wsMatch = wsDefault;
			}
			m_wsPending = -1;
			// Next, see if it is the current langid of any ws. This will leave it -1 if we didn't find such a match.
			if (wsMatch == -1)
				wsMatch = wsCurrentLang;

			if (wsMatch == -1)
			{
				// Nothing matched.
				if (defaultLangId == nLangId) // We're trying to set to the default keyboard
				{
					// The default keyboard sets set for odd reasons. Just ignore it.
					// Review: what if the HKL's are different versions of the same language,
					// eg UK and US English?
				}
				else
				{
					// We will make this the current input language for the current writing system for the current session.
					IWritingSystem wsCurrent = wsf.get_EngineOrNull(wsSel);
					if (wsCurrent != null)
						wsCurrent.CurrentInputLanguage = nLangId;
				}
				return;
			}

			// We are going to make wsMatch the current writing system.
			// Make sure it is set to use the langid that the user just selected.
			// (This cleans up any earlier overrides).
			IWritingSystem wsMatchEng = wsf.get_EngineOrNull(wsMatch);
			if (wsMatchEng != null)
				wsMatchEng.CurrentInputLanguage = nLangId;

			if (vwsel == null)
			{
				// Delay handling it until we get a selection.
				m_wsPending = wsMatch;
				return;
			}
			bool fRange = vwsel.IsRange;
			if (fRange)
			{
				// Delay handling it until we get an insertion point.
				m_wsPending = wsMatch;
				return;
			}

			ITsTextProps[] vttp;
			IVwPropertyStore[] vvps;
			int cttp;

			SelectionHelper.GetSelectionProps(vwsel, out vttp, out vvps, out cttp);

			if (cttp == 0)
				return;
			Debug.Assert(cttp == 1);

			// If nothing changed, avoid the infinite loop that happens when we change the selection
			// and update the system keyboard, which in turn tells the program to change its writing system.
			// (This is a problem on Windows 98.)
			int wsTmp;
			int var;
			wsTmp = vttp[0].GetIntPropValues((int)FwTextPropType.ktptWs, out var);
			if (wsTmp == wsMatch)
				return;

			ITsPropsBldr tpb = vttp[0].GetBldr();
			tpb.SetIntPropValues((int)FwTextPropType.ktptWs,
				(int)FwTextPropVar.ktpvDefault, wsMatch);
			vttp[0] = tpb.GetTextProps();
			vwsel.SetSelectionProps(cttp, vttp);
			SelectionChanged(m_rootb, vwsel);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:101,代码来源:SimpleRootSite.cs


注:本文中的IVwSelection.SetSelectionProps方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。