private void CommonAddWS(bool isAnalysis, MenuItem selectedMI)
		{
			string icuLocal = "", mapName = "", wsName = "";
			bool addWs = true;

			if (selectedMI.Text == LexTextControls.ks_DefineNew_)
			{
				using (WritingSystemWizard wiz = new WritingSystemWizard())
				{
					wiz.Init(m_cache.LanguageWritingSystemFactoryAccessor, FwApp.App);
					DialogResult dr = (DialogResult)wiz.ShowDialog();
					if (dr == DialogResult.OK)
					{
						// The engine from the wizard isn't the real one, so it doesn't have an id.
						IWritingSystem wsEngine = wiz.WritingSystem();
						icuLocal = wsEngine.IcuLocale;
						mapName = wsEngine.LegacyMapping;
						wsName = wsEngine.LanguageName;
					}
					else
						addWs = false;
				}
			}
			else
			{
				NamedWritingSystem namedWs = selectedMI.Tag as NamedWritingSystem;
				ILgWritingSystem wsEngine = namedWs.GetLgWritingSystem(m_cache);
				icuLocal = wsEngine.ICULocale;
				mapName = wsEngine.LegacyMapping;
				wsName = wsEngine.Name.BestAnalysisAlternative.Text;
			}

			if (addWs)
			{
				int ws = m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(icuLocal);
				// string wsName = ws.get_UiName(wsUser);
				WsInfo wsi = new WsInfo(ws, wsName, icuLocal, mapName);
				m_wsInfo.Add(wsi.KEY, wsi);

				// now select it for the ws combo box
				int index = cbWS.Items.Add(wsi);
				cbWS.SelectedIndex = index;

				// now if there's an encoding converter for the ws, select it
				if (mapName != null && mapName.Length > 0)
				{
					index = cbEC.Items.Add(mapName);
					cbEC.SelectedIndex = index;
				}
				else
				{
					index = cbEC.FindStringExact(m_blankEC);
					cbEC.SelectedIndex = index;
				}

				// now add the ws to the FDO list for it
				if (isAnalysis)
				{
					m_cache.LangProject.AnalysisWssRC.Add(ws);
					m_cache.LangProject.CurAnalysisWssRS.Append(ws);
				}
				else
				{
					m_cache.LangProject.VernWssRC.Add(ws);
					m_cache.LangProject.CurVernWssRS.Append(ws);
				}
			}
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="comboWS">Combo box containing the list of writing systems</param>
		/// ------------------------------------------------------------------------------------
		private void RunWizard(ComboBox comboWS)
		{
			using (new WaitCursor(this))
			{
				using (WritingSystemWizard wiz = new WritingSystemWizard())
				{
					ILgWritingSystemFactory wsf = LgWritingSystemFactoryClass.Create();
					try
					{
						wiz.Init(wsf, m_helpTopicProvider);
						if (comboWS == m_cbVernWrtSys)
							wiz.PerformInitialSearch(m_txtName.Text.Trim());

						if (wiz.ShowDialog() == DialogResult.OK)
						{
							UpdateLanguageCombos();
							string target = wiz.WritingSystem().IcuLocale;
							for (int i = 0; i < comboWS.Items.Count; ++i)
							{
								if (((NamedWritingSystem)comboWS.Items[i]).IcuLocale == target)
								{
									comboWS.SelectedIndex = i;
									break;
								}
							}
						}
					}
					finally
					{
						wsf.Shutdown();
					}
				}
			}
		}
Esempio n. 3
0
		private void InvokeWritingSystemWizard(ContextMenuStrip cmnuAddWs, out ILgWritingSystem lws,
			FdoCache cache, IHelpTopicProvider helpTopicProvider)
		{
			lws = null;
			using (new WaitCursor(this))
			{
				using (WritingSystemWizard wiz = new WritingSystemWizard())
				{
					wiz.Init(cache.LanguageWritingSystemFactoryAccessor, helpTopicProvider);
					if (wiz.ShowDialog() == DialogResult.OK)
					{
						// The engine from the wizard isn't the real one, so it doesn't have an id.
						IWritingSystem wsEngine = wiz.WritingSystem();
						string strws = wsEngine.IcuLocale;
						ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor;
						wsEngine = wsf.get_Engine(strws);
						cache.ResetLanguageEncodings();
						lws = LgWritingSystem.CreateFromDBObject(cache, wsEngine.WritingSystem);
					}
				}
			}
		}