本文整理汇总了C#中XCore.List.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# List.IndexOf方法的具体用法?C# List.IndexOf怎么用?C# List.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.List
的用法示例。
在下文中一共展示了List.IndexOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertDummyToReal
/// <summary>
/// Let the caller issue a PropChanged for this list whenever it is through with its conversions.
/// </summary>
/// <param name="owningflid"></param>
/// <param name="hvoDummyId"></param>
/// <returns></returns>
private ICmObject ConvertDummyToReal(int owningHvo, int virtflid, int hvoDummyId)
{
ICmObject ann = null;
List<int> annotationItems = new List<int>(m_cache.GetVectorProperty(owningHvo, virtflid, true));
int indexOfId = annotationItems.IndexOf(hvoDummyId);
Debug.Assert(indexOfId >= 0);
if (indexOfId >= 0)
{
ann = CmObject.ConvertDummyToReal(m_cache, hvoDummyId);
Debug.Assert(ann != null);
m_cache.VwCacheDaAccessor.CacheReplace(owningHvo,
virtflid, indexOfId, indexOfId + 1, new int[] { ann.Hvo }, 1);
}
return ann;
}
示例2: FindSlotNameOfMsa
private string FindSlotNameOfMsa(int hvoSlot)
{
#if WantWWStuff // TODO: AndyB(RandyR): Fix this, if it is still needed.
IMoInflAffixSlot slot = new SIL.FieldWorks.FDO.Ling.MoInflAffixSlot(Cache, hvoSlot);
List<int> listMsaHvos = new List<int>(slot.AffixesRS.HvoArray);
int index = listMsaHvos.IndexOf(m_hvo);
if (index >= 0)
return slot.Name.AnalysisDefaultWritingSystem;
#endif
return null;
}
示例3: SetDlgInfo
protected virtual void SetDlgInfo(FdoCache cache, WindowParams wp, Mediator mediator, int wsVern)
{
CheckDisposed();
Debug.Assert(cache != null);
m_cache = cache;
m_mediator = mediator;
if (m_mediator != null)
{
ReplaceMatchingItemsControl();
// Reset window location.
// Get location to the stored values, if any.
object locWnd = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgLocation");
object szWnd = m_mediator.PropertyTable.GetValue(PersistenceLabel + "DlgSize");
if (locWnd != null && szWnd != null)
{
Rectangle rect = new Rectangle((Point)locWnd, (Size)szWnd);
//grow it if it's too small. This will happen when we add new controls to the dialog box.
if(rect.Width < btnHelp.Left + btnHelp.Width + 30)
rect.Width = btnHelp.Left + btnHelp.Width + 30;
if(rect.Height < btnHelp.Top + btnHelp.Height + 50)
rect.Height = btnHelp.Top + btnHelp.Height + 50;
//rect.Height = 600;
ScreenUtils.EnsureVisibleRect(ref rect);
DesktopBounds = rect;
StartPosition = FormStartPosition.Manual;
}
}
SetupBasicTextProperties(wp);
IVwStylesheet stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
InitializeMatchingEntries(cache, mediator);
int hvoWs = wsVern;
// Set font, writing system factory, and writing system code for the Lexical Form
// edit box. Also set an empty string with the proper writing system.
m_tbForm.Font =
new Font(cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsVern).DefaultSerif, 10);
m_tbForm.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
m_tbForm.WritingSystemCode = hvoWs;
m_tsf = TsStrFactoryClass.Create();
m_tbForm.AdjustStringHeight = false;
m_tbForm.Tss = m_tsf.MakeString("", hvoWs);
m_tbForm.StyleSheet = stylesheet;
// Setup the fancy message text box.
// Note: at 120DPI (only), it seems to be essential to set at least the WSF of the
// bottom message even if not using it.
SetupBottomMsg();
SetBottomMessage();
m_fwTextBoxBottomMsg.BorderStyle = BorderStyle.None;
m_analHvos.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
List<int> vernList = new List<int>(cache.LangProject.CurVernWssRS.HvoArray);
m_vernHvos.AddRange(vernList);
LoadWritingSystemCombo();
int iWs = vernList.IndexOf(hvoWs);
ILgWritingSystem lgwsCurrent;
if (iWs < 0)
{
List<int> analList = new List<int>(cache.LangProject.CurAnalysisWssRS.HvoArray);
iWs = analList.IndexOf(hvoWs);
if (iWs < 0)
{
lgwsCurrent = LgWritingSystem.CreateFromDBObject(cache, hvoWs);
m_cbWritingSystems.Items.Add(lgwsCurrent);
}
else
{
lgwsCurrent = cache.LangProject.CurAnalysisWssRS[iWs];
}
}
else
{
lgwsCurrent = cache.LangProject.CurVernWssRS[iWs];
}
Debug.Assert(lgwsCurrent != null && lgwsCurrent.Hvo == hvoWs);
m_skipCheck = true;
m_cbWritingSystems.SelectedItem = lgwsCurrent;
m_skipCheck = false;
// Don't hook this up until AFTER we've initialized it; otherwise, it can
// modify the contents of the form as a side effect of initialization.
// Also, doing that triggers laying out the dialog prematurely, before
// we've set WSF on all the controls.
m_cbWritingSystems.SelectedIndexChanged += new System.EventHandler(this.m_cbWritingSystems_SelectedIndexChanged);
// Adjust things if the form box needs to grow to accommodate its style.
int oldHeight = m_tbForm.Height;
int newHeight = Math.Max(oldHeight, m_tbForm.PreferredHeight);
int delta = newHeight - oldHeight;
if (delta != 0)
//.........这里部分代码省略.........
示例4: UpdateBookFilter
/// ------------------------------------------------------------------------------------
/// <summary>
/// Update the book filter with new set of filtered books. Preserve any existing
/// selections for all views.
/// </summary>
/// <param name="rghvoBooks">Array of ids for the books that are to comprise the new
/// filtered set</param>
/// ------------------------------------------------------------------------------------
private void UpdateBookFilter(IScrBook[] rghvoBooks)
{
using (new WaitCursor(this))
{
List<RestoreSelInfo> restoreInfos = new List<RestoreSelInfo>(m_rgClientViews.Count);
List<IScrBook> newFilteredBooks = new List<IScrBook>(rghvoBooks);
foreach (IRootSite rootsite in m_viewHelper.Views)
{
if (rootsite == null || rootsite.EditingHelper == null ||
rootsite.EditingHelper.CurrentSelection == null)
continue;
SelectionHelper selHelper = rootsite.EditingHelper.CurrentSelection;
ITeView itev = rootsite.EditingHelper.Control as ITeView;
if (itev == null || itev.LocationTracker == null)
continue;
ILocationTracker tracker = itev.LocationTracker;
IScrBook bookAnchor = tracker.GetBook(selHelper, SelectionHelper.SelLimitType.Anchor);
IScrBook bookEnd = tracker.GetBook(selHelper, SelectionHelper.SelLimitType.End);
int iSectionAnchor = tracker.GetSectionIndexInBook(selHelper, SelectionHelper.SelLimitType.Anchor);
int iSectionEnd = tracker.GetSectionIndexInBook(selHelper, SelectionHelper.SelLimitType.End);
int ihvoBookNewAnchor = newFilteredBooks.IndexOf(bookAnchor);
int ihvoBookNewEnd = newFilteredBooks.IndexOf(bookEnd);
if (ihvoBookNewAnchor >= 0 || ihvoBookNewEnd >= 0)
{
// Book is still in the filter. Keep the selection in the same place.
if (ihvoBookNewAnchor < 0)
{
ihvoBookNewAnchor = ihvoBookNewEnd;
iSectionAnchor = iSectionEnd;
}
else if (ihvoBookNewEnd < 0)
{
ihvoBookNewEnd = ihvoBookNewAnchor;
iSectionEnd = iSectionAnchor;
}
restoreInfos.Add(new RestoreSelInfo(tracker, selHelper,
ihvoBookNewAnchor, iSectionAnchor, ihvoBookNewEnd, iSectionEnd,
rootsite == m_viewHelper.ActiveView));
}
else
{
// Book isn't in filter anymore. Set IP to beginning of first displayed
// book
selHelper.AssocPrev = false;
selHelper.IchAnchor = 0;
if (selHelper.GetLevelForTag(StTextTags.kflidParagraphs) >= 0)
{
selHelper.LevelInfo[selHelper.GetLevelForTag(
StTextTags.kflidParagraphs)].ihvo = 0;
}
restoreInfos.Add(new RestoreSelInfo(tracker, selHelper,
0, 0, 0, 0, rootsite == m_viewHelper.ActiveView));
}
}
m_bookFilter.FilteredBooks = rghvoBooks;
RestoreSelInfo activeViewSelInfo = null;
// Restore the selection in the active view. If the selection cannot be restored because
// the book is now filtered out of view, just go to the top of the window instead.
// We used to restore the selection in all views, but this caused problems described in
// TE-8379 and was totally pointless since we try to make a useful selection based on the
// previous view whenever switching to a new active view.
foreach (RestoreSelInfo restoreSelInfo in restoreInfos)
{
if (restoreSelInfo.IsActiveView)
activeViewSelInfo = restoreSelInfo;
}
// Do the active view last so that the style combo box shows the right style
if (activeViewSelInfo != null)
RestoreSelection(activeViewSelInfo);
if (KeyTermsViewIsCreated)
UpdateKeyTermsBookFilter();
}
}
示例5: MoveToNextPane
/// <summary>
/// Move focus to next/previous pane.
/// 'Pane' here means:
/// 1. the Sidebar (m_sidebar),
/// 2. the record list, (if showing at all, m_recordBar),
/// 3. the first or second control of a MultiPane, or a parent MultiPane.
/// 4. the main content control, if is not a MultiPane, or 'focusedControl'
/// is not contained in a MultiPane.
/// </summary>
/// <param name="fForward"></param>
/// <returns>control in pane that got the focus.</returns>
private Control MoveToNextPane(bool fForward)
{
Control focusedControl = FocusedControl();
if (focusedControl == this)
return null;
Control indexControl = null;
// We can make a complete collection of candidates here.
// In all cases, we add m_sidebar, since it is always showing.
// We may want to include m_recordBar, if it is also showing.
// We then want one or more controls from the m_mainContentControl.
// (Note: m_mainContentPlaceholderPanel will be replaced by m_mainContentControl in normal operations,
// but is is theoretically possible it is a current option.)
List<Control> targetCandidates = new List<Control>();
// The m_sidebar is currently always showing (as of Jan 11, 2007),
// but it may not be in the future, so add it is it is showing.
if (m_mainSplitContainer.Panel1.Controls[0] == m_sidebar)
{
if (m_sidebar.ContainsFocus)
{
targetCandidates.Add(focusedControl);
indexControl = focusedControl;
}
else
{
Control target = m_sidebar;
foreach (Control child in m_sidebar.Controls)
{
if (child.Controls.Count > 0)
{
Control innerChild = child.Controls[0];
if (innerChild is ListView)
{
if ((innerChild as ListView).SelectedItems.Count > 0)
{
target = innerChild;
break;
}
}
}
}
targetCandidates.Add(target);
}
}
if (!m_secondarySplitContainer.Panel1Collapsed
&& m_secondarySplitContainer.Panel1.Controls[0] == m_recordBar)
{
if (m_recordBar.ContainsFocus)
{
targetCandidates.Add(focusedControl);
indexControl = focusedControl;
}
else
{
// It looks like the record list can deal with waht is selected,
// so just toss in the whole thing.
targetCandidates.Add(m_recordBar);
}
}
if (!m_secondarySplitContainer.Panel2Collapsed
&& m_secondarySplitContainer.Panel2.Controls[0] == m_mainContentControl)
{
// Now deal with the m_mainContentControl side of things.
Control otherControl = (m_mainContentControl as IxCoreCtrlTabProvider).PopulateCtrlTabTargetCandidateList(targetCandidates);
if (otherControl != null)
{
Debug.Assert(indexControl == null, "indexCntrol should have been null.");
indexControl = otherControl;
}
}
Debug.Assert(indexControl != null, "Couldn't find the focused control anywhere.");
Debug.Assert(targetCandidates.Contains(indexControl));
int srcIndex = targetCandidates.IndexOf(indexControl);
int targetIndex = 0;
if (fForward)
{
targetIndex = srcIndex + 1 < targetCandidates.Count ? srcIndex + 1 : 0;
}
else
{
targetIndex = srcIndex > 0 ? srcIndex - 1 : targetCandidates.Count - 1;
}
Control newFocusedControl = targetCandidates[targetIndex];
newFocusedControl.Focus(); // Note: may result in Focusing in a subcontrol.
return newFocusedControl;
}
示例6: btnAdd_Click
private void btnAdd_Click(object sender, EventArgs e)
{
// Get the checked twfics;
List<int> twfics = m_rbv.CheckedItems;
if (twfics == null || twfics.Count == 0)
{
// do nothing.
return;
}
List<int> twficSegments = StTxtPara.TwficSegments(m_cache, twfics);
Set<int> uniqueSegments = new Set<int>(twficSegments);
FdoObjectSet<CmBaseAnnotation> cbaSegments = new FdoObjectSet<CmBaseAnnotation>(m_cache, uniqueSegments.ToArray(), true);
int insertIndex = m_owningSense.ExamplesOS.Count; // by default, insert at the end.
int sourceIndex = -1;
if (m_les != null)
{
// we were given a LexExampleSentence, so set our insertion index after the given one.
List<int> examples = new List<int>(m_owningSense.ExamplesOS.HvoArray);
sourceIndex = examples.IndexOf(m_les.Hvo);
insertIndex = sourceIndex + 1;
}
// Load all the annotations for these twfics.
int tagSegFF = StTxtPara.SegmentFreeformAnnotationsFlid(m_cache);
Set<int> allAnalWsIds = new Set<int>(m_cache.LangProject.AnalysisWssRC.HvoArray);
StTxtPara.LoadSegmentFreeformAnnotationData(m_cache, uniqueSegments, allAnalWsIds);
bool fBoolModifiedExisting = false;
List<ILexExampleSentence> newExamples = new List<ILexExampleSentence>(); // keep track of how many new objects we created.
ILexExampleSentence newLexExample = null;
// delay prop changes until all the new examples are added.
using (new IgnorePropChanged(m_cache, PropChangedHandling.SuppressView))
{
foreach (CmBaseAnnotation cbaSegment in cbaSegments)
{
if (newExamples.Count == 0 && m_les != null && m_les.Example.BestVernacularAlternative.Text == "***" &&
(m_les.TranslationsOC == null || m_les.TranslationsOC.Count == 0) &&
m_les.Reference.Length == 0)
{
// we were given an empty LexExampleSentence, so use this one for our first new Example.
newLexExample = m_les;
fBoolModifiedExisting = true;
}
else
{
// create a new example sentence.
newLexExample = m_owningSense.ExamplesOS.InsertAt(new LexExampleSentence(), insertIndex + newExamples.Count);
newExamples.Add(newLexExample);
}
// copy the segment string into the new LexExampleSentence
// Enhance: bold the relevant twfic(s).
newLexExample.Example.SetVernacularDefaultWritingSystem(StTxtPara.TssSubstring(cbaSegment).Text);
int segDefn_literalTranslation = m_cache.GetIdFromGuid(LangProject.kguidAnnLiteralTranslation);
int segDefn_freeTranslation = m_cache.GetIdFromGuid(LangProject.kguidAnnFreeTranslation);
int hvoTransType_literalTranslation = m_cache.GetIdFromGuid(LangProject.kguidTranLiteralTranslation);
int hvoTransType_freeTranslation = m_cache.GetIdFromGuid(LangProject.kguidTranFreeTranslation);
// copy the translation information
List<ICmTranslation> newTranslations = new List<ICmTranslation>();
foreach (int freeFormAnnotationId in m_cache.GetVectorProperty(cbaSegment.Hvo, tagSegFF, true))
{
int hvoAnnType = m_cache.MainCacheAccessor.get_ObjectProp(freeFormAnnotationId, (int)CmAnnotation.CmAnnotationTags.kflidAnnotationType);
// map annotation type to translation type.
int hvoTranslationType = 0;
if (hvoAnnType == segDefn_literalTranslation)
{
hvoTranslationType = hvoTransType_literalTranslation;
}
else if (hvoAnnType == segDefn_freeTranslation)
{
hvoTranslationType = hvoTransType_freeTranslation;
}
else
{
continue; // skip unsupported translation type.
}
ICmTranslation newTranslation = newLexExample.TranslationsOC.Add(new CmTranslation());
newTranslations.Add(newTranslation);
newTranslation.TypeRAHvo = hvoTranslationType;
foreach (int analWs in allAnalWsIds)
{
ITsString tssComment = m_cache.GetMultiStringAlt(freeFormAnnotationId, (int)CmAnnotation.CmAnnotationTags.kflidComment, analWs);
if (tssComment.Length > 0)
{
newTranslation.Translation.SetAlternative(tssComment, analWs);
}
}
}
// copy the reference.
// Enhance: get the ws from the 'Reference' column spec?
// Enhance: AnnotationRefHandler can also m_cache the reference directly to the segment.
int iTwfic = twficSegments.IndexOf(cbaSegment.Hvo);
newLexExample.Reference.UnderlyingTsString = m_cache.GetTsStringProperty(twfics[iTwfic], m_virtFlidReference);
// Need to correctly add Translations (or ghost if none).
}
//.........这里部分代码省略.........
示例7: PropChanged
public override void PropChanged(int hvo, int tag, int ivMin, int cvIns, int cvDel)
{
CheckDisposed();
if (m_fUpdatingList &&
(tag == m_flid ||
tag == (int)WfiWordform.WfiWordformTags.kflidForm ||
tag == (int)WordformInventory.WordformInventoryTags.kflidWordforms))
{
return; // we're already in the process of changing our list.
}
// if we've added or removed an occurrence of a wordform, then update the relevant items in our list.
int hvoWordform = 0;
switch (tag)
{
default:
// ktagWordformOccurrences isn't a constant,
// so it can't be in its own case statement.
if (tag == ktagWordformOccurrences)
hvoWordform = hvo;
break;
case (int)WfiWordform.WfiWordformTags.kflidForm:
WordformInventory.OnChangedWordformsOC();
hvoWordform = hvo;
break;
case (int)WordformInventory.WordformInventoryTags.kflidWordforms:
WordformInventory.OnChangedWordformsOC();
if (cvDel > 0)
{
RemoveUnwantedSortItems(null);
// Only quit, if none were also added.
// If they were also added, then it will end up calling the base class impl.
if (cvIns == 0)
return;
}
break;
case (int)LangProject.LangProjectTags.kflidTexts:
case (int)Text.TextTags.kflidContents:
m_fReloadConcordanceTexts = true;
break;
case (int)StText.StTextTags.kflidParagraphs: // Fall through.
case (int)StTxtPara.StTxtParaTags.kflidContents:
// we should mark the owning text as being modified.
// how do we detect that a paragraph has been deleted?
//m_fReloadConcordanceTexts = true;
break;
}
// update the display of any word that has changed its occurrences
// Enhance: we could expand this to include changes to other properties in our columns.
if (hvoWordform != 0)
{
List<int> wordformsList;
// try to avoid reloading our ConcordanceWordforms if it's not already loaded.
if (VirtualHandler.IsPropInCache(Cache.MainCacheAccessor, m_owningObject.Hvo, 0))
{
wordformsList = new List<int>(m_cache.GetVectorProperty(m_owningObject.Hvo, m_flid, true));
int owningIndex = wordformsList.IndexOf(hvoWordform);
if (owningIndex >= 0)
{
try
{
// Don't apply filters while we're editing away. See LT-7607.
m_fEnableFilters = false;
ReplaceListItem(hvoWordform);
}
finally
{
m_fEnableFilters = true;
}
return;
}
}
}
// in general, we don't want to reload this list due to PropChanges
// since that could take a long time.
// We'll just let the list figure out if it needs to reload
// next time we re-enter the tool or the user does Refresh.
using (RecordClerk.ListUpdateHelper luh = new RecordClerk.ListUpdateHelper(Clerk))
{
base.PropChanged(hvo, tag, ivMin, cvIns, cvDel);
// if LangProject.InterlinearTexts has changed, we do
// want to reload the list, otherwise we don't.
if (tag != vtagInterlinearTexts)
luh.TriggerPendingReloadOnDispose = false;
}
}
示例8: GetAffixSequenceContainingHvo
private void GetAffixSequenceContainingHvo(int hvo, out FdoReferenceSequence<IMoInflAffixSlot> seq, out int index)
{
List<int> listHvos = new List<int>(m_template.PrefixSlotsRS.HvoArray);
index = listHvos.IndexOf(hvo);
if (index >= 0)
{
seq = m_template.PrefixSlotsRS;
}
else
{
listHvos = new List<int>(m_template.SuffixSlotsRS.HvoArray);
index = listHvos.IndexOf(hvo);
if (index >= 0)
seq = m_template.SuffixSlotsRS;
else
seq = null;
}
}
示例9: GetIsPrefixSlot
private bool GetIsPrefixSlot(bool fBefore)
{
bool fIsPrefixSlot = false;
if (m_class == MoInflAffixTemplate.kclsidMoInflAffixTemplate)
{
if (fBefore)
fIsPrefixSlot = true;
else
fIsPrefixSlot = false;
}
else if (m_class == MoInflAffixSlot.kclsidMoInflAffixSlot)
{
List<int> listHvos = new List<int>(m_template.PrefixSlotsRS.HvoArray);
int index = listHvos.IndexOf(m_hvoSlot);
if (index >= 0)
fIsPrefixSlot = true;
else
fIsPrefixSlot = false;
}
return fIsPrefixSlot;
}
示例10: SetEnabledIfFindSlotInSequence
private bool SetEnabledIfFindSlotInSequence(List<int> listSlotHvos, out bool fEnabled, bool bIsLeft)
{
int index = listSlotHvos.IndexOf(m_hvo);
if (index >= 0)
{ // it was found
bool bAtEdge;
if (bIsLeft)
bAtEdge = (index == 0);
else
bAtEdge = (index == listSlotHvos.Count - 1);
if (bAtEdge || listSlotHvos.Count == 1)
fEnabled = false; // Cannot move it left when it's at the left edge or there's only one
else
fEnabled = true;
return true;
}
else
{
fEnabled = false;
return false;
}
}