protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget)
		{
			int tagNamePOS = UseAbbr ?
				CmPossibilityTags.kflidAbbreviation :
				CmPossibilityTags.kflidName;


			List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>();
			GatherPartsOfSpeech(Cache, List.Hvo, CmPossibilityListTags.kflidPossibilities,
				CmPossibilityTags.kflidSubPossibilities,
				PartOfSpeechTags.kflidInflectionClasses,
				tagNamePOS, WritingSystem,
				relevantPartsOfSpeech);
			relevantPartsOfSpeech.Sort();
			int tagNameClass = UseAbbr ?
				MoInflClassTags.kflidAbbreviation :
				MoInflClassTags.kflidName;
			TreeNode match = null;
			foreach(HvoTreeNode item in relevantPartsOfSpeech)
			{
				popupTree.Nodes.Add(item);
				TreeNode match1 = AddNodes(item.Nodes, item.Hvo,
					PartOfSpeechTags.kflidInflectionClasses,
					MoInflClassTags.kflidSubclasses,
					hvoTarget, tagNameClass);
				if (match1 != null)
					match = match1;
			}
			return match;
		}
		protected override TreeNode MakeMenuItems(PopupTree popupTree, int hvoTarget)
		{
			int tagNamePOS = UseAbbr ?
				(int)CmPossibility.CmPossibilityTags.kflidAbbreviation :
				(int)CmPossibility.CmPossibilityTags.kflidName;

			List<HvoTreeNode> relevantPartsOfSpeech = new List<HvoTreeNode>();
			InflectionClassPopupTreeManager.GatherPartsOfSpeech(Cache, List.Hvo,
				(int)CmPossibilityList.CmPossibilityListTags.kflidPossibilities,
				(int)CmPossibility.CmPossibilityTags.kflidSubPossibilities,
				(int)PartOfSpeech.PartOfSpeechTags.kflidInflectableFeats,
				tagNamePOS, WritingSystem,
				relevantPartsOfSpeech);
			relevantPartsOfSpeech.Sort();
			TreeNode match = null;
			foreach(HvoTreeNode item in relevantPartsOfSpeech)
			{
				popupTree.Nodes.Add(item);
				IPartOfSpeech pos = (IPartOfSpeech)PartOfSpeech.CreateFromDBObject(Cache, item.Hvo, false);
				foreach(IFsFeatStruc fs in pos.ReferenceFormsOC)
				{
					// Note: beware of using fs.ShortName. That can be
					// absolutely EMPTY (if the user has turned off the 'Show Abbreviation as its label'
					// field for both the feature category and value).
					// ChooserName shows the short name if it is non-empty, otherwise the long name.
					HvoTreeNode node = new HvoTreeNode(fs.ChooserNameTS, fs.Hvo);
					item.Nodes.Add(node);
					if (fs.Hvo == hvoTarget)
						match = node;
				}
				item.Nodes.Add(new HvoTreeNode(Cache.MakeUserTss(LexTextControls.ksChooseInflFeats), kMore));
			}
			return match;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Load tool bar settings from the registry, if available.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private bool LoadBarSettings()
		{
			if (m_appsRegKeyPath == null)
				return false;

			List<InitialBarProps> ibpList = new List<InitialBarProps>();

			foreach (ToolStrip bar in m_bars.Values)
			{
				int dx = (int)m_appsRegKeyPath.GetValue(bar.Name + "X", -1);
				if (dx == -1)
					return false;

				InitialBarProps ibp = new InitialBarProps();
				ibp.Name = bar.Name;
				ibp.Side = m_appsRegKeyPath.GetValue(bar.Name + "Side", "Top") as string;
				ibp.Location = new Point(dx,
					(int)m_appsRegKeyPath.GetValue(bar.Name + "Y", bar.Top));

				string strVal = m_appsRegKeyPath.GetValue(bar.Name + "Visible") as string;
				bool visible;
				ibp.Visible = (bool.TryParse(strVal, out visible) ? visible : false);
				m_displayedBars[bar.Name] = ibp.Visible;

				ibpList.Add(ibp);
			}

			// Sort the bar information read from the registry by visibility and location.
			ibpList.Sort(InitialBarPropsComparer);

			foreach (InitialBarProps sbp in ibpList)
			{
				ToolStrip bar = m_bars[sbp.Name];
				bar.Visible = sbp.Visible;
				bar.Location = sbp.Location;

				if (m_tsContainer == null)
					m_tsPanel.Controls.Add(bar);
				else
				{
					switch (sbp.Side)
					{
						case "Bottom": m_tsContainer.BottomToolStripPanel.Controls.Add(bar); break;
						case "Right": m_tsContainer.RightToolStripPanel.Controls.Add(bar); break;
						case "Left": m_tsContainer.LeftToolStripPanel.Controls.Add(bar); break;
						default: m_tsContainer.TopToolStripPanel.Controls.Add(bar); break;
					}
				}
			}

			return true;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Positions the toolbars to the positions specified in the xml deffinition file.
		/// This method only gets called when tool bar locations and visibilities cannot be
		/// found in the registry.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void LoadDefaultToolbarLayout()
		{
			List<InitialBarProps> ibpList = new List<InitialBarProps>();

			foreach (ToolStrip bar in m_bars.Values)
			{
				InitialBarProps ibp = new InitialBarProps();
				ibp.Name = bar.Name;
				ibp.Location = bar.Location = m_barLocations[bar];
				ibp.Side = "Top";

				bool isBarDisplayed;
				ibp.Visible = (m_displayedBars.TryGetValue(bar.Name, out isBarDisplayed) ?
					isBarDisplayed : false);

				ibpList.Add(ibp);
			}

			// Sort bars by visibility and location.
			ibpList.Sort(InitialBarPropsComparer);

			// Now add the bars to the top panel, arranging them accordingly.
			int prevRow = 0;
			int dx = 0;
			foreach (InitialBarProps ibp in ibpList)
			{
				ToolStrip bar = m_bars[ibp.Name];
				bar.Visible = ibp.Visible;
				int barRow = bar.Top;

				if (barRow != prevRow)
				{
					prevRow = barRow;
					dx = 0;
				}

				bar.Top = (barRow * bar.Height);
				bar.Left = dx;
				if (m_tsContainer != null)
					m_tsContainer.TopToolStripPanel.Controls.Add(bar);
				else
					m_tsPanel.Controls.Add(bar);

				dx += (bar.Left + bar.Width);
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Fill the Style menu the "No style" item, plus a an alphabetized list of all
		/// character styles in stylesheet of the last Fw Edit Box to have focus. The style of
		/// the current selection (if there is exactly one) will be checked. If the selection
		/// contains no style, then "No style" will be checked. If the selection covers multiple
		/// styles, nothing will be checked.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void PopulateStyleMenu()
		{
			// TODO: Convert this method to use StyleListHelper.

			// First clear any items added previously
			mnuStyle.MenuItems.Clear();
			EventHandler clickEvent = new EventHandler(StyleMenu_Click);

			string sSelectedStyle = LastTextBoxInFocus.SelectedStyle;
			MenuItem mnuItem = new MenuItem(FwCoreDlgs.kstidNoStyle, clickEvent);
			mnuItem.Checked = (sSelectedStyle == string.Empty);
			mnuStyle.MenuItems.Add(mnuItem);

			mnuItem = new MenuItem(FdoResources.DefaultParaCharsStyleName, clickEvent);
			mnuItem.Checked = (sSelectedStyle == FwStyleSheet.kstrDefaultCharStyle);
			mnuStyle.MenuItems.Add(mnuItem);

			int count = 0;
			if (LastTextBoxInFocus.StyleSheet != null)
				count = LastTextBoxInFocus.StyleSheet.CStyles;
			string styleName;
			List<string> styleNames = new List<string>(count / 2);
			for (int i = 0; i < count; i++)
			{
				styleName = LastTextBoxInFocus.StyleSheet.get_NthStyleName(i);
				if (LastTextBoxInFocus.StyleSheet.GetType(styleName) == 1) // character style
				{
					ContextValues context =
						(ContextValues)LastTextBoxInFocus.StyleSheet.GetContext(styleName);

					// Exclude Internal and InternalMappable style contexts
					if (context != ContextValues.Internal &&
						context != ContextValues.InternalMappable)
					{
						styleNames.Add(styleName);
					}
				}
			}
			styleNames.Sort();

			foreach (string s in styleNames)
			{
				mnuItem = new MenuItem(s, clickEvent);
				mnuItem.Checked = (sSelectedStyle == s);
				mnuStyle.MenuItems.Add(mnuItem);
			}
		}
		protected override void OnNextButton()
		{
			if (CurrentStepNumber == 0)
			{
				// Populate m_mappingsList based on the selected files.
				var sfmcounts = new Dictionary<string, int>();
				var sfmOrder = new Dictionary<int, string>(); // key is 100000*fileNum + orderInFile, value is a marker
				int fileNum = 0;
				foreach (var pathName in InputFiles)
				{
					var reader = new SfmFileReaderEx(pathName);
					followedBy = reader.GetFollowedByInfo();
					foreach (string marker in reader.SfmInfo)
					{
						int oldVal;
						if (!sfmcounts.TryGetValue(marker, out oldVal))
						{
							// first time we've seen it: this file determines order;
							sfmOrder[fileNum * 100000 + reader.GetSFMOrder(marker)] = marker;
						}
						sfmcounts[marker] = oldVal + reader.GetSFMCount(marker);
					}
					fileNum++;
				}
				// Read the map file (unless we've been to this pane before...then use the saved settings), integrate with the sfmcount info.
				var savedMappings = new Dictionary<string, InterlinearMapping>();
				m_oldMappings = m_firstTimeInMappingsPane ? LoadSettings() : new List<InterlinearMapping>((m_mappings));
				m_firstTimeInMappingsPane = false;
				foreach (var mapping in m_oldMappings)
					savedMappings[mapping.Marker] = mapping;
				m_mappings.Clear();
				var keys = new List<int>(sfmOrder.Keys);
				keys.Sort();
				foreach (var key in keys)
				{
					var marker = sfmOrder[key];
					InterlinearMapping mapping;
					if (savedMappings.TryGetValue(marker, out mapping))
					{
						mapping = new InterlinearMapping(mapping);
						if (string.IsNullOrEmpty(mapping.WritingSystem))
						{
							var ws = GetDefaultWs(mapping);
							if (ws != 0)
								mapping.WritingSystem = m_cache.WritingSystemFactory.GetStrFromWs(ws);
						}
						else if (mapping.WritingSystem == "{vern}")
							mapping.WritingSystem = m_cache.WritingSystemFactory.GetStrFromWs(m_cache.DefaultVernWs);
					}
					else
						mapping = new InterlinearMapping() {Marker = marker};
					mapping.Count = sfmcounts[marker].ToString();
					m_mappings.Add(mapping);
				}
				m_mappingsList.SuspendLayout();
				m_mappingsList.Items.Clear();
				foreach (var mapping in m_mappings)
				{
					var item = new ListViewItem("\\" + mapping.Marker);
					item.SubItems.Add(mapping.Count);
					item.SubItems.Add(GetDestinationName(mapping.Destination));
					item.SubItems.Add(mapping.WritingSystem != null ? GetWritingSystemName(mapping.WritingSystem) : "");
					item.SubItems.Add(mapping.Converter ?? "");
					m_mappingsList.Items.Add(item);
				}
				if (m_mappingsList.Items.Count > 0)
					m_mappingsList.SelectedIndices.Add(0);
				m_mappingsList.ResumeLayout();
			}
			else if(CurrentStepNumber == 1)
			{
				ICollection<IWritingSystem> currentVernacWSs = m_cache.LanguageProject.VernacularWritingSystems;
				ICollection<IWritingSystem> currentAnalysWSs = m_cache.LanguageProject.AnalysisWritingSystems;
				var vernToAdd = new ArrayList();
				var analysToAdd = new ArrayList();
				int textCount = CalculateTextCount(m_mappings, followedBy);
				foreach(var mapping in m_mappings)
				{
					if (mapping.Destination == InterlinDestination.Ignored)
						continue; // may well have no WS, in any case, we don't care whether it's in our list.
					bool creationCancelled = false;
					var ws = (IWritingSystem)m_cache.WritingSystemFactory.get_Engine(mapping.WritingSystem);
					if (mapping.Destination == InterlinDestination.Baseline || mapping.Destination == InterlinDestination.Wordform)
					{
						if(!currentVernacWSs.Contains(ws) && !vernToAdd.Contains(ws))
						{
							//Show creation dialog for Vernacular
							var result = MessageBox.Show(this,
														 String.Format(ITextStrings.ksImportSFMInterlinNewVernac, ws),
														 String.Format(ITextStrings.ksImportSFMInterlinNewWSTitle, ws), MessageBoxButtons.YesNo);
							if(result == DialogResult.Yes)
							{
								vernToAdd.Add(ws);
							}
							else //if they bail out we won't add any writing systems, they might change them all
							{
								return;
							}
						}
					}
					else
					{
						if(!currentAnalysWSs.Contains(ws) && !analysToAdd.Contains(ws))
						{
							var result = MessageBox.Show(this,
														 String.Format(ITextStrings.ksImportSFMInterlinNewAnalysis, ws),
														 String.Format(ITextStrings.ksImportSFMInterlinNewWSTitle, ws), MessageBoxButtons.YesNo);
							if (result == DialogResult.Yes)
							{
								analysToAdd.Add(ws);
							}
							else  //if they bail out we won't add any writing systems, they might change them all
							{
								return;
							}
						}
					}
				}
				NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(m_cache.ActionHandlerAccessor,
					() => //Add all the collected new languages into the project in their proper section.
					{
						foreach (IWritingSystem analysLang in analysToAdd)
						{
							m_cache.LanguageProject.AddToCurrentAnalysisWritingSystems(analysLang);
						}
						foreach (IWritingSystem vernLang in vernToAdd)
						{
							m_cache.LanguageProject.AddToCurrentVernacularWritingSystems(vernLang);
						}
					});
				if(textCount > 1)
				{
					numberOfTextsLabel.Text = String.Format(ITextStrings.ksImportSFMInterlinTextCount, textCount);
				}
				else
				{
					numberOfTextsLabel.Text = String.Empty;
				}
			}
			base.OnNextButton();
		}
Exemple #7
0
		/// <summary>
		/// Merge the underling objects. This method handles the confirm dialog, then delegates
		/// the actual merge to ReallyMergeUnderlyingObject. If the flag is true, we merge
		/// strings and owned atomic objects; otherwise, we don't change any that aren't null
		/// to begin with.
		/// </summary>
		/// <param name="fLoseNoTextData"></param>
		public void MergeUnderlyingObject(bool fLoseNoTextData)
		{
			CheckDisposed();

			var mainWindow = (Form) m_mediator.PropertyTable.GetValue("window");
			using (new WaitCursor(mainWindow))
			{
				using (var dlg = new MergeObjectDlg(m_mediator.HelpTopicProvider))
				{
					var wp = new WindowParams();
					var mergeCandidates = new List<DummyCmObject>();
					string guiControl, helpTopic;
					DummyCmObject dObj = GetMergeinfo(wp, mergeCandidates, out guiControl, out helpTopic);
					mergeCandidates.Sort();
					dlg.SetDlgInfo(m_cache, m_mediator, wp, dObj, mergeCandidates, guiControl, helpTopic);
					if (DialogResult.OK == dlg.ShowDialog(mainWindow))
						ReallyMergeUnderlyingObject(dlg.Hvo, fLoseNoTextData);
				}
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Fill the Writing Systems menu with an alphebetized list of all writing systems
		/// defined in this language project. The writing system of the current selection
		/// (if there is exactly one) will be checked; otherwise, nothing will be checked.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void PopulateWritingSystemMenu()
		{
			// First clear any items added previously
			mnuWritingSystem.MenuItems.Clear();
			EventHandler clickEvent = new EventHandler(WritingSystemMenu_Click);
			m_htNamedWS.Clear();

			// Convert from Set to List, since the Set can't sort.
			List<NamedWritingSystem> writingSystems = new List<NamedWritingSystem>(m_cache.LangProject.GetActiveNamedWritingSystems().ToArray());
			writingSystems.Sort();
			string sCurrentWs = GetCurrentWS(LastTextBoxInFocus);
			foreach (NamedWritingSystem nws in writingSystems)
			{
				// Writing systems come from vernacular and analysis lists and can exist in both.
				// Do not try to add the same WS twice.
				if (!m_htNamedWS.ContainsKey(nws.Name))
				{
					m_htNamedWS.Add(nws.Name, nws);
					MenuItem mi = new MenuItem(nws.Name, clickEvent);
					mi.Checked = (sCurrentWs == nws.Name);
					mnuWritingSystem.MenuItems.Add(mi);
				}
			}
		}
Exemple #9
0
		/// <summary>
		/// This will remove the given hvosToRemove (if they exist in our sort items) and any items that refer to invalid objects.
		/// Reload the view if there were any changes, and adjust the CurrentIndex
		/// </summary>
		protected internal void RemoveUnwantedSortItems(List<int> hvosToRemove)
		{
			if (m_sortedObjects == null)
				return;	// nothing to remove.
			bool fUpdatingListOrig = m_fUpdatingList;
			m_fUpdatingList = true;
			try
			{
				int currentIndex = CurrentIndex;
				int cOrigSortObjects = m_sortedObjects.Count;
				// Note: We start with a Set, since it can't have duplicates.
				// First remove the given hvos from our sort items.
				Set<int> unwantedIndices = new Set<int>(IndicesOfSortItems(hvosToRemove));
				// then remove any remaining items that point to invalid objects.
				unwantedIndices.AddRange(IndicesOfInvalidSortItems());
				// Put the now unique indices into a list,
				// so we can make sure they are processed in reverse order.
				List<int> sortedIndices = new List<int>(unwantedIndices.ToArray());
				sortedIndices.Sort();
				sortedIndices.Reverse();
				foreach (int indexOfSortItem in sortedIndices)
				{
					if (indexOfSortItem >= 0)
					{
						m_sortedObjects.RemoveAt(indexOfSortItem);
						if (indexOfSortItem < currentIndex || SortedObjects.Count <= currentIndex)
							currentIndex--;
					}
				}
				if (m_sortedObjects.Count == 0)
					currentIndex = -1;
				else if (currentIndex >= m_sortedObjects.Count)
					currentIndex = m_sortedObjects.Count - 1;
				CurrentIndex = currentIndex;
				if (m_sortedObjects.Count != cOrigSortObjects)
				{
					SendPropChangedOnListChange(CurrentIndex,
						SortedObjects, ListChangedEventArgs.ListChangedActions.Normal);
				}
			}
			finally
			{
				m_fUpdatingList = fUpdatingListOrig;
			}
		}
Exemple #10
0
		public void ModifyOverlay(bool fApplyTag, IVwOverlay pvo, int itag)
		{
			CheckDisposed();
			if (m_rootb == null)
				return;

			Debug.WriteLine("WARNING: RootSite.ModifyOverlay() isn't tested yet");
			int hvo;
			uint clrFore;
			uint clrBack;
			uint clrUnder;
			int unt;
			bool fHidden;
			string uid;
			using (ArrayPtr arrayPtr = MarshalEx.StringToNative((int)VwConst1.kcchGuidRepLength + 1, true))
			{
				pvo.GetDbTagInfo(itag, out hvo, out clrFore, out clrBack, out clrUnder, out unt,
					out fHidden, arrayPtr);
				uid = MarshalEx.NativeToString(arrayPtr,
					(int)VwConst1.kcchGuidRepLength, false);
			}

			IVwSelection vwsel;
			ITsTextProps[] vttp;
			IVwPropertyStore[] vvps;
			if (EditingHelper.GetCharacterProps(out vwsel, out vttp, out vvps))
			{
				int cttp = vttp.Length;
				for (int ittp = 0; ittp < cttp; ittp++)
				{
					string strGuid = vttp[ittp].GetStrPropValue(
						(int)FwTextPropType.ktptTags);

					// REVIEW (EberhardB): I'm not sure if this works
					int cGuids = strGuid.Length / Marshal.SizeOf(typeof(Guid));
					List<string> guids = new List<string>();
					for (int i = 0; i < cGuids; i++)
						guids.Add(strGuid.Substring(i, Marshal.SizeOf(typeof(Guid))));

					if (fApplyTag)
					{
						// Add the tag if it does not exist
						if (guids.BinarySearch(uid) >= 0)
						{
							// The tag has already been applied to the textprop, so it doesn't
							// need to be modified.
							vttp[ittp] = null;
							continue;
						}
						else
						{
							// We need to add the tag to the textprop.
							guids.Add(uid);
							guids.Sort();
						}
					}
					else
					{
						// Remove the tag from the textprop.
						guids.Remove(uid);
					}

					ITsPropsBldr tpb = vttp[ittp].GetBldr();
					tpb.SetStrPropValue((int)FwTextPropType.ktptTags,
						guids.ToString());

					vttp[ittp] = tpb.GetTextProps();
				}
				vwsel.SetSelectionProps(cttp, vttp);

				/*
				 * ENHANCE (EberhardB): Implement this if we need it. It probably should be
				 * implemented in a derived class (view class for DataNotebook?)
				// Update the RnGenericRec_PhraseTags table as necessary.
				// (Yes, this is special case code!)

				AfDbInfo * pdbi = NULL;
				AfMainWnd * pamw = m_pwndSubclass->MainWindow();
				if (pamw)
				{
					AfMdiMainWnd * pammw = dynamic_cast<AfMdiMainWnd *>(pamw);
					AfLpInfo * plpi = NULL;
					if (pammw)
					{
						plpi = pammw->GetLpInfo();
						if (plpi)
							pdbi = plpi->GetDbInfo();
					}
				}
				if (pdbi)
				{
					int clevEnd;
					int clevAnchor;
					HVO hvoEnd;
					HVO hvoAnchor;
					PropTag tagEnd;
					PropTag tagAnchor;
					int ihvo;
					int cpropPrev;
					IVwPropertyStorePtr qvps;
					CheckHr(qvwsel->CLevels(true, &clevEnd));
					Assert(clevEnd >= 1);
					CheckHr(qvwsel->CLevels(false, &clevAnchor));
					Assert(clevAnchor >= 1);
					CheckHr(qvwsel->PropInfo(true, clevEnd - 1, &hvoEnd, &tagEnd, &ihvo,
						&cpropPrev, &qvps));
					CheckHr(qvwsel->PropInfo(false, clevAnchor - 1, &hvoAnchor, &tagAnchor, &ihvo,
						&cpropPrev, &qvps));

					IOleDbEncapPtr qode;
					pdbi->GetDbAccess(&qode);
				DbStringCrawler::UpdatePhraseTagsTable(kflidRnGenericRec_PhraseTags, fApplyTag, qode,
									 hvo, hvoEnd, hvoAnchor);
				}
				*/
			}
			if (FindForm() == Form.ActiveForm)
				Focus();
		}
		private void FixLexRelationTypeList(LayoutTreeNode ltn)
		{
			// Get the canonical list from the project.
			if (m_rgRelationTypes == null)
			{
				m_rgRelationTypes = m_cache.LangProject.LexDbOA.ReferencesOA.PossibilitiesOS.ToList();
				m_rgRelationTypes.Sort(ComparePossibilitiesByName);
			}
			// Add any new types to our ordered list (or fill in an empty list).
			var setSortedGuids = new Set<GuidAndSubClass>();
			foreach (var lri in ltn.RelTypeList)
				setSortedGuids.Add(new GuidAndSubClass(lri.ItemGuid, lri.SubClass));
			foreach (var poss in m_rgRelationTypes)
			{
				var lrt = (ILexRefType)poss;
				if (ltn.LexRelType == "sense")
				{
					if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryCollection ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryPair ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntrySequence ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree)
					{
						continue;
					}
				}
				else
				{
					if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseCollection ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSensePair ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseSequence ||
						lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
					{
						continue;
					}
				}
				var gsc = new GuidAndSubClass(poss.Guid, LexReferenceInfo.TypeSubClass.Normal);
				if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
				{
					gsc.SubClass = LexReferenceInfo.TypeSubClass.Forward;
				}
				if (!setSortedGuids.Contains(gsc))
				{
					var lri = new LexReferenceInfo(true, poss.Guid)
						{
							SubClass = gsc.SubClass
						};
					ltn.RelTypeList.Add(lri);
				}
				if (gsc.SubClass == LexReferenceInfo.TypeSubClass.Forward)
				{
					gsc.SubClass = LexReferenceInfo.TypeSubClass.Reverse;
					if (!setSortedGuids.Contains(gsc))
					{
						var lri = new LexReferenceInfo(true, poss.Guid)
							{
								SubClass = gsc.SubClass
							};
						ltn.RelTypeList.Add(lri);
					}
				}
			}
			// Remove any obsolete types from our ordered list.
			var mapGuidType = new Dictionary<GuidAndSubClass, ILexRefType>();
			foreach (var poss in m_rgRelationTypes)
			{
				var lrt = (ILexRefType)poss;
				var gsc = new GuidAndSubClass(lrt.Guid, LexReferenceInfo.TypeSubClass.Normal);
				if (lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseAsymmetricPair ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryTree ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtEntryOrSenseTree ||
					lrt.MappingType == (int)LexRefTypeTags.MappingTypes.kmtSenseTree)
				{
					gsc.SubClass = LexReferenceInfo.TypeSubClass.Forward;
				}
				mapGuidType.Add(gsc, lrt);
				if (gsc.SubClass == LexReferenceInfo.TypeSubClass.Forward)
				{
					var gsc2 = new GuidAndSubClass(lrt.Guid, LexReferenceInfo.TypeSubClass.Reverse);
					mapGuidType.Add(gsc2, lrt);
				}
			}
			var obsoleteItems = ltn.RelTypeList.Where(
				lri => !mapGuidType.ContainsKey(new GuidAndSubClass(lri.ItemGuid, lri.SubClass))).ToList();
			foreach (var lri in obsoleteItems)
				ltn.RelTypeList.Remove(lri);
			// Add the names to the items in the ordered list.
			foreach (var lri in ltn.RelTypeList)
			{
				var lrt = mapGuidType[new GuidAndSubClass(lri.ItemGuid, lri.SubClass)];
				if (lri.SubClass == LexReferenceInfo.TypeSubClass.Reverse)
					lri.Name = lrt.ReverseName.BestAnalysisVernacularAlternative.Text;
				else
					lri.Name = lrt.Name.BestAnalysisVernacularAlternative.Text;
			}
		}
Exemple #12
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads the list view, sorted by the current sort column.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void LoadListView(List<ListViewItem> list)
		{
			m_lvModel.SuspendLayout();
			m_lvModel.Items.Clear();
			bool sortAscending = (bool)m_lvModel.Columns[m_sortCol].Tag;

			list.Sort((x, y) => sortAscending ?
				x.SubItems[m_sortCol].Text.CompareTo(y.SubItems[m_sortCol].Text) :
				y.SubItems[m_sortCol].Text.CompareTo(x.SubItems[m_sortCol].Text));

			m_lvModel.Items.AddRange(list.ToArray());
			m_lvModel.ResumeLayout(true);
		}
Exemple #13
0
		protected void SetDlgInfo(FdoCache cache, IMoMorphType morphType, int wsVern, MorphTypeFilterType filter)
		{
			try
			{
				IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
				var xnWindow = (XmlNode) m_mediator.PropertyTable.GetValue("WindowConfiguration");
				XmlNode configNode = xnWindow.SelectSingleNode("controls/parameters/guicontrol[@id=\"matchingEntries\"]/parameters");

				SearchEngine searchEngine = SearchEngine.Get(m_mediator, "InsertEntrySearchEngine", () => new InsertEntrySearchEngine(cache));

				m_matchingObjectsBrowser.Initialize(cache, stylesheet, m_mediator, configNode,
					searchEngine);

				m_cache = cache;

				m_fNewlyCreated = false;
				m_oldForm = "";

				// Set fonts for the two edit boxes.
				if (stylesheet != null)
				{
					m_tbLexicalForm.StyleSheet = stylesheet;
					m_tbGloss.StyleSheet = stylesheet;
				}

				// Set writing system factory and code for the two edit boxes.
				IWritingSystemContainer wsContainer = cache.ServiceLocator.WritingSystems;
				IWritingSystem defAnalWs = wsContainer.DefaultAnalysisWritingSystem;
				IWritingSystem defVernWs = wsContainer.DefaultVernacularWritingSystem;
				m_tbLexicalForm.WritingSystemFactory = cache.WritingSystemFactory;
				m_tbGloss.WritingSystemFactory = cache.WritingSystemFactory;

				m_tbLexicalForm.AdjustStringHeight = false;
				m_tbGloss.AdjustStringHeight = false;

				if (wsVern <= 0)
					wsVern = defVernWs.Handle;
				// initialize to empty TsStrings
				ITsStrFactory tsf = cache.TsStrFactory;
				//we need to use the wsVern so that tbLexicalForm is sized correctly for the font size.
				//In Interlinear text the baseline can be in any of the vernacular writing systems, not just
				//the defaultVernacularWritingSystem.
				ITsString tssForm = tsf.MakeString("", wsVern);
				ITsString tssGloss = tsf.MakeString("", defAnalWs.Handle);

				using (m_updateTextMonitor.Enter())
				{
					m_tbLexicalForm.WritingSystemCode = wsVern;
					m_tbGloss.WritingSystemCode = defAnalWs.Handle;

					TssForm = tssForm;
					TssGloss = tssGloss;
				}

				// start building index
				m_matchingObjectsBrowser.SearchAsync(BuildSearchFieldArray(tssForm, tssGloss));

				((ISupportInitialize)(m_tbLexicalForm)).EndInit();
				((ISupportInitialize)(m_tbGloss)).EndInit();

				if (WritingSystemServices.GetWritingSystemList(m_cache, WritingSystemServices.kwsVerns, false).Count > 1)
				{
					msLexicalForm = ReplaceTextBoxWithMultiStringBox(m_tbLexicalForm, WritingSystemServices.kwsVerns, stylesheet);
					msLexicalForm.TextChanged += tbLexicalForm_TextChanged;
				}
				else
				{
					// See if we need to adjust the height of the lexical form
					AdjustTextBoxAndDialogHeight(m_tbLexicalForm);
				}

				// JohnT addition: if multiple analysis writing systems, replace tbGloss with msGloss
				if (WritingSystemServices.GetWritingSystemList(m_cache, WritingSystemServices.kwsAnals, false).Count > 1)
				{
					msGloss = ReplaceTextBoxWithMultiStringBox(m_tbGloss, WritingSystemServices.kwsAnals, stylesheet);
					m_lnkAssistant.Top = msGloss.Bottom - m_lnkAssistant.Height;
					msGloss.TextChanged += tbGloss_TextChanged;
				}
				else
				{
					// See if we need to adjust the height of the gloss
					AdjustTextBoxAndDialogHeight(m_tbGloss);
				}

				m_msaGroupBox.Initialize(cache, m_mediator, m_lnkAssistant, this);
				// See if we need to adjust the height of the MSA group box.
				int oldHeight = m_msaGroupBox.Height;
				int newHeight = Math.Max(m_msaGroupBox.PreferredHeight, oldHeight);
				GrowDialogAndAdjustControls(newHeight - oldHeight, m_msaGroupBox);
				m_msaGroupBox.AdjustInternalControlsAndGrow();

				Text = GetTitle();
				m_lnkAssistant.Enabled = false;

				// Set font for the combobox.
				m_cbMorphType.Font = new Font(defAnalWs.DefaultFontName, 10);

				// Populate morph type combo.
				// first Fill ComplexFormType combo, since cbMorphType controls
				// whether it gets enabled and which index is selected.
				m_cbComplexFormType.Font = new Font(defAnalWs.DefaultFontName, 10);
				var rgComplexTypes = new List<ICmPossibility>(m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.ReallyReallyAllPossibilities.ToArray());
				rgComplexTypes.Sort();
				m_idxNotComplex = m_cbComplexFormType.Items.Count;
				m_cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksNotApplicable, false));
				m_idxUnknownComplex = m_cbComplexFormType.Items.Count;
				m_cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksUnknownComplexForm, true));
				for (int i = 0; i < rgComplexTypes.Count; ++i)
				{
					var type = (ILexEntryType)rgComplexTypes[i];
					m_cbComplexFormType.Items.Add(type);
				}
				m_cbComplexFormType.SelectedIndex = 0;
				m_cbComplexFormType.Visible = true;
				m_cbComplexFormType.Enabled = true;
				// Convert from Set to List, since the Set can't sort.

				var al = new List<IMoMorphType>();
				foreach (IMoMorphType mType in m_cache.LanguageProject.LexDbOA.MorphTypesOA.ReallyReallyAllPossibilities.Cast<IMoMorphType>())
				{
					switch (filter)
					{
						case MorphTypeFilterType.Prefix:
							if (mType.IsPrefixishType)
								al.Add(mType);
							break;

						case MorphTypeFilterType.Suffix:
							if (mType.IsSuffixishType)
								al.Add(mType);
							break;

						case MorphTypeFilterType.Any:
							al.Add(mType);
							break;
					}
				}
				al.Sort();
				for (int i = 0; i < al.Count; ++i)
				{
					m_cbMorphType.Items.Add(al[i]);
					if (al[i] == morphType)
						m_cbMorphType.SelectedIndex = i;
				}

				m_morphType = morphType; // Is this still needed?
				m_msaGroupBox.MorphTypePreference = m_morphType;
				// Now position the searching animation
				/*
					* This position put the animation over the Glossing Assistant button. LT-9146
				m_searchAnimation.Top = groupBox2.Top - m_searchAnimation.Height - 5;
				m_searchAnimation.Left = groupBox2.Right - m_searchAnimation.Width - 10;
					*/
				/* This position puts the animation over the top left corner, but will that
					* look okay with right-to-left?
				m_searchAnimation.Top = groupBox2.Top + 40;
				m_searchAnimation.Left = groupBox2.Left + 10;
					*/
				// This position puts the animation close to the middle of the list.
				m_searchAnimation.Top = m_matchingEntriesGroupBox.Top + (m_matchingEntriesGroupBox.Height / 2) - (m_searchAnimation.Height / 2);
				m_searchAnimation.Left = m_matchingEntriesGroupBox.Left + (m_matchingEntriesGroupBox.Width / 2) - (m_searchAnimation.Width / 2);
			}
			catch(Exception e)
			{
				MessageBox.Show(e.ToString());
				MessageBox.Show(e.StackTrace);
			}
		}
Exemple #14
0
		protected void SetDlgInfo(FdoCache cache, IMoMorphType morphType, int wsVern, MorphTypeFilterType filter)
		{
			ReplaceMatchingEntriesControl();
			IVwStylesheet stylesheet = null;
			if (m_mediator != null)
			{
				stylesheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
				if (matchingEntries != null)
					matchingEntries.Initialize(cache, stylesheet, m_mediator);
			}
			m_cache = cache;

			m_fNewlyCreated = false;
			m_oldForm = "";

			if (m_types == null)
				m_types = new MoMorphTypeCollection(cache);

			// Set fonts for the two edit boxes.
			if (stylesheet != null)
			{
				tbLexicalForm.StyleSheet = stylesheet;
				tbGloss.StyleSheet = stylesheet;
			}

			// Set writing system factory and code for the two edit boxes.
			tbLexicalForm.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			if (wsVern <= 0)
				wsVern = cache.LangProject.DefaultVernacularWritingSystem;
			tbLexicalForm.WritingSystemCode = wsVern;
			tbLexicalForm.AdjustStringHeight = false;

			tbGloss.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			tbGloss.WritingSystemCode = cache.LangProject.DefaultAnalysisWritingSystem;
			tbGloss.AdjustStringHeight = false;

			// initialize to empty TsStrings
			ITsStrFactory tsf = TsStrFactoryClass.Create();
			//we need to use the weVern so that tbLexicalForm is sized correctly for the font size.
			//In Interlinear text the baseline can be in any of the vernacular writing systems, not just
			//the defaultVernacularWritingSystem.
			TssForm = tsf.MakeString("", wsVern);
			TssGloss = tsf.MakeString("", cache.LangProject.DefaultAnalysisWritingSystem);
			((System.ComponentModel.ISupportInitialize)(this.tbLexicalForm)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.tbGloss)).EndInit();


			int cVern = LabeledMultiStringView.GetWritingSystemList(m_cache, LangProject.kwsVerns, false).Length;
			if (cVern > 1)
			{
				msLexicalForm = ReplaceTextBoxWithMultiStringBox(tbLexicalForm, LangProject.kwsVerns, stylesheet);
				msLexicalForm.TextChanged += new EventHandler(tbLexicalForm_TextChanged);
			}
			else
			{
				// See if we need to adjust the height of the lexical form
				AdjustTextBoxAndDialogHeight(tbLexicalForm);
			}

			// JohnT addition: if multiple analysis writing systems, replace tbGloss with msGloss
			int cWritingSystem = LabeledMultiStringView.GetWritingSystemList(m_cache, LangProject.kwsAnals, false).Length;
			if (cWritingSystem > 1)
			{
				msGloss = ReplaceTextBoxWithMultiStringBox(tbGloss, LangProject.kwsAnals, stylesheet);
				m_lnkAssistant.Top = msGloss.Bottom - m_lnkAssistant.Height;
				msGloss.TextChanged += new System.EventHandler(this.tbGloss_TextChanged);
			}
			else
			{
				// See if we need to adjust the height of the gloss
				AdjustTextBoxAndDialogHeight(tbGloss);
			}

			m_msaGroupBox.Initialize(cache, m_mediator, m_lnkAssistant, this);
			// See if we need to adjust the height of the MSA group box.
			int oldHeight = m_msaGroupBox.Height;
			int newHeight = Math.Max(m_msaGroupBox.PreferredHeight, oldHeight);
			GrowDialogAndAdjustControls(newHeight - oldHeight, m_msaGroupBox);
			m_msaGroupBox.AdjustInternalControlsAndGrow();

			Text = GetTitle();
			m_lnkAssistant.Enabled = false;

			// Set font for the combobox.
			cbMorphType.Font =
				new Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10);

			// Populate morph type combo.
			// first Fill ComplexFormType combo, since cbMorphType controls
			// whether it gets enabled and which index is selected.
			cbComplexFormType.Font =
				new Font(cache.LangProject.DefaultAnalysisWritingSystemFont, 10);
			List<ICmPossibility> rgComplexTypes = new List<ICmPossibility>(m_cache.LangProject.LexDbOA.ComplexEntryTypesOA.ReallyReallyAllPossibilities.ToArray());
			rgComplexTypes.Sort();
			m_idxNotComplex = cbComplexFormType.Items.Count;
			cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksNotApplicable, false));
			m_idxUnknownComplex = cbComplexFormType.Items.Count;
			cbComplexFormType.Items.Add(new DummyEntryType(LexTextControls.ksUnknownComplexForm, true));
			for (int i = 0; i < rgComplexTypes.Count; ++i)
			{
				ILexEntryType type = (ILexEntryType)rgComplexTypes[i];
				cbComplexFormType.Items.Add(type);
			}
			cbComplexFormType.SelectedIndex = 0;
			cbComplexFormType.Visible = true;
			cbComplexFormType.Enabled = true;
			// Convert from Set to List, since the Set can't sort.

			List<ICmPossibility> al = new List<ICmPossibility>();
			foreach (ICmPossibility mType in m_cache.LangProject.LexDbOA.MorphTypesOA.ReallyReallyAllPossibilities)
			{
				switch (filter)
				{
					case MorphTypeFilterType.prefix:
						if (MoMorphType.IsPrefixishType(m_cache, mType.Hvo))
							al.Add(mType);
						break;

					case MorphTypeFilterType.suffix:
						if (MoMorphType.IsSuffixishType(m_cache, mType.Hvo))
							al.Add(mType);
						break;

					case MorphTypeFilterType.any:
						al.Add(mType);
						break;
				}
			}
			al.Sort();
			for (int i = 0; i < al.Count; ++i)
			{
				IMoMorphType type = (IMoMorphType)al[i];

				cbMorphType.Items.Add(type);
				//previously had "if (type == morphType)" which was always false
				if (type.Equals(morphType))
					cbMorphType.SelectedIndex = i;
			}

			m_morphType = morphType; // Is this still needed?
			m_msaGroupBox.MorphTypePreference = m_morphType;
			// Now position the searching animation
			/*
			 * This position put the animation over the Glossing Assistant button. LT-9146
			m_searchAnimtation.Top = groupBox2.Top - m_searchAnimtation.Height - 5;
			m_searchAnimtation.Left = groupBox2.Right - m_searchAnimtation.Width - 10;
			 */
			/* This position puts the animation over the top left corner, but will that
			 * look okay with right-to-left?
			m_searchAnimtation.Top = groupBox2.Top + 40;
			m_searchAnimtation.Left = groupBox2.Left + 10;
			 */
			// This position puts the animation close to the middle of the list.
			m_searchAnimtation.Top = groupBox2.Top + (groupBox2.Top / 2);
			m_searchAnimtation.Left = groupBox2.Left + (groupBox2.Right / 2);
		}
Exemple #15
0
		public static void Report()
		{
			// Can't use StringCollection, because it can't sort.
			List<string> items = new List<string>();
			foreach (KeyValuePair<string, TimeVal> kvp in s_dict)
			{
				items.Add(kvp.Key);
			}
			items.Sort();
			foreach(string key in items)
			{
				Debug.WriteLine(key + ": " + s_dict[key].duration.ToString());
			}
			s_dict.Clear();
			s_blockname = ""; // just to be sure
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Updates the key term equivalents.
		/// </summary>
		/// <param name="progressDlg">The progress dialog box.</param>
		/// ------------------------------------------------------------------------------------
		protected void UpdateKeyTermEquivalentsInternal(IProgress progressDlg)
		{
			List<InvalidRendering> invalidRenderings = new List<InvalidRendering>();
			try
			{
				// first build a map from verses to the keyterms that should have renderings.
				Set<IChkTerm> chkTerms = m_ktTree.ChkTermsWithRefs;
				if (progressDlg != null)
				{
					progressDlg.Message = TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressLoading");
					progressDlg.Minimum = 0;
					progressDlg.Maximum = chkTerms.Count;
				}
				Dictionary<int, List<KeyTermRef>> bcvToChkRefs = new Dictionary<int, List<KeyTermRef>>();
				foreach (IChkTerm keyTerm in chkTerms)
				{
					AddChkRefsToBCVmap(keyTerm, ref bcvToChkRefs);
					if (progressDlg != null)
						progressDlg.Step(0);
				}
				// set progress bar to the number of verses to step through.
				if (progressDlg != null)
				{
					progressDlg.Minimum = 0;
					progressDlg.Maximum = bcvToChkRefs.Count;
				}
				// for each keyterm occurrences in each verse, make sure renderings are up to date.
				List<int> sortedKeys = new List<int>(bcvToChkRefs.Keys);
				sortedKeys.Sort();
				foreach (int bcv in sortedKeys)
				{
					// REVIEW (TE-6532): For now, all Key Term Refs in the DB use the Original
					// versisifcation. Should we support other versifications?
					ScrReference currentVerse = new ScrReference(bcv, ScrVers.Original,
						m_scr.Versification);
					if (progressDlg != null)
					{
						progressDlg.Message = String.Format(TeResourceHelper.GetResourceString("kstidUpdateKeyTermEquivalentsProgressMessage"),
							currentVerse.AsString);
					}
					List<KeyTermRef> chkRefsForVerse = bcvToChkRefs[bcv];
					foreach (KeyTermRef keyRef in chkRefsForVerse)
					{
						// skip doing anything about references that have been marked as "Ignore"
						if (keyRef.RenderingStatus == KeyTermRenderingStatus.Ignored)
							continue;
						if (keyRef.ChkRef.RenderingRA != null)
						{
							if (CanFindTextInVerse(keyRef.ChkRef.RenderingRA, currentVerse))
							{
								if (keyRef.RenderingStatus == KeyTermRenderingStatus.Missing)
									keyRef.RenderingStatus = KeyTermRenderingStatus.Assigned;
								continue;
							}
						}
						// if an expected rendering is not found (or there was no previous assignment)
						// see if we can find an alternative rendering to AutoAssign.
						IChkTerm parentKeyTerm = (IChkTerm)keyRef.ChkRef.Owner;
						bool fFound = false;
						foreach (IChkRendering rendering in parentKeyTerm.RenderingsOC)
						{
							if (rendering.SurfaceFormRA == null)
							{
								// We found a surface form that is not defined. Later we'll need to
								// remove this rendering, but for now we'll continue to the next one.
								invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
								continue;
							}
							if (CanFindTextInVerse(rendering.SurfaceFormRA, currentVerse))
							{
								try
								{
									keyRef.ChkRef.RenderingRA = rendering.SurfaceFormRA;
									if (keyRef.RenderingStatus != KeyTermRenderingStatus.AutoAssigned)
										keyRef.RenderingStatus = KeyTermRenderingStatus.AutoAssigned;
									fFound = true;
									break;
								}
								catch
								{
									// Unable to set rendering because it is invalid.
									invalidRenderings.Add(new InvalidRendering(parentKeyTerm, rendering));
									continue;
								}
							}
						}
						if (!fFound)
						{
							if (keyRef.RenderingStatus == KeyTermRenderingStatus.Assigned &&
								keyRef.ChkRef.RenderingRA != null)
							{
								// keep RenderingsRA info, so we know what is missing.
								keyRef.RenderingStatus = KeyTermRenderingStatus.Missing;
							}
							else
							{
								if (keyRef.ChkRef.RenderingRA != null)
									keyRef.ChkRef.RenderingRA = null;
								if (keyRef.RenderingStatus != KeyTermRenderingStatus.Unassigned)
									keyRef.RenderingStatus = KeyTermRenderingStatus.Unassigned;
							}
						}
					}
					if (progressDlg != null)
						progressDlg.Step(0);
				}
			}
			finally
			{
				if (invalidRenderings.Count > 0)
				{
					// We found at least one invalid surface form, so we need to search through our
					// renderings and remove any that are invalid.
					foreach (InvalidRendering rendering in invalidRenderings)
					{
						// Rendering may be in list twice, so only delete the valid objects
						if (rendering.m_rendering.IsValidObject)
							rendering.m_parentKeyTerm.RenderingsOC.Remove(rendering.m_rendering);
					}
				}
			}
		}
Exemple #17
0
		/// <summary>
		/// Replace SortObjects corresponding to hvoToReplace with new SortObjects for newObj.
		/// </summary>
		/// <param name="newObj"></param>
		/// <param name="hvoToReplace"></param>
		/// <param name="fAssumeSame">if true, we'll try to replace sort objects for hvoToReplace with newObj at the same indices.
		/// if false, we'll rely upon sorter to merge the new item into the right index, or else add to the end.
		/// Enhance: Is there some way we can compare the sort/filter results for newObj and hvoToReplace that is hvo indepedendent?</param>
		/// <returns>resulting list of newSortItems added to SortedObjects</returns>
		protected ArrayList ReplaceListItem(ICmObject newObj, int hvoToReplace, bool fAssumeSame)
		{
			ArrayList newSortItems = new ArrayList();
			// Note: don't check NeedToReloadVirtualProperty here, so we can update the list, even if we need to
			// reload it at a later time. This allows joining/breaking wordforms in the Concordance tools, without
			// necessarily having to reload the entire list. Typically replacements will be with real ids, and those
			// should be stable to add in the new view.
			//if (NeedToReloadVirtualProperty)
			//    return newSortItems;	// we don't need to update the list, if we're planning to reload the whole thing.
			List<int> indicesOfSortItemsToRemove = new List<int>(IndicesOfSortItems(new List<int>(new int[] { hvoToReplace })));
			ArrayList remainingInsertItems = new ArrayList();
			int hvoNewObject = 0;
			if (newObj != null)
			{
				hvoNewObject = newObj.Hvo;
				// we don't want to add new sort items, if we've already added them, but we do want to allow
				// a replacement.
				if (hvoToReplace == hvoNewObject || IndexOfFirstSortItem(new List<int>(new int[] { hvoNewObject })) < 0)
					MakeItemsFor(newSortItems, newObj);
				remainingInsertItems = (ArrayList)newSortItems.Clone();
				if (fAssumeSame)
				{
					//assume we're converting a dummy item to a real one.
					//In that case, the real item should have same basic content as the dummy item we are replacing,
					//so we can replace the item at the same sortItem indices.
					foreach (object itemToInsert in newSortItems)
					{
						if (indicesOfSortItemsToRemove.Count > 0)
						{
							int iToReplace = indicesOfSortItemsToRemove[0];
							SortedObjects.RemoveAt(iToReplace);
							SortedObjects.Insert(iToReplace, itemToInsert);
							indicesOfSortItemsToRemove.RemoveAt(0);
							remainingInsertItems.RemoveAt(0);
						}
						else
						{
							break;
						}
					}
				}
			}
			// Although, ideally, during a dummy conversion there should be a one-to-one correspondence between
			// the sort items found for the dummy object, and the sort items generated for its real object,
			// it's possible that at the time we added the dummy item to the record sort list, it didn't
			// have the same properties matching a filter or sorter as the real item. Try to do the best we
			// can by removing remaining sort items for the dummy object and then adding any additional sort items
			// for the real object.

			// remove the remaining items.
			indicesOfSortItemsToRemove.Sort();
			indicesOfSortItemsToRemove.Reverse();
			foreach (int iToRemove in indicesOfSortItemsToRemove)
			{
				SortedObjects.RemoveAt(iToRemove);
			}
			// add the remaining items.
			if (m_sorter != null)
			{
				m_sorter.MergeInto(SortedObjects, remainingInsertItems);
			}
			else
			{
				// Add at the end.
				SortedObjects.AddRange(remainingInsertItems);
			}

			// update our current selected hvo, if necessary
			if (m_hvoCurrent == hvoToReplace)
				m_hvoCurrent = hvoNewObject;
			return newSortItems;
		}
Exemple #18
0
		private void AddWritingSystemList(UIListDisplayProperties display, Set<NamedWritingSystem> set)
		{
			List<NamedWritingSystem> list = new List<NamedWritingSystem>(set.ToArray()); // A Set doesn't know about sorting, so use a list.
			list.Sort();
			foreach(NamedWritingSystem ws in list)
			{
				display.List.Add(ws.Name, ws.Hvo.ToString(), null, null);
			}
		}
Exemple #19
0
		private static List<string> GetDriveMountList()
		{
			// TODO-Linux: GetDrives() on Mono is only implemented for Linux.
			DriveInfo[] allDrives = DriveInfo.GetDrives();
			List<string> driveMounts = new List<string>();
			foreach (DriveInfo d in allDrives)
			{
				// TODO-Linux: IsReady always returns true on Mono
				if (!d.IsReady || d.AvailableFreeSpace == 0)
					continue;
				switch (d.DriveType)
				{
					case DriveType.Fixed:
					case DriveType.Network:
					case DriveType.Removable:
						if (MiscUtils.IsUnix)
							driveMounts.Add(d.Name + (d.Name.EndsWith("/") ? "" : "/"));	// ensure terminated with a slash
						else
							driveMounts.Add(d.Name.ToLowerInvariant());		// Windows produces C:\ D:\ etc.
						break;
				}
			}
			driveMounts.Sort(longestFirst);
			return driveMounts;
		}