Esempio n. 1
0
		private void btnModifyMapping_Click(object sender, System.EventArgs e)
		{
			string llName, fwName, ec, fwCode, llCode;
			ListViewItem lvItem;

			ListView.SelectedIndexCollection selIndexes = listViewMapping.SelectedIndices;
			if (selIndexes.Count < 1 || selIndexes.Count > 1)
				return;	// only handle single selection at this time

			int selIndex = selIndexes[0];	// only support 1
			lvItem = listViewMapping.Items[selIndex];
			LexImportWizardLanguage dlg = new LexImportWizardLanguage(m_cache);
			llName = lvItem.Text;
			fwName = lvItem.SubItems[1].Text;
			ec = lvItem.SubItems[2].Text;
			llCode = lvItem.SubItems[3].Text;
			dlg.LangToModify(llName, fwName, ec);

			if (dlg.ShowDialog(this) == DialogResult.OK)
			{
				// retrieve the new WS information from the dlg
				dlg.GetCurrentLangInfo(out llName, out fwName, out ec, out fwCode);

				// remove the one that was modified
				listViewMapping.Items.Remove(lvItem);

				// now add the modified one
				lvItem = new ListViewItem(new string[] {llName, fwName, ec, llCode, fwCode});
				lvItem.Tag = llName;
				listViewMapping.Items.Add(lvItem);
				int ii = listViewMapping.Items.IndexOf(lvItem);
				listViewMapping.Items[ii].Selected = true;
			}

			CheckImportEnabled();
		}
Esempio n. 2
0
		private void btnModifyMappingLanguage_Click(object sender, EventArgs e)
		{
			// get list of current Language descriptor values
			Hashtable langDescs = new Hashtable();
			string desc, name, map;
			desc = name = map = string.Empty;
//			ListViewItem selectedItem = null;
			bool selectedFound = false;
			foreach(ListViewItem lvItem in listViewMappingLanguages.Items)
			{
				langDescs.Add(lvItem.Text, null);
				if (lvItem.Selected && !selectedFound)
				{
//					selectedItem = lvItem;	// save for future modification
					desc = lvItem.Text;
					name = lvItem.SubItems[1].Text;
					map = lvItem.SubItems[2].Text;
					selectedFound = true;
					// only one selected at a time, but can't break as that
					// keeps the rest of the list from being added to the list of current
					// Language Descriptors which is used in the dlg for making sure that
					// there aren't duplicates.  Fix for LT-5745
				}
			}

			using (var dlg = new LexImportWizardLanguage(m_cache, langDescs,
					m_mediator.HelpTopicProvider, m_app, m_stylesheet))
			{
			dlg.LangToModify(desc, name, map);
			if (dlg.ShowDialog(this) == DialogResult.OK)
			{
				m_dirtySenseLastSave = true;
				string langDesc, ws, ec, wsId;
				// retrieve the new WS information from the dlg
				dlg.GetCurrentLangInfo(out langDesc, out ws, out ec, out wsId);

				int selectedIndex = listViewMappingLanguages.SelectedIndices[0];
				listViewMappingLanguages.Items[selectedIndex] = CreateLanguageMappingItem(langDesc, ws, ec, wsId);
				listViewMappingLanguages.Items[selectedIndex].Selected = true; // maintain the selection

				// remove the one that was modified
				//listViewMappingLanguages.Items.Remove(selectedItem);

				//// now add the modified one
				//AddLanguage(langDesc, ws, ec, icu);
				//
				//				ListViewItem lvItem = new ListViewItem(new string[] {langDesc, ws, ec});
				//				LanguageInfoUI langInfo = new LanguageInfoUI(langDesc, ws, ec);
				//				lvItem.Tag = langInfo;
				//				listViewMappingLanguages.Items.Add(lvItem);

				// Make sure we don't read in the file and clobber the memory changes if
				// the user cancels/saves right now.
				m_dirtyMapFile = false;

				if (m_MappingMgr != null)
				{
					// now update any existing markers that have this langdescriptor
					bool anyUpdated = false;
					Hashtable markers = m_MappingMgr.ContentMappingItems;
					foreach(DictionaryEntry markerEntry in markers)
					{
						MarkerPresenter.ContentMapping info = markerEntry.Value as MarkerPresenter.ContentMapping;
						if (info.LanguageDescriptorRaw == langDesc)
						{
							info.UpdateLangaugeValues(ws,wsId,langDesc);
							anyUpdated = true;
						}
					}
					if (anyUpdated)
						DisplayMarkerStep();
				}
			}
		}
		}